Skip to content

Commit

Permalink
[SYCLomatic] Add mapping query of 36 APIs. (oneapi-src#2201)
Browse files Browse the repository at this point in the history
Signed-off-by: Tang, Jiajun [email protected]
  • Loading branch information
tangjj11 authored Jul 30, 2024
1 parent 3ea5526 commit 627576f
Show file tree
Hide file tree
Showing 47 changed files with 644 additions and 1 deletion.
7 changes: 7 additions & 0 deletions clang/examples/DPCT/Driver/cuArray3DCreate.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Option: --use-experimental-features=bindless_images

void test(CUarray *pa, const CUDA_ARRAY3D_DESCRIPTOR *pd) {
// Start
cuArray3DCreate(pa /*CUarray **/, pd /*const CUDA_ARRAY3D_DESCRIPTOR **/);
// End
}
7 changes: 7 additions & 0 deletions clang/examples/DPCT/Driver/cuArrayCreate.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Option: --use-experimental-features=bindless_images

void test(CUarray *pa, const CUDA_ARRAY_DESCRIPTOR *pd) {
// Start
cuArrayCreate(pa /*CUarray **/, pd /*const CUDA_ARRAY_DESCRIPTOR **/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuCtxCreate.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUcontext *pc, unsigned u, CUdevice d) {
// Start
cuCtxCreate(pc /*CUcontext **/, u /*unsigned*/, d /*CUdevice*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuCtxEnablePeerAccess.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUcontext c, unsigned u) {
// Start
cuCtxEnablePeerAccess(c /*CUcontext*/, u /*unsigned*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuCtxGetLimit.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(size_t *ps) {
// Start
cuCtxGetLimit(ps /*size_t **/, CU_LIMIT_PRINTF_FIFO_SIZE);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuCtxResetPersistingL2Cache.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test() {
// Start
cuCtxResetPersistingL2Cache();
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuCtxSetLimit.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUlimit l, size_t s) {
// Start
cuCtxSetLimit(l /*CUlimit*/, s /*size_t*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuDeviceCanAccessPeer.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(int *pi, CUdevice d1, CUdevice d2) {
// Start
cuDeviceCanAccessPeer(pi /*int **/, d1 /*CUdevice*/, d2 /*CUdevice*/);
// End
}
41 changes: 41 additions & 0 deletions clang/examples/DPCT/Driver/cuDeviceGetAttribute.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
void test(int *pi, CUdevice d) {
// Start
/* 1 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK, d /*CUdevice*/);
/* 2 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X, d /*CUdevice*/);
/* 3 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y, d /*CUdevice*/);
/* 4 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z, d /*CUdevice*/);
/* 5 */ cuDeviceGetAttribute(pi /*int **/,
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK,
d /*CUdevice*/);
/* 6 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY, d /*CUdevice*/);
/* 7 */ cuDeviceGetAttribute(pi /*int **/, CU_DEVICE_ATTRIBUTE_WARP_SIZE,
d /*CUdevice*/);
/* 8 */ cuDeviceGetAttribute(pi /*int **/,
CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK,
d /*CUdevice*/);
/* 9 */ cuDeviceGetAttribute(pi /*int **/, CU_DEVICE_ATTRIBUTE_CLOCK_RATE,
d /*CUdevice*/);
/* 10 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT, d /*CUdevice*/);
/* 11 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, d /*CUdevice*/);
/* 12 */ cuDeviceGetAttribute(pi /*int **/, CU_DEVICE_ATTRIBUTE_INTEGRATED,
d /*CUdevice*/);
/* 13 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY, d /*CUdevice*/);
/* 14 */ cuDeviceGetAttribute(pi /*int **/,
CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
d /*CUdevice*/);
/* 15 */ cuDeviceGetAttribute(pi /*int **/,
CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
d /*CUdevice*/);
/* 16 */ cuDeviceGetAttribute(
pi /*int **/, CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED,
d /*CUdevice*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuDeviceGetUuid.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUuuid *pu, CUdevice d) {
// Start
cuDeviceGetUuid(pu /*CUuuid **/, d /*CUdevice*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuDeviceGetUuid_v2.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUuuid *pu, CUdevice d) {
// Start
cuDeviceGetUuid_v2(pu /*CUuuid **/, d /*CUdevice*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuFuncSetAttribute.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUfunction f, CUfunction_attribute fa, int i) {
// Start
cuFuncSetAttribute(f /*CUfunction*/, fa /*CUfunction_attribute*/, i /*int*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuGetErrorString.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUresult r, const char **ppc) {
// Start
cuGetErrorString(r /*CUresult*/, ppc /*const char ***/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuMemcpy3DPeer.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(const CUDA_MEMCPY3D_PEER *c) {
// Start
cuMemcpy3DPeer(c /*CUDA_MEMCPY3D_PEER **/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuMemcpy3DPeerAsync.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(const CUDA_MEMCPY3D_PEER *c, CUstream cs) {
// Start
cuMemcpy3DPeerAsync(c /*CUDA_MEMCPY3D_PEER **/, cs /*CUstream*/);
// End
}
7 changes: 7 additions & 0 deletions clang/examples/DPCT/Driver/cuMemcpyPeer.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void test(CUdeviceptr pd1, CUcontext c1, CUdeviceptr pd2, CUcontext c2,
size_t s) {
// Start
cuMemcpyPeer(pd1 /*CUdeviceptr*/, c1 /*CUcontext*/, pd2 /*CUdeviceptr*/,
c2 /*CUcontext*/, s /*size_t*/);
// End
}
7 changes: 7 additions & 0 deletions clang/examples/DPCT/Driver/cuMemcpyPeerAsync.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void test(CUdeviceptr pd1, CUcontext c1, CUdeviceptr pd2, CUcontext c2,
size_t s, CUstream cs) {
// Start
cuMemcpyPeerAsync(pd1 /*CUdeviceptr*/, c1 /*CUcontext*/, pd2 /*CUdeviceptr*/,
c2 /*CUcontext*/, s /*size_t*/, cs /*CUstream*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD16.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUdeviceptr d, unsigned short us, size_t s) {
// Start
cuMemsetD16(d /*CUdeviceptr*/, us /*unsigned short*/, s /*size_t*/);
// End
}
6 changes: 6 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD16Async.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void test(CUdeviceptr d, unsigned short us, size_t s, CUstream cs) {
// Start
cuMemsetD16Async(d /*CUdeviceptr*/, us /*unsigned short*/, s /*size_t*/,
cs /*CUstream*/);
// End
}
6 changes: 6 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD2D16.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void test(CUdeviceptr d, size_t s1, unsigned short us, size_t s2, size_t s3) {
// Start
cuMemsetD2D16(d /*CUdeviceptr*/, s1 /*size_t*/, us /*unsigned short*/,
s2 /*size_t*/, s3 /*size_t*/);
// End
}
7 changes: 7 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD2D16Async.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void test(CUdeviceptr d, size_t s1, unsigned short us, size_t s2, size_t s3,
CUstream cs) {
// Start
cuMemsetD2D16Async(d /*CUdeviceptr*/, s1 /*size_t*/, us /*unsigned short*/,
s2 /*size_t*/, s3 /*size_t*/, cs /*CUstream*/);
// End
}
6 changes: 6 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD2D32.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void test(CUdeviceptr d, size_t s1, unsigned u, size_t s2, size_t s3) {
// Start
cuMemsetD2D32(d /*CUdeviceptr*/, s1 /*size_t*/, u /*unsigned*/, s2 /*size_t*/,
s3 /*size_t*/);
// End
}
7 changes: 7 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD2D32Async.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void test(CUdeviceptr d, size_t s1, unsigned u, size_t s2, size_t s3,
CUstream cs) {
// Start
cuMemsetD2D32Async(d /*CUdeviceptr*/, s1 /*size_t*/, u /*unsigned*/,
s2 /*size_t*/, s3 /*size_t*/, cs /*CUstream*/);
// End
}
6 changes: 6 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD2D8.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void test(CUdeviceptr d, size_t s1, unsigned char uc, size_t s2, size_t s3) {
// Start
cuMemsetD2D8(d /*CUdeviceptr*/, s1 /*size_t*/, uc /*unsigned char*/,
s2 /*size_t*/, s3 /*size_t*/);
// End
}
7 changes: 7 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD2D8Async.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void test(CUdeviceptr d, size_t s1, unsigned char uc, size_t s2, size_t s3,
CUstream cs) {
// Start
cuMemsetD2D8Async(d /*CUdeviceptr*/, s1 /*size_t*/, uc /*unsigned char*/,
s2 /*size_t*/, s3 /*size_t*/, cs /*CUstream*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD32.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUdeviceptr d, unsigned u, size_t s) {
// Start
cuMemsetD32(d /*CUdeviceptr*/, u /*unsigned*/, s /*size_t*/);
// End
}
6 changes: 6 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD32Async.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void test(CUdeviceptr d, unsigned u, size_t s, CUstream cs) {
// Start
cuMemsetD32Async(d /*CUdeviceptr*/, u /*unsigned*/, s /*size_t*/,
cs /*CUstream*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD8.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void test(CUdeviceptr d, unsigned char uc, size_t s) {
// Start
cuMemsetD8(d /*CUdeviceptr*/, uc /*unsigned char*/, s /*size_t*/);
// End
}
6 changes: 6 additions & 0 deletions clang/examples/DPCT/Driver/cuMemsetD8Async.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void test(CUdeviceptr d, unsigned char uc, size_t s, CUstream cs) {
// Start
cuMemsetD8Async(d /*CUdeviceptr*/, uc /*unsigned char*/, s /*size_t*/,
cs /*CUstream*/);
// End
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Option: --use-experimental-features=occupancy-calculation

void test(int *pi, CUfunction f, int i, size_t s) {
// Start
cuOccupancyMaxActiveBlocksPerMultiprocessor(pi /*int **/, f /*CUfunction*/,
i /*int*/, s /*size_t*/);
// End
}
6 changes: 6 additions & 0 deletions clang/examples/DPCT/Driver/cuStreamQuery.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void test() {
// Start
CUstream s;
cuStreamQuery(s);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Guide/__nanosleep.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__global__ void test(unsigned u) {
// Start
__nanosleep(u /*unsigned*/);
// End
}
15 changes: 15 additions & 0 deletions clang/examples/DPCT/Guide/atomicAdd.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "cuda_fp16.h"

__global__ void test(int *pi, int i, unsigned *pu, unsigned u,
unsigned long long *pull, unsigned long long ull,
unsigned short *pus, float *pf, float f, double *pd,
double d, __half2 *ph2, __half2 h2) {
// Start
atomicAdd(pi /*int **/, i /*int*/);
atomicAdd(pu /*unsigned **/, u /*unsigned*/);
atomicAdd(pull /*unsigned long long **/, ull /*unsigned long long*/);
atomicAdd(pf /*float **/, f /*float*/);
atomicAdd(pd /*double **/, d /*double*/);
atomicAdd(ph2 /*__half2 **/, h2 /*__half2*/);
// End
}
12 changes: 12 additions & 0 deletions clang/examples/DPCT/Guide/atomicAdd_system.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
__global__ void test(int *pi, int i, unsigned *pu, unsigned u,
unsigned long long *pull, unsigned long long ull,
unsigned short *pus, float *pf, float f, double *pd,
double d) {
// Start
atomicAdd_system(pi /*int **/, i /*int*/);
atomicAdd_system(pu /*unsigned **/, u /*unsigned*/);
atomicAdd_system(pull /*unsigned long long **/, ull /*unsigned long long*/);
atomicAdd_system(pf /*float **/, f /*float*/);
atomicAdd_system(pd /*double **/, d /*double*/);
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Guide/clock.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__global__ void test() {
// Start
clock();
// End
}
5 changes: 5 additions & 0 deletions clang/examples/DPCT/Guide/clock64.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__global__ void test() {
// Start
clock64();
// End
}
3 changes: 2 additions & 1 deletion clang/lib/DPCT/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ std::unordered_map<int, DiagnosticsMessage> CommentIDTable;
#include "Diagnostics.inc"

std::unordered_set<int> APIQueryNeedReportWarningIDSet = {
// More IDs may need to be added, like: 1007, 1008, 1028, 1030, 1031, 1037,
// More IDs may need to be added, like: 1007, 1028, 1030, 1031, 1037,
// 1051, 1053, 1067, 1069, 1076, 1082, 1090, 1107.
1008, // API_NOT_MIGRATED_SYCL_UNDEF
1009, // TRNA_WARNING_ERROR_HANDLING_API_COMMENTED
1014, // STREAM_FLAG_PRIORITY_NOT_SUPPORTED
1023, // MASK_UNSUPPORTED
Expand Down
10 changes: 10 additions & 0 deletions clang/test/dpct/query_api_mapping/Driver/test-after11.4.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1, cuda-9.2, cuda-10.0, cuda-10.1, cuda-10.2, cuda-11.0, cuda-11.1, cuda-11.2, cuda-11.3
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2, v11.0, v11.1, v11.2, v11.3

/// Device Management

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuDeviceGetUuid_v2 | FileCheck %s -check-prefix=CUDEVICEGETUUID_V2
// CUDEVICEGETUUID_V2: CUDA API:
// CUDEVICEGETUUID_V2-NEXT: cuDeviceGetUuid_v2(pu /*CUuuid **/, d /*CUdevice*/);
// CUDEVICEGETUUID_V2-NEXT: Is migrated to:
// CUDEVICEGETUUID_V2-NEXT: *pu = dpct::get_device(d).get_device_info().get_uuid();
10 changes: 10 additions & 0 deletions clang/test/dpct/query_api_mapping/Driver/test-after11.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1, cuda-9.2, cuda-10.0, cuda-10.1, cuda-10.2
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2

/// Context Management

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuCtxResetPersistingL2Cache | FileCheck %s -check-prefix=CUCTXRESETPERSISTINGL2CACHE
// CUCTXRESETPERSISTINGL2CACHE: CUDA API:
// CUCTXRESETPERSISTINGL2CACHE-NEXT: cuCtxResetPersistingL2Cache();
// CUCTXRESETPERSISTINGL2CACHE-NEXT: The API is Removed.
// CUCTXRESETPERSISTINGL2CACHE-EMPTY:
10 changes: 10 additions & 0 deletions clang/test/dpct/query_api_mapping/Driver/test-after9.0.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// UNSUPPORTED: cuda-8.0
// UNSUPPORTED: v8.0

/// Execution Control

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuFuncSetAttribute | FileCheck %s -check-prefix=CUFUNCSETATTRIBUTE
// CUFUNCSETATTRIBUTE: CUDA API:
// CUFUNCSETATTRIBUTE-NEXT: cuFuncSetAttribute(f /*CUfunction*/, fa /*CUfunction_attribute*/, i /*int*/);
// CUFUNCSETATTRIBUTE-NEXT: The API is Removed.
// CUFUNCSETATTRIBUTE-EMPTY:
10 changes: 10 additions & 0 deletions clang/test/dpct/query_api_mapping/Driver/test-after9.2.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1
// UNSUPPORTED: v8.0, v9.0, v9.1

/// Device Management

// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuDeviceGetUuid | FileCheck %s -check-prefix=CUDEVICEGETUUID
// CUDEVICEGETUUID: CUDA API:
// CUDEVICEGETUUID-NEXT: cuDeviceGetUuid(pu /*CUuuid **/, d /*CUdevice*/);
// CUDEVICEGETUUID-NEXT: Is migrated to:
// CUDEVICEGETUUID-NEXT: *pu = dpct::get_device(d).get_device_info().get_uuid();
Loading

0 comments on commit 627576f

Please sign in to comment.