[Openmp-commits] [openmp] r363825 - [OpenMP][libomptarget] Add support for declare target to clause under unified memory
Gheorghe-Teodor Bercea via Openmp-commits
openmp-commits at lists.llvm.org
Wed Jun 19 08:48:11 PDT 2019
Author: gbercea
Date: Wed Jun 19 08:48:10 2019
New Revision: 363825
URL: http://llvm.org/viewvc/llvm-project?rev=363825&view=rev
Log:
[OpenMP][libomptarget] Add support for declare target to clause under unified memory
Summary:
This patch adds support for handling variables under the:
```
#pragma omp declare target to()
```
clause when the
```
#pragma omp requires unified_shared_memory
```
is used.
The address of the host variable is copied into the device pointer just like for the declare target link case.
Reviewers: ABataev, caomhin, grokos, AlexEichenberger
Reviewed By: grokos
Subscribers: jcownie, guansong, jdoerfert, openmp-commits
Tags: #openmp
Differential Revision: https://reviews.llvm.org/D63106
Modified:
openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp
Modified: openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp?rev=363825&r1=363824&r2=363825&view=diff
==============================================================================
--- openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp (original)
+++ openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp Wed Jun 19 08:48:10 2019
@@ -448,9 +448,18 @@ __tgt_target_table *__tgt_rtl_load_binar
DPxPTR(e - HostBegin), e->name, DPxPTR(cuptr));
entry.addr = (void *)cuptr;
- if (DeviceInfo.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY &&
- e->flags & OMP_DECLARE_TARGET_LINK) {
- // If unified memory is present any target link variables
+ // Note: In the current implementation declare target variables
+ // can either be link or to. This means that once unified
+ // memory is activated via the requires directive, the variable
+ // can be used directly from the host in both cases.
+ // TODO: when variables types other than to or link are added,
+ // the below condition should be changed to explicitely
+ // check for to and link variables types:
+ // (DeviceInfo.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY &&
+ // (e->flags & OMP_DECLARE_TARGET_LINK ||
+ // e->flags == OMP_DECLARE_TARGET_TO))
+ if (DeviceInfo.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) {
+ // If unified memory is present any target link or to variables
// can access host addresses directly. There is no longer a
// need for device copies.
cuMemcpyHtoD(cuptr, e->addr, sizeof(void *));
More information about the Openmp-commits
mailing list