Skip to content

Commit 27bbfcf

Browse files
uwedolinskymartygrant
authored andcommitted
[SYCL][NATIVECPU] Added remaining UR interface functions, PI exports and ABI Check (#10883)
This PR adds the remaining (not fully implemented) UR interface functions to the NativeCPU/UR adapter. The NativeCPU PI plugin now also exports all PI interface functions and an ABI check was added.
1 parent c077125 commit 27bbfcf

File tree

5 files changed

+337
-0
lines changed

5 files changed

+337
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
//===--------- command_buffer.cpp - NativeCPU Adapter ---------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===-----------------------------------------------------------------===//
8+
9+
#include "common.hpp"
10+
11+
/// Stub implementations of UR experimental feature command-buffers
12+
/// Taken almost unchanged from another adapter. Perhaps going forward
13+
/// these stubs could be defined in core UR as the default which would
14+
/// reduce code duplication. Adapters could then "override" these defaults.
15+
16+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
17+
ur_context_handle_t, ur_device_handle_t,
18+
const ur_exp_command_buffer_desc_t *, ur_exp_command_buffer_handle_t *) {
19+
detail::ur::die("Experimental Command-buffer feature is not "
20+
"implemented for the NativeCPU adapter.");
21+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
22+
}
23+
24+
UR_APIEXPORT ur_result_t UR_APICALL
25+
urCommandBufferRetainExp(ur_exp_command_buffer_handle_t) {
26+
detail::ur::die("Experimental Command-buffer feature is not "
27+
"implemented for the NativeCPU adapter.");
28+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
29+
}
30+
31+
UR_APIEXPORT ur_result_t UR_APICALL
32+
urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t) {
33+
detail::ur::die("Experimental Command-buffer feature is not "
34+
"implemented for the NativeCPU adapter.");
35+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
36+
}
37+
38+
UR_APIEXPORT ur_result_t UR_APICALL
39+
urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t) {
40+
detail::ur::die("Experimental Command-buffer feature is not "
41+
"implemented for the NativeCPU adapter.");
42+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
43+
}
44+
45+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(
46+
ur_exp_command_buffer_handle_t, ur_kernel_handle_t, uint32_t,
47+
const size_t *, const size_t *, const size_t *, uint32_t,
48+
const ur_exp_command_buffer_sync_point_t *,
49+
ur_exp_command_buffer_sync_point_t *) {
50+
detail::ur::die("Experimental Command-buffer feature is not "
51+
"implemented for the NativeCPU adapter.");
52+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
53+
}
54+
55+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemcpyUSMExp(
56+
ur_exp_command_buffer_handle_t, void *, const void *, size_t, uint32_t,
57+
const ur_exp_command_buffer_sync_point_t *,
58+
ur_exp_command_buffer_sync_point_t *) {
59+
detail::ur::die("Experimental Command-buffer feature is not "
60+
"implemented for the NativeCPU adapter.");
61+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
62+
}
63+
64+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyExp(
65+
ur_exp_command_buffer_handle_t, ur_mem_handle_t, ur_mem_handle_t, size_t,
66+
size_t, size_t, uint32_t, const ur_exp_command_buffer_sync_point_t *,
67+
ur_exp_command_buffer_sync_point_t *) {
68+
detail::ur::die("Experimental Command-buffer feature is not "
69+
"implemented for the NativeCPU adapter.");
70+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
71+
}
72+
73+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMembufferCopyRectExp(
74+
ur_exp_command_buffer_handle_t, ur_mem_handle_t, ur_mem_handle_t,
75+
ur_rect_offset_t, ur_rect_offset_t, ur_rect_region_t, size_t, size_t,
76+
size_t, size_t, uint32_t, const ur_exp_command_buffer_sync_point_t *,
77+
ur_exp_command_buffer_sync_point_t *) {
78+
detail::ur::die("Experimental Command-buffer feature is not "
79+
"implemented for the NativeCPU adapter.");
80+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
81+
}
82+
83+
UR_APIEXPORT
84+
ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteExp(
85+
ur_exp_command_buffer_handle_t, ur_mem_handle_t, size_t, size_t,
86+
const void *, uint32_t, const ur_exp_command_buffer_sync_point_t *,
87+
ur_exp_command_buffer_sync_point_t *) {
88+
detail::ur::die("Experimental Command-buffer feature is not "
89+
"implemented for the NativeCPU adapter.");
90+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
91+
}
92+
93+
UR_APIEXPORT
94+
ur_result_t UR_APICALL urCommandBufferAppendMembufferReadExp(
95+
ur_exp_command_buffer_handle_t, ur_mem_handle_t, size_t, size_t, void *,
96+
uint32_t, const ur_exp_command_buffer_sync_point_t *,
97+
ur_exp_command_buffer_sync_point_t *) {
98+
detail::ur::die("Experimental Command-buffer feature is not "
99+
"implemented for the NativeCPU adapter.");
100+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
101+
}
102+
103+
UR_APIEXPORT
104+
ur_result_t UR_APICALL urCommandBufferAppendMembufferWriteRectExp(
105+
ur_exp_command_buffer_handle_t, ur_mem_handle_t, ur_rect_offset_t,
106+
ur_rect_offset_t, ur_rect_region_t, size_t, size_t, size_t, size_t, void *,
107+
uint32_t, const ur_exp_command_buffer_sync_point_t *,
108+
ur_exp_command_buffer_sync_point_t *) {
109+
detail::ur::die("Experimental Command-buffer feature is not "
110+
"implemented for the NativeCPU adapter.");
111+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
112+
}
113+
114+
UR_APIEXPORT
115+
ur_result_t UR_APICALL urCommandBufferAppendMembufferReadRectExp(
116+
ur_exp_command_buffer_handle_t, ur_mem_handle_t, ur_rect_offset_t,
117+
ur_rect_offset_t, ur_rect_region_t, size_t, size_t, size_t, size_t, void *,
118+
uint32_t, const ur_exp_command_buffer_sync_point_t *,
119+
ur_exp_command_buffer_sync_point_t *) {
120+
detail::ur::die("Experimental Command-buffer feature is not "
121+
"implemented for the NativeCPU adapter.");
122+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
123+
}
124+
125+
UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
126+
ur_exp_command_buffer_handle_t, ur_queue_handle_t, uint32_t,
127+
const ur_event_handle_t *, ur_event_handle_t *) {
128+
detail::ur::die("Experimental Command-buffer feature is not "
129+
"implemented for the NativeCPU adapter.");
130+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
131+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ ur_result_t urGetLastResult(ur_platform_handle_t, const char **ppMessage) {
2525
*ppMessage = &ErrorMessage[0];
2626
return ErrorMessageCode;
2727
}
28+
29+
void detail::ur::die(const char *pMessage) {
30+
std::cerr << "ur_die: " << pMessage << '\n';
31+
std::terminate();
32+
}

sycl/plugins/unified_runtime/ur/adapters/native_cpu/common.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ extern thread_local char ErrorMessage[MaxMessageSize];
4141
} \
4242
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
4343

