Skip to content

Commit 7e8c469

Browse files
committed
Fix used ext function lookup type
Signed-off-by: Larsen, Steffen <[email protected]>
1 parent bc54043 commit 7e8c469

File tree

3 files changed

+36
-69
lines changed

3 files changed

+36
-69
lines changed

source/adapters/opencl/command_buffer.cpp

Lines changed: 26 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
2121

2222
cl_context CLContext = cl_adapter::cast<cl_context>(hContext);
2323
cl_ext::clCreateCommandBufferKHR_fn clCreateCommandBufferKHR = nullptr;
24-
cl_int Res =
24+
UR_RETURN_ON_FAILURE(
2525
cl_ext::getExtFuncFromContext<decltype(clCreateCommandBufferKHR)>(
2626
CLContext, cl_ext::ExtFuncPtrCache->clCreateCommandBufferKHRCache,
27-
cl_ext::CreateCommandBufferName, &clCreateCommandBufferKHR);
28-
29-
if (Res != CL_SUCCESS)
30-
return Res;
27+
cl_ext::CreateCommandBufferName, &clCreateCommandBufferKHR));
3128

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

5249
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
5350
cl_ext::clRetainCommandBufferKHR_fn clRetainCommandBuffer = nullptr;
54-
cl_int Res = cl_ext::getExtFuncFromContext<decltype(clRetainCommandBuffer)>(
55-
CLContext, cl_ext::ExtFuncPtrCache->clRetainCommandBufferKHRCache,
56-
cl_ext::RetainCommandBufferName, &clRetainCommandBuffer);
57-
58-
if (Res != CL_SUCCESS)
59-
return Res;
51+
UR_RETURN_ON_FAILURE(
52+
cl_ext::getExtFuncFromContext<decltype(clRetainCommandBuffer)>(
53+
CLContext, cl_ext::ExtFuncPtrCache->clRetainCommandBufferKHRCache,
54+
cl_ext::RetainCommandBufferName, &clRetainCommandBuffer));
6055

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

6964
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
7065
cl_ext::clReleaseCommandBufferKHR_fn clReleaseCommandBufferKHR = nullptr;
71-
cl_int Res =
66+
UR_RETURN_ON_FAILURE(
7267
cl_ext::getExtFuncFromContext<decltype(clReleaseCommandBufferKHR)>(
7368
CLContext, cl_ext::ExtFuncPtrCache->clReleaseCommandBufferKHRCache,
74-
cl_ext::ReleaseCommandBufferName, &clReleaseCommandBufferKHR);
75-
76-
if (Res != CL_SUCCESS)
77-
return Res;
69+
cl_ext::ReleaseCommandBufferName, &clReleaseCommandBufferKHR));
7870

7971
CL_RETURN_ON_FAILURE(
8072
clReleaseCommandBufferKHR(hCommandBuffer->CLCommandBuffer));
@@ -85,13 +77,10 @@ UR_APIEXPORT ur_result_t UR_APICALL
8577
urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
8678
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
8779
cl_ext::clFinalizeCommandBufferKHR_fn clFinalizeCommandBufferKHR = nullptr;
88-
cl_int Res =
80+
UR_RETURN_ON_FAILURE(
8981
cl_ext::getExtFuncFromContext<decltype(clFinalizeCommandBufferKHR)>(
9082
CLContext, cl_ext::ExtFuncPtrCache->clFinalizeCommandBufferKHRCache,
91-
cl_ext::FinalizeCommandBufferName, &clFinalizeCommandBufferKHR);
92-
93-
if (Res != CL_SUCCESS)
94-
return Res;
83+
cl_ext::FinalizeCommandBufferName, &clFinalizeCommandBufferKHR));
9584

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

11099
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
111100
cl_ext::clCommandNDRangeKernelKHR_fn clCommandNDRangeKernelKHR = nullptr;
112-
cl_int Res =
101+
UR_RETURN_ON_FAILURE(
113102
cl_ext::getExtFuncFromContext<decltype(clCommandNDRangeKernelKHR)>(
114103
CLContext, cl_ext::ExtFuncPtrCache->clCommandNDRangeKernelKHRCache,
115-
cl_ext::CommandNRRangeKernelName, &clCommandNDRangeKernelKHR);
116-
117-
if (Res != CL_SUCCESS)
118-
return Res;
104+
cl_ext::CommandNRRangeKernelName, &clCommandNDRangeKernelKHR));
119105

