Skip to content

Commit 59857f1

Browse files
author
Fábio Mestre
committed
[SYCL][OpenCL] Cleanup code and address common review feedback
1 parent 381356c commit 59857f1

File tree

15 files changed

+233
-284
lines changed

15 files changed

+233
-284
lines changed

sycl/plugins/unified_runtime/CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,32 +256,38 @@ if ("opencl" IN_LIST SYCL_ENABLE_PLUGINS)
256256
SOURCES
257257
"ur/ur.hpp"
258258
"ur/ur.cpp"
259+
"ur/adapters/opencl/command_buffer.hpp"
260+
"ur/adapters/opencl/command_buffer.cpp"
259261
"ur/adapters/opencl/common.cpp"
260262
"ur/adapters/opencl/common.hpp"
261263
"ur/adapters/opencl/context.cpp"
262264
"ur/adapters/opencl/context.hpp"
263265
"ur/adapters/opencl/device.cpp"
264266
"ur/adapters/opencl/device.hpp"
265267
"ur/adapters/opencl/enqueue.cpp"
268+
"ur/adapters/opencl/event.cpp"
266269
"ur/adapters/opencl/kernel.cpp"
270+
"ur/adapters/opencl/memory.cpp"
267271
"ur/adapters/opencl/platform.cpp"
268272
"ur/adapters/opencl/platform.hpp"
269273
"ur/adapters/opencl/program.cpp"
270-
"ur/adapters/opencl/sampler.cpp"
271-
"ur/adapters/opencl/memory.cpp"
272-
"ur/adapters/opencl/event.cpp"
273274
"ur/adapters/opencl/queue.cpp"
275+
"ur/adapters/opencl/sampler.cpp"
274276
"ur/adapters/opencl/ur_interface_loader.cpp"
275277
"ur/adapters/opencl/usm.cpp"
276-
"ur/adapters/opencl/command_buffer.hpp"
277-
"ur/adapters/opencl/command_buffer.cpp"
278+
278279
INCLUDE_DIRS
279280
${sycl_inc_dir}
280281
LIBRARIES
281282
UnifiedRuntime-Headers
282283
Threads::Threads
283284
OpenCL-ICD
284285
)
286+
287+
set_target_properties("ur_adapter_opencl" PROPERTIES
288+
VERSION "0.0.0"
289+
SOVERSION "0"
290+
)
285291
endif()
286292

287293
if (TARGET UnifiedRuntimeLoader)

