summaryrefslogtreecommitdiffstats
path: root/openmp/libomptarget/src
diff options
context:
space:
mode:
authorGheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com>2019-06-04 15:05:53 +0000
committerGheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com>2019-06-04 15:05:53 +0000
commitc5fe030c166b0fee57b7a5dfea20f24f4571fe29 (patch)
treec6b9d25b30544a280b3eb90042d830f67f48c9c6 /openmp/libomptarget/src
parenta6e289e9f8b1a4b03c96176483e5ec478e281720 (diff)
downloadbcm5719-llvm-c5fe030c166b0fee57b7a5dfea20f24f4571fe29.tar.gz
bcm5719-llvm-c5fe030c166b0fee57b7a5dfea20f24f4571fe29.zip
[OpenMP][libomptarget] Enable usage of unified memory for declare target link variables
Summary: This patch enables the usage of a host variable on the device for declare target link variables when unified memory is available. Reviewers: ABataev, caomhin, grokos Reviewed By: grokos Subscribers: Hahnfeld, guansong, jdoerfert, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D60884 llvm-svn: 362505
Diffstat (limited to 'openmp/libomptarget/src')
-rw-r--r--openmp/libomptarget/src/device.cpp3
-rw-r--r--openmp/libomptarget/src/rtl.cpp4
-rw-r--r--openmp/libomptarget/src/rtl.h7
3 files changed, 12 insertions, 2 deletions
diff --git a/openmp/libomptarget/src/device.cpp b/openmp/libomptarget/src/device.cpp
index a946b928be9..5ecba5759eb 100644
--- a/openmp/libomptarget/src/device.cpp
+++ b/openmp/libomptarget/src/device.cpp
@@ -275,6 +275,9 @@ int DeviceTy::deallocTgtPtr(void *HstPtrBegin, int64_t Size, bool ForceDelete) {
/// Init device, should not be called directly.
void DeviceTy::init() {
+ // Make call to init_requires if it exists for this plugin.
+ if (RTL->init_requires)
+ RTL->init_requires(RTLRequiresFlags);
int32_t rc = RTL->init_device(RTLDeviceID);
if (rc == OFFLOAD_SUCCESS) {
IsInit = true;
diff --git a/openmp/libomptarget/src/rtl.cpp b/openmp/libomptarget/src/rtl.cpp
index 770ae36a829..4eb7ab71489 100644
--- a/openmp/libomptarget/src/rtl.cpp
+++ b/openmp/libomptarget/src/rtl.cpp
@@ -107,6 +107,10 @@ void RTLsTy::LoadRTLs() {
dynlib_handle, "__tgt_rtl_run_target_team_region")))
continue;
+ // Optional functions
+ *((void**) &R.init_requires) = dlsym(
+ dynlib_handle, "__tgt_rtl_init_requires");
+
// No devices are supported by this RTL?
if (!(R.NumberOfDevices = R.number_of_devices())) {
DP("No devices supported in this RTL\n");
diff --git a/openmp/libomptarget/src/rtl.h b/openmp/libomptarget/src/rtl.h
index 381f23ea054..8148e81e7df 100644
--- a/openmp/libomptarget/src/rtl.h
+++ b/openmp/libomptarget/src/rtl.h
@@ -36,6 +36,7 @@ struct RTLInfoTy {
int32_t);
typedef int32_t(run_team_region_ty)(int32_t, void *, void **, ptrdiff_t *,
int32_t, int32_t, int32_t, uint64_t);
+ typedef int64_t(init_requires_ty)(int64_t);
int32_t Idx; // RTL index, index is the number of devices
// of other RTLs that were registered before,
@@ -60,6 +61,7 @@ struct RTLInfoTy {
data_delete_ty *data_delete;
run_region_ty *run_region;
run_team_region_ty *run_team_region;
+ init_requires_ty *init_requires;
// Are there images associated with this RTL.
bool isUsed;
@@ -78,8 +80,8 @@ struct RTLInfoTy {
#endif
is_valid_binary(0), number_of_devices(0), init_device(0),
load_binary(0), data_alloc(0), data_submit(0), data_retrieve(0),
- data_delete(0), run_region(0), run_team_region(0), isUsed(false),
- Mtx() {}
+ data_delete(0), run_region(0), run_team_region(0),
+ init_requires(0), isUsed(false), Mtx() {}
RTLInfoTy(const RTLInfoTy &r) : Mtx() {
Idx = r.Idx;
@@ -98,6 +100,7 @@ struct RTLInfoTy {
data_delete = r.data_delete;
run_region = r.run_region;
run_team_region = r.run_team_region;
+ init_requires = r.init_requires;
isUsed = r.isUsed;
}
};
OpenPOWER on IntegriCloud