From 2639f407db7fce24cdbc2e7759256d76deeec4b3 Mon Sep 17 00:00:00 2001 From: "chenwei.sun" Date: Wed, 9 Jul 2025 09:59:33 +0800 Subject: [PATCH 1/5] [SYCLomatic] Add 12 runtime APIs for query-api-mapping Signed-off-by: chenwei.sun --- .../Runtime/cudaBindTextureToMipmappedArray.cu | 11 +++++++++++ .../DPCT/Runtime/cudaCreateChannelDescHalf.cu | 11 +++++++++++ .../DPCT/Runtime/cudaCreateChannelDescHalf1.cu | 11 +++++++++++ .../DPCT/Runtime/cudaCreateChannelDescHalf2.cu | 11 +++++++++++ .../DPCT/Runtime/cudaCreateChannelDescHalf4.cu | 11 +++++++++++ .../DPCT/Runtime/cudaCreateSurfaceObject.cu | 14 ++++++++++++++ .../DPCT/Runtime/cudaDestroySurfaceObject.cu | 13 +++++++++++++ .../DPCT/Runtime/cudaGetDeviceProperties_v2.cu | 8 ++++++++ .../Runtime/cudaGetSurfaceObjectResourceDesc.cu | 14 ++++++++++++++ .../DPCT/Runtime/cudaGraphAddDependencies.cu | 15 +++++++++++++++ .../DPCT/Runtime/cudaGraphAddEmptyNode.cu | 15 +++++++++++++++ clang/examples/DPCT/Runtime/cudaGraphDestroy.cu | 15 +++++++++++++++ 12 files changed, 149 insertions(+) create mode 100644 clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu create mode 100644 clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf.cu create mode 100644 clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf1.cu create mode 100644 clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf2.cu create mode 100644 clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf4.cu create mode 100644 clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu create mode 100644 clang/examples/DPCT/Runtime/cudaDestroySurfaceObject.cu create mode 100644 clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu create mode 100644 clang/examples/DPCT/Runtime/cudaGetSurfaceObjectResourceDesc.cu create mode 100644 clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu create mode 100644 clang/examples/DPCT/Runtime/cudaGraphAddEmptyNode.cu create mode 100644 clang/examples/DPCT/Runtime/cudaGraphDestroy.cu diff --git a/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu b/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu new file mode 100644 index 000000000000..0b19306da996 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu @@ -0,0 +1,11 @@ +// Option: --use-experimental-features=bindless_images + +void test() { + static texture tex3; + cudaMipmappedArray_t pMipMapArr; + // clang-format off + // Start + cudaBindTextureToMipmappedArray(tex3 /*const struct texture*/, pMipMapArr /*cudaMipmappedArray_const_t*/); + // End + // clang-format on +} diff --git a/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf.cu b/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf.cu new file mode 100644 index 000000000000..2518014d4dbe --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf.cu @@ -0,0 +1,11 @@ +// Option: --use-experimental-features=bindless_images + +void test() { + static texture tex3; + cudaMipmappedArray_t pMipMapArr; + // clang-format off + // Start + cudaChannelFormatDesc halfChn = cudaCreateChannelDescHalf(); + // End + // clang-format on +} diff --git a/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf1.cu b/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf1.cu new file mode 100644 index 000000000000..9f66a6a77c4d --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf1.cu @@ -0,0 +1,11 @@ +// Option: --use-experimental-features=bindless_images + +void test() { + static texture tex3; + cudaMipmappedArray_t pMipMapArr; + // clang-format off + // Start + cudaChannelFormatDesc half1Chn = cudaCreateChannelDescHalf1(); + // End + // clang-format on +} diff --git a/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf2.cu b/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf2.cu new file mode 100644 index 000000000000..6c680fd99d14 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf2.cu @@ -0,0 +1,11 @@ +// Option: --use-experimental-features=bindless_images + +void test() { + static texture tex3; + cudaMipmappedArray_t pMipMapArr; + // clang-format off + // Start + cudaChannelFormatDesc half2Chn = cudaCreateChannelDescHalf2(); + // End + // clang-format on +} diff --git a/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf4.cu b/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf4.cu new file mode 100644 index 000000000000..822a3b12da2e --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaCreateChannelDescHalf4.cu @@ -0,0 +1,11 @@ +// Option: --use-experimental-features=bindless_images + +void test() { + static texture tex3; + cudaMipmappedArray_t pMipMapArr; + // clang-format off + // Start + cudaChannelFormatDesc half4Chn = cudaCreateChannelDescHalf4(); + // End + // clang-format on +} diff --git a/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu b/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu new file mode 100644 index 000000000000..50cdd87702a4 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu @@ -0,0 +1,14 @@ +// Option: --use-experimental-features=bindless_images +#include +#include + +void test() { + cudaSurfaceObject_t surf; + cudaResourceDesc resDesc; + // clang-format off + // Start + cudaCreateSurfaceObject(&surf, &resDesc); + // End + // clang-format on +} + diff --git a/clang/examples/DPCT/Runtime/cudaDestroySurfaceObject.cu b/clang/examples/DPCT/Runtime/cudaDestroySurfaceObject.cu new file mode 100644 index 000000000000..27aae76d3f38 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaDestroySurfaceObject.cu @@ -0,0 +1,13 @@ +// Option: --use-experimental-features=bindless_images +#include +#include + +void test() { + cudaSurfaceObject_t surf; + // clang-format off + // Start + cudaDestroySurfaceObject(surf); + // End + // clang-format on +} + diff --git a/clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu b/clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu new file mode 100644 index 000000000000..169f707cad16 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu @@ -0,0 +1,8 @@ +#include + +void test(int i) { + // Start + cudaDeviceProp *pd; + cudaGetDeviceProperties_v2(pd, i /*int*/); + // End +} diff --git a/clang/examples/DPCT/Runtime/cudaGetSurfaceObjectResourceDesc.cu b/clang/examples/DPCT/Runtime/cudaGetSurfaceObjectResourceDesc.cu new file mode 100644 index 000000000000..6eb950f0a418 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaGetSurfaceObjectResourceDesc.cu @@ -0,0 +1,14 @@ +// Option: --use-experimental-features=bindless_images +#include +#include + +void test() { + cudaSurfaceObject_t surf; + cudaResourceDesc resDesc; + // clang-format off + // Start + cudaGetSurfaceObjectResourceDesc(&resDesc, surf); + // End + // clang-format on +} + diff --git a/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu b/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu new file mode 100644 index 000000000000..33b866cafba9 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu @@ -0,0 +1,15 @@ +// Option: --use-experimental-features=graph +#include +#include + +void test() { + cudaGraph_t graph; + cudaGraphNode_t node4[10]; + cudaGraphNode_t node5[10]; + // clang-format off + // Start + cudaGraphAddDependencies(graph, node4, node5, 10); + // End + // clang-format on +} + diff --git a/clang/examples/DPCT/Runtime/cudaGraphAddEmptyNode.cu b/clang/examples/DPCT/Runtime/cudaGraphAddEmptyNode.cu new file mode 100644 index 000000000000..ca945abbd827 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaGraphAddEmptyNode.cu @@ -0,0 +1,15 @@ +// Option: --use-experimental-features=graph +#include +#include + +void test() { + cudaGraph_t graph; + cudaGraphNode_t node4[10]; + cudaGraphNode_t node; + // clang-format off + // Start + cudaGraphAddEmptyNode(&node, graph, node4, 10); + // End + // clang-format on +} + diff --git a/clang/examples/DPCT/Runtime/cudaGraphDestroy.cu b/clang/examples/DPCT/Runtime/cudaGraphDestroy.cu new file mode 100644 index 000000000000..0f6747433e87 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaGraphDestroy.cu @@ -0,0 +1,15 @@ +// Option: --use-experimental-features=graph +#include +#include + +void test() { + cudaGraph_t graph; + cudaGraph_t *graph2; + // clang-format off + // Start + cudaGraphDestroy(graph); + cudaGraphDestroy(*graph2); + // End + // clang-format on +} + From a53af0e46027ae514a2206ea6422f0491ed2997b Mon Sep 17 00:00:00 2001 From: "chenwei.sun" Date: Wed, 9 Jul 2025 11:05:42 +0800 Subject: [PATCH 2/5] add test cases Signed-off-by: chenwei.sun --- .../cudaBindTextureToMipmappedArray.cu | 4 +- .../DPCT/Runtime/cudaCreateSurfaceObject.cu | 2 +- .../DPCT/Runtime/cudaDestroySurfaceObject.cu | 2 +- .../cudaGetSurfaceObjectResourceDesc.cu | 2 +- .../DPCT/Runtime/cudaGraphAddDependencies.cu | 2 +- .../DPCT/Runtime/cudaGraphAddEmptyNode.cu | 2 +- .../examples/DPCT/Runtime/cudaGraphDestroy.cu | 4 +- .../Runtime/test-before12.cu | 70 +++++++++++++++++++ clang/test/dpct/query_api_mapping/test_all.cu | 12 ++++ 9 files changed, 90 insertions(+), 10 deletions(-) diff --git a/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu b/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu index 0b19306da996..177453912bdf 100644 --- a/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu +++ b/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu @@ -1,10 +1,10 @@ // Option: --use-experimental-features=bindless_images void test() { - static texture tex3; - cudaMipmappedArray_t pMipMapArr; // clang-format off // Start + static texture tex3; + cudaMipmappedArray_t pMipMapArr; cudaBindTextureToMipmappedArray(tex3 /*const struct texture*/, pMipMapArr /*cudaMipmappedArray_const_t*/); // End // clang-format on diff --git a/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu b/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu index 50cdd87702a4..10d8e8f5e04f 100644 --- a/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu +++ b/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu @@ -7,7 +7,7 @@ void test() { cudaResourceDesc resDesc; // clang-format off // Start - cudaCreateSurfaceObject(&surf, &resDesc); + cudaCreateSurfaceObject(&surf /*cudaSurfaceObject_t* */, &resDesc /*const cudaResourceDesc* pResDesc */); // End // clang-format on } diff --git a/clang/examples/DPCT/Runtime/cudaDestroySurfaceObject.cu b/clang/examples/DPCT/Runtime/cudaDestroySurfaceObject.cu index 27aae76d3f38..c4983b148e27 100644 --- a/clang/examples/DPCT/Runtime/cudaDestroySurfaceObject.cu +++ b/clang/examples/DPCT/Runtime/cudaDestroySurfaceObject.cu @@ -6,7 +6,7 @@ void test() { cudaSurfaceObject_t surf; // clang-format off // Start - cudaDestroySurfaceObject(surf); + cudaDestroySurfaceObject(surf /*cudaSurfaceObject_t*/); // End // clang-format on } diff --git a/clang/examples/DPCT/Runtime/cudaGetSurfaceObjectResourceDesc.cu b/clang/examples/DPCT/Runtime/cudaGetSurfaceObjectResourceDesc.cu index 6eb950f0a418..df1dfd4f9beb 100644 --- a/clang/examples/DPCT/Runtime/cudaGetSurfaceObjectResourceDesc.cu +++ b/clang/examples/DPCT/Runtime/cudaGetSurfaceObjectResourceDesc.cu @@ -7,7 +7,7 @@ void test() { cudaResourceDesc resDesc; // clang-format off // Start - cudaGetSurfaceObjectResourceDesc(&resDesc, surf); + cudaGetSurfaceObjectResourceDesc(&resDesc /*cudaResourceDesc* */, surf /*cudaSurfaceObject_t*/); // End // clang-format on } diff --git a/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu b/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu index 33b866cafba9..5d86b7db1a4e 100644 --- a/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu +++ b/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu @@ -8,7 +8,7 @@ void test() { cudaGraphNode_t node5[10]; // clang-format off // Start - cudaGraphAddDependencies(graph, node4, node5, 10); + cudaGraphAddDependencies(graph /*cudaGraph_t*/, node4 /*const cudaGraphNode_t* */, node5 /*const cudaGraphNode_t* */, 10 /*size_t */); // End // clang-format on } diff --git a/clang/examples/DPCT/Runtime/cudaGraphAddEmptyNode.cu b/clang/examples/DPCT/Runtime/cudaGraphAddEmptyNode.cu index ca945abbd827..bf1b2c308209 100644 --- a/clang/examples/DPCT/Runtime/cudaGraphAddEmptyNode.cu +++ b/clang/examples/DPCT/Runtime/cudaGraphAddEmptyNode.cu @@ -8,7 +8,7 @@ void test() { cudaGraphNode_t node; // clang-format off // Start - cudaGraphAddEmptyNode(&node, graph, node4, 10); + cudaGraphAddEmptyNode(&node /*cudaGraphNode_t* */, graph /*cudaGraph_t*/, node4 /*const cudaGraphNode_t* */, 10 /*size_t*/); // End // clang-format on } diff --git a/clang/examples/DPCT/Runtime/cudaGraphDestroy.cu b/clang/examples/DPCT/Runtime/cudaGraphDestroy.cu index 0f6747433e87..33b298919937 100644 --- a/clang/examples/DPCT/Runtime/cudaGraphDestroy.cu +++ b/clang/examples/DPCT/Runtime/cudaGraphDestroy.cu @@ -4,11 +4,9 @@ void test() { cudaGraph_t graph; - cudaGraph_t *graph2; // clang-format off // Start - cudaGraphDestroy(graph); - cudaGraphDestroy(*graph2); + cudaGraphDestroy(graph /*cudaGraph_t*/); // End // clang-format on } diff --git a/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu b/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu index c6daef017739..e8cae11a3813 100644 --- a/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu +++ b/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu @@ -32,3 +32,73 @@ // CUDAUNBINDTEXTURE-NEXT: cudaUnbindTexture(ptr /*const textureReference **/); // CUDAUNBINDTEXTURE-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): // CUDAUNBINDTEXTURE-NEXT: ptr->detach(); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaBindTextureToMipmappedArray | FileCheck %s -check-prefix=cudaBindTextureToMipmappedArray +// cudaBindTextureToMipmappedArray: CUDA API: +// cudaBindTextureToMipmappedArray-NEXT: static texture tex3; +// cudaBindTextureToMipmappedArray-NEXT: cudaMipmappedArray_t pMipMapArr; +// cudaBindTextureToMipmappedArray-NEXT: cudaBindTextureToMipmappedArray(tex3 /*const struct texture*/, pMipMapArr /*cudaMipmappedArray_const_t*/); +// cudaBindTextureToMipmappedArray-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): +// cudaBindTextureToMipmappedArray-NEXT: dpct::experimental::bindless_image_wrapper tex3; +// cudaBindTextureToMipmappedArray-NEXT: dpct::experimental::image_mem_wrapper_ptr pMipMapArr; +// cudaBindTextureToMipmappedArray-NEXT: tex3.attach(pMipMapArr); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaCreateChannelDescHalf | FileCheck %s -check-prefix=cudaCreateChannelDescHalf +// cudaCreateChannelDescHalf: CUDA API: +// cudaCreateChannelDescHalf-NEXT: cudaChannelFormatDesc halfChn = cudaCreateChannelDescHalf(); +// cudaCreateChannelDescHalf-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): +// cudaCreateChannelDescHalf-NEXT: dpct::image_channel halfChn = dpct::image_channel::create(); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaCreateChannelDescHalf1 | FileCheck %s -check-prefix=cudaCreateChannelDescHalf1 +// cudaCreateChannelDescHalf1: CUDA API: +// cudaCreateChannelDescHalf1-NEXT: cudaChannelFormatDesc half1Chn = cudaCreateChannelDescHalf1(); +// cudaCreateChannelDescHalf1-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): +// cudaCreateChannelDescHalf1-NEXT: dpct::image_channel half1Chn = dpct::image_channel::create(); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaCreateChannelDescHalf2 | FileCheck %s -check-prefix=cudaCreateChannelDescHalf2 +// cudaCreateChannelDescHalf2: CUDA API: +// cudaCreateChannelDescHalf2-NEXT: cudaChannelFormatDesc half2Chn = cudaCreateChannelDescHalf2(); +// cudaCreateChannelDescHalf2-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): +// cudaCreateChannelDescHalf2-NEXT: dpct::image_channel half2Chn = dpct::image_channel::create(); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaCreateChannelDescHalf4 | FileCheck %s -check-prefix=cudaCreateChannelDescHalf4 +// cudaCreateChannelDescHalf4: CUDA API: +// cudaCreateChannelDescHalf4-NEXT: cudaChannelFormatDesc half4Chn = cudaCreateChannelDescHalf4(); +// cudaCreateChannelDescHalf4-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): +// cudaCreateChannelDescHalf4-NEXT: dpct::image_channel half4Chn = dpct::image_channel::create(); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaCreateSurfaceObject | FileCheck %s -check-prefix=cudaCreateSurfaceObject +// cudaCreateSurfaceObject: CUDA API: +// cudaCreateSurfaceObject-NEXT: cudaCreateSurfaceObject(&surf /*cudaSurfaceObject_t* */, &resDesc /*const cudaResourceDesc* pResDesc */); +// cudaCreateSurfaceObject-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): +// cudaCreateSurfaceObject-NEXT: surf = dpct::experimental::create_bindless_image(resDesc); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaDestroySurfaceObject | FileCheck %s -check-prefix=cudaDestroySurfaceObject +// cudaDestroySurfaceObject: CUDA API: +// cudaDestroySurfaceObject-NEXT: cudaDestroySurfaceObject(surf /*cudaSurfaceObject_t*/); +// cudaDestroySurfaceObject-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): +// cudaDestroySurfaceObject-NEXT: dpct::experimental::destroy_bindless_image(surf, dpct::get_in_order_queue()); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaGetSurfaceObjectResourceDesc | FileCheck %s -check-prefix=cudaGetSurfaceObjectResourceDesc +// cudaGetSurfaceObjectResourceDesc: CUDA API: +// cudaGetSurfaceObjectResourceDesc-NEXT: cudaGetSurfaceObjectResourceDesc(&resDesc /*cudaResourceDesc* */, surf /*cudaSurfaceObject_t*/); +// cudaGetSurfaceObjectResourceDesc-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): +// cudaGetSurfaceObjectResourceDesc-NEXT: resDesc = dpct::experimental::get_data(surf); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaGraphAddDependencies | FileCheck %s -check-prefix=cudaGraphAddDependencies +// cudaGraphAddDependencies: CUDA API: +// cudaGraphAddDependencies-NEXT: cudaGraphAddDependencies(graph /*cudaGraph_t*/, node4 /*const cudaGraphNode_t* */, node5 /*const cudaGraphNode_t* */, 10 /*size_t */); +// cudaGraphAddDependencies-NEXT: Is migrated to (with the option --use-experimental-features=graph): +// cudaGraphAddDependencies-NEXT: dpct::experimental::add_dependencies(graph, node4, node5, 10); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaGraphAddEmptyNode | FileCheck %s -check-prefix=cudaGraphAddEmptyNode +// cudaGraphAddEmptyNode: CUDA API: +// cudaGraphAddEmptyNode-NEXT: cudaGraphAddEmptyNode(&node /*cudaGraphNode_t* */, graph /*cudaGraph_t*/, node4 /*const cudaGraphNode_t* */, 10 /*size_t*/); +// cudaGraphAddEmptyNode-NEXT: Is migrated to (with the option --use-experimental-features=graph): +// cudaGraphAddEmptyNode-NEXT: dpct::experimental::add_empty_node(&node, graph, node4, 10); + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaGraphDestroy | FileCheck %s -check-prefix=cudaGraphDestroy +// cudaGraphDestroy: CUDA API: +// cudaGraphDestroy-NEXT: cudaGraphDestroy(graph /*cudaGraph_t*/); +// cudaGraphDestroy-NEXT: Is migrated to (with the option --use-experimental-features=graph): +// cudaGraphDestroy-NEXT: delete (graph); diff --git a/clang/test/dpct/query_api_mapping/test_all.cu b/clang/test/dpct/query_api_mapping/test_all.cu index 1eae79a9b5ea..634016c1213d 100644 --- a/clang/test/dpct/query_api_mapping/test_all.cu +++ b/clang/test/dpct/query_api_mapping/test_all.cu @@ -1424,11 +1424,18 @@ // CHECK-NEXT: cudaBindTexture // CHECK-NEXT: cudaBindTexture2D // CHECK-NEXT: cudaBindTextureToArray +// CHECK-NEXT: cudaBindTextureToMipmappedArray // CHECK-NEXT: cudaCreateChannelDesc +// CHECK-NEXT: cudaCreateChannelDescHalf +// CHECK-NEXT: cudaCreateChannelDescHalf1 +// CHECK-NEXT: cudaCreateChannelDescHalf2 +// CHECK-NEXT: cudaCreateChannelDescHalf4 +// CHECK-NEXT: cudaCreateSurfaceObject // CHECK-NEXT: cudaCreateTextureObject // CHECK-NEXT: cudaCtxResetPersistingL2Cache // CHECK-NEXT: cudaDestroyExternalMemory // CHECK-NEXT: cudaDestroyExternalSemaphore +// CHECK-NEXT: cudaDestroySurfaceObject // CHECK-NEXT: cudaDestroyTextureObject // CHECK-NEXT: cudaDeviceCanAccessPeer // CHECK-NEXT: cudaDeviceDisablePeerAccess @@ -1465,14 +1472,19 @@ // CHECK-NEXT: cudaGetDevice // CHECK-NEXT: cudaGetDeviceCount // CHECK-NEXT: cudaGetDeviceProperties +// CHECK-NEXT: cudaGetDeviceProperties_v2 // CHECK-NEXT: cudaGetErrorName // CHECK-NEXT: cudaGetErrorString // CHECK-NEXT: cudaGetLastError // CHECK-NEXT: cudaGetMipmappedArrayLevel +// CHECK-NEXT: cudaGetSurfaceObjectResourceDesc // CHECK-NEXT: cudaGetSymbolAddress // CHECK-NEXT: cudaGetSymbolSize // CHECK-NEXT: cudaGetTextureObjectResourceDesc // CHECK-NEXT: cudaGetTextureObjectTextureDesc +// CHECK-NEXT: cudaGraphAddDependencies +// CHECK-NEXT: cudaGraphAddEmptyNode +// CHECK-NEXT: cudaGraphDestroy // CHECK-NEXT: cudaGraphicsD3D11RegisterResource // CHECK-NEXT: cudaGraphicsMapResources // CHECK-NEXT: cudaGraphicsResourceGetMappedMipmappedArray From 327369d62ab64402cf9a73a222598c0ddb535f10 Mon Sep 17 00:00:00 2001 From: "chenwei.sun" Date: Wed, 9 Jul 2025 12:58:49 +0800 Subject: [PATCH 3/5] add last test Signed-off-by: chenwei.sun --- clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu b/clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu index 169f707cad16..29b47857e7b2 100644 --- a/clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu +++ b/clang/examples/DPCT/Runtime/cudaGetDeviceProperties_v2.cu @@ -3,6 +3,6 @@ void test(int i) { // Start cudaDeviceProp *pd; - cudaGetDeviceProperties_v2(pd, i /*int*/); + cudaGetDeviceProperties_v2(pd /*cudaDeviceProp* */, i /*int*/); // End } From 073c79f2832e3cfe3880eb1d38cc06b62326bc65 Mon Sep 17 00:00:00 2001 From: "chenwei.sun" Date: Wed, 9 Jul 2025 13:15:39 +0800 Subject: [PATCH 4/5] split test case specific to cuda versions Signed-off-by: chenwei.sun --- .../dpct/query_api_mapping/Runtime/test-after111.cu | 9 +++++++++ .../dpct/query_api_mapping/Runtime/test-after12.cu | 10 ++++++++++ clang/test/dpct/query_api_mapping/Runtime/test.cu | 6 ------ 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 clang/test/dpct/query_api_mapping/Runtime/test-after111.cu create mode 100644 clang/test/dpct/query_api_mapping/Runtime/test-after12.cu diff --git a/clang/test/dpct/query_api_mapping/Runtime/test-after111.cu b/clang/test/dpct/query_api_mapping/Runtime/test-after111.cu new file mode 100644 index 000000000000..ac7351f91cc8 --- /dev/null +++ b/clang/test/dpct/query_api_mapping/Runtime/test-after111.cu @@ -0,0 +1,9 @@ +// 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 +// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2, v11.0, v11.1 + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaEventRecordWithFlags | FileCheck %s -check-prefix=cudaEventRecordWithFlags +// cudaEventRecordWithFlags: CUDA API: +// cudaEventRecordWithFlags-NEXT: cudaEventRecordWithFlags(event /*cudaEvent_t*/, stream /*cudaStream_t*/, +// cudaEventRecordWithFlags-NEXT: cudaEventRecordDefault /*unsigned int*/); +// cudaEventRecordWithFlags-NEXT: Is migrated to (with the option --enable-profiling): +// cudaEventRecordWithFlags-NEXT: dpct::sync_barrier(event /*cudaEvent_t*/, stream /*unsigned int*/); diff --git a/clang/test/dpct/query_api_mapping/Runtime/test-after12.cu b/clang/test/dpct/query_api_mapping/Runtime/test-after12.cu new file mode 100644 index 000000000000..3e2046d2441b --- /dev/null +++ b/clang/test/dpct/query_api_mapping/Runtime/test-after12.cu @@ -0,0 +1,10 @@ +// UNSUPPORTED: cuda-8.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, cuda-11.4, cuda-11.5, cuda-11.6, cuda-11.7, cuda-11.8 +// UNSUPPORTED: v8.0, v9.1, v9.2, v10.0, v10.1, v10.2, v11.0, v11.1, v11.2, v11.3, v11.4, v11.5, v11.6, v11.7, v11.8 + +// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaGetDeviceProperties_v2 | FileCheck %s -check-prefix=cudaGetDeviceProperties_v2 +// cudaGetDeviceProperties_v2: CUDA API: +// cudaGetDeviceProperties_v2-NEXT: cudaDeviceProp *pd; +// cudaGetDeviceProperties_v2-NEXT: cudaGetDeviceProperties_v2(pd /*cudaDeviceProp* */, i /*int*/); +// cudaGetDeviceProperties_v2-NEXT: Is migrated to: +// cudaGetDeviceProperties_v2-NEXT: dpct::device_info *pd; +// cudaGetDeviceProperties_v2-NEXT: dpct::get_device(i).get_device_info(*pd); diff --git a/clang/test/dpct/query_api_mapping/Runtime/test.cu b/clang/test/dpct/query_api_mapping/Runtime/test.cu index 6db94acbb8a7..89f5e0ef7a7b 100644 --- a/clang/test/dpct/query_api_mapping/Runtime/test.cu +++ b/clang/test/dpct/query_api_mapping/Runtime/test.cu @@ -555,9 +555,3 @@ // CUDAPROFILERSTOP-NEXT: cudaProfilerStop(); // CUDAPROFILERSTOP-NEXT: The API is Removed. // CUDAPROFILERSTOP-EMPTY: -// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaEventRecordWithFlags | FileCheck %s -check-prefix=cudaEventRecordWithFlags -// cudaEventRecordWithFlags: CUDA API: -// cudaEventRecordWithFlags-NEXT: cudaEventRecordWithFlags(event /*cudaEvent_t*/, stream /*cudaStream_t*/, -// cudaEventRecordWithFlags-NEXT: cudaEventRecordDefault /*unsigned int*/); -// cudaEventRecordWithFlags-NEXT: Is migrated to (with the option --enable-profiling): -// cudaEventRecordWithFlags-NEXT: dpct::sync_barrier(event /*cudaEvent_t*/, stream /*unsigned int*/); From 21d03b92379f5f46b73c3a2c348d1352ce3dcee5 Mon Sep 17 00:00:00 2001 From: "chenwei.sun" Date: Thu, 10 Jul 2025 09:13:40 +0800 Subject: [PATCH 5/5] Address review comments Signed-off-by: chenwei.sun --- clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu | 2 +- clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu | 2 +- clang/test/dpct/query_api_mapping/Runtime/test-before12.cu | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu b/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu index 10d8e8f5e04f..c0891baa6c21 100644 --- a/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu +++ b/clang/examples/DPCT/Runtime/cudaCreateSurfaceObject.cu @@ -7,7 +7,7 @@ void test() { cudaResourceDesc resDesc; // clang-format off // Start - cudaCreateSurfaceObject(&surf /*cudaSurfaceObject_t* */, &resDesc /*const cudaResourceDesc* pResDesc */); + cudaCreateSurfaceObject(&surf /*cudaSurfaceObject_t* */, &resDesc /*const cudaResourceDesc* */); // End // clang-format on } diff --git a/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu b/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu index 5d86b7db1a4e..c764266c506a 100644 --- a/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu +++ b/clang/examples/DPCT/Runtime/cudaGraphAddDependencies.cu @@ -8,7 +8,7 @@ void test() { cudaGraphNode_t node5[10]; // clang-format off // Start - cudaGraphAddDependencies(graph /*cudaGraph_t*/, node4 /*const cudaGraphNode_t* */, node5 /*const cudaGraphNode_t* */, 10 /*size_t */); + cudaGraphAddDependencies(graph /*cudaGraph_t*/, node4 /*const cudaGraphNode_t* */, node5 /*const cudaGraphNode_t* */, 10 /*size_t*/); // End // clang-format on } diff --git a/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu b/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu index e8cae11a3813..86ecab153b07 100644 --- a/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu +++ b/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu @@ -69,7 +69,7 @@ // RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaCreateSurfaceObject | FileCheck %s -check-prefix=cudaCreateSurfaceObject // cudaCreateSurfaceObject: CUDA API: -// cudaCreateSurfaceObject-NEXT: cudaCreateSurfaceObject(&surf /*cudaSurfaceObject_t* */, &resDesc /*const cudaResourceDesc* pResDesc */); +// cudaCreateSurfaceObject-NEXT: cudaCreateSurfaceObject(&surf /*cudaSurfaceObject_t* */, &resDesc /*const cudaResourceDesc* */); // cudaCreateSurfaceObject-NEXT: Is migrated to (with the option --use-experimental-features=bindless_images): // cudaCreateSurfaceObject-NEXT: surf = dpct::experimental::create_bindless_image(resDesc); @@ -87,7 +87,7 @@ // RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cudaGraphAddDependencies | FileCheck %s -check-prefix=cudaGraphAddDependencies // cudaGraphAddDependencies: CUDA API: -// cudaGraphAddDependencies-NEXT: cudaGraphAddDependencies(graph /*cudaGraph_t*/, node4 /*const cudaGraphNode_t* */, node5 /*const cudaGraphNode_t* */, 10 /*size_t */); +// cudaGraphAddDependencies-NEXT: cudaGraphAddDependencies(graph /*cudaGraph_t*/, node4 /*const cudaGraphNode_t* */, node5 /*const cudaGraphNode_t* */, 10 /*size_t*/); // cudaGraphAddDependencies-NEXT: Is migrated to (with the option --use-experimental-features=graph): // cudaGraphAddDependencies-NEXT: dpct::experimental::add_dependencies(graph, node4, node5, 10);