[Openmp-commits] [PATCH] D60223: [OpenMP][libomptarget] Add support for target link variables when unified memory is enabled
Gheorghe-Teodor Bercea via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Apr 3 12:20:05 PDT 2019
gtbercea updated this revision to Diff 193568.
gtbercea added a comment.
- Fix size.
Repository:
rOMP OpenMP
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60223/new/
https://reviews.llvm.org/D60223
Files:
libomptarget/include/omptarget.h
libomptarget/plugins/cuda/src/rtl.cpp
libomptarget/src/device.cpp
libomptarget/src/interface.cpp
libomptarget/src/omptarget.cpp
libomptarget/src/rtl.cpp
Index: libomptarget/src/rtl.cpp
===================================================================
--- libomptarget/src/rtl.cpp
+++ libomptarget/src/rtl.cpp
@@ -177,10 +177,6 @@
DPxPTR(entry->addr));
Device.PendingCtorsDtors[desc].PendingDtors.push_front(entry->addr);
}
-
- if (entry->flags & OMP_DECLARE_TARGET_LINK) {
- DP("The \"link\" attribute is not yet supported!\n");
- }
}
Device.PendingGlobalsMtx.unlock();
}
Index: libomptarget/src/omptarget.cpp
===================================================================
--- libomptarget/src/omptarget.cpp
+++ libomptarget/src/omptarget.cpp
@@ -216,7 +216,8 @@
for (int32_t i = 0; i < arg_num; ++i) {
// Ignore private variables and arrays - there is no mapping for them.
if ((arg_types[i] & OMP_TGT_MAPTYPE_LITERAL) ||
- (arg_types[i] & OMP_TGT_MAPTYPE_PRIVATE))
+ (arg_types[i] & OMP_TGT_MAPTYPE_PRIVATE) ||
+ (arg_types[i] & OMP_TGT_MAPTYPE_USE_HOST_VAR))
continue;
void *HstPtrBegin = args[i];
Index: libomptarget/src/interface.cpp
===================================================================
--- libomptarget/src/interface.cpp
+++ libomptarget/src/interface.cpp
@@ -57,7 +57,7 @@
}
break;
case tgt_default:
- FATAL_MESSAGE0(1, "default offloading policy must switched to "
+ FATAL_MESSAGE0(1, "default offloading policy must switched to "
"mandatory or disabled");
break;
case tgt_mandatory:
Index: libomptarget/src/device.cpp
===================================================================
--- libomptarget/src/device.cpp
+++ libomptarget/src/device.cpp
@@ -152,7 +152,7 @@
// Used by target_data_begin
// Return the target pointer begin (where the data will be moved).
-// Allocate memory if this is the first occurrence if this mapping.
+// Allocate memory if this is the first occurrence of this mapping.
// Increment the reference counter.
// If NULL is returned, then either data allocation failed or the user tried
// to do an illegal mapping.
Index: libomptarget/plugins/cuda/src/rtl.cpp
===================================================================
--- libomptarget/plugins/cuda/src/rtl.cpp
+++ libomptarget/plugins/cuda/src/rtl.cpp
@@ -435,6 +435,17 @@
DP("Entry point " DPxMOD " maps to global %s (" DPxMOD ")\n",
DPxPTR(e - HostBegin), e->name, DPxPTR(cuptr));
entry.addr = (void *)cuptr;
+ if (e->flags & OMP_DECLARE_TARGET_LINK) {
+ // By default, we handle declare target link global variables as if
+ // unified memory can be used. If at target region launch it turns
+ // out that unified memory is not available then this value will
+ // be overwritten with the device address of the device-allocated
+ // variable.
+ cuMemcpyHtoD(cuptr, e->addr, sizeof(void *));
+ DP("Copy linked variable host address (" DPxMOD ")"
+ "to device address (" DPxMOD ")\n",
+ DPxPTR(*((void**)e->addr)), DPxPTR(cuptr));
+ }
DeviceInfo.addOffloadEntry(device_id, entry);
Index: libomptarget/include/omptarget.h
===================================================================
--- libomptarget/include/omptarget.h
+++ libomptarget/include/omptarget.h
@@ -47,6 +47,8 @@
OMP_TGT_MAPTYPE_LITERAL = 0x100,
// mapping is implicit
OMP_TGT_MAPTYPE_IMPLICIT = 0x200,
+ // use host version
+ OMP_TGT_MAPTYPE_USE_HOST_VAR = 0x400,
// member of struct, member given by [16 MSBs] - 1
OMP_TGT_MAPTYPE_MEMBER_OF = 0xffff000000000000
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60223.193568.patch
Type: text/x-patch
Size: 3631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190403/c0f2fa0d/attachment.bin>
More information about the Openmp-commits
mailing list