diff --git a/include/opencl_wrapper.h b/include/opencl_wrapper.h index 62f6a1a..8f04b9c 100644 --- a/include/opencl_wrapper.h +++ b/include/opencl_wrapper.h @@ -30,6 +30,9 @@ bool LoadOpenCLLibrary(void **handle_ptr); bool UnLoadOpenCLLibrary(void *handle); bool InitOpenCL(); +bool InitOpenCLExtern(void **clSoHandle); +bool UnLoadCLExtern(void *clSoHandle); + // get platform id using clGetPlatformIDsFunc = cl_int (*)(cl_uint, cl_platform_id *, cl_uint *); // get platform info diff --git a/src/opencl_wrapper.cpp b/src/opencl_wrapper.cpp index a856e87..81cb91f 100644 --- a/src/opencl_wrapper.cpp +++ b/src/opencl_wrapper.cpp @@ -65,6 +65,25 @@ bool UnLoadOpenCLLibrary(void *handle) return true; } +bool InitOpenCLExtern(void **clSoHandle) +{ + if (clSoHandle == nullptr) { + return false; + } + return LoadOpenCLLibrary(clSoHandle); +} + +bool UnLoadCLExtern(void *clSoHandle) +{ + if (clSoHandle == nullptr) { + return false; + } + if (dlclose(clSoHandle) != 0) { + return false; + } + return true; +} + static bool LoadLibraryFromPath(const std::string &library_path, void **handle_ptr) { if (handle_ptr == nullptr) {