Skip to content

Commit

Permalink
Fix used ext function lookup type
Browse files Browse the repository at this point in the history
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
  • Loading branch information
steffenlarsen committed Mar 15, 2024
1 parent bc54043 commit 7e8c469
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 69 deletions.
79 changes: 26 additions & 53 deletions source/adapters/opencl/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(

cl_context CLContext = cl_adapter::cast<cl_context>(hContext);
cl_ext::clCreateCommandBufferKHR_fn clCreateCommandBufferKHR = nullptr;
cl_int Res =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clCreateCommandBufferKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clCreateCommandBufferKHRCache,
cl_ext::CreateCommandBufferName, &clCreateCommandBufferKHR);

if (Res != CL_SUCCESS)
return Res;
cl_ext::CreateCommandBufferName, &clCreateCommandBufferKHR));

auto CLCommandBuffer = clCreateCommandBufferKHR(
1, cl_adapter::cast<cl_command_queue *>(&Queue), nullptr, &Res);
Expand All @@ -51,12 +48,10 @@ urCommandBufferRetainExp(ur_exp_command_buffer_handle_t hCommandBuffer) {

cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clRetainCommandBufferKHR_fn clRetainCommandBuffer = nullptr;
cl_int Res = cl_ext::getExtFuncFromContext<decltype(clRetainCommandBuffer)>(
CLContext, cl_ext::ExtFuncPtrCache->clRetainCommandBufferKHRCache,
cl_ext::RetainCommandBufferName, &clRetainCommandBuffer);

if (Res != CL_SUCCESS)
return Res;
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clRetainCommandBuffer)>(
CLContext, cl_ext::ExtFuncPtrCache->clRetainCommandBufferKHRCache,
cl_ext::RetainCommandBufferName, &clRetainCommandBuffer));

CL_RETURN_ON_FAILURE(clRetainCommandBuffer(hCommandBuffer->CLCommandBuffer));
return UR_RESULT_SUCCESS;
Expand All @@ -68,13 +63,10 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) {

cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clReleaseCommandBufferKHR_fn clReleaseCommandBufferKHR = nullptr;
cl_int Res =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clReleaseCommandBufferKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clReleaseCommandBufferKHRCache,
cl_ext::ReleaseCommandBufferName, &clReleaseCommandBufferKHR);

if (Res != CL_SUCCESS)
return Res;
cl_ext::ReleaseCommandBufferName, &clReleaseCommandBufferKHR));

CL_RETURN_ON_FAILURE(
clReleaseCommandBufferKHR(hCommandBuffer->CLCommandBuffer));
Expand All @@ -85,13 +77,10 @@ UR_APIEXPORT ur_result_t UR_APICALL
urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clFinalizeCommandBufferKHR_fn clFinalizeCommandBufferKHR = nullptr;
cl_int Res =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clFinalizeCommandBufferKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clFinalizeCommandBufferKHRCache,
cl_ext::FinalizeCommandBufferName, &clFinalizeCommandBufferKHR);

if (Res != CL_SUCCESS)
return Res;
cl_ext::FinalizeCommandBufferName, &clFinalizeCommandBufferKHR));

CL_RETURN_ON_FAILURE(
clFinalizeCommandBufferKHR(hCommandBuffer->CLCommandBuffer));
Expand All @@ -109,13 +98,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(

cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clCommandNDRangeKernelKHR_fn clCommandNDRangeKernelKHR = nullptr;
cl_int Res =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clCommandNDRangeKernelKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clCommandNDRangeKernelKHRCache,
cl_ext::CommandNRRangeKernelName, &clCommandNDRangeKernelKHR);

if (Res != CL_SUCCESS)
return Res;
cl_ext::CommandNRRangeKernelName, &clCommandNDRangeKernelKHR));

