Skip to content

Commit

Permalink
Add check to only cast opaque handles to cl::BufferDescriptor at runt…
Browse files Browse the repository at this point in the history
…ime. (apache#8256)
  • Loading branch information
csullivan authored and trevor-m committed Jun 17, 2021
1 parent 5ee4091 commit 93039ac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/runtime/opencl/opencl_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ class OpenCLWrappedFunc {
}
// setup arguments.
for (cl_uint i = 0; i < arg_size_.size(); ++i) {
auto* arg = static_cast<cl::BufferDescriptor*>(void_args[i]);
OPENCL_CALL(clSetKernelArg(kernel, i, arg_size_[i], arg->buffer));
void* arg = nullptr;
if (args.type_codes[i] == DLDataTypeCode::kDLOpaqueHandle) {
arg = static_cast<cl::BufferDescriptor*>(void_args[i])->buffer;
} else {
arg = void_args[i];
}
OPENCL_CALL(clSetKernelArg(kernel, i, arg_size_[i], arg));
}
cl_command_queue queue = w_->GetQueue(t->device);
ThreadWorkLoad wl = thread_axis_cfg_.Extract(args);
Expand Down

0 comments on commit 93039ac

Please sign in to comment.