pr to master #8

Open
m7grui4p8 wants to merge 201 commits from p69201753/mindspore:cpu-kernel-reuse-1 into master
6 changed files with 355 additions and 291 deletions
Showing only changes of commit 8523b68894 - Show all commits

View File

@ -133,11 +133,10 @@ int ActivationOpenClKernel::GetImageSize(size_t idx, std::vector<size_t> *img_si
return RET_OK;
}
kernel::LiteKernel *OpenClActivationFp32KernelCreator(const std::vector<lite::Tensor *> &inputs,
const std::vector<lite::Tensor *> &outputs,
OpParameter *opParameter, const lite::InnerContext *ctx,
const kernel::KernelKey &desc,
const mindspore::lite::PrimitiveC *primitive) {
kernel::LiteKernel *OpenClActivationKernelCreator(const std::vector<lite::Tensor *> &inputs,
const std::vector<lite::Tensor *> &outputs, OpParameter *opParameter,
const lite::InnerContext *ctx, const kernel::KernelKey &desc,
const mindspore::lite::PrimitiveC *primitive) {
if (inputs.empty()) {
MS_LOG(ERROR) << "Input data size must be greater than 0, but your size is " << inputs.size();
return nullptr;
@ -160,5 +159,6 @@ kernel::LiteKernel *OpenClActivationFp32KernelCreator(const std::vector<lite::Te
}
return kernel;
}
REG_KERNEL(kGPU, kNumberTypeFloat32, PrimitiveType_Activation, OpenClActivationFp32KernelCreator)
REG_KERNEL(kGPU, kNumberTypeFloat16, PrimitiveType_Activation, OpenClActivationKernelCreator)
REG_KERNEL(kGPU, kNumberTypeFloat32, PrimitiveType_Activation, OpenClActivationKernelCreator)
} // namespace mindspore::kernel

View File

@ -38,11 +38,10 @@ constexpr size_t CI_TILE = C4NUM;
constexpr size_t CO_TILE = C4NUM;
int ConvolutionOpenCLKernel::Init() {
static int init_count = 0;
unsigned int init_count = 0;
auto allocator = ocl_runtime_->GetAllocator();
auto param = reinterpret_cast<ConvParameter *>(op_parameter_);
std::set<std::string> build_options;
init_count++;
use_fp16_ = ocl_runtime_->GetFp16Enable();
if (op_format_ != Format_NHWC4 && op_format_ != Format_NC4HW4) {
@ -70,23 +69,48 @@ int ConvolutionOpenCLKernel::Init() {
TILES_XY_ = TILES_X_ * TILES_Y_;
use_winograd_ = UseWinograd4x4To6x6();
std::vector<int> vpara{IH_, IW_, OH_, OW_, KH_, KW_, CI_SLICES_, CO_SLICES_,
param->stride_h_,
param->stride_w_,
param->pad_u_,
param->pad_l_,
param->pad_d_,
param->pad_r_};
std::string code_id;
for (auto &iv : vpara) {
code_id += "_" + std::to_string(iv);
}
// gen code id: bit(OW_ * CO_SLICES_ <= MAX_IMAGE2D_SIZE, format(nhwc4, hc4hw4) , act_type(relu6, relu),
// padTop||padBottom, check_ow, fp16)
init_count |= ((unsigned int)use_fp16_);
init_count |= ((unsigned int)(OW_ % 2 == 1)) << 1;
init_count |= ((unsigned int)(param->pad_u_ || param->pad_d_)) << 2;
init_count |= ((unsigned int)(param->act_type_ == ActType_Relu)) << 3;
init_count |= ((unsigned int)(param->act_type_ == ActType_Relu6)) << 4;
init_count |= ((unsigned int)(op_format_ == schema::Format_NHWC4)) << 5;
init_count |= ((unsigned int)(op_format_ == schema::Format_NC4HW4)) << 6;
init_count |= ((unsigned int)(OW_ * CO_SLICES_ <= MAX_IMAGE2D_SIZE)) << 7;
code_id += "_" + std::to_string(init_count);
// build kernel
if (use_winograd_) {
MS_LOG(DEBUG) << "use winograd";
std::string program_name;
program_name = "Winograd4x4To36" + std::to_string(init_count);
program_name = "Winograd4x4To36" + code_id;
ocl_runtime_->LoadSource(program_name, CodeGenWinograd4x4To36());
ocl_runtime_->BuildKernel(kernel_4x4to36_, program_name, "Winograd4x4To36", build_options);
program_name = "WinogradConvolution" + std::to_string(init_count);
program_name = "WinogradConvolution" + code_id;
ocl_runtime_->LoadSource(program_name, CodeGenWinogradConvolution());
ocl_runtime_->BuildKernel(kernel_conv_, program_name, "WinogradConvolution", build_options);
program_name = "Winograd36To4x4" + std::to_string(init_count);
program_name = "Winograd36To4x4" + code_id;
ocl_runtime_->LoadSource(program_name, CodeGenWinograd36To4x4());
ocl_runtime_->BuildKernel(kernel_36to4x4_, program_name, "Winograd36To4x4", build_options);
} else {
std::string program_name = "convolution" + std::to_string(init_count);
std::string program_name = "convolution" + code_id;
std::string source = op_format_ == Format_NHWC4 ? CodeGenConvolutionNHWC4() : CodeGenConvolutionNC4HW4();
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_conv_, program_name, "Convolution", build_options);

View File

@ -83,16 +83,16 @@ int OpenCLRuntime::Init() {
MS_LOG(INFO) << "CL_HPP_MINIMUM_OPENCL_VERSION " << CL_HPP_MINIMUM_OPENCL_VERSION;
#ifdef USE_OPENCL_WRAPPER
if (OpenCLWrapper::GetInstance()->LoadOpenCLLibrary() == false) {
if (lite::opencl::LoadOpenCLLibrary(handle_) == false) {
MS_LOG(ERROR) << "Load OpenCL symbols failed!";
return RET_ERROR;
}
#endif // USE_OPENCL_WRAPPER
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
cl_int ret = cl::Platform::get(&platforms);
if (platforms.size() == 0) {
MS_LOG(ERROR) << "OpenCL Platform not found!";
MS_LOG(ERROR) << "OpenCL Platform not found!" << CLErrorCode(ret);
return RET_ERROR;
}
@ -137,7 +137,7 @@ int OpenCLRuntime::Init() {
<< max_work_item_sizes_[2];
gpu_info_ = ParseGpuInfo(device_name, device_version);
cl_int ret;
// cl_int ret;
#if defined(SHARING_MEM_WITH_OPENGL) && (CL_HPP_TARGET_OPENCL_VERSION >= 120)
// create context from glcontext
MS_LOG(INFO) << "Create special opencl context to share with OpenGL";
@ -235,7 +235,8 @@ int OpenCLRuntime::Uninit() {
context_ = nullptr;
device_ = nullptr;
#ifdef USE_OPENCL_WRAPPER
OpenCLWrapper::GetInstance()->UnLoadOpenCLLibrary();
lite::opencl::UnLoadOpenCLLibrary(handle_);
handle_ = nullptr;
#endif
init_done_ = false;
return RET_OK;

View File

@ -166,6 +166,7 @@ class OpenCLRuntime {
cl_device_svm_capabilities svm_capabilities_{0};
cl_uint image_pitch_align_{0};
std::vector<size_t> max_work_item_sizes_;
void *handle_{nullptr};
};
} // namespace mindspore::lite::opencl

View File

@ -65,51 +65,28 @@ static const std::vector<std::string> g_opencl_library_paths = {
#endif
};
OpenCLWrapper *OpenCLWrapper::GetInstance() {
static OpenCLWrapper ocl_wrapper;
return &ocl_wrapper;
}
OpenCLWrapper::OpenCLWrapper() {}
OpenCLWrapper::~OpenCLWrapper() {}
// load default library path
bool OpenCLWrapper::LoadOpenCLLibrary() {
if (handle_ != nullptr) {
return true;
}
for (const auto &lib_path : g_opencl_library_paths) {
if (LoadLibraryFromPath(lib_path)) {
MS_LOG(DEBUG) << "Find a OpenCL dynamic library : " << lib_path;
return true;
}
}
return false;
}
bool OpenCLWrapper::UnLoadOpenCLLibrary() {
if (handle_ != nullptr) {
if (dlclose(handle_) != 0) {
bool UnLoadOpenCLLibrary(void *handle) {
if (handle != nullptr) {
if (dlclose(handle) != 0) {
return false;
}
handle_ = nullptr;
return true;
}
return true;
}
bool OpenCLWrapper::LoadLibraryFromPath(const std::string &library_path) {
handle_ = dlopen(library_path.c_str(), RTLD_NOW | RTLD_LOCAL);
if (handle_ == nullptr) {
bool LoadLibraryFromPath(const std::string &library_path, void *handle) {
handle = dlopen(library_path.c_str(), RTLD_NOW | RTLD_LOCAL);
if (handle == nullptr) {
return false;
}
// load function ptr use dlopen and dlsym.
#define LOAD_OPENCL_FUNCTION_PTR(func_name) \
func_name = reinterpret_cast<func_name##Func>(dlsym(handle_, #func_name)); \
func_name = reinterpret_cast<func_name##Func>(dlsym(handle, #func_name)); \
if (func_name == nullptr) { \
MS_LOG(ERROR) << "load func (" << #func_name << ") from (" << library_path << ") failed!"; \
UnLoadOpenCLLibrary(handle); \
return false; \
}
@ -180,16 +157,96 @@ bool OpenCLWrapper::LoadLibraryFromPath(const std::string &library_path) {
#endif
#endif
#undef LOAD_OPENCL_FUNCTION_PTR
return true;
}
// load default library path
bool LoadOpenCLLibrary(void *handle) {
if (handle != nullptr) {
return true;
}
auto it = std::find_if(
g_opencl_library_paths.begin(), g_opencl_library_paths.end(),
[&handle](const std::string &lib_path) { return lite::opencl::LoadLibraryFromPath(lib_path, handle); });
if (it != g_opencl_library_paths.end()) {
MS_LOG(DEBUG) << "Find a OpenCL dynamic library : " << *it;
return true;
}
return false;
}
#define CL_DEFINE_FUNC_PTR(func) func##Func func = nullptr
CL_DEFINE_FUNC_PTR(clGetPlatformIDs);
CL_DEFINE_FUNC_PTR(clGetPlatformInfo);
CL_DEFINE_FUNC_PTR(clBuildProgram);
CL_DEFINE_FUNC_PTR(clEnqueueNDRangeKernel);
CL_DEFINE_FUNC_PTR(clSetKernelArg);
CL_DEFINE_FUNC_PTR(clReleaseKernel);
CL_DEFINE_FUNC_PTR(clCreateProgramWithSource);
CL_DEFINE_FUNC_PTR(clCreateBuffer);
CL_DEFINE_FUNC_PTR(clCreateImage2D);
CL_DEFINE_FUNC_PTR(clCreateImage3D);
CL_DEFINE_FUNC_PTR(clRetainKernel);
CL_DEFINE_FUNC_PTR(clCreateKernel);
CL_DEFINE_FUNC_PTR(clGetProgramInfo);
CL_DEFINE_FUNC_PTR(clFlush);
CL_DEFINE_FUNC_PTR(clFinish);
CL_DEFINE_FUNC_PTR(clReleaseProgram);
CL_DEFINE_FUNC_PTR(clRetainContext);
CL_DEFINE_FUNC_PTR(clGetContextInfo);
CL_DEFINE_FUNC_PTR(clCreateProgramWithBinary);
CL_DEFINE_FUNC_PTR(clCreateCommandQueue);
CL_DEFINE_FUNC_PTR(clGetCommandQueueInfo);
CL_DEFINE_FUNC_PTR(clReleaseCommandQueue);
CL_DEFINE_FUNC_PTR(clEnqueueMapBuffer);
CL_DEFINE_FUNC_PTR(clEnqueueMapImage);
CL_DEFINE_FUNC_PTR(clEnqueueCopyImage);
CL_DEFINE_FUNC_PTR(clRetainProgram);
CL_DEFINE_FUNC_PTR(clGetProgramBuildInfo);
CL_DEFINE_FUNC_PTR(clEnqueueReadBuffer);
CL_DEFINE_FUNC_PTR(clEnqueueWriteBuffer);
CL_DEFINE_FUNC_PTR(clEnqueueWriteImage);
CL_DEFINE_FUNC_PTR(clEnqueueReadImage);
CL_DEFINE_FUNC_PTR(clWaitForEvents);
CL_DEFINE_FUNC_PTR(clReleaseEvent);
CL_DEFINE_FUNC_PTR(clCreateContext);
CL_DEFINE_FUNC_PTR(clCreateContextFromType);
CL_DEFINE_FUNC_PTR(clReleaseContext);
CL_DEFINE_FUNC_PTR(clRetainCommandQueue);
CL_DEFINE_FUNC_PTR(clEnqueueUnmapMemObject);
CL_DEFINE_FUNC_PTR(clRetainMemObject);
CL_DEFINE_FUNC_PTR(clReleaseMemObject);
CL_DEFINE_FUNC_PTR(clGetDeviceInfo);
CL_DEFINE_FUNC_PTR(clGetDeviceIDs);
CL_DEFINE_FUNC_PTR(clRetainEvent);
CL_DEFINE_FUNC_PTR(clGetKernelWorkGroupInfo);
CL_DEFINE_FUNC_PTR(clGetEventInfo);
CL_DEFINE_FUNC_PTR(clGetEventProfilingInfo);
CL_DEFINE_FUNC_PTR(clGetImageInfo);
CL_DEFINE_FUNC_PTR(clEnqueueCopyBufferToImage);
CL_DEFINE_FUNC_PTR(clEnqueueCopyImageToBuffer);
#if CL_HPP_TARGET_OPENCL_VERSION >= 120
CL_DEFINE_FUNC_PTR(clRetainDevice);
CL_DEFINE_FUNC_PTR(clReleaseDevice);
CL_DEFINE_FUNC_PTR(clCreateImage);
#endif
#if CL_HPP_TARGET_OPENCL_VERSION >= 200
CL_DEFINE_FUNC_PTR(clGetKernelSubGroupInfoKHR);
CL_DEFINE_FUNC_PTR(clCreateCommandQueueWithProperties);
CL_DEFINE_FUNC_PTR(clGetExtensionFunctionAddress);
CL_DEFINE_FUNC_PTR(clCreateProgramWithIL);
CL_DEFINE_FUNC_PTR(clSVMAlloc);
CL_DEFINE_FUNC_PTR(clSVMFree);
CL_DEFINE_FUNC_PTR(clEnqueueSVMMap);
CL_DEFINE_FUNC_PTR(clEnqueueSVMUnmap);
CL_DEFINE_FUNC_PTR(clSetKernelArgSVMPointer);
#endif
#undef LOAD_OPENCL_FUNCTION_PTR
} // namespace mindspore::lite::opencl
// clGetPlatformIDs wrapper, use OpenCLWrapper function. use OpenCLWrapper function.
cl_int clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetPlatformIDs;
auto func = mindspore::lite::opencl::clGetPlatformIDs;
MS_ASSERT(func != nullptr);
return func(num_entries, platforms, num_platforms);
}
@ -197,7 +254,7 @@ cl_int clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint
// clGetPlatformInfo wrapper, use OpenCLWrapper function. use OpenCLWrapper function.
cl_int clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name, size_t param_value_size,
void *param_value, size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetPlatformInfo;
auto func = mindspore::lite::opencl::clGetPlatformInfo;
MS_ASSERT(func != nullptr);
return func(platform, param_name, param_value_size, param_value, param_value_size_ret);
}
@ -205,7 +262,7 @@ cl_int clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name, s
// clGetDeviceIDs wrapper, use OpenCLWrapper function.
cl_int clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices,
cl_uint *num_devices) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetDeviceIDs;
auto func = mindspore::lite::opencl::clGetDeviceIDs;
MS_ASSERT(func != nullptr);
return func(platform, device_type, num_entries, devices, num_devices);
}
@ -213,7 +270,7 @@ cl_int clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type, cl_ui
// clGetDeviceInfo wrapper, use OpenCLWrapper function.
cl_int clGetDeviceInfo(cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value,
size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetDeviceInfo;
auto func = mindspore::lite::opencl::clGetDeviceInfo;
MS_ASSERT(func != nullptr);
return func(device, param_name, param_value_size, param_value, param_value_size_ret);
}
@ -222,7 +279,7 @@ cl_int clGetDeviceInfo(cl_device_id device, cl_device_info param_name, size_t pa
cl_context clCreateContext(const cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices,
void(CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), void *user_data,
cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateContext;
auto func = mindspore::lite::opencl::clCreateContext;
MS_ASSERT(func != nullptr);
return func(properties, num_devices, devices, pfn_notify, user_data, errcode_ret);
}
@ -231,21 +288,21 @@ cl_context clCreateContext(const cl_context_properties *properties, cl_uint num_
cl_context clCreateContextFromType(const cl_context_properties *properties, cl_device_type device_type,
void(CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *),
void *user_data, cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateContextFromType;
auto func = mindspore::lite::opencl::clCreateContextFromType;
MS_ASSERT(func != nullptr);
return func(properties, device_type, pfn_notify, user_data, errcode_ret);
}
// clRetainContext wrapper, use OpenCLWrapper function.
cl_int clRetainContext(cl_context context) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clRetainContext;
auto func = mindspore::lite::opencl::clRetainContext;
MS_ASSERT(func != nullptr);
return func(context);
}
// clReleaseContext wrapper, use OpenCLWrapper function.
cl_int clReleaseContext(cl_context context) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clReleaseContext;
auto func = mindspore::lite::opencl::clReleaseContext;
MS_ASSERT(func != nullptr);
return func(context);
}
@ -253,7 +310,7 @@ cl_int clReleaseContext(cl_context context) {
// clGetContextInfo wrapper, use OpenCLWrapper function.
cl_int clGetContextInfo(cl_context context, cl_context_info param_name, size_t param_value_size, void *param_value,
size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetContextInfo;
auto func = mindspore::lite::opencl::clGetContextInfo;
MS_ASSERT(func != nullptr);
return func(context, param_name, param_value_size, param_value, param_value_size_ret);
}
@ -261,7 +318,7 @@ cl_int clGetContextInfo(cl_context context, cl_context_info param_name, size_t p
// clCreateProgramWithSource wrapper, use OpenCLWrapper function.
cl_program clCreateProgramWithSource(cl_context context, cl_uint count, const char **strings, const size_t *lengths,
cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateProgramWithSource;
auto func = mindspore::lite::opencl::clCreateProgramWithSource;
MS_ASSERT(func != nullptr);
return func(context, count, strings, lengths, errcode_ret);
}
@ -270,7 +327,7 @@ cl_program clCreateProgramWithSource(cl_context context, cl_uint count, const ch
cl_program clCreateProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id *devices_list,
const size_t *lengths, const unsigned char **binaries, cl_int *binary_status,
cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateProgramWithBinary;
auto func = mindspore::lite::opencl::clCreateProgramWithBinary;
MS_ASSERT(func != nullptr);
return func(context, num_devices, devices_list, lengths, binaries, binary_status, errcode_ret);
}
@ -278,7 +335,7 @@ cl_program clCreateProgramWithBinary(cl_context context, cl_uint num_devices, co
// clGetProgramInfo wrapper, use OpenCLWrapper function.
cl_int clGetProgramInfo(cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value,
size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetProgramInfo;
auto func = mindspore::lite::opencl::clGetProgramInfo;
MS_ASSERT(func != nullptr);
return func(program, param_name, param_value_size, param_value, param_value_size_ret);
}
@ -286,21 +343,21 @@ cl_int clGetProgramInfo(cl_program program, cl_program_info param_name, size_t p
// clGetProgramBuildInfo wrapper, use OpenCLWrapper function.
cl_int clGetProgramBuildInfo(cl_program program, cl_device_id device, cl_program_build_info param_name,
size_t param_value_size, void *param_value, size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetProgramBuildInfo;
auto func = mindspore::lite::opencl::clGetProgramBuildInfo;
MS_ASSERT(func != nullptr);
return func(program, device, param_name, param_value_size, param_value, param_value_size_ret);
}
// clRetainProgram wrapper, use OpenCLWrapper function.
cl_int clRetainProgram(cl_program program) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clRetainProgram;
auto func = mindspore::lite::opencl::clRetainProgram;
MS_ASSERT(func != nullptr);
return func(program);
}
// clReleaseProgram wrapper, use OpenCLWrapper function.
cl_int clReleaseProgram(cl_program program) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clReleaseProgram;
auto func = mindspore::lite::opencl::clReleaseProgram;
MS_ASSERT(func != nullptr);
return func(program);
}
@ -308,56 +365,56 @@ cl_int clReleaseProgram(cl_program program) {
// clBuildProgram wrapper, use OpenCLWrapper function.
cl_int clBuildProgram(cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options,
void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clBuildProgram;
auto func = mindspore::lite::opencl::clBuildProgram;
MS_ASSERT(func != nullptr);
return func(program, num_devices, device_list, options, pfn_notify, user_data);
}
// clCreateKernel wrapper, use OpenCLWrapper function.
cl_kernel clCreateKernel(cl_program program, const char *kernelName, cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateKernel;
auto func = mindspore::lite::opencl::clCreateKernel;
MS_ASSERT(func != nullptr);
return func(program, kernelName, errcode_ret);
}
// clRetainKernel wrapper, use OpenCLWrapper function.
cl_int clRetainKernel(cl_kernel kernel) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clRetainKernel;
auto func = mindspore::lite::opencl::clRetainKernel;
MS_ASSERT(func != nullptr);
return func(kernel);
}
// clReleaseKernel wrapper, use OpenCLWrapper function.
cl_int clReleaseKernel(cl_kernel kernel) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clReleaseKernel;
auto func = mindspore::lite::opencl::clReleaseKernel;
MS_ASSERT(func != nullptr);
return func(kernel);
}
// clSetKernelArg wrapper, use OpenCLWrapper function.
cl_int clSetKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clSetKernelArg;
auto func = mindspore::lite::opencl::clSetKernelArg;
MS_ASSERT(func != nullptr);
return func(kernel, arg_index, arg_size, arg_value);
}
// clCreateBuffer wrapper, use OpenCLWrapper function.
cl_mem clCreateBuffer(cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateBuffer;
auto func = mindspore::lite::opencl::clCreateBuffer;
MS_ASSERT(func != nullptr);
return func(context, flags, size, host_ptr, errcode_ret);
}
// clRetainMemObject wrapper, use OpenCLWrapper function.
cl_int clRetainMemObject(cl_mem memobj) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clRetainMemObject;
auto func = mindspore::lite::opencl::clRetainMemObject;
MS_ASSERT(func != nullptr);
return func(memobj);
}
// clReleaseMemObject wrapper, use OpenCLWrapper function.
cl_int clReleaseMemObject(cl_mem memobj) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clReleaseMemObject;
auto func = mindspore::lite::opencl::clReleaseMemObject;
MS_ASSERT(func != nullptr);
return func(memobj);
}
@ -365,21 +422,21 @@ cl_int clReleaseMemObject(cl_mem memobj) {
// clGetImageInfo wrapper, use OpenCLWrapper function.
cl_int clGetImageInfo(cl_mem image, cl_image_info param_name, size_t param_value_size, void *param_value,
size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetImageInfo;
auto func = mindspore::lite::opencl::clGetImageInfo;
MS_ASSERT(func != nullptr);
return func(image, param_name, param_value_size, param_value, param_value_size_ret);
}
// clRetainCommandQueue wrapper, use OpenCLWrapper function.
cl_int clRetainCommandQueue(cl_command_queue command_queue) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clRetainCommandQueue;
auto func = mindspore::lite::opencl::clRetainCommandQueue;
MS_ASSERT(func != nullptr);
return func(command_queue);
}
// clReleaseCommandQueue wrapper, use OpenCLWrapper function.
cl_int clReleaseCommandQueue(cl_command_queue command_queue) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clReleaseCommandQueue;
auto func = mindspore::lite::opencl::clReleaseCommandQueue;
MS_ASSERT(func != nullptr);
return func(command_queue);
}
@ -388,7 +445,7 @@ cl_int clReleaseCommandQueue(cl_command_queue command_queue) {
cl_int clEnqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset,
size_t size, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list,
cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueReadBuffer;
auto func = mindspore::lite::opencl::clEnqueueReadBuffer;
MS_ASSERT(func != nullptr);
return func(command_queue, buffer, blocking_read, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
}
@ -397,7 +454,7 @@ cl_int clEnqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_boo
cl_int clEnqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset,
size_t size, const void *ptr, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueWriteBuffer;
auto func = mindspore::lite::opencl::clEnqueueWriteBuffer;
MS_ASSERT(func != nullptr);
return func(command_queue, buffer, blocking_write, offset, size, ptr, num_events_in_wait_list, event_wait_list,
event);
@ -407,7 +464,7 @@ cl_int clEnqueueWriteBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bo
cl_int clEnqueueWriteImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_write, const size_t *origin,
const size_t *region, size_t input_row_pitch, size_t input_slice_pitch, const void *ptr,
cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueWriteImage;
auto func = mindspore::lite::opencl::clEnqueueWriteImage;
MS_ASSERT(func != nullptr);
return func(command_queue, image, blocking_write, origin, region, input_row_pitch, input_slice_pitch, ptr,
num_events_in_wait_list, event_wait_list, event);
@ -417,7 +474,7 @@ cl_int clEnqueueWriteImage(cl_command_queue command_queue, cl_mem image, cl_bool
cl_int clEnqueueReadImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_read, const size_t *origin,
const size_t *region, size_t row_pitch, size_t slice_pitch, void *ptr,
cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueReadImage;
auto func = mindspore::lite::opencl::clEnqueueReadImage;
MS_ASSERT(func != nullptr);
return func(command_queue, image, blocking_read, origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list,
event_wait_list, event);
@ -427,7 +484,7 @@ cl_int clEnqueueReadImage(cl_command_queue command_queue, cl_mem image, cl_bool
void *clEnqueueMapBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags,
size_t offset, size_t size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list,
cl_event *event, cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueMapBuffer;
auto func = mindspore::lite::opencl::clEnqueueMapBuffer;
MS_ASSERT(func != nullptr);
return func(command_queue, buffer, blocking_map, map_flags, offset, size, num_events_in_wait_list, event_wait_list,
event, errcode_ret);
@ -438,7 +495,7 @@ void *clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, cl_bool bl
const size_t *origin, const size_t *region, size_t *image_row_pitch, size_t *image_slice_pitch,
cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event,
cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueMapImage;
auto func = mindspore::lite::opencl::clEnqueueMapImage;
MS_ASSERT(func != nullptr);
return func(command_queue, image, blocking_map, map_flags, origin, region, image_row_pitch, image_slice_pitch,
num_events_in_wait_list, event_wait_list, event, errcode_ret);
@ -447,7 +504,7 @@ void *clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, cl_bool bl
// clEnqueueUnmapMemObject wrapper, use OpenCLWrapper function.
cl_int clEnqueueUnmapMemObject(cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr,
cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueUnmapMemObject;
auto func = mindspore::lite::opencl::clEnqueueUnmapMemObject;
MS_ASSERT(func != nullptr);
return func(command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
}
@ -455,7 +512,7 @@ cl_int clEnqueueUnmapMemObject(cl_command_queue command_queue, cl_mem memobj, vo
// clGetKernelWorkGroupInfo wrapper, use OpenCLWrapper function.
cl_int clGetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name,
size_t param_value_size, void *param_value, size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetKernelWorkGroupInfo;
auto func = mindspore::lite::opencl::clGetKernelWorkGroupInfo;
MS_ASSERT(func != nullptr);
return func(kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
}
@ -463,7 +520,7 @@ cl_int clGetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device, cl_kernel
// clGetEventProfilingInfo wrapper, use OpenCLWrapper function.
cl_int clGetEventProfilingInfo(cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value,
size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetEventProfilingInfo;
auto func = mindspore::lite::opencl::clGetEventProfilingInfo;
MS_ASSERT(func != nullptr);
return func(event, param_name, param_value_size, param_value, param_value_size_ret);
}
@ -473,7 +530,7 @@ cl_int clEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel,
const size_t *global_work_offset, const size_t *global_work_size,
const size_t *local_work_size, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueNDRangeKernel;
auto func = mindspore::lite::opencl::clEnqueueNDRangeKernel;
MS_ASSERT(func != nullptr);
return func(command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size,
num_events_in_wait_list, event_wait_list, event);
@ -481,21 +538,21 @@ cl_int clEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel,
// clWaitForEvents wrapper, use OpenCLWrapper function.
cl_int clWaitForEvents(cl_uint num_events, const cl_event *event_list) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clWaitForEvents;
auto func = mindspore::lite::opencl::clWaitForEvents;
MS_ASSERT(func != nullptr);
return func(num_events, event_list);
}
// clRetainEvent wrapper, use OpenCLWrapper function.
cl_int clRetainEvent(cl_event event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clRetainEvent;
auto func = mindspore::lite::opencl::clRetainEvent;
MS_ASSERT(func != nullptr);
return func(event);
}
// clReleaseEvent wrapper, use OpenCLWrapper function.
cl_int clReleaseEvent(cl_event event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clReleaseEvent;
auto func = mindspore::lite::opencl::clReleaseEvent;
MS_ASSERT(func != nullptr);
return func(event);
}
@ -503,21 +560,21 @@ cl_int clReleaseEvent(cl_event event) {
// clGetEventInfo wrapper, use OpenCLWrapper function.
cl_int clGetEventInfo(cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value,
size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetEventInfo;
auto func = mindspore::lite::opencl::clGetEventInfo;
MS_ASSERT(func != nullptr);
return func(event, param_name, param_value_size, param_value, param_value_size_ret);
}
// clFlush wrapper, use OpenCLWrapper function.
cl_int clFlush(cl_command_queue command_queue) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clFlush;
auto func = mindspore::lite::opencl::clFlush;
MS_ASSERT(func != nullptr);
return func(command_queue);
}
// clFinish wrapper, use OpenCLWrapper function.
cl_int clFinish(cl_command_queue command_queue) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clFinish;
auto func = mindspore::lite::opencl::clFinish;
MS_ASSERT(func != nullptr);
return func(command_queue);
}
@ -525,7 +582,7 @@ cl_int clFinish(cl_command_queue command_queue) {
// clCreateImage2D wrapper, use OpenCLWrapper function.
cl_mem clCreateImage2D(cl_context context, cl_mem_flags flags, const cl_image_format *image_format, size_t imageWidth,
size_t imageHeight, size_t image_row_pitch, void *host_ptr, cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateImage2D;
auto func = mindspore::lite::opencl::clCreateImage2D;
MS_ASSERT(func != nullptr);
return func(context, flags, image_format, imageWidth, imageHeight, image_row_pitch, host_ptr, errcode_ret);
}
@ -534,7 +591,7 @@ cl_mem clCreateImage2D(cl_context context, cl_mem_flags flags, const cl_image_fo
cl_mem clCreateImage3D(cl_context context, cl_mem_flags flags, const cl_image_format *image_format, size_t imageWidth,
size_t imageHeight, size_t imageDepth, size_t image_row_pitch, size_t image_slice_pitch,
void *host_ptr, cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateImage3D;
auto func = mindspore::lite::opencl::clCreateImage3D;
MS_ASSERT(func != nullptr);
return func(context, flags, image_format, imageWidth, imageHeight, imageDepth, image_row_pitch, image_slice_pitch,
host_ptr, errcode_ret);
@ -543,7 +600,7 @@ cl_mem clCreateImage3D(cl_context context, cl_mem_flags flags, const cl_image_fo
// clCreateCommandQueue wrapper, use OpenCLWrapper function.
cl_command_queue clCreateCommandQueue(cl_context context, cl_device_id device, cl_command_queue_properties properties,
cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateCommandQueue;
auto func = mindspore::lite::opencl::clCreateCommandQueue;
MS_ASSERT(func != nullptr);
return func(context, device, properties, errcode_ret);
}
@ -551,7 +608,7 @@ cl_command_queue clCreateCommandQueue(cl_context context, cl_device_id device, c
// clGetCommandQueueInfo wrapper, use OpenCLWrapper function.
cl_int clGetCommandQueueInfo(cl_command_queue command_queue, cl_command_queue_info param_name, size_t param_value_size,
void *param_value, size_t *param_value_size_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetCommandQueueInfo;
auto func = mindspore::lite::opencl::clGetCommandQueueInfo;
MS_ASSERT(func != nullptr);
return func(command_queue, param_name, param_value_size, param_value, param_value_size_ret);
}
@ -560,7 +617,7 @@ cl_int clGetCommandQueueInfo(cl_command_queue command_queue, cl_command_queue_in
cl_int clEnqueueCopyImage(cl_command_queue queue, cl_mem src_image, cl_mem dst_image, const size_t *src_origin,
const size_t *dst_origin, const size_t *region, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueCopyImage;
auto func = mindspore::lite::opencl::clEnqueueCopyImage;
MS_ASSERT(func != nullptr);
return func(queue, src_image, dst_image, src_origin, dst_origin, region, num_events_in_wait_list, event_wait_list,
event);
@ -570,7 +627,7 @@ cl_int clEnqueueCopyImage(cl_command_queue queue, cl_mem src_image, cl_mem dst_i
cl_int clEnqueueCopyBufferToImage(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_image,
size_t src_offset, const size_t *dst_origin, const size_t *region,
cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueCopyBufferToImage;
auto func = mindspore::lite::opencl::clEnqueueCopyBufferToImage;
MS_ASSERT(func != nullptr);
return func(command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events_in_wait_list,
event_wait_list, event);
@ -580,7 +637,7 @@ cl_int clEnqueueCopyBufferToImage(cl_command_queue command_queue, cl_mem src_buf
cl_int clEnqueueCopyImageToBuffer(cl_command_queue command_queue, cl_mem src_image, cl_mem dst_buffer,
const size_t *src_origin, const size_t *region, size_t dst_offset,
cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueCopyImageToBuffer;
auto func = mindspore::lite::opencl::clEnqueueCopyImageToBuffer;
MS_ASSERT(func != nullptr);
return func(command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events_in_wait_list,
event_wait_list, event);
@ -590,14 +647,14 @@ cl_int clEnqueueCopyImageToBuffer(cl_command_queue command_queue, cl_mem src_ima
// clRetainDevice wrapper, use OpenCLWrapper function.
cl_int clRetainDevice(cl_device_id device) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clRetainDevice;
auto func = mindspore::lite::opencl::clRetainDevice;
MS_ASSERT(func != nullptr);
return func(device);
}
// clReleaseDevice wrapper, use OpenCLWrapper function.
cl_int clReleaseDevice(cl_device_id device) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clReleaseDevice;
auto func = mindspore::lite::opencl::clReleaseDevice;
MS_ASSERT(func != nullptr);
return func(device);
}
@ -605,7 +662,7 @@ cl_int clReleaseDevice(cl_device_id device) {
// clCreateImage wrapper, use OpenCLWrapper function.
cl_mem clCreateImage(cl_context context, cl_mem_flags flags, const cl_image_format *image_format,
const cl_image_desc *image_desc, void *host_ptr, cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateImage;
auto func = mindspore::lite::opencl::clCreateImage;
MS_ASSERT(func != nullptr);
return func(context, flags, image_format, image_desc, host_ptr, errcode_ret);
}
@ -617,34 +674,34 @@ cl_mem clCreateImage(cl_context context, cl_mem_flags flags, const cl_image_form
// clCreateCommandQueueWithProperties wrapper, use OpenCLWrapper function.
cl_command_queue clCreateCommandQueueWithProperties(cl_context context, cl_device_id device,
const cl_queue_properties *properties, cl_int *errcode_ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateCommandQueueWithProperties;
auto func = mindspore::lite::opencl::clCreateCommandQueueWithProperties;
MS_ASSERT(func != nullptr);
return func(context, device, properties, errcode_ret);
}
// clGetExtensionFunctionAddress wrapper, use OpenCLWrapper function.
void *clGetExtensionFunctionAddress(const char *func_name) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clGetExtensionFunctionAddress;
auto func = mindspore::lite::opencl::clGetExtensionFunctionAddress;
MS_ASSERT(func != nullptr);
return func(func_name);
}
// clCreateProgramWithIL wrapper, use OpenCLWrapper function.
cl_program clCreateProgramWithIL(cl_context context, const void *il, size_t length, cl_int *ret) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clCreateProgramWithIL;
auto func = mindspore::lite::opencl::clCreateProgramWithIL;
MS_ASSERT(func != nullptr);
return func(context, il, length, ret);
}
// clSVMAlloc wrapper, use OpenCLWrapper function.
void *clSVMAlloc(cl_context context, cl_mem_flags flags, size_t size, cl_uint align) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clSVMAlloc;
auto func = mindspore::lite::opencl::clSVMAlloc;
MS_ASSERT(func != nullptr);
return func(context, flags, size, align);
}
// clSVMFree wrapper, use OpenCLWrapper function.
void clSVMFree(cl_context context, void *buffer) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clSVMFree;
auto func = mindspore::lite::opencl::clSVMFree;
MS_ASSERT(func != nullptr);
func(context, buffer);
}
@ -652,7 +709,7 @@ void clSVMFree(cl_context context, void *buffer) {
// clEnqueueSVMMap wrapper, use OpenCLWrapper function.
cl_int clEnqueueSVMMap(cl_command_queue command_queue, cl_bool blocking, cl_map_flags flags, void *host_ptr,
size_t size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueSVMMap;
auto func = mindspore::lite::opencl::clEnqueueSVMMap;
MS_ASSERT(func != nullptr);
return func(command_queue, blocking, flags, host_ptr, size, num_events_in_wait_list, event_wait_list, event);
}
@ -660,14 +717,14 @@ cl_int clEnqueueSVMMap(cl_command_queue command_queue, cl_bool blocking, cl_map_
// clEnqueueSVMUnmap wrapper, use OpenCLWrapper function.
cl_int clEnqueueSVMUnmap(cl_command_queue command_queue, void *host_ptr, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clEnqueueSVMUnmap;
auto func = mindspore::lite::opencl::clEnqueueSVMUnmap;
MS_ASSERT(func != nullptr);
return func(command_queue, host_ptr, num_events_in_wait_list, event_wait_list, event);
}
// clSetKernelArgSVMPointer wrapper, use OpenCLWrapper function.
cl_int clSetKernelArgSVMPointer(cl_kernel kernel, cl_uint index, const void *host_ptr) {
auto func = mindspore::lite::opencl::OpenCLWrapper::GetInstance()->clSetKernelArgSVMPointer;
auto func = mindspore::lite::opencl::clSetKernelArgSVMPointer;
MS_ASSERT(func != nullptr);
return func(kernel, index, host_ptr);
}

View File

@ -37,201 +37,182 @@
#ifdef USE_OPENCL_WRAPPER
namespace mindspore::lite::opencl {
// This is a opencl function wrapper.
class OpenCLWrapper {
public:
static OpenCLWrapper *GetInstance();
bool LoadOpenCLLibrary(void *handle);
bool UnLoadOpenCLLibrary(void *handle);
~OpenCLWrapper();
OpenCLWrapper(const OpenCLWrapper &) = delete;
OpenCLWrapper &operator=(const OpenCLWrapper &) = delete;
// get platfrom id
using clGetPlatformIDsFunc = cl_int (*)(cl_uint, cl_platform_id *, cl_uint *);
// get platform info
using clGetPlatformInfoFunc = cl_int (*)(cl_platform_id, cl_platform_info, size_t, void *, size_t *);
// build program
using clBuildProgramFunc = cl_int (*)(cl_program, cl_uint, const cl_device_id *, const char *,
void (*pfn_notify)(cl_program, void *), void *);
// enqueue run kernel
using clEnqueueNDRangeKernelFunc = cl_int (*)(cl_command_queue, cl_kernel, cl_uint, const size_t *, const size_t *,
const size_t *, cl_uint, const cl_event *, cl_event *);
// set kernel parameter
using clSetKernelArgFunc = cl_int (*)(cl_kernel, cl_uint, size_t, const void *);
using clRetainMemObjectFunc = cl_int (*)(cl_mem);
using clReleaseMemObjectFunc = cl_int (*)(cl_mem);
using clEnqueueUnmapMemObjectFunc = cl_int (*)(cl_command_queue, cl_mem, void *, cl_uint, const cl_event *, cl_event *);
using clRetainCommandQueueFunc = cl_int (*)(cl_command_queue command_queue);
// create context
using clCreateContextFunc = cl_context (*)(const cl_context_properties *, cl_uint, const cl_device_id *,
void(CL_CALLBACK *)( // NOLINT(readability/casting)
const char *, const void *, size_t, void *),
void *, cl_int *);
using clEnqueueCopyImageFunc = cl_int (*)(cl_command_queue, cl_mem, cl_mem, const size_t *, const size_t *,
const size_t *, cl_uint, const cl_event *, cl_event *);
bool LoadOpenCLLibrary();
bool UnLoadOpenCLLibrary();
// get platfrom id
using clGetPlatformIDsFunc = cl_int (*)(cl_uint, cl_platform_id *, cl_uint *);
// get platform info
using clGetPlatformInfoFunc = cl_int (*)(cl_platform_id, cl_platform_info, size_t, void *, size_t *);
// build program
using clBuildProgramFunc = cl_int (*)(cl_program, cl_uint, const cl_device_id *, const char *,
void (*pfn_notify)(cl_program, void *), void *);
// enqueue run kernel
using clEnqueueNDRangeKernelFunc = cl_int (*)(cl_command_queue, cl_kernel, cl_uint, const size_t *, const size_t *,
const size_t *, cl_uint, const cl_event *, cl_event *);
// set kernel parameter
using clSetKernelArgFunc = cl_int (*)(cl_kernel, cl_uint, size_t, const void *);
using clRetainMemObjectFunc = cl_int (*)(cl_mem);
using clReleaseMemObjectFunc = cl_int (*)(cl_mem);
using clEnqueueUnmapMemObjectFunc = cl_int (*)(cl_command_queue, cl_mem, void *, cl_uint, const cl_event *,
cl_event *);
using clRetainCommandQueueFunc = cl_int (*)(cl_command_queue command_queue);
// create context
using clCreateContextFunc = cl_context (*)(const cl_context_properties *, cl_uint, const cl_device_id *,
void(CL_CALLBACK *)( // NOLINT(readability/casting)
const char *, const void *, size_t, void *),
void *, cl_int *);
using clEnqueueCopyImageFunc = cl_int (*)(cl_command_queue, cl_mem, cl_mem, const size_t *, const size_t *,
const size_t *, cl_uint, const cl_event *, cl_event *);
using clCreateContextFromTypeFunc = cl_context (*)(const cl_context_properties *, cl_device_type,
void(CL_CALLBACK *)( // NOLINT(readability/casting)
const char *, const void *, size_t, void *),
void *, cl_int *);
using clReleaseContextFunc = cl_int (*)(cl_context);
using clWaitForEventsFunc = cl_int (*)(cl_uint, const cl_event *);
using clReleaseEventFunc = cl_int (*)(cl_event);
using clEnqueueWriteBufferFunc = cl_int (*)(cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint,
const cl_event *, cl_event *);
using clEnqueueWriteImageFunc = cl_int (*)(cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *, size_t,
size_t, const void *, cl_uint, const cl_event *, cl_event *);
using clEnqueueReadImageFunc = cl_int (*)(cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *, size_t,
size_t, void *, cl_uint, const cl_event *, cl_event *);
using clEnqueueReadBufferFunc = cl_int (*)(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void *, cl_uint,
const cl_event *, cl_event *);
using clGetProgramBuildInfoFunc = cl_int (*)(cl_program, cl_device_id, cl_program_build_info, size_t, void *,
size_t *);
using clRetainProgramFunc = cl_int (*)(cl_program program);
using clEnqueueMapBufferFunc = void *(*)(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint,
const cl_event *, cl_event *, cl_int *);
using clEnqueueMapImageFunc = void *(*)(cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t *,
const size_t *, size_t *, size_t *, cl_uint, const cl_event *, cl_event *,
cl_int *);
using clCreateCommandQueueFunc = cl_command_queue(CL_API_CALL *)(cl_context, cl_device_id,
cl_command_queue_properties, cl_int *);
using clGetCommandQueueInfoFunc = cl_int (*)(cl_command_queue, cl_command_queue_info, size_t, void *, size_t *);
using clReleaseCommandQueueFunc = cl_int (*)(cl_command_queue);
using clCreateProgramWithBinaryFunc = cl_program (*)(cl_context, cl_uint, const cl_device_id *, const size_t *,
const unsigned char **, cl_int *, cl_int *);
using clRetainContextFunc = cl_int (*)(cl_context context);
using clGetContextInfoFunc = cl_int (*)(cl_context, cl_context_info, size_t, void *, size_t *);
using clReleaseProgramFunc = cl_int (*)(cl_program program);
using clFlushFunc = cl_int (*)(cl_command_queue command_queue);
using clFinishFunc = cl_int (*)(cl_command_queue command_queue);
using clGetProgramInfoFunc = cl_int (*)(cl_program, cl_program_info, size_t, void *, size_t *);
using clCreateKernelFunc = cl_kernel (*)(cl_program, const char *, cl_int *);
using clRetainKernelFunc = cl_int (*)(cl_kernel kernel);
using clCreateBufferFunc = cl_mem (*)(cl_context, cl_mem_flags, size_t, void *, cl_int *);
using clCreateImage2DFunc = cl_mem(CL_API_CALL *)(cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t,
size_t, void *, cl_int *);
using clCreateImage3DFunc = cl_mem(CL_API_CALL *)(cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t,
size_t, size_t, size_t, void *, cl_int *);
using clCreateProgramWithSourceFunc = cl_program (*)(cl_context, cl_uint, const char **, const size_t *, cl_int *);
using clReleaseKernelFunc = cl_int (*)(cl_kernel kernel);
using clGetDeviceInfoFunc = cl_int (*)(cl_device_id, cl_device_info, size_t, void *, size_t *);
using clGetDeviceIDsFunc = cl_int (*)(cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
using clRetainEventFunc = cl_int (*)(cl_event);
using clGetKernelWorkGroupInfoFunc = cl_int (*)(cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void *,
size_t *);
using clGetEventInfoFunc = cl_int (*)(cl_event event, cl_event_info param_name, size_t param_value_size,
void *param_value, size_t *param_value_size_ret);
using clGetEventProfilingInfoFunc = cl_int (*)(cl_event event, cl_profiling_info param_name, size_t param_value_size,
void *param_value, size_t *param_value_size_ret);
using clGetImageInfoFunc = cl_int (*)(cl_mem, cl_image_info, size_t, void *, size_t *);
using clEnqueueCopyBufferToImageFunc = cl_int(CL_API_CALL *)(cl_command_queue, cl_mem, cl_mem, size_t, const size_t *,
const size_t *, cl_uint, const cl_event *, cl_event *);
using clEnqueueCopyImageToBufferFunc = cl_int(CL_API_CALL *)(cl_command_queue, cl_mem, cl_mem, const size_t *,
const size_t *, size_t, cl_uint, const cl_event *,
cl_event *);
using clCreateContextFromTypeFunc = cl_context (*)(const cl_context_properties *, cl_device_type,
void(CL_CALLBACK *)( // NOLINT(readability/casting)
const char *, const void *, size_t, void *),
void *, cl_int *);
using clReleaseContextFunc = cl_int (*)(cl_context);
using clWaitForEventsFunc = cl_int (*)(cl_uint, const cl_event *);
using clReleaseEventFunc = cl_int (*)(cl_event);
using clEnqueueWriteBufferFunc = cl_int (*)(cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint,
const cl_event *, cl_event *);
using clEnqueueWriteImageFunc = cl_int (*)(cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *, size_t,
size_t, const void *, cl_uint, const cl_event *, cl_event *);
using clEnqueueReadImageFunc = cl_int (*)(cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *, size_t,
size_t, void *, cl_uint, const cl_event *, cl_event *);
using clEnqueueReadBufferFunc = cl_int (*)(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void *, cl_uint,
const cl_event *, cl_event *);
using clGetProgramBuildInfoFunc = cl_int (*)(cl_program, cl_device_id, cl_program_build_info, size_t, void *, size_t *);
using clRetainProgramFunc = cl_int (*)(cl_program program);
using clEnqueueMapBufferFunc = void *(*)(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint,
const cl_event *, cl_event *, cl_int *);
using clEnqueueMapImageFunc = void *(*)(cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t *, const size_t *,
size_t *, size_t *, cl_uint, const cl_event *, cl_event *, cl_int *);
using clCreateCommandQueueFunc = cl_command_queue(CL_API_CALL *)(cl_context, cl_device_id, cl_command_queue_properties,
cl_int *);
using clGetCommandQueueInfoFunc = cl_int (*)(cl_command_queue, cl_command_queue_info, size_t, void *, size_t *);
using clReleaseCommandQueueFunc = cl_int (*)(cl_command_queue);
using clCreateProgramWithBinaryFunc = cl_program (*)(cl_context, cl_uint, const cl_device_id *, const size_t *,
const unsigned char **, cl_int *, cl_int *);
using clRetainContextFunc = cl_int (*)(cl_context context);
using clGetContextInfoFunc = cl_int (*)(cl_context, cl_context_info, size_t, void *, size_t *);
using clReleaseProgramFunc = cl_int (*)(cl_program program);
using clFlushFunc = cl_int (*)(cl_command_queue command_queue);
using clFinishFunc = cl_int (*)(cl_command_queue command_queue);
using clGetProgramInfoFunc = cl_int (*)(cl_program, cl_program_info, size_t, void *, size_t *);
using clCreateKernelFunc = cl_kernel (*)(cl_program, const char *, cl_int *);
using clRetainKernelFunc = cl_int (*)(cl_kernel kernel);
using clCreateBufferFunc = cl_mem (*)(cl_context, cl_mem_flags, size_t, void *, cl_int *);
using clCreateImage2DFunc = cl_mem(CL_API_CALL *)(cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t,
size_t, void *, cl_int *);
using clCreateImage3DFunc = cl_mem(CL_API_CALL *)(cl_context, cl_mem_flags, const cl_image_format *, size_t, size_t,
size_t, size_t, size_t, void *, cl_int *);
using clCreateProgramWithSourceFunc = cl_program (*)(cl_context, cl_uint, const char **, const size_t *, cl_int *);
using clReleaseKernelFunc = cl_int (*)(cl_kernel kernel);
using clGetDeviceInfoFunc = cl_int (*)(cl_device_id, cl_device_info, size_t, void *, size_t *);
using clGetDeviceIDsFunc = cl_int (*)(cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
using clRetainEventFunc = cl_int (*)(cl_event);
using clGetKernelWorkGroupInfoFunc = cl_int (*)(cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void *,
size_t *);
using clGetEventInfoFunc = cl_int (*)(cl_event event, cl_event_info param_name, size_t param_value_size,
void *param_value, size_t *param_value_size_ret);
using clGetEventProfilingInfoFunc = cl_int (*)(cl_event event, cl_profiling_info param_name, size_t param_value_size,
void *param_value, size_t *param_value_size_ret);
using clGetImageInfoFunc = cl_int (*)(cl_mem, cl_image_info, size_t, void *, size_t *);
using clEnqueueCopyBufferToImageFunc = cl_int(CL_API_CALL *)(cl_command_queue, cl_mem, cl_mem, size_t, const size_t *,
const size_t *, cl_uint, const cl_event *, cl_event *);
using clEnqueueCopyImageToBufferFunc = cl_int(CL_API_CALL *)(cl_command_queue, cl_mem, cl_mem, const size_t *,
const size_t *, size_t, cl_uint, const cl_event *,
cl_event *);
#if CL_HPP_TARGET_OPENCL_VERSION >= 120
using clRetainDeviceFunc = cl_int (*)(cl_device_id);
using clReleaseDeviceFunc = cl_int (*)(cl_device_id);
using clCreateImageFunc = cl_mem (*)(cl_context, cl_mem_flags, const cl_image_format *, const cl_image_desc *, void *,
cl_int *);
using clRetainDeviceFunc = cl_int (*)(cl_device_id);
using clReleaseDeviceFunc = cl_int (*)(cl_device_id);
using clCreateImageFunc = cl_mem (*)(cl_context, cl_mem_flags, const cl_image_format *, const cl_image_desc *, void *,
cl_int *);
#endif
#if CL_HPP_TARGET_OPENCL_VERSION >= 200
using clCreateProgramWithILFunc = cl_program (*)(cl_context, const void *, size_t, cl_int *);
using clSVMAllocFunc = void *(*)(cl_context, cl_mem_flags, size_t size, cl_uint);
using clSVMFreeFunc = void (*)(cl_context, void *);
using clEnqueueSVMMapFunc = cl_int (*)(cl_command_queue, cl_bool, cl_map_flags, void *, size_t, cl_uint,
const cl_event *, cl_event *);
using clEnqueueSVMUnmapFunc = cl_int (*)(cl_command_queue, void *, cl_uint, const cl_event *, cl_event *);
using clSetKernelArgSVMPointerFunc = cl_int (*)(cl_kernel, cl_uint, const void *);
// opencl 2.0 can get sub group info and wave size.
using clGetKernelSubGroupInfoKHRFunc = cl_int(CL_API_CALL *)(cl_kernel, cl_device_id, cl_kernel_sub_group_info,
size_t, const void *, size_t, void *, size_t *);
using clCreateCommandQueueWithPropertiesFunc = cl_command_queue(CL_API_CALL *)(cl_context, cl_device_id,
const cl_queue_properties *, cl_int *);
using clGetExtensionFunctionAddressFunc = void *(CL_API_CALL *)(const char *);
using clCreateProgramWithILFunc = cl_program (*)(cl_context, const void *, size_t, cl_int *);
using clSVMAllocFunc = void *(*)(cl_context, cl_mem_flags, size_t size, cl_uint);
using clSVMFreeFunc = void (*)(cl_context, void *);
using clEnqueueSVMMapFunc = cl_int (*)(cl_command_queue, cl_bool, cl_map_flags, void *, size_t, cl_uint,
const cl_event *, cl_event *);
using clEnqueueSVMUnmapFunc = cl_int (*)(cl_command_queue, void *, cl_uint, const cl_event *, cl_event *);
using clSetKernelArgSVMPointerFunc = cl_int (*)(cl_kernel, cl_uint, const void *);
// opencl 2.0 can get sub group info and wave size.
using clGetKernelSubGroupInfoKHRFunc = cl_int(CL_API_CALL *)(cl_kernel, cl_device_id, cl_kernel_sub_group_info, size_t,
const void *, size_t, void *, size_t *);
using clCreateCommandQueueWithPropertiesFunc = cl_command_queue(CL_API_CALL *)(cl_context, cl_device_id,
const cl_queue_properties *, cl_int *);
using clGetExtensionFunctionAddressFunc = void *(CL_API_CALL *)(const char *);
#endif
#define CL_DEFINE_FUNC_PTR(func) func##Func func = nullptr
#define CL_DECLARE_FUNC_PTR(func) extern func##Func func
CL_DEFINE_FUNC_PTR(clGetPlatformIDs);
CL_DEFINE_FUNC_PTR(clGetPlatformInfo);
CL_DEFINE_FUNC_PTR(clBuildProgram);
CL_DEFINE_FUNC_PTR(clEnqueueNDRangeKernel);
CL_DEFINE_FUNC_PTR(clSetKernelArg);
CL_DEFINE_FUNC_PTR(clReleaseKernel);
CL_DEFINE_FUNC_PTR(clCreateProgramWithSource);
CL_DEFINE_FUNC_PTR(clCreateBuffer);
CL_DEFINE_FUNC_PTR(clCreateImage2D);
CL_DEFINE_FUNC_PTR(clCreateImage3D);
CL_DEFINE_FUNC_PTR(clRetainKernel);
CL_DEFINE_FUNC_PTR(clCreateKernel);
CL_DEFINE_FUNC_PTR(clGetProgramInfo);
CL_DEFINE_FUNC_PTR(clFlush);
CL_DEFINE_FUNC_PTR(clFinish);
CL_DEFINE_FUNC_PTR(clReleaseProgram);
CL_DEFINE_FUNC_PTR(clRetainContext);
CL_DEFINE_FUNC_PTR(clGetContextInfo);
CL_DEFINE_FUNC_PTR(clCreateProgramWithBinary);
CL_DEFINE_FUNC_PTR(clCreateCommandQueue);
CL_DEFINE_FUNC_PTR(clGetCommandQueueInfo);
CL_DEFINE_FUNC_PTR(clReleaseCommandQueue);
CL_DEFINE_FUNC_PTR(clEnqueueMapBuffer);
CL_DEFINE_FUNC_PTR(clEnqueueMapImage);
CL_DEFINE_FUNC_PTR(clEnqueueCopyImage);
CL_DEFINE_FUNC_PTR(clRetainProgram);
CL_DEFINE_FUNC_PTR(clGetProgramBuildInfo);
CL_DEFINE_FUNC_PTR(clEnqueueReadBuffer);
CL_DEFINE_FUNC_PTR(clEnqueueWriteBuffer);
CL_DEFINE_FUNC_PTR(clEnqueueWriteImage);
CL_DEFINE_FUNC_PTR(clEnqueueReadImage);
CL_DEFINE_FUNC_PTR(clWaitForEvents);
CL_DEFINE_FUNC_PTR(clReleaseEvent);
CL_DEFINE_FUNC_PTR(clCreateContext);
CL_DEFINE_FUNC_PTR(clCreateContextFromType);
CL_DEFINE_FUNC_PTR(clReleaseContext);
CL_DEFINE_FUNC_PTR(clRetainCommandQueue);
CL_DEFINE_FUNC_PTR(clEnqueueUnmapMemObject);
CL_DEFINE_FUNC_PTR(clRetainMemObject);
CL_DEFINE_FUNC_PTR(clReleaseMemObject);
CL_DEFINE_FUNC_PTR(clGetDeviceInfo);
CL_DEFINE_FUNC_PTR(clGetDeviceIDs);
CL_DEFINE_FUNC_PTR(clRetainEvent);
CL_DEFINE_FUNC_PTR(clGetKernelWorkGroupInfo);
CL_DEFINE_FUNC_PTR(clGetEventInfo);
CL_DEFINE_FUNC_PTR(clGetEventProfilingInfo);
CL_DEFINE_FUNC_PTR(clGetImageInfo);
CL_DEFINE_FUNC_PTR(clEnqueueCopyBufferToImage);
CL_DEFINE_FUNC_PTR(clEnqueueCopyImageToBuffer);
CL_DECLARE_FUNC_PTR(clGetPlatformIDs);
CL_DECLARE_FUNC_PTR(clGetPlatformInfo);
CL_DECLARE_FUNC_PTR(clBuildProgram);
CL_DECLARE_FUNC_PTR(clEnqueueNDRangeKernel);
CL_DECLARE_FUNC_PTR(clSetKernelArg);
CL_DECLARE_FUNC_PTR(clReleaseKernel);
CL_DECLARE_FUNC_PTR(clCreateProgramWithSource);
CL_DECLARE_FUNC_PTR(clCreateBuffer);
CL_DECLARE_FUNC_PTR(clCreateImage2D);
CL_DECLARE_FUNC_PTR(clCreateImage3D);
CL_DECLARE_FUNC_PTR(clRetainKernel);
CL_DECLARE_FUNC_PTR(clCreateKernel);
CL_DECLARE_FUNC_PTR(clGetProgramInfo);
CL_DECLARE_FUNC_PTR(clFlush);
CL_DECLARE_FUNC_PTR(clFinish);
CL_DECLARE_FUNC_PTR(clReleaseProgram);
CL_DECLARE_FUNC_PTR(clRetainContext);
CL_DECLARE_FUNC_PTR(clGetContextInfo);
CL_DECLARE_FUNC_PTR(clCreateProgramWithBinary);
CL_DECLARE_FUNC_PTR(clCreateCommandQueue);
CL_DECLARE_FUNC_PTR(clGetCommandQueueInfo);
CL_DECLARE_FUNC_PTR(clReleaseCommandQueue);
CL_DECLARE_FUNC_PTR(clEnqueueMapBuffer);
CL_DECLARE_FUNC_PTR(clEnqueueMapImage);
CL_DECLARE_FUNC_PTR(clEnqueueCopyImage);
CL_DECLARE_FUNC_PTR(clRetainProgram);
CL_DECLARE_FUNC_PTR(clGetProgramBuildInfo);
CL_DECLARE_FUNC_PTR(clEnqueueReadBuffer);
CL_DECLARE_FUNC_PTR(clEnqueueWriteBuffer);
CL_DECLARE_FUNC_PTR(clEnqueueWriteImage);
CL_DECLARE_FUNC_PTR(clEnqueueReadImage);
CL_DECLARE_FUNC_PTR(clWaitForEvents);
CL_DECLARE_FUNC_PTR(clReleaseEvent);
CL_DECLARE_FUNC_PTR(clCreateContext);
CL_DECLARE_FUNC_PTR(clCreateContextFromType);
CL_DECLARE_FUNC_PTR(clReleaseContext);
CL_DECLARE_FUNC_PTR(clRetainCommandQueue);
CL_DECLARE_FUNC_PTR(clEnqueueUnmapMemObject);
CL_DECLARE_FUNC_PTR(clRetainMemObject);
CL_DECLARE_FUNC_PTR(clReleaseMemObject);
CL_DECLARE_FUNC_PTR(clGetDeviceInfo);
CL_DECLARE_FUNC_PTR(clGetDeviceIDs);
CL_DECLARE_FUNC_PTR(clRetainEvent);
CL_DECLARE_FUNC_PTR(clGetKernelWorkGroupInfo);
CL_DECLARE_FUNC_PTR(clGetEventInfo);
CL_DECLARE_FUNC_PTR(clGetEventProfilingInfo);
CL_DECLARE_FUNC_PTR(clGetImageInfo);
CL_DECLARE_FUNC_PTR(clEnqueueCopyBufferToImage);
CL_DECLARE_FUNC_PTR(clEnqueueCopyImageToBuffer);
#if CL_HPP_TARGET_OPENCL_VERSION >= 120
CL_DEFINE_FUNC_PTR(clRetainDevice);
CL_DEFINE_FUNC_PTR(clReleaseDevice);
CL_DEFINE_FUNC_PTR(clCreateImage);
CL_DECLARE_FUNC_PTR(clRetainDevice);
CL_DECLARE_FUNC_PTR(clReleaseDevice);
CL_DECLARE_FUNC_PTR(clCreateImage);
#endif
#if CL_HPP_TARGET_OPENCL_VERSION >= 200
CL_DEFINE_FUNC_PTR(clGetKernelSubGroupInfoKHR);
CL_DEFINE_FUNC_PTR(clCreateCommandQueueWithProperties);
CL_DEFINE_FUNC_PTR(clGetExtensionFunctionAddress);
CL_DEFINE_FUNC_PTR(clCreateProgramWithIL);
CL_DEFINE_FUNC_PTR(clSVMAlloc);
CL_DEFINE_FUNC_PTR(clSVMFree);
CL_DEFINE_FUNC_PTR(clEnqueueSVMMap);
CL_DEFINE_FUNC_PTR(clEnqueueSVMUnmap);
CL_DEFINE_FUNC_PTR(clSetKernelArgSVMPointer);
CL_DECLARE_FUNC_PTR(clGetKernelSubGroupInfoKHR);
CL_DECLARE_FUNC_PTR(clCreateCommandQueueWithProperties);
CL_DECLARE_FUNC_PTR(clGetExtensionFunctionAddress);
CL_DECLARE_FUNC_PTR(clCreateProgramWithIL);
CL_DECLARE_FUNC_PTR(clSVMAlloc);
CL_DECLARE_FUNC_PTR(clSVMFree);
CL_DECLARE_FUNC_PTR(clEnqueueSVMMap);
CL_DECLARE_FUNC_PTR(clEnqueueSVMUnmap);
CL_DECLARE_FUNC_PTR(clSetKernelArgSVMPointer);
#endif
#undef TNN_CL_DEFINE_FUNC_PTR
private:
OpenCLWrapper();
bool LoadLibraryFromPath(const std::string &path);
private:
void *handle_{nullptr};
};
#undef CL_DECLARE_FUNC_PTR
} // namespace mindspore::lite::opencl
#endif // USE_OPENCL_WRAPPER