Skip to content

Commit 4ac0755

Browse files
[SYCLomatic][External Resource Interop][Semaphores] Added support for 2 more semaphore types (#2786)
1 parent dba8684 commit 4ac0755

16 files changed

+280
-44
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Option: --use-experimental-features=bindless_images
2+
3+
void test(cudaExternalMemory_t extMem) {
4+
// Start
5+
cudaDestroyExternalMemory(extMem /*cudaExternalMemory_t*/);
6+
// End
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Option: --use-experimental-features=bindless_images
2+
3+
void test(cudaExternalSemaphore_t extSem) {
4+
// Start
5+
cudaDestroyExternalSemaphore(extSem /*cudaExternalSemaphore_t*/);
6+
// End
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Option: --use-experimental-features=bindless_images
2+
3+
void test(void **devPtr, cudaExternalMemory_t extMem,
4+
const cudaExternalMemoryBufferDesc *bufferDesc) {
5+
// Start
6+
cudaExternalMemoryGetMappedBuffer(
7+
devPtr /*void ***/, extMem /*cudaExternalMemory_t*/,
8+
bufferDesc /*const cudaExternalMemoryBufferDesc **/);
9+
// End
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Option: --use-experimental-features=bindless_images
2+
3+
void test(cudaMipmappedArray_t *mipmap, cudaExternalMemory_t extMem,
4+
const cudaExternalMemoryMipmappedArrayDesc *mipmapDesc) {
5+
// Start
6+
cudaExternalMemoryGetMappedMipmappedArray(
7+
mipmap /*cudaMipmappedArray_t **/, extMem /*cudaExternalMemory_t*/,
8+
mipmapDesc /*const cudaExternalMemoryMipmappedArrayDesc **/);
9+
// End
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Option: --use-experimental-features=bindless_images
2+
3+
void test(cudaExternalMemory_t *extMem,
4+
const cudaExternalMemoryHandleDesc *memHandleDesc) {
5+
// Start
6+
cudaImportExternalMemory(
7+
extMem /*cudaExternalMemory_t **/,
8+
memHandleDesc /*const cudaExternalMemoryHandleDesc **/);
9+
// End
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Option: --use-experimental-features=bindless_images
2+
3+
void test(cudaExternalSemaphore_t *extSem,
4+
const cudaExternalSemaphoreHandleDesc *semHandleDesc) {
5+
// Start
6+
cudaImportExternalSemaphore(
7+
extSem /*cudaExternalSemaphore_t **/,
8+
semHandleDesc /*const cudaExternalSemaphoreHandleDesc **/);
9+
// End
10+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Option: --use-experimental-features=bindless_images
2+
3+
void test(const cudaExternalSemaphore_t *extSemArray,
4+
const cudaExternalSemaphoreSignalParams *paramsArray,
5+
unsigned int numExtSems, cudaStream_t stream = 0) {
6+
// Start
7+
cudaSignalExternalSemaphoresAsync(
8+
extSemArray /*const cudaExternalSemaphore_t **/,
9+
paramsArray /*const cudaExternalSemaphoreSignalParams **/,
10+
numExtSems /*unsigned int*/);
11+
cudaSignalExternalSemaphoresAsync(
12+
extSemArray /*const cudaExternalSemaphore_t **/,
13+
paramsArray /*const cudaExternalSemaphoreSignalParams **/,
14+
numExtSems /*unsigned int*/, stream /*cudaStream_t*/);
15+
// End
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Option: --use-experimental-features=bindless_images
2+
3+
void test(const cudaExternalSemaphore_t *extSemArray,
4+
const cudaExternalSemaphoreWaitParams *paramsArray,
5+
unsigned int numExtSems, cudaStream_t stream = 0) {
6+
// Start
7+
cudaWaitExternalSemaphoresAsync(
8+
extSemArray /*const cudaExternalSemaphore_t **/,
9+
paramsArray /*const cudaExternalSemaphoreWaitParams **/,
10+
numExtSems /*unsigned int*/);
11+
cudaWaitExternalSemaphoresAsync(
12+
extSemArray /*const cudaExternalSemaphore_t **/,
13+
paramsArray /*const cudaExternalSemaphoreWaitParams **/,
14+
numExtSems /*unsigned int*/, stream /*cudaStream_t*/);
15+
// End
16+
}

clang/lib/DPCT/RuleInfra/MapNames.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,18 @@ void MapNames::setExplicitNamespaceMap(
16451645
? getExpNamespace() +
16461646
"external_semaphore_handle_type::win32_nt_dx12_fence"
16471647
: "cudaExternalSemaphoreHandleTypeD3D12Fence")},
1648+
{"cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd",
1649+
std::make_shared<EnumNameRule>(
1650+
DpctGlobalInfo::useExtBindlessImages()
1651+
? getExpNamespace() +
1652+
"external_semaphore_handle_type::timeline_fd"
1653+
: "cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd")},
1654+
{"cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32",
1655+
std::make_shared<EnumNameRule>(
1656+
DpctGlobalInfo::useExtBindlessImages()
1657+
? getExpNamespace() +
1658+
"external_semaphore_handle_type::timeline_win32_nt_handle"
1659+
: "cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32")},
16481660
{"NVSHMEM_TEAM_WORLD",
16491661
std::make_shared<EnumNameRule>("ISHMEM_TEAM_WORLD")},
16501662
{"NVSHMEM_TEAM_SHARED",

clang/lib/DPCT/RulesLang/APINamesGraphicsInterop.inc

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,33 +195,65 @@ CONDITIONAL_FACTORY_ENTRY(
195195
ARG("cudaImportExternalSemaphore"),
196196
ARG("--use-experimental-features=bindless_images")))
197197

198+
CONDITIONAL_FACTORY_ENTRY(
199+
UseExtBindlessImages,
200+
CONDITIONAL_FACTORY_ENTRY(
201+
makeCheckNot(CheckArgIsDefaultCudaStream(3)),
202+
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaSignalExternalSemaphoresAsync",
203+
CALL(MapNames::getDpctNamespace() +
204+
"experimental::signal_external_semaphores",
205+
ARG(0), ARG(1), ARG(2), ARG(3)))),
206+
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaSignalExternalSemaphoresAsync",
207+
CALL(MapNames::getDpctNamespace() +
208+
"experimental::signal_external_semaphores",
209+
ARG(0), ARG(1), ARG(2))))),
210+
UNSUPPORT_FACTORY_ENTRY("cudaSignalExternalSemaphoresAsync", Diagnostics::TRY_EXPERIMENTAL_FEATURE,
211+
ARG("cudaSignalExternalSemaphoresAsync"),
212+
ARG("--use-experimental-features=bindless_images")))
213+
198214
CONDITIONAL_FACTORY_ENTRY(
199215
UseExtBindlessImages,
200216
CONDITIONAL_FACTORY_ENTRY(
201217
makeCheckNot(CheckArgIsDefaultCudaStream(3)),
202218
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaSignalExternalSemaphoresAsync_v2",
203219
CALL(MapNames::getDpctNamespace() +
204-
"experimental::signal_external_semaphore",
220+
"experimental::signal_external_semaphores",
205221
ARG(0), ARG(1), ARG(2), ARG(3)))),
206222
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaSignalExternalSemaphoresAsync_v2",
207223
CALL(MapNames::getDpctNamespace() +
208-
"experimental::signal_external_semaphore",
224+
"experimental::signal_external_semaphores",
209225
ARG(0), ARG(1), ARG(2))))),
210226
UNSUPPORT_FACTORY_ENTRY("cudaSignalExternalSemaphoresAsync_v2", Diagnostics::TRY_EXPERIMENTAL_FEATURE,
211227
ARG("cudaSignalExternalSemaphoresAsync_v2"),
212228
ARG("--use-experimental-features=bindless_images")))
213229