CL_RETURN_ON_FAILURE(clCommandNDRangeKernelKHR(
hCommandBuffer->CLCommandBuffer, nullptr, nullptr,
Expand Down Expand Up @@ -157,12 +143,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp(

cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clCommandCopyBufferKHR_fn clCommandCopyBufferKHR = nullptr;
cl_int Res = cl_ext::getExtFuncFromContext<decltype(clCommandCopyBufferKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clCommandCopyBufferKHRCache,
cl_ext::CommandCopyBufferName, &clCommandCopyBufferKHR);

if (Res != CL_SUCCESS)
return Res;
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clCommandCopyBufferKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clCommandCopyBufferKHRCache,
cl_ext::CommandCopyBufferName, &clCommandCopyBufferKHR));

CL_RETURN_ON_FAILURE(clCommandCopyBufferKHR(
hCommandBuffer->CLCommandBuffer, nullptr,
Expand Down Expand Up @@ -193,13 +177,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp(

cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clCommandCopyBufferRectKHR_fn clCommandCopyBufferRectKHR = nullptr;
cl_int Res =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clCommandCopyBufferRectKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clCommandCopyBufferRectKHRCache,
cl_ext::CommandCopyBufferRectName, &clCommandCopyBufferRectKHR);

if (Res != CL_SUCCESS)
return Res;
cl_ext::CommandCopyBufferRectName, &clCommandCopyBufferRectKHR));

CL_RETURN_ON_FAILURE(clCommandCopyBufferRectKHR(
hCommandBuffer->CLCommandBuffer, nullptr,
Expand Down Expand Up @@ -283,12 +264,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp(

cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clCommandFillBufferKHR_fn clCommandFillBufferKHR = nullptr;
cl_int Res = cl_ext::getExtFuncFromContext<decltype(clCommandFillBufferKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clCommandFillBufferKHRCache,
cl_ext::CommandFillBufferName, &clCommandFillBufferKHR);

if (Res != CL_SUCCESS)
return Res;
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clCommandFillBufferKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clCommandFillBufferKHRCache,
cl_ext::CommandFillBufferName, &clCommandFillBufferKHR));

CL_RETURN_ON_FAILURE(clCommandFillBufferKHR(
hCommandBuffer->CLCommandBuffer, nullptr,
Expand Down Expand Up @@ -339,13 +318,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(

cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clEnqueueCommandBufferKHR_fn clEnqueueCommandBufferKHR = nullptr;
cl_int Res =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clEnqueueCommandBufferKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clEnqueueCommandBufferKHRCache,
cl_ext::EnqueueCommandBufferName, &clEnqueueCommandBufferKHR);

if (Res != CL_SUCCESS)
return Res;
cl_ext::EnqueueCommandBufferName, &clEnqueueCommandBufferKHR));

const uint32_t NumberOfQueues = 1;

Expand Down Expand Up @@ -382,13 +358,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferGetInfoExp(

cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
cl_ext::clGetCommandBufferInfoKHR_fn clGetCommandBufferInfoKHR = nullptr;
cl_int Res =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<decltype(clGetCommandBufferInfoKHR)>(
CLContext, cl_ext::ExtFuncPtrCache->clGetCommandBufferInfoKHRCache,
cl_ext::GetCommandBufferInfoName, &clGetCommandBufferInfoKHR);

if (Res != CL_SUCCESS)
return Res;
cl_ext::GetCommandBufferInfoName, &clGetCommandBufferInfoKHR));

if (propName != UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT) {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
Expand Down
22 changes: 8 additions & 14 deletions source/adapters/opencl/enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite(
return mapCLErrorToUR(Res);

cl_ext::clEnqueueWriteGlobalVariable_fn F = nullptr;
Res = cl_ext::getExtFuncFromContext<decltype(F)>(
UR_RETURN_ON_FAILURE(cl_ext::getExtFuncFromContext<decltype(F)>(
Ctx, cl_ext::ExtFuncPtrCache->clEnqueueWriteGlobalVariableCache,
cl_ext::EnqueueWriteGlobalVariableName, &F);

if (Res != CL_SUCCESS)
return Res;
cl_ext::EnqueueWriteGlobalVariableName, &F));

Res = F(cl_adapter::cast<cl_command_queue>(hQueue),
cl_adapter::cast<cl_program>(hProgram), name, blockingWrite, count,
Expand All @@ -378,12 +375,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead(
return mapCLErrorToUR(Res);

cl_ext::clEnqueueReadGlobalVariable_fn F = nullptr;
Res = cl_ext::getExtFuncFromContext<decltype(F)>(
UR_RETURN_ON_FAILURE(cl_ext::getExtFuncFromContext<decltype(F)>(
Ctx, cl_ext::ExtFuncPtrCache->clEnqueueReadGlobalVariableCache,
cl_ext::EnqueueReadGlobalVariableName, &F);

if (Res != CL_SUCCESS)
return Res;
cl_ext::EnqueueReadGlobalVariableName, &F));

Res = F(cl_adapter::cast<cl_command_queue>(hQueue),
cl_adapter::cast<cl_program>(hProgram), name, blockingRead, count,
Expand All @@ -409,10 +403,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueReadHostPipe(
}

cl_ext::clEnqueueReadHostPipeINTEL_fn FuncPtr = nullptr;
ur_result_t RetVal =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<cl_ext::clEnqueueReadHostPipeINTEL_fn>(
CLContext, cl_ext::ExtFuncPtrCache->clEnqueueReadHostPipeINTELCache,
cl_ext::EnqueueReadHostPipeName, &FuncPtr);
cl_ext::EnqueueReadHostPipeName, &FuncPtr));

if (FuncPtr) {
RetVal = mapCLErrorToUR(
Expand Down Expand Up @@ -441,10 +435,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueWriteHostPipe(
}

cl_ext::clEnqueueWriteHostPipeINTEL_fn FuncPtr = nullptr;
ur_result_t RetVal =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<cl_ext::clEnqueueWriteHostPipeINTEL_fn>(
CLContext, cl_ext::ExtFuncPtrCache->clEnqueueWriteHostPipeINTELCache,
cl_ext::EnqueueWriteHostPipeName, &FuncPtr);
cl_ext::EnqueueWriteHostPipeName, &FuncPtr));

if (FuncPtr) {
RetVal = mapCLErrorToUR(
Expand Down
4 changes: 2 additions & 2 deletions source/adapters/opencl/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreate(
clCreateBufferWithPropertiesINTEL_fn FuncPtr = nullptr;
cl_context CLContext = cl_adapter::cast<cl_context>(hContext);
// First we need to look up the function pointer
RetErr =
UR_RETURN_ON_FAILURE(
cl_ext::getExtFuncFromContext<clCreateBufferWithPropertiesINTEL_fn>(
CLContext,
cl_ext::ExtFuncPtrCache->clCreateBufferWithPropertiesINTELCache,
cl_ext::CreateBufferWithPropertiesName, &FuncPtr);
cl_ext::CreateBufferWithPropertiesName, &FuncPtr));
if (FuncPtr) {
std::vector<cl_mem_properties_intel> PropertiesIntel;
auto Prop = static_cast<ur_base_properties_t *>(pProperties->pNext);
Expand Down

0 comments on commit 7e8c469

Please sign in to comment.