44+
/// ------ Error handling, matching OpenCL plugin semantics.
45+
/// Taken from other adapter
46+
namespace detail {
47+
namespace ur {
48+
49+
// Report error and no return (keeps compiler from printing warnings).
50+
// TODO: Probably change that to throw a catchable exception,
51+
// but for now it is useful to see every failure.
52+
//
53+
[[noreturn]] void die(const char *pMessage);
54+
} // namespace ur
55+
} // namespace detail
56+
4457
// Base class to store common data
4558
struct _ur_object {
4659
ur_shared_mutex Mutex;
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
//===--------- image.cpp - NativeCPU Adapter ------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===-----------------------------------------------------------------===//
8+
9+
#include "ur/ur.hpp"
10+
11+
UR_APIEXPORT ur_result_t UR_APICALL urUSMPitchedAllocExp(
12+
[[maybe_unused]] ur_context_handle_t hContext,
13+
[[maybe_unused]] ur_device_handle_t hDevice,
14+
[[maybe_unused]] const ur_usm_desc_t *pUSMDesc,
15+
[[maybe_unused]] ur_usm_pool_handle_t pool,
16+
[[maybe_unused]] size_t widthInBytes, [[maybe_unused]] size_t height,
17+
[[maybe_unused]] size_t elementSizeBytes, [[maybe_unused]] void **ppMem,
18+
[[maybe_unused]] size_t *pResultPitch) {
19+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
20+
}
21+
22+
UR_APIEXPORT ur_result_t UR_APICALL
23+
urBindlessImagesUnsampledImageHandleDestroyExp(
24+
[[maybe_unused]] ur_context_handle_t hContext,
25+
[[maybe_unused]] ur_device_handle_t hDevice,
26+
[[maybe_unused]] ur_exp_image_handle_t hImage) {
27+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
28+
}
29+
30+
UR_APIEXPORT ur_result_t UR_APICALL
31+
urBindlessImagesSampledImageHandleDestroyExp(
32+
[[maybe_unused]] ur_context_handle_t hContext,
33+
[[maybe_unused]] ur_device_handle_t hDevice,
34+
[[maybe_unused]] ur_exp_image_handle_t hImage) {
35+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
36+
}
37+
38+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp(
39+
[[maybe_unused]] ur_context_handle_t hContext,
40+
[[maybe_unused]] ur_device_handle_t hDevice,
41+
[[maybe_unused]] const ur_image_format_t *pImageFormat,
42+
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
43+
[[maybe_unused]] ur_exp_image_mem_handle_t *phImageMem) {
44+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
45+
}
46+
47+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageFreeExp(
48+
[[maybe_unused]] ur_context_handle_t hContext,
49+
[[maybe_unused]] ur_device_handle_t hDevice,
50+
[[maybe_unused]] ur_exp_image_mem_handle_t hImageMem) {
51+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
52+
}
53+
54+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp(
55+
[[maybe_unused]] ur_context_handle_t hContext,
56+
[[maybe_unused]] ur_device_handle_t hDevice,
57+
[[maybe_unused]] ur_exp_image_mem_handle_t hImageMem,
58+
[[maybe_unused]] const ur_image_format_t *pImageFormat,
59+
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
60+
[[maybe_unused]] ur_mem_handle_t *phMem,
61+
[[maybe_unused]] ur_exp_image_handle_t *phImage) {
62+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
63+
}
64+
65+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
66+
[[maybe_unused]] ur_context_handle_t hContext,
67+
[[maybe_unused]] ur_device_handle_t hDevice,
68+
[[maybe_unused]] ur_exp_image_mem_handle_t hImageMem,
69+
[[maybe_unused]] const ur_image_format_t *pImageFormat,
70+
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
71+
[[maybe_unused]] ur_sampler_handle_t hSampler,
72+
[[maybe_unused]] ur_mem_handle_t *phMem,
73+
[[maybe_unused]] ur_exp_image_handle_t *phImage) {
74+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
75+
}
76+
77+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
78+
[[maybe_unused]] ur_queue_handle_t hQueue, [[maybe_unused]] void *pDst,
79+
[[maybe_unused]] void *pSrc,
80+
[[maybe_unused]] const ur_image_format_t *pImageFormat,
81+
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
82+
[[maybe_unused]] ur_exp_image_copy_flags_t imageCopyFlags,
83+
[[maybe_unused]] ur_rect_offset_t srcOffset,
84+
[[maybe_unused]] ur_rect_offset_t dstOffset,
85+
[[maybe_unused]] ur_rect_region_t copyExtent,
86+
[[maybe_unused]] ur_rect_region_t hostExtent,
87+
[[maybe_unused]] uint32_t numEventsInWaitList,
88+
[[maybe_unused]] const ur_event_handle_t *phEventWaitList,
89+
[[maybe_unused]] ur_event_handle_t *phEvent) {
90+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
91+
}
92+
93+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp(
94+
[[maybe_unused]] ur_exp_image_mem_handle_t hImageMem,
95+
[[maybe_unused]] ur_image_info_t propName,
96+
[[maybe_unused]] void *pPropValue, [[maybe_unused]] size_t *pPropSizeRet) {
97+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
98+
}
99+
100+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMipmapGetLevelExp(
101+
[[maybe_unused]] ur_context_handle_t hContext,
102+
[[maybe_unused]] ur_device_handle_t hDevice,
103+
[[maybe_unused]] ur_exp_image_mem_handle_t hImageMem,
104+
[[maybe_unused]] uint32_t mipmapLevel,
105+
[[maybe_unused]] ur_exp_image_mem_handle_t *phImageMem) {
106+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
107+
}
108+
109+
UR_APIEXPORT ur_result_t UR_APICALL
110+
urBindlessImagesMipmapFreeExp([[maybe_unused]] ur_context_handle_t hContext,
111+
[[maybe_unused]] ur_device_handle_t hDevice,
112+
[[maybe_unused]] ur_exp_image_mem_handle_t hMem) {
113+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
114+
}
115+
116+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportOpaqueFDExp(
117+
[[maybe_unused]] ur_context_handle_t hContext,
118+
[[maybe_unused]] ur_device_handle_t hDevice, [[maybe_unused]] size_t size,
119+
[[maybe_unused]] ur_exp_interop_mem_desc_t *pInteropMemDesc,
120+
[[maybe_unused]] ur_exp_interop_mem_handle_t *phInteropMem) {
121+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
122+
}
123+
124+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp(
125+
[[maybe_unused]] ur_context_handle_t hContext,
126+
[[maybe_unused]] ur_device_handle_t hDevice,
127+
[[maybe_unused]] const ur_image_format_t *pImageFormat,
128+
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
129+
[[maybe_unused]] ur_exp_interop_mem_handle_t hInteropMem,
130+
[[maybe_unused]] ur_exp_image_mem_handle_t *phImageMem) {
131+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
132+
}
133+
134+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp(
135+
[[maybe_unused]] ur_context_handle_t hContext,
136+
[[maybe_unused]] ur_device_handle_t hDevice,
137+
[[maybe_unused]] ur_exp_interop_mem_handle_t hInteropMem) {
138+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
139+
}
140+
141+
UR_APIEXPORT ur_result_t UR_APICALL
142+
urBindlessImagesImportExternalSemaphoreOpaqueFDExp(
143+
[[maybe_unused]] ur_context_handle_t hContext,
144+
[[maybe_unused]] ur_device_handle_t hDevice,
145+
[[maybe_unused]] ur_exp_interop_semaphore_desc_t *pInteropSemaphoreDesc,
146+
[[maybe_unused]] ur_exp_interop_semaphore_handle_t *phInteropSemaphore) {
147+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
148+
}
149+
150+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp(
151+
[[maybe_unused]] ur_context_handle_t hContext,
152+
[[maybe_unused]] ur_device_handle_t hDevice,
153+
[[maybe_unused]] ur_exp_interop_semaphore_handle_t hInteropSemaphore) {
154+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
155+
}
156+
157+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesWaitExternalSemaphoreExp(
158+
[[maybe_unused]] ur_queue_handle_t hQueue,
159+
[[maybe_unused]] ur_exp_interop_semaphore_handle_t hSemaphore,
160+
[[maybe_unused]] uint32_t numEventsInWaitList,
161+
[[maybe_unused]] const ur_event_handle_t *phEventWaitList,
162+
[[maybe_unused]] ur_event_handle_t *phEvent) {
163+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
164+
}
165+
166+
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSignalExternalSemaphoreExp(
167+
[[maybe_unused]] ur_queue_handle_t hQueue,
168+
[[maybe_unused]] ur_exp_interop_semaphore_handle_t hSemaphore,
169+
[[maybe_unused]] uint32_t numEventsInWaitList,
170+
[[maybe_unused]] const ur_event_handle_t *phEventWaitList,
171+
[[maybe_unused]] ur_event_handle_t *phEvent) {
172+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
173+
}

sycl/plugins/unified_runtime/ur/adapters/native_cpu/usm.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,18 @@ urUSMPoolGetInfo(ur_usm_pool_handle_t hPool, ur_usm_pool_info_t propName,
122122

123123
DIE_NO_IMPLEMENTATION;
124124
}
125+
126+
UR_APIEXPORT ur_result_t UR_APICALL urUSMImportExp(ur_context_handle_t Context,
127+
void *HostPtr, size_t Size) {
128+
std::ignore = Context;
129+
std::ignore = HostPtr;
130+
std::ignore = Size;
131+
DIE_NO_IMPLEMENTATION;
132+
}
133+
134+
UR_APIEXPORT ur_result_t UR_APICALL urUSMReleaseExp(ur_context_handle_t Context,
135+
void *HostPtr) {
136+
std::ignore = Context;
137+
std::ignore = HostPtr;
138+
DIE_NO_IMPLEMENTATION;
139+
}

0 commit comments

Comments
 (0)