120106
CL_RETURN_ON_FAILURE(clCommandNDRangeKernelKHR(
121107
hCommandBuffer->CLCommandBuffer, nullptr, nullptr,
@@ -157,12 +143,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp(
157143

158144
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
159145
cl_ext::clCommandCopyBufferKHR_fn clCommandCopyBufferKHR = nullptr;
160-
cl_int Res = cl_ext::getExtFuncFromContext<decltype(clCommandCopyBufferKHR)>(
161-
CLContext, cl_ext::ExtFuncPtrCache->clCommandCopyBufferKHRCache,
162-
cl_ext::CommandCopyBufferName, &clCommandCopyBufferKHR);
163-
164-
if (Res != CL_SUCCESS)
165-
return Res;
146+
UR_RETURN_ON_FAILURE(
147+
cl_ext::getExtFuncFromContext<decltype(clCommandCopyBufferKHR)>(
148+
CLContext, cl_ext::ExtFuncPtrCache->clCommandCopyBufferKHRCache,
149+
cl_ext::CommandCopyBufferName, &clCommandCopyBufferKHR));
166150

167151
CL_RETURN_ON_FAILURE(clCommandCopyBufferKHR(
168152
hCommandBuffer->CLCommandBuffer, nullptr,
@@ -193,13 +177,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp(
193177

194178
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
195179
cl_ext::clCommandCopyBufferRectKHR_fn clCommandCopyBufferRectKHR = nullptr;
196-
cl_int Res =
180+
UR_RETURN_ON_FAILURE(
197181
cl_ext::getExtFuncFromContext<decltype(clCommandCopyBufferRectKHR)>(
198182
CLContext, cl_ext::ExtFuncPtrCache->clCommandCopyBufferRectKHRCache,
199-
cl_ext::CommandCopyBufferRectName, &clCommandCopyBufferRectKHR);
200-
201-
if (Res != CL_SUCCESS)
202-
return Res;
183+
cl_ext::CommandCopyBufferRectName, &clCommandCopyBufferRectKHR));
203184

204185
CL_RETURN_ON_FAILURE(clCommandCopyBufferRectKHR(
205186
hCommandBuffer->CLCommandBuffer, nullptr,
@@ -283,12 +264,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferFillExp(
283264

284265
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
285266
cl_ext::clCommandFillBufferKHR_fn clCommandFillBufferKHR = nullptr;
286-
cl_int Res = cl_ext::getExtFuncFromContext<decltype(clCommandFillBufferKHR)>(
287-
CLContext, cl_ext::ExtFuncPtrCache->clCommandFillBufferKHRCache,
288-
cl_ext::CommandFillBufferName, &clCommandFillBufferKHR);
289-
290-
if (Res != CL_SUCCESS)
291-
return Res;
267+
UR_RETURN_ON_FAILURE(
268+
cl_ext::getExtFuncFromContext<decltype(clCommandFillBufferKHR)>(
269+
CLContext, cl_ext::ExtFuncPtrCache->clCommandFillBufferKHRCache,
270+
cl_ext::CommandFillBufferName, &clCommandFillBufferKHR));
292271

293272
CL_RETURN_ON_FAILURE(clCommandFillBufferKHR(
294273
hCommandBuffer->CLCommandBuffer, nullptr,
@@ -339,13 +318,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
339318

340319
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
341320
cl_ext::clEnqueueCommandBufferKHR_fn clEnqueueCommandBufferKHR = nullptr;
342-
cl_int Res =
321+
UR_RETURN_ON_FAILURE(
343322
cl_ext::getExtFuncFromContext<decltype(clEnqueueCommandBufferKHR)>(
344323
CLContext, cl_ext::ExtFuncPtrCache->clEnqueueCommandBufferKHRCache,
345-
cl_ext::EnqueueCommandBufferName, &clEnqueueCommandBufferKHR);
346-
347-
if (Res != CL_SUCCESS)
348-
return Res;
324+
cl_ext::EnqueueCommandBufferName, &clEnqueueCommandBufferKHR));
349325

350326
const uint32_t NumberOfQueues = 1;
351327

@@ -382,13 +358,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferGetInfoExp(
382358

383359
cl_context CLContext = cl_adapter::cast<cl_context>(hCommandBuffer->hContext);
384360
cl_ext::clGetCommandBufferInfoKHR_fn clGetCommandBufferInfoKHR = nullptr;
385-
cl_int Res =
361+
UR_RETURN_ON_FAILURE(
386362
cl_ext::getExtFuncFromContext<decltype(clGetCommandBufferInfoKHR)>(
387363
CLContext, cl_ext::ExtFuncPtrCache->clGetCommandBufferInfoKHRCache,
388-
cl_ext::GetCommandBufferInfoName, &clGetCommandBufferInfoKHR);
389-
390-
if (Res != CL_SUCCESS)
391-
return Res;
364+
cl_ext::GetCommandBufferInfoName, &clGetCommandBufferInfoKHR));
392365

393366
if (propName != UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT) {
394367
return UR_RESULT_ERROR_INVALID_ENUMERATION;

source/adapters/opencl/enqueue.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite(
347347
return mapCLErrorToUR(Res);
348348

349349
cl_ext::clEnqueueWriteGlobalVariable_fn F = nullptr;
350-
Res = cl_ext::getExtFuncFromContext<decltype(F)>(
350+
UR_RETURN_ON_FAILURE(cl_ext::getExtFuncFromContext<decltype(F)>(
351351
Ctx, cl_ext::ExtFuncPtrCache->clEnqueueWriteGlobalVariableCache,
352-
cl_ext::EnqueueWriteGlobalVariableName, &F);
353-
354-
if (Res != CL_SUCCESS)
355-
return Res;
352+
cl_ext::EnqueueWriteGlobalVariableName, &F));
356353

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

380377
cl_ext::clEnqueueReadGlobalVariable_fn F = nullptr;
381-
Res = cl_ext::getExtFuncFromContext<decltype(F)>(
378+
UR_RETURN_ON_FAILURE(cl_ext::getExtFuncFromContext<decltype(F)>(
382379
Ctx, cl_ext::ExtFuncPtrCache->clEnqueueReadGlobalVariableCache,
383-
cl_ext::EnqueueReadGlobalVariableName, &F);
384-
385-
if (Res != CL_SUCCESS)
386-
return Res;
380+
cl_ext::EnqueueReadGlobalVariableName, &F));
387381

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

411405
cl_ext::clEnqueueReadHostPipeINTEL_fn FuncPtr = nullptr;
412-
ur_result_t RetVal =
406+
UR_RETURN_ON_FAILURE(
413407
cl_ext::getExtFuncFromContext<cl_ext::clEnqueueReadHostPipeINTEL_fn>(
414408
CLContext, cl_ext::ExtFuncPtrCache->clEnqueueReadHostPipeINTELCache,
415-
cl_ext::EnqueueReadHostPipeName, &FuncPtr);
409+
cl_ext::EnqueueReadHostPipeName, &FuncPtr));
416410

417411
if (FuncPtr) {
418412
RetVal = mapCLErrorToUR(
@@ -441,10 +435,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueWriteHostPipe(
441435
}
442436

443437
cl_ext::clEnqueueWriteHostPipeINTEL_fn FuncPtr = nullptr;
444-
ur_result_t RetVal =
438+
UR_RETURN_ON_FAILURE(
445439
cl_ext::getExtFuncFromContext<cl_ext::clEnqueueWriteHostPipeINTEL_fn>(
446440
CLContext, cl_ext::ExtFuncPtrCache->clEnqueueWriteHostPipeINTELCache,
447-
cl_ext::EnqueueWriteHostPipeName, &FuncPtr);
441+
cl_ext::EnqueueWriteHostPipeName, &FuncPtr));
448442

449443
if (FuncPtr) {
450444
RetVal = mapCLErrorToUR(

source/adapters/opencl/memory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreate(
232232
clCreateBufferWithPropertiesINTEL_fn FuncPtr = nullptr;
233233
cl_context CLContext = cl_adapter::cast<cl_context>(hContext);
234234
// First we need to look up the function pointer
235-
RetErr =
235+
UR_RETURN_ON_FAILURE(
236236
cl_ext::getExtFuncFromContext<clCreateBufferWithPropertiesINTEL_fn>(
237237
CLContext,
238238
cl_ext::ExtFuncPtrCache->clCreateBufferWithPropertiesINTELCache,
239-
cl_ext::CreateBufferWithPropertiesName, &FuncPtr);
239+
cl_ext::CreateBufferWithPropertiesName, &FuncPtr));
240240
if (FuncPtr) {
241241
std::vector<cl_mem_properties_intel> PropertiesIntel;
242242
auto Prop = static_cast<ur_base_properties_t *>(pProperties->pNext);

0 commit comments

Comments
 (0)