From fe530401fb256b6633f6192a0e3fe04062fb3975 Mon Sep 17 00:00:00 2001 From: Siva Rama Krishna Reddy B Date: Thu, 17 Nov 2022 16:26:03 +0530 Subject: [PATCH] * lint error --- src/runtime/opencl/opencl_common.h | 4 ++-- src/runtime/opencl/opencl_device_api.cc | 22 +++++++++---------- .../opencl/opencl_wrapper/opencl_wrapper.cc | 20 ++++++++--------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/runtime/opencl/opencl_common.h b/src/runtime/opencl/opencl_common.h index efe8e5d675f88..43e70d68efea8 100644 --- a/src/runtime/opencl/opencl_common.h +++ b/src/runtime/opencl/opencl_common.h @@ -313,7 +313,7 @@ class OpenCLWorkspace : public DeviceAPI { void CopyDataFromTo(DLTensor* from, DLTensor* to, TVMStreamHandle stream) final; - void* CreateHostPtrIfEnabled(BufferDescriptor *desc, Device dev, size_t size); + void* CreateHostPtrIfEnabled(BufferDescriptor* desc, Device dev, size_t size); }; /*! \brief Thread local workspace */ @@ -375,7 +375,7 @@ struct BufferDescriptor { static String ScopeFromMemoryLayout(MemoryLayout mem_scope); cl_mem buffer{nullptr}; - cl_uchar *host_ptr{nullptr}; + cl_uchar* host_ptr{nullptr}; MemoryLayout layout{MemoryLayout::kBuffer1D}; }; } // namespace cl diff --git a/src/runtime/opencl/opencl_device_api.cc b/src/runtime/opencl/opencl_device_api.cc index 0b1edc850dd74..4f97fd3170d2c 100644 --- a/src/runtime/opencl/opencl_device_api.cc +++ b/src/runtime/opencl/opencl_device_api.cc @@ -28,7 +28,7 @@ #include "opencl_common.h" #ifdef OPENCL_ENABLE_HOST_PTR -#define CL_MEM_CREATE_FLAGS CL_MEM_READ_WRITE|CL_MEM_ALLOC_HOST_PTR +#define CL_MEM_CREATE_FLAGS CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR #else #define CL_MEM_CREATE_FLAGS CL_MEM_READ_WRITE #endif @@ -203,15 +203,15 @@ void OpenCLWorkspace::GetAttr(Device dev, DeviceAttrKind kind, TVMRetValue* rv) } } -void * OpenCLWorkspace::CreateHostPtrIfEnabled(cl::BufferDescriptor* desc, Device dev, size_t size) { +void* OpenCLWorkspace::CreateHostPtrIfEnabled(cl::BufferDescriptor* desc, Device dev, size_t size) { #if defined(OPENCL_ENABLE_HOST_PTR) - cl_int err_code; - desc->host_ptr = (cl_uchar *)clEnqueueMapBuffer(this->GetQueue(dev), desc->buffer, CL_TRUE, - CL_MAP_WRITE, 0, sizeof(cl_uchar) * size, 0, - NULL, NULL, &err_code); - OPENCL_CHECK_ERROR(err_code); + cl_int err_code; + desc->host_ptr = reinterpret_cast( + clEnqueueMapBuffer(this->GetQueue(dev), desc->buffer, CL_TRUE, CL_MAP_WRITE, 0, + sizeof(cl_uchar) * size, 0, NULL, NULL, &err_code)); + OPENCL_CHECK_ERROR(err_code); #endif // OPENCL_ENABLE_HOST_PTR - return desc; + return desc; } void* OpenCLWorkspace::AllocDataSpace(Device dev, size_t size, size_t alignment, @@ -260,9 +260,9 @@ void OpenCLWorkspace::FreeDataSpace(Device dev, void* ptr) { OPENCL_CALL(clFinish(this->GetQueue(dev))); cl::BufferDescriptor* desc = static_cast(ptr); - if(desc->host_ptr) { - clEnqueueUnmapMemObject(this->GetQueue(dev), desc->buffer, (void *) desc->host_ptr, 0, NULL, - NULL); + if (desc->host_ptr) { + clEnqueueUnmapMemObject(this->GetQueue(dev), desc->buffer, + reinterpret_cast(desc->host_ptr), 0, NULL, NULL); } OPENCL_CALL(clReleaseMemObject(desc->buffer)); delete desc; diff --git a/src/runtime/opencl/opencl_wrapper/opencl_wrapper.cc b/src/runtime/opencl/opencl_wrapper/opencl_wrapper.cc index ced34e4204a15..2c2768945424c 100644 --- a/src/runtime/opencl/opencl_wrapper/opencl_wrapper.cc +++ b/src/runtime/opencl/opencl_wrapper/opencl_wrapper.cc @@ -173,10 +173,10 @@ using f_clEnqueueNDRangeKernel = cl_int (*)(cl_command_queue, cl_kernel, cl_uint cl_event*); using f_clCreateCommandQueue = cl_command_queue (*)(cl_context, cl_device_id, cl_command_queue_properties, cl_int*); -using f_clEnqueueUnmapMemObject = cl_int (*)(cl_command_queue, cl_mem, void*, - cl_uint, const cl_event*, cl_event*); -using f_clEnqueueMapBuffer = 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 f_clEnqueueUnmapMemObject = cl_int (*)(cl_command_queue, cl_mem, void*, cl_uint, + const cl_event*, cl_event*); +using f_clEnqueueMapBuffer = void* (*)(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, + size_t, cl_uint, const cl_event*, cl_event*, cl_int*); } // namespace @@ -590,15 +590,15 @@ cl_int clEnqueueUnmapMemObject(cl_command_queue queue, cl_mem memobj, void* mapp } } -void * clEnqueueMapBuffer (cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, - cl_map_flags map_flags, size_t offset, size_t cb, - cl_uint num_events_in_wait_list, const cl_event *event_wait_list, - cl_event *event, cl_int *errcode_ret) { +void* clEnqueueMapBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, + cl_map_flags map_flags, size_t offset, size_t cb, + cl_uint num_events_in_wait_list, const cl_event* event_wait_list, + cl_event* event, cl_int* errcode_ret) { auto& lib = LibOpenCLWrapper::getInstance(); auto func = (f_clEnqueueMapBuffer)lib.getOpenCLFunction("clEnqueueMapBuffer"); if (func) { - return func(command_queue, buffer, blocking_map, map_flags, offset, cb, - num_events_in_wait_list, event_wait_list, event, errcode_ret); + return func(command_queue, buffer, blocking_map, map_flags, offset, cb, num_events_in_wait_list, + event_wait_list, event, errcode_ret); } else { return nullptr; }