diff options
author | Gheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com> | 2019-06-20 18:04:47 +0000 |
---|---|---|
committer | Gheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com> | 2019-06-20 18:04:47 +0000 |
commit | 0034e84aa5420827845c464327646b0ca54b424b (patch) | |
tree | 84294f7c35edfee5e88d8ec35b7a5556440d0f05 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 04c5bc989a31b81bd7dda1f3e53de2930c8c7ec0 (diff) | |
download | bcm5719-llvm-0034e84aa5420827845c464327646b0ca54b424b.tar.gz bcm5719-llvm-0034e84aa5420827845c464327646b0ca54b424b.zip |
[OpenMP] Add support for handling declare target to clause when unified memory is required
Summary:
This patch adds support for the handling of the variables under the declare target to clause.
The variables in this case are handled like link variables are. A pointer is created on the host and then mapped to the device. The runtime will then copy the address of the host variable in the device pointer.
Reviewers: ABataev, AlexEichenberger, caomhin
Reviewed By: ABataev
Subscribers: guansong, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D63108
llvm-svn: 363959
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 559f3a73d38..d0f62beed96 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2475,13 +2475,19 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { // Emit declaration of the must-be-emitted declare target variable. if (llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy> Res = OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD)) { - if (*Res == OMPDeclareTargetDeclAttr::MT_To) { + bool UnifiedMemoryEnabled = + getOpenMPRuntime().hasRequiresUnifiedSharedMemory(); + if (*Res == OMPDeclareTargetDeclAttr::MT_To && + !UnifiedMemoryEnabled) { (void)GetAddrOfGlobalVar(VD); } else { - assert(*Res == OMPDeclareTargetDeclAttr::MT_Link && - "link claue expected."); - (void)getOpenMPRuntime().getAddrOfDeclareTargetLink(VD); + assert(((*Res == OMPDeclareTargetDeclAttr::MT_Link) || + (*Res == OMPDeclareTargetDeclAttr::MT_To && + UnifiedMemoryEnabled)) && + "Link clause or to clause with unified memory expected."); + (void)getOpenMPRuntime().getAddrOfDeclareTargetVar(VD); } + return; } } |