Skip to content

Commit

Permalink
[OPENCL] Workaround for zero size allocation (#9379)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinLu1114 authored Oct 27, 2021
1 parent 92ee99f commit 1224d48
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/runtime/opencl/opencl_device_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ void* OpenCLWorkspace::AllocDataSpace(Device dev, size_t size, size_t alignment,
ICHECK(context != nullptr) << "No OpenCL device";
cl_int err_code;
cl::BufferDescriptor* desc = new cl::BufferDescriptor;
// CL_INVALID_BUFFER_SIZE if size is 0.
if (size == 0) {
size = 1;
}
desc->buffer = clCreateBuffer(this->context, CL_MEM_READ_WRITE, size, nullptr, &err_code);
desc->layout = cl::BufferDescriptor::MemoryLayout::kBuffer1D;
OPENCL_CHECK_ERROR(err_code);
Expand Down

0 comments on commit 1224d48

Please sign in to comment.