Skip to content

Commit

Permalink
Merge pull request #2160 from aarongreig/aaron/clQuerySourceWGSize
Browse files Browse the repository at this point in the history
Query out and use local size set in program IL in CL adapter.
  • Loading branch information
aarongreig authored Oct 24, 2024
2 parents a96fdde + a97df49 commit 58abf8f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
25 changes: 23 additions & 2 deletions source/adapters/opencl/enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,33 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
const size_t *pGlobalWorkOffset, const size_t *pGlobalWorkSize,
const size_t *pLocalWorkSize, uint32_t numEventsInWaitList,
const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) {
std::vector<size_t> compiledLocalWorksize;
if (!pLocalWorkSize) {
cl_device_id device = nullptr;
CL_RETURN_ON_FAILURE(clGetCommandQueueInfo(
cl_adapter::cast<cl_command_queue>(hQueue), CL_QUEUE_DEVICE,
sizeof(device), &device, nullptr));
// This query always returns size_t[3], if nothing was specified it returns
// all zeroes.
size_t queriedLocalWorkSize[3] = {0, 0, 0};
CL_RETURN_ON_FAILURE(clGetKernelWorkGroupInfo(
cl_adapter::cast<cl_kernel>(hKernel), device,
CL_KERNEL_COMPILE_WORK_GROUP_SIZE, sizeof(size_t[3]),
queriedLocalWorkSize, nullptr));
if (queriedLocalWorkSize[0] != 0) {
for (uint32_t i = 0; i < workDim; i++) {
compiledLocalWorksize.push_back(queriedLocalWorkSize[i]);
}
}
}

CL_RETURN_ON_FAILURE(clEnqueueNDRangeKernel(
cl_adapter::cast<cl_command_queue>(hQueue),
cl_adapter::cast<cl_kernel>(hKernel), workDim, pGlobalWorkOffset,
pGlobalWorkSize, pLocalWorkSize, numEventsInWaitList,
cl_adapter::cast<const cl_event *>(phEventWaitList),
pGlobalWorkSize,
compiledLocalWorksize.empty() ? pLocalWorkSize
: compiledLocalWorksize.data(),
numEventsInWaitList, cl_adapter::cast<const cl_event *>(phEventWaitList),
cl_adapter::cast<cl_event *>(phEvent)));

return UR_RESULT_SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion test/conformance/enqueue/enqueue_adapter_opencl.match
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
{{NONDETERMINISTIC}}
urEnqueueKernelLaunchKernelWgSizeTest.Success/Intel_R__OpenCL___{{.*}}_
{{OPT}}urEnqueueKernelLaunchUSMLinkedList.Success/Intel_R__OpenCL___{{.*}}_UsePoolEnabled

0 comments on commit 58abf8f

Please sign in to comment.