sycl/plugins/unified_runtime/pi2ur.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,6 @@ inline pi_result piProgramRelease(pi_program Program) {
23512351
inline pi_result piextKernelSetArgPointer(pi_kernel Kernel, pi_uint32 ArgIndex,
23522352
size_t, const void *ArgValue) {
23532353
ur_kernel_handle_t UrKernel = reinterpret_cast<ur_kernel_handle_t>(Kernel);
2354-
23552354
HANDLE_ERRORS(urKernelSetArgPointer(UrKernel, ArgIndex, nullptr, ArgValue));
23562355

23572356
return PI_SUCCESS;

sycl/plugins/unified_runtime/ur/adapters/opencl/command_buffer.cpp

Lines changed: 93 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -12,127 +12,99 @@
1212
/// Stub implementations of UR experimental feature command-buffers
1313

1414
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
15-
ur_context_handle_t hContext, ur_device_handle_t hDevice,
16-
const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
17-
ur_exp_command_buffer_handle_t *phCommandBuffer) {
18-
(void)hContext;
19-
(void)hDevice;
20-
(void)pCommandBufferDesc;
21-
(void)phCommandBuffer;
15+
[[maybe_unused]] ur_context_handle_t hContext,
16+
[[maybe_unused]] ur_device_handle_t hDevice,
17+
[[maybe_unused]] const ur_exp_command_buffer_desc_t *pCommandBufferDesc,
18+
[[maybe_unused]] ur_exp_command_buffer_handle_t *phCommandBuffer) {
19+
2220
cl_adapter::die("Experimental Command-buffer feature is not "
2321
"implemented for OpenCL adapter.");
2422
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
2523
}
2624

27-
UR_APIEXPORT ur_result_t UR_APICALL
28-
urCommandBufferRetainExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
29-
(void)hCommandBuffer;
25+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferRetainExp(
26+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer) {
3027

3128
cl_adapter::die("Experimental Command-buffer feature is not "
3229
"implemented for OpenCL adapter.");
3330
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
3431
}
3532

36-
UR_APIEXPORT ur_result_t UR_APICALL
37-
urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
38-
(void)hCommandBuffer;
33+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferReleaseExp(
34+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer) {
3935

4036
cl_adapter::die("Experimental Command-buffer feature is not "
4137
"implemented for OpenCL adapter.");
4238
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
4339
}
4440

45-
UR_APIEXPORT ur_result_t UR_APICALL
46-
urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
47-
(void)hCommandBuffer;
41+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferFinalizeExp(
42+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer) {
4843

4944
cl_adapter::die("Experimental Command-buffer feature is not "
5045
"implemented for OpenCL adapter.");
5146
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
5247
}
5348

5449
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(
55-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_kernel_handle_t hKernel,
56-
uint32_t workDim, const size_t *pGlobalWorkOffset,
57-
const size_t *pGlobalWorkSize, const size_t *pLocalWorkSize,
58-
uint32_t numSyncPointsInWaitList,
59-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
60-
ur_exp_command_buffer_sync_point_t *pSyncPoint) {
61-
(void)hCommandBuffer;
62-
(void)hKernel;
63-
(void)workDim;
64-
(void)pGlobalWorkOffset;
65-
(void)pGlobalWorkSize;
66-
(void)pLocalWorkSize;
67-
(void)numSyncPointsInWaitList;
68-
(void)pSyncPointWaitList;
69-
(void)pSyncPoint;
50+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
51+
[[maybe_unused]] ur_kernel_handle_t hKernel,
52+
[[maybe_unused]] uint32_t workDim,
53+
[[maybe_unused]] const size_t *pGlobalWorkOffset,
54+
[[maybe_unused]] const size_t *pGlobalWorkSize,
55+
[[maybe_unused]] const size_t *pLocalWorkSize,
56+
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
57+
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
58+
*pSyncPointWaitList,
59+
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
7060

7161
cl_adapter::die("Experimental Command-buffer feature is not "
7262
"implemented for OpenCL adapter.");
7363
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
7464
}
7565

7666
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemcpyUSMExp(
77-
ur_exp_command_buffer_handle_t hCommandBuffer, void *pDst, const void *pSrc,
78-
size_t size, uint32_t numSyncPointsInWaitList,
79-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
80-
ur_exp_command_buffer_sync_point_t *pSyncPoint) {
81-
(void)hCommandBuffer;
82-
(void)pDst;
83-
(void)pSrc;
84-
(void)size;
85-
(void)numSyncPointsInWaitList;
86-
(void)pSyncPointWaitList;
87-
(void)pSyncPoint;
67+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
68+
[[maybe_unused]] void *pDst, [[maybe_unused]] const void *pSrc,
69+
[[maybe_unused]] size_t size,
70+
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
71+
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
72+
*pSyncPointWaitList,
73+
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
8874

8975
cl_adapter::die("Experimental Command-buffer feature is not "
9076
"implemented for OpenCL adapter.");
9177
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
9278
}
9379

9480
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyExp(
95-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
96-
ur_mem_handle_t hDstMem, size_t srcOffset, size_t dstOffset, size_t size,
97-
uint32_t numSyncPointsInWaitList,
98-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
99-
ur_exp_command_buffer_sync_point_t *pSyncPoint) {
100-
(void)hCommandBuffer;
101-
(void)hSrcMem;
102-
(void)hDstMem;
103-
(void)srcOffset;
104-
(void)dstOffset;
105-
(void)size;
106-
(void)numSyncPointsInWaitList;
107-
(void)pSyncPointWaitList;
108-
(void)pSyncPoint;
81+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
82+
[[maybe_unused]] ur_mem_handle_t hSrcMem,
83+
[[maybe_unused]] ur_mem_handle_t hDstMem, [[maybe_unused]] size_t srcOffset,
84+
[[maybe_unused]] size_t dstOffset, [[maybe_unused]] size_t size,
85+
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
86+
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
87+
*pSyncPointWaitList,
88+
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
10989

11090
cl_adapter::die("Experimental Command-buffer feature is not "
11191
"implemented for OpenCL adapter.");
11292
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
11393
}
11494

11595
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyRectExp(
116-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
117-
ur_mem_handle_t hDstMem, ur_rect_offset_t srcOrigin,
118-
ur_rect_offset_t dstOrigin, ur_rect_region_t region, size_t srcRowPitch,
119-
size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
120-
uint32_t numSyncPointsInWaitList,
121-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
122-
ur_exp_command_buffer_sync_point_t *pSyncPoint) {
123-
(void)hCommandBuffer;
124-
(void)hSrcMem;
125-
(void)hDstMem;
126-
(void)srcOrigin;
127-
(void)dstOrigin;
128-
(void)region;
129-
(void)srcRowPitch;
130-
(void)srcSlicePitch;
131-
(void)dstRowPitch;
132-
(void)dstSlicePitch;
133-
(void)numSyncPointsInWaitList;
134-
(void)pSyncPointWaitList;
135-
(void)pSyncPoint;
96+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
97+
[[maybe_unused]] ur_mem_handle_t hSrcMem,
98+
[[maybe_unused]] ur_mem_handle_t hDstMem,
99+
[[maybe_unused]] ur_rect_offset_t srcOrigin,
100+
[[maybe_unused]] ur_rect_offset_t dstOrigin,
101+
[[maybe_unused]] ur_rect_region_t region,
102+
[[maybe_unused]] size_t srcRowPitch, [[maybe_unused]] size_t srcSlicePitch,
103+
[[maybe_unused]] size_t dstRowPitch, [[maybe_unused]] size_t dstSlicePitch,
104+
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
105+
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
106+
*pSyncPointWaitList,
107+
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
136108

137109
cl_adapter::die("Experimental Command-buffer feature is not "
138110
"implemented for OpenCL adapter.");
@@ -141,19 +113,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyRectExp(
141113

142114
UR_APIEXPORT
143115
ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteExp(
144-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
145-
size_t offset, size_t size, const void *pSrc,
146-
uint32_t numSyncPointsInWaitList,
147-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
148-
ur_exp_command_buffer_sync_point_t *pSyncPoint) {
149-
(void)hCommandBuffer;
150-
(void)hBuffer;
151-
(void)offset;
152-
(void)size;
153-
(void)pSrc;
154-
(void)numSyncPointsInWaitList;
155-
(void)pSyncPointWaitList;
156-
(void)pSyncPoint;
116+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
117+
[[maybe_unused]] ur_mem_handle_t hBuffer, [[maybe_unused]] size_t offset,
118+
[[maybe_unused]] size_t size, [[maybe_unused]] const void *pSrc,
119+
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
120+
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
121+
*pSyncPointWaitList,
122+
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
157123

158124
cl_adapter::die("Experimental Command-buffer feature is not "
159125
"implemented for OpenCL adapter.");
@@ -162,18 +128,13 @@ ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteExp(
162128

163129
UR_APIEXPORT
164130
ur_result_t UR_APICALL urCommandBufferAppendMembufferReadExp(
165-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
166-
size_t offset, size_t size, void *pDst, uint32_t numSyncPointsInWaitList,
167-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
168-
ur_exp_command_buffer_sync_point_t *pSyncPoint) {
169-
(void)hCommandBuffer;
170-
(void)hBuffer;
171-
(void)offset;
172-
(void)size;
173-
(void)pDst;
174-
(void)numSyncPointsInWaitList;
175-
(void)pSyncPointWaitList;
176-
(void)pSyncPoint;
131+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
132+
[[maybe_unused]] ur_mem_handle_t hBuffer, [[maybe_unused]] size_t offset,
133+
[[maybe_unused]] size_t size, [[maybe_unused]] void *pDst,
134+
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
135+
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
136+
*pSyncPointWaitList,
137+
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
177138

178139
cl_adapter::die("Experimental Command-buffer feature is not "
179140
"implemented for OpenCL adapter.");
@@ -182,26 +143,19 @@ ur_result_t UR_APICALL urCommandBufferAppendMembufferReadExp(
182143

183144
UR_APIEXPORT
184145
ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteRectExp(
185-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
186-
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
187-
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
188-
size_t hostRowPitch, size_t hostSlicePitch, void *pSrc,
189-
uint32_t numSyncPointsInWaitList,
190-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
191-
ur_exp_command_buffer_sync_point_t *pSyncPoint) {
192-
(void)hCommandBuffer;
193-
(void)hBuffer;
194-
(void)bufferOffset;
195-
(void)hostOffset;
196-
(void)region;
197-
(void)bufferRowPitch;
198-
(void)bufferSlicePitch;
199-
(void)hostRowPitch;
200-
(void)hostSlicePitch;
201-
(void)pSrc;
202-
(void)numSyncPointsInWaitList;
203-
(void)pSyncPointWaitList;
204-
(void)pSyncPoint;
146+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
147+
[[maybe_unused]] ur_mem_handle_t hBuffer,
148+
[[maybe_unused]] ur_rect_offset_t bufferOffset,
149+
[[maybe_unused]] ur_rect_offset_t hostOffset,
150+
[[maybe_unused]] ur_rect_region_t region,
151+
[[maybe_unused]] size_t bufferRowPitch,
152+
[[maybe_unused]] size_t bufferSlicePitch,
153+
[[maybe_unused]] size_t hostRowPitch,
154+
[[maybe_unused]] size_t hostSlicePitch, [[maybe_unused]] void *pSrc,
155+
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
156+
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
157+
*pSyncPointWaitList,
158+
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
205159

206160
cl_adapter::die("Experimental Command-buffer feature is not "
207161
"implemented for OpenCL adapter.");
@@ -210,42 +164,31 @@ ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteRectExp(
210164

211165
UR_APIEXPORT
212166
ur_result_t UR_APICALL urCommandBufferAppendMembufferReadRectExp(
213-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
214-
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
215-
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
216-
size_t hostRowPitch, size_t hostSlicePitch, void *pDst,
217-
uint32_t numSyncPointsInWaitList,
218-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
219-
ur_exp_command_buffer_sync_point_t *pSyncPoint) {
220-
(void)hCommandBuffer;
221-
(void)hBuffer;
222-
(void)bufferOffset;
223-
(void)hostOffset;
224-
(void)region;
225-
(void)bufferRowPitch;
226-
(void)bufferSlicePitch;
227-
(void)hostRowPitch;
228-
(void)hostSlicePitch;
229-
(void)pDst;
230-
231-
(void)numSyncPointsInWaitList;
232-
(void)pSyncPointWaitList;
233-
(void)pSyncPoint;
167+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
168+
[[maybe_unused]] ur_mem_handle_t hBuffer,
169+
[[maybe_unused]] ur_rect_offset_t bufferOffset,
170+
[[maybe_unused]] ur_rect_offset_t hostOffset,
171+
[[maybe_unused]] ur_rect_region_t region,
172+
[[maybe_unused]] size_t bufferRowPitch,
173+
[[maybe_unused]] size_t bufferSlicePitch,
174+
[[maybe_unused]] size_t hostRowPitch,
175+
[[maybe_unused]] size_t hostSlicePitch, [[maybe_unused]] void *pDst,
176+
[[maybe_unused]] uint32_t numSyncPointsInWaitList,
177+
[[maybe_unused]] const ur_exp_command_buffer_sync_point_t
178+
*pSyncPointWaitList,
179+
[[maybe_unused]] ur_exp_command_buffer_sync_point_t *pSyncPoint) {
234180

235181
cl_adapter::die("Experimental Command-buffer feature is not "
236182
"implemented for OpenCL adapter.");
237183
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
238184
}
239185

240186
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
241-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_queue_handle_t hQueue,
242-
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
243-
ur_event_handle_t *phEvent) {
244-
(void)hCommandBuffer;
245-
(void)hQueue;
246-
(void)numEventsInWaitList;
247-
(void)phEventWaitList;
248-
(void)phEvent;
187+
[[maybe_unused]] ur_exp_command_buffer_handle_t hCommandBuffer,
188+
[[maybe_unused]] ur_queue_handle_t hQueue,
189+
[[maybe_unused]] uint32_t numEventsInWaitList,
190+
[[maybe_unused]] const ur_event_handle_t *phEventWaitList,
191+
[[maybe_unused]] ur_event_handle_t *phEvent) {
249192

250193
cl_adapter::die("Experimental Command-buffer feature is not "
251194
"implemented for OpenCL adapter.");

sycl/plugins/unified_runtime/ur/adapters/opencl/common.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ur_result_t mapCLErrorToUR(cl_int Result) {
6464
}
6565

6666
void cl_adapter::die(const char *Message) {
67-
std::cerr << "ur_die: " << Message << std::endl;
67+
std::cerr << "ur_die: " << Message << "\n";
6868
std::terminate();
6969
}
7070

@@ -79,5 +79,3 @@ ur_result_t getNativeHandle(void *URObj, ur_native_handle_t *NativeHandle) {
7979
*NativeHandle = reinterpret_cast<ur_native_handle_t>(URObj);
8080
return UR_RESULT_SUCCESS;
8181
}
82-
83-
cl_ext::ExtFuncPtrCacheT *ExtFuncPtrCache;

0 commit comments

Comments
 (0)