[PATCH] D59361: [CUDA][Windows] Partial fix for bug 38811 (Step 1 of 3)

Evgeny Mankov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 06:25:04 PDT 2019

emankov created this revision.
emankov added a reviewer: tra.
Herald added subscribers: cfe-commits, jdoerfert.
Herald added a project: clang.

Partial fix for the clang Bug 38811 <https://bugs.llvm.org/show_bug.cgi?id=38811> "Clang fails to compile with CUDA-9.x on Windows".

Adding  `defined(_WIN64)` check along with existing `#if defined(__LP64__)` eliminates the below clang (64-bit) compilation error on Windows.

  C:/GIT/LLVM/trunk/llvm-64-release-vs2017/dist/lib/clang/9.0.0\include\__clang_cuda_device_functions.h(1609,45): error GEF7559A7: no matching function for call to 'roundf'
   __DEVICE__ long lroundf(float __a) { return roundf(__a); }

[How to repro]

  clang++.exe -x cuda "c:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.0\0_Simple\simplePrintf\simplePrintf.cu" -I"c:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\common\inc" --cuda-gpu-arch=sm_50 --cuda-path="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0" -L"c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64" -lcudart.lib  -v

  rC Clang



Index: clang/lib/Headers/__clang_cuda_device_functions.h
--- clang/lib/Headers/__clang_cuda_device_functions.h
+++ clang/lib/Headers/__clang_cuda_device_functions.h
@@ -1563,7 +1563,7 @@
 __DEVICE__ float j1f(float __a) { return __nv_j1f(__a); }
 __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); }
 __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); }
-#if defined(__LP64__)
+#if defined(__LP64__) || defined(_WIN64)
 __DEVICE__ long labs(long __a) { return llabs(__a); };
 __DEVICE__ long labs(long __a) { return __nv_abs(__a); };
@@ -1597,7 +1597,7 @@
 __DEVICE__ float logf(float __a) {
   return __FAST_OR_SLOW(__nv_fast_logf, __nv_logf)(__a);
-#if defined(__LP64__)
+#if defined(__LP64__) || defined(_WIN64)
 __DEVICE__ long lrint(double __a) { return llrint(__a); }
 __DEVICE__ long lrintf(float __a) { return __float2ll_rn(__a); }
 __DEVICE__ long lround(double __a) { return llround(__a); }

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59361.190607.patch
Type: text/x-patch
Size: 1017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190314/3ca1beae/attachment.bin>

More information about the cfe-commits mailing list