add CL so load and unload interface

Signed-off-by: fanghuameng <fanghuameng@huawei.com>
This commit is contained in:
fanghuameng 2024-04-08 15:43:13 +08:00
parent 5d905009d9
commit f1cc9ae857
2 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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) {