[PATCH] D17562: [CUDA] Add hack so code which includes "curand.h" doesn't break.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 23 22:52:01 PST 2016
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: cfe-commits, echristo.
curand.h includes curand_mtgp32_kernel.h. In host mode, this header
redefines threadIdx and blockDim, giving them their "proper" types of
uint3 and dim3, respectively.
clang has its own plan for these variables -- their types are magic
builtin classes. So these redefinitions are incompatible.
As a hack, we force-include the offending CUDA header and use #defines
to get the right types for threadIdx and blockDim.
@@ -274,5 +274,19 @@
+// curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
+// mode, giving them their "proper" types of dim3 and uint3. This is
+// incompatible with the types we give in cuda_builtin_vars.h. As as hack,
+// force-include the header (nvcc doesn't include it by default) but redefine
+// dim3 and uint3 to our builtin types. (Thankfully dim3 and uint3 are only
+// used here for the redeclarations of blockDim and threadIdx.)
+#define dim3 __cuda_builtin_blockDim_t
+#define uint3 __cuda_builtin_threadIdx_t
#endif // __CUDA__
#endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1012 bytes
Desc: not available
More information about the cfe-commits