Skip to content

Commit a9679ba

Browse files
authored
[SYCLomatic] Add the 3 IPC APIs query API Mapping. (#2907)
Signed-off-by: Chen, Sheng S <sheng.s.chen@intel.com>
1 parent fd576d3 commit a9679ba

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Option: --use-experimental-features=level_zero
2+
#include <cuda.h>
3+
4+
void test() {
5+
void *ptr;
6+
// Start
7+
cudaIpcCloseMemHandle(ptr/*void **/);
8+
// End
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Option: --use-experimental-features=level_zero
2+
#include <cuda.h>
3+
4+
void test() {
5+
cudaIpcMemHandle_t *handle;
6+
void *ptr;
7+
// Start
8+
cudaIpcGetMemHandle(handle/*cudaIpcMemHandle_t **/, ptr/*void **/);
9+
// End
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Option: --use-experimental-features=level_zero
2+
3+
#include <cuda.h>
4+
5+
void test() {
6+
cudaIpcMemHandle_t *handle;
7+
void *ptr;
8+
// Start
9+
cudaIpcOpenMemHandle((void **)&ptr/*void ***/, *handle/*cudaIpcMemHandle_t*/, cudaIpcMemLazyEnablePeerAccess/*unsigned int*/);
10+
// End
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// UNSUPPORTED: system-windows
2+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaIpcOpenMemHandle | FileCheck %s -check-prefix=CUDA_IPC_OPEN_MEM_HANDLE
3+
// CUDA_IPC_OPEN_MEM_HANDLE: CUDA API:
4+
// CUDA_IPC_OPEN_MEM_HANDLE-NEXT: cudaIpcOpenMemHandle((void **)&ptr/*void ***/, *handle/*cudaIpcMemHandle_t*/, cudaIpcMemLazyEnablePeerAccess/*unsigned int*/);
5+
// CUDA_IPC_OPEN_MEM_HANDLE-NEXT: Is migrated to (with the option --use-experimental-features=level_zero):
6+
// CUDA_IPC_OPEN_MEM_HANDLE-NEXT: dpct::experimental::open_mem_ipc_handle(*handle, (void **)&ptr);
7+
8+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaIpcCloseMemHandle | FileCheck %s -check-prefix=CUDA_IPC_CLOSE_MEM_HANDLE
9+
// CUDA_IPC_CLOSE_MEM_HANDLE: CUDA API:
10+
// CUDA_IPC_CLOSE_MEM_HANDLE-NEXT: cudaIpcCloseMemHandle(ptr/*void **/);
11+
// CUDA_IPC_CLOSE_MEM_HANDLE-NEXT: Is migrated to (with the option --use-experimental-features=level_zero):
12+
// CUDA_IPC_CLOSE_MEM_HANDLE-NEXT: zeMemCloseIpcHandle(sycl::get_native<sycl::backend::ext_oneapi_level_zero>(dpct::get_current_device().get_context()), ptr);
13+
14+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaIpcGetMemHandle | FileCheck %s -check-prefix=CUDA_IPC_GET_MEM_HANDLE
15+
// CUDA_IPC_GET_MEM_HANDLE: CUDA API:
16+
// CUDA_IPC_GET_MEM_HANDLE-NEXT: cudaIpcGetMemHandle(handle/*cudaIpcMemHandle_t **/, ptr/*void **/)
17+
// CUDA_IPC_GET_MEM_HANDLE-NEXT: Is migrated to (with the option --use-experimental-features=level_zero):
18+
// CUDA_IPC_GET_MEM_HANDLE-NEXT: dpct::experimental::get_mem_ipc_handle(ptr, handle);

clang/test/dpct/query_api_mapping/test_all.cu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,9 @@
13761376
// CHECK-NEXT: cudaHostUnregister
13771377
// CHECK-NEXT: cudaImportExternalMemory
13781378
// CHECK-NEXT: cudaImportExternalSemaphore
1379+
// CHECK-NEXT: cudaIpcCloseMemHandle
1380+
// CHECK-NEXT: cudaIpcGetMemHandle
1381+
// CHECK-NEXT: cudaIpcOpenMemHandle
13791382
// CHECK-NEXT: cudaLaunchCooperativeKernel
13801383
// CHECK-NEXT: cudaLaunchKernel
13811384
// CHECK-NEXT: cudaMalloc

0 commit comments

Comments
 (0)