diff options
author | Artem Belevich <tra@google.com> | 2016-03-02 18:28:50 +0000 |
---|---|---|
committer | Artem Belevich <tra@google.com> | 2016-03-02 18:28:50 +0000 |
commit | 42e1949b4649c2ecbc9a13ca8b56f902b5214b95 (patch) | |
tree | 039124b3490f5cb0926e371b806aa50e94fd4a2d /clang/lib/CodeGen/CGCUDARuntime.h | |
parent | cdf3a2a5be7fb4c650ae30a44200248980e214ed (diff) | |
download | bcm5719-llvm-42e1949b4649c2ecbc9a13ca8b56f902b5214b95.tar.gz bcm5719-llvm-42e1949b4649c2ecbc9a13ca8b56f902b5214b95.zip |
[CUDA] Emit host-side 'shadows' for device-side global variables
... and register them with CUDA runtime.
This is needed for commonly used cudaMemcpy*() APIs that use address of
host-side shadow to access their counterparts on device side.
Fixes PR26340
Differential Revision: http://reviews.llvm.org/D17779
llvm-svn: 262498
Diffstat (limited to 'clang/lib/CodeGen/CGCUDARuntime.h')
-rw-r--r-- | clang/lib/CodeGen/CGCUDARuntime.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCUDARuntime.h b/clang/lib/CodeGen/CGCUDARuntime.h index dcacf970327..0168f4f9e94 100644 --- a/clang/lib/CodeGen/CGCUDARuntime.h +++ b/clang/lib/CodeGen/CGCUDARuntime.h @@ -18,6 +18,7 @@ namespace llvm { class Function; +class GlobalVariable; } namespace clang { @@ -37,6 +38,12 @@ protected: CodeGenModule &CGM; public: + // Global variable properties that must be passed to CUDA runtime. + enum DeviceVarFlags { + ExternDeviceVar = 0x01, // extern + ConstantDeviceVar = 0x02, // __constant__ + }; + CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {} virtual ~CGCUDARuntime(); @@ -46,6 +53,7 @@ public: /// Emits a kernel launch stub. virtual void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) = 0; + virtual void registerDeviceVar(llvm::GlobalVariable &Var, unsigned Flags) = 0; /// Constructs and returns a module initialization function or nullptr if it's /// not needed. Must be called after all kernels have been emitted. |