[PATCH] [CUDA] Support for built-in cuda variables (threadIdx and its friends).

Richard Smith richard at metafoo.co.uk
Fri Apr 17 18:24:43 PDT 2015


================
Comment at: lib/Headers/cuda/cuda_builtin_vars.h:89
@@ +88,3 @@
+// architectures have a WARP_SZ value of 32'.
+__CUDA_BUILTIN_VAR int warpSize = 32;
+
----------------
This is a (strong) definition due to the `extern` in the `__CUDA_BUILTIN_VAR` macro, and will cause a link error if this file is `#include`d into multiple objects in the same binary. You could solve this by removing the `extern` (that'd give the variable internal linkage) or by using `enum { warpSize = 32 };` or similar. I'm not sure exactly what the CUDA spec requires here.

================
Comment at: lib/Headers/cuda/cuda_builtin_vars.h:11
@@ +10,3 @@
+
+struct __cuda_builtin_threadIdx_t {
+  __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_tid_x());
----------------
Should these types also have deleted copy constructors and copy assignment operators? I'd imagine these should both be ill-formed:

  auto x = threadIdx;
  threadIdx = threadIdx;

http://reviews.llvm.org/D9064

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list