230+
CONDITIONAL_FACTORY_ENTRY(
231+
UseExtBindlessImages,
232+
CONDITIONAL_FACTORY_ENTRY(
233+
makeCheckNot(CheckArgIsDefaultCudaStream(3)),
234+
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaWaitExternalSemaphoresAsync",
235+
CALL(MapNames::getDpctNamespace() +
236+
"experimental::wait_external_semaphores",
237+
ARG(0), ARG(1), ARG(2), ARG(3)))),
238+
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaWaitExternalSemaphoresAsync",
239+
CALL(MapNames::getDpctNamespace() +
240+
"experimental::wait_external_semaphores",
241+
ARG(0), ARG(1), ARG(2))))),
242+
UNSUPPORT_FACTORY_ENTRY("cudaWaitExternalSemaphoresAsync", Diagnostics::TRY_EXPERIMENTAL_FEATURE,
243+
ARG("cudaWaitExternalSemaphoresAsync"),
244+
ARG("--use-experimental-features=bindless_images")))
245+
214246
CONDITIONAL_FACTORY_ENTRY(
215247
UseExtBindlessImages,
216248
CONDITIONAL_FACTORY_ENTRY(
217249
makeCheckNot(CheckArgIsDefaultCudaStream(3)),
218250
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaWaitExternalSemaphoresAsync_v2",
219251
CALL(MapNames::getDpctNamespace() +
220-
"experimental::wait_external_semaphore",
252+
"experimental::wait_external_semaphores",
221253
ARG(0), ARG(1), ARG(2), ARG(3)))),
222254
ASSIGNABLE_FACTORY(CALL_FACTORY_ENTRY("cudaWaitExternalSemaphoresAsync_v2",
223255
CALL(MapNames::getDpctNamespace() +
224-
"experimental::wait_external_semaphore",
256+
"experimental::wait_external_semaphores",
225257
ARG(0), ARG(1), ARG(2))))),
226258
UNSUPPORT_FACTORY_ENTRY("cudaWaitExternalSemaphoresAsync_v2", Diagnostics::TRY_EXPERIMENTAL_FEATURE,
227259
ARG("cudaWaitExternalSemaphoresAsync_v2"),

0 commit comments

Comments
 (0)