[Openmp-commits] [openmp] r298516 - [OpenMP] Allow multiple weak symbols to be loaded from the fat binary
George Rokos via Openmp-commits
openmp-commits at lists.llvm.org
Wed Mar 22 09:43:40 PDT 2017
Author: grokos
Date: Wed Mar 22 11:43:40 2017
New Revision: 298516
URL: http://llvm.org/viewvc/llvm-project?rev=298516&view=rev
Log:
[OpenMP] Allow multiple weak symbols to be loaded from the fat binary
For compatibility with Fortran.
Differential Revision: https://reviews.llvm.org/D31205
Modified:
openmp/trunk/libomptarget/src/omptarget.cpp
Modified: openmp/trunk/libomptarget/src/omptarget.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/libomptarget/src/omptarget.cpp?rev=298516&r1=298515&r2=298516&view=diff
==============================================================================
--- openmp/trunk/libomptarget/src/omptarget.cpp (original)
+++ openmp/trunk/libomptarget/src/omptarget.cpp Wed Mar 22 11:43:40 2017
@@ -1303,7 +1303,6 @@ 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,
@@ -1314,20 +1313,20 @@ static int InitLibrary(DeviceTy& Device)
// has data.
assert(CurrDeviceEntry->size == CurrHostEntry->size &&
"data size mismatch");
- assert(Device.getTgtPtrBegin(CurrHostEntry->addr,
- CurrHostEntry->size) == NULL &&
- "data in declared target should not be already mapped");
- // add entry to map.
+
+ // Fortran may use multiple weak declarations for the same symbol,
+ // 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.
DP("Add mapping from host " DPxMOD " to device " DPxMOD " with size %zu"
"\n", DPxPTR(CurrHostEntry->addr), DPxPTR(CurrDeviceEntry->addr),
CurrDeviceEntry->size);
- Device.HostDataToTargetMap.push_front(HostDataToTargetTy(
- (uintptr_t)CurrHostEntry->addr, (uintptr_t)CurrHostEntry->addr,
- (uintptr_t)CurrHostEntry->addr + CurrHostEntry->size,
- (uintptr_t)CurrDeviceEntry->addr));
+ bool IsNew; //unused
+ Device.getOrAllocTgtPtr(CurrHostEntry->addr /*HstPtrBegin*/,
+ CurrHostEntry->addr /*HstPtrBase*/, CurrHostEntry->size /*Size*/,
+ IsNew, false /*IsImplicit*/, true /*UpdateRefCount*/);
}
}
- Device.DataMapMtx.unlock();
}
TrlTblMtx.unlock();
More information about the Openmp-commits
mailing list