diff --git a/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu b/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu new file mode 100644 index 000000000000..177453912bdf --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaBindTextureToMipmappedArray.cu @@ -0,0 +1,11 @@ +// Option: --use-experimental-features=bindless_images + +void test() { + // 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/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..c0891baa6c21 --- /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 /*cudaSurfaceObject_t* */, &resDesc /*const cudaResourceDesc* */); + // 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..c4983b148e27 --- /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 /*cudaSurfaceObject_t*/); + // 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..29b47857e7b2 --- /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 /*cudaDeviceProp* */, 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..df1dfd4f9beb --- /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 /*cudaResourceDesc* */, surf /*cudaSurfaceObject_t*/); + // 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..c764266c506a --- /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 /*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 new file mode 100644 index 000000000000..bf1b2c308209 --- /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 /*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 new file mode 100644 index 000000000000..33b298919937 --- /dev/null +++ b/clang/examples/DPCT/Runtime/cudaGraphDestroy.cu @@ -0,0 +1,13 @@ +// Option: --use-experimental-features=graph +#include +#include + +void test() { + cudaGraph_t graph; + // clang-format off + // Start + cudaGraphDestroy(graph /*cudaGraph_t*/); + // End + // clang-format on +} + 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-before12.cu b/clang/test/dpct/query_api_mapping/Runtime/test-before12.cu index c6daef017739..86ecab153b07 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* */); +// 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/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*/); 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