diff options
author | unknown <rmaynard@nvidia.com> | 2021-12-08 14:19:31 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2021-12-14 19:55:48 (GMT) |
commit | 574b492b47316dbb860535e870a74cdf60b7e446 (patch) | |
tree | 75d30ef376be533ff27fc2ac9d4576bcdfcaae7e /Tests/CudaOnly/ExportPTX | |
parent | 065604b2b3cabef95c0f406c990274f439452bbd (diff) | |
download | CMake-574b492b47316dbb860535e870a74cdf60b7e446.zip CMake-574b492b47316dbb860535e870a74cdf60b7e446.tar.gz CMake-574b492b47316dbb860535e870a74cdf60b7e446.tar.bz2 |
CUDA: Visual Studio Generator propagates definitions for PTX files
From CUDA 9.0 to CUDA 11.4 the CUDA Visual Studio integration
defines omitted user defines from PTX generation.
With CUDA 11.5 this has been resolved, so we backport the fix
to allow for consistent behavior when using CMake
Diffstat (limited to 'Tests/CudaOnly/ExportPTX')
-rw-r--r-- | Tests/CudaOnly/ExportPTX/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CudaOnly/ExportPTX/kernelA.cu | 4 | ||||
-rw-r--r-- | Tests/CudaOnly/ExportPTX/kernelB.cu | 3 |
3 files changed, 8 insertions, 0 deletions
diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt index f1667af..e97274d 100644 --- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt +++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt @@ -11,6 +11,7 @@ list(SUBLIST CMAKE_CUDA_ARCHITECTURES 0 1 CMAKE_CUDA_ARCHITECTURES) string(APPEND CMAKE_CUDA_ARCHITECTURES "-virtual") add_library(CudaPTX OBJECT kernelA.cu kernelB.cu) +target_compile_definitions(CudaPTX PRIVATE "CUDA_PTX_COMPILATION") set_property(TARGET CudaPTX PROPERTY CUDA_PTX_COMPILATION ON) #Test ObjectFiles with file(GENERATE) diff --git a/Tests/CudaOnly/ExportPTX/kernelA.cu b/Tests/CudaOnly/ExportPTX/kernelA.cu index fbe0d26..8967298 100644 --- a/Tests/CudaOnly/ExportPTX/kernelA.cu +++ b/Tests/CudaOnly/ExportPTX/kernelA.cu @@ -1,4 +1,8 @@ +#ifndef CUDA_PTX_COMPILATION +# error "CUDA_PTX_COMPILATION define not provided" +#endif + __global__ void kernelA(float* r, float* x, float* y, float* z, int size) { for (int i = threadIdx.x; i < size; i += blockDim.x) { diff --git a/Tests/CudaOnly/ExportPTX/kernelB.cu b/Tests/CudaOnly/ExportPTX/kernelB.cu index 11872e4..be4613a 100644 --- a/Tests/CudaOnly/ExportPTX/kernelB.cu +++ b/Tests/CudaOnly/ExportPTX/kernelB.cu @@ -1,4 +1,7 @@ +#ifndef CUDA_PTX_COMPILATION +# error "CUDA_PTX_COMPILATION define not provided" +#endif __global__ void kernelB(float* r, float* x, float* y, float* z, int size) { |