Skip to content

Commit

Permalink
* lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
srkreddy1238 committed Nov 17, 2022
1 parent 597a945 commit fe53040
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/runtime/opencl/opencl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/runtime/opencl/opencl_device_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<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);
#endif // OPENCL_ENABLE_HOST_PTR
return desc;
return desc;
}

void* OpenCLWorkspace::AllocDataSpace(Device dev, size_t size, size_t alignment,
Expand Down Expand Up @@ -260,9 +260,9 @@ void OpenCLWorkspace::FreeDataSpace(Device dev, void* ptr) {
OPENCL_CALL(clFinish(this->GetQueue(dev)));

cl::BufferDescriptor* desc = static_cast<cl::BufferDescriptor*>(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<void*>(desc->host_ptr), 0, NULL, NULL);
}
OPENCL_CALL(clReleaseMemObject(desc->buffer));
delete desc;
Expand Down
20 changes: 10 additions & 10 deletions src/runtime/opencl/opencl_wrapper/opencl_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit fe53040

Please sign in to comment.