summaryrefslogtreecommitdiffstats
path: root/openmp/libomptarget/src
diff options
context:
space:
mode:
authorGeorge Rokos <grokos@us.ibm.com>2017-04-22 11:45:03 +0000
committerGeorge Rokos <grokos@us.ibm.com>2017-04-22 11:45:03 +0000
commitd57681b703259c8a87877edcb90db79b01ebc71b (patch)
treebff2f4871b30f06a3b8d54e08040d209249a31aa /openmp/libomptarget/src
parentf9cb9c18a023ed2c88056dab85ceb3c50ea530c8 (diff)
downloadbcm5719-llvm-d57681b703259c8a87877edcb90db79b01ebc71b.tar.gz
bcm5719-llvm-d57681b703259c8a87877edcb90db79b01ebc71b.zip
[OpenMP] libomptarget: Set ref count for global objects to positive infinity
Differential Revision: https://reviews.llvm.org/D32326 llvm-svn: 301076
Diffstat (limited to 'openmp/libomptarget/src')
-rw-r--r--openmp/libomptarget/src/omptarget.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp
index eb1e765ba2f..c182dfbcbb7 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/openmp/libomptarget/src/omptarget.cpp
@@ -60,6 +60,10 @@ struct HostDataToTargetTy {
HostDataToTargetTy(uintptr_t BP, uintptr_t B, uintptr_t E, uintptr_t TB)
: HstPtrBase(BP), HstPtrBegin(B), HstPtrEnd(E),
TgtPtrBegin(TB), RefCount(1) {}
+ HostDataToTargetTy(uintptr_t BP, uintptr_t B, uintptr_t E, uintptr_t TB,
+ long RF)
+ : HstPtrBase(BP), HstPtrBegin(B), HstPtrEnd(E),
+ TgtPtrBegin(TB), RefCount(RF) {}
};
typedef std::list<HostDataToTargetTy> HostDataToTargetListTy;
@@ -902,7 +906,7 @@ void *DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size, bool &IsLast,
}
// Return the target pointer begin (where the data will be moved).
-// Lock-free version called from within assertions.
+// Lock-free version called when loading global symbols from the fat binary.
void *DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size) {
uintptr_t hp = (uintptr_t)HstPtrBegin;
LookupResult lr = lookupMapping(HstPtrBegin, Size);
@@ -1303,6 +1307,7 @@ static int InitLibrary(DeviceTy& Device) {
}
// process global data that needs to be mapped.
+ Device.DataMapMtx.lock();
__tgt_target_table *HostTable = &TransTable->HostTable;
for (__tgt_offload_entry *CurrDeviceEntry = TargetTable->EntriesBegin,
*CurrHostEntry = HostTable->EntriesBegin,
@@ -1318,15 +1323,20 @@ static int InitLibrary(DeviceTy& Device) {
// therefore we must allow for multiple weak symbols to be loaded from
// the fat binary. Treat these mappings as any other "regular" mapping.
// Add entry to map.
+ if (Device.getTgtPtrBegin(CurrHostEntry->addr, CurrHostEntry->size))
+ continue;
DP("Add mapping from host " DPxMOD " to device " DPxMOD " with size %zu"
"\n", DPxPTR(CurrHostEntry->addr), DPxPTR(CurrDeviceEntry->addr),
CurrDeviceEntry->size);
- bool IsNew; //unused
- Device.getOrAllocTgtPtr(CurrHostEntry->addr /*HstPtrBegin*/,
- CurrHostEntry->addr /*HstPtrBase*/, CurrHostEntry->size /*Size*/,
- IsNew, false /*IsImplicit*/, true /*UpdateRefCount*/);
+ Device.HostDataToTargetMap.push_front(HostDataToTargetTy(
+ (uintptr_t)CurrHostEntry->addr /*HstPtrBase*/,
+ (uintptr_t)CurrHostEntry->addr /*HstPtrBegin*/,
+ (uintptr_t)CurrHostEntry->addr + CurrHostEntry->size /*HstPtrEnd*/,
+ (uintptr_t)CurrDeviceEntry->addr /*TgtPtrBegin*/,
+ INF_REF_CNT /*RefCount*/));
}
}
+ Device.DataMapMtx.unlock();
}
TrlTblMtx.unlock();
OpenPOWER on IntegriCloud