Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/src/device.cpp
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | if (search != HostDataToTargetMap.end()) { | ||||
REPORT("Association not found\n"); | REPORT("Association not found\n"); | ||||
} | } | ||||
// Mapping not found | // Mapping not found | ||||
DataMapMtx.unlock(); | DataMapMtx.unlock(); | ||||
return OFFLOAD_FAIL; | return OFFLOAD_FAIL; | ||||
} | } | ||||
LookupResult DeviceTy::lookupMapping(void *HstPtrBegin, int64_t Size) { | LookupResult DeviceTy::lookupMapping(void *HstPtrBase, void *HstPtrBegin, | ||||
int64_t Size) { | |||||
uintptr_t hp = (uintptr_t)HstPtrBegin; | uintptr_t hp = (uintptr_t)HstPtrBegin; | ||||
uintptr_t hb = (uintptr_t)HstPtrBase; | |||||
LookupResult lr; | LookupResult lr; | ||||
DP("Looking up mapping(HstPtrBegin=" DPxMOD ", Size=%" PRId64 ")...\n", | DP("Looking up mapping(HstPtrBegin=" DPxMOD ", Size=%" PRId64 ")...\n", | ||||
DPxPTR(hp), Size); | DPxPTR(hp), Size); | ||||
if (HostDataToTargetMap.empty()) | if (HostDataToTargetMap.empty()) | ||||
return lr; | return lr; | ||||
auto upper = HostDataToTargetMap.upper_bound(hp); | auto upper = HostDataToTargetMap.upper_bound(hp); | ||||
// check the left bin | // check the left bin | ||||
if (upper != HostDataToTargetMap.begin()) { | if (upper != HostDataToTargetMap.begin()) { | ||||
lr.Entry = std::prev(upper); | lr.Entry = std::prev(upper); | ||||
auto &HT = *lr.Entry; | auto &HT = *lr.Entry; | ||||
// Is it contained? | // Is it contained? | ||||
lr.Flags.IsContained = hp >= HT.HstPtrBegin && hp < HT.HstPtrEnd && | lr.Flags.IsContained = hp >= HT.HstPtrBegin && hp < HT.HstPtrEnd && | ||||
(hp + Size) <= HT.HstPtrEnd; | (hp + Size) <= HT.HstPtrEnd; | ||||
// Does it extend beyond the mapped region? | // Does it extend beyond the mapped region? | ||||
lr.Flags.ExtendsAfter = hp < HT.HstPtrEnd && (hp + Size) > HT.HstPtrEnd; | lr.Flags.ExtendsAfter = hp < HT.HstPtrEnd && (hp + Size) > HT.HstPtrEnd; | ||||
// Did we just find the base? | |||||
// There is a special case where we map a struct via a double pointer, e.g. | |||||
// typedef struct {...} S; | |||||
// S s; | |||||
// S *sp = &s; | |||||
// S **spp = &sp; | |||||
// #pragma omp target map (to: spp[0][0]) {...} | |||||
// In that case, the record for pointer sp will share the same base as the | |||||
// record for struct s, but we shouldn't report that we only found the base, | |||||
// i.e. we must let libomptarget create a new record in HostDataToTargetMap | |||||
// for the struct s itself which will have the same base as the record for | |||||
// pointer sp. This scenario can only happen in the left bin. | |||||
if (!lr.Flags.IsContained && !lr.Flags.ExtendsAfter && | |||||
hb == HT.HstPtrBase && | |||||
Lint: Pre-merge checks: clang-format: please reformat the code
```
- hb == HT.HstPtrBase &&
- HT. | |||||
HT.HstPtrEnd - HT.HstPtrBegin != sizeof(void *)) | |||||
lr.Flags.OnlyBaseFound = true; | |||||
} | } | ||||
// check the right bin | // check the right bin | ||||
if (!(lr.Flags.IsContained || lr.Flags.ExtendsAfter) && | if (!(lr.Flags.IsContained || lr.Flags.ExtendsAfter || lr.Flags.OnlyBaseFound) | ||||
Lint: Pre-merge checks clang-format: please reformat the code - if (!(lr.Flags.IsContained || lr.Flags.ExtendsAfter || lr.Flags.OnlyBaseFound) - && upper != HostDataToTargetMap.end()) { + if (!(lr.Flags.IsContained || lr.Flags.ExtendsAfter || + lr.Flags.OnlyBaseFound) && + upper != HostDataToTargetMap.end()) { Lint: Pre-merge checks: clang-format: please reformat the code
```
- if (!(lr.Flags.IsContained || lr.Flags. | |||||
upper != HostDataToTargetMap.end()) { | && upper != HostDataToTargetMap.end()) { | ||||
lr.Entry = upper; | lr.Entry = upper; | ||||
auto &HT = *lr.Entry; | auto &HT = *lr.Entry; | ||||
// Does it extend into an already mapped region? | // Does it extend into an already mapped region? | ||||
lr.Flags.ExtendsBefore = | lr.Flags.ExtendsBefore = | ||||
hp < HT.HstPtrBegin && (hp + Size) > HT.HstPtrBegin; | hp < HT.HstPtrBegin && (hp + Size) > HT.HstPtrBegin; | ||||
// Does it extend beyond the mapped region? | // Does it extend beyond the mapped region? | ||||
lr.Flags.ExtendsAfter = hp < HT.HstPtrEnd && (hp + Size) > HT.HstPtrEnd; | lr.Flags.ExtendsAfter = hp < HT.HstPtrEnd && (hp + Size) > HT.HstPtrEnd; | ||||
// Did we just find the base? | |||||
if (!lr.Flags.ExtendsBefore && !lr.Flags.ExtendsAfter && | |||||
hb == HT.HstPtrBase) | |||||
lr.Flags.OnlyBaseFound = true; | |||||
} | } | ||||
if (lr.Flags.ExtendsBefore) { | if (lr.Flags.ExtendsBefore) { | ||||
DP("WARNING: Pointer is not mapped but section extends into already " | DP("WARNING: Pointer is not mapped but section extends into already " | ||||
"mapped data\n"); | "mapped data\n"); | ||||
} | } | ||||
if (lr.Flags.ExtendsAfter) { | if (lr.Flags.ExtendsAfter) { | ||||
DP("WARNING: Pointer is already mapped but section extends beyond mapped " | DP("WARNING: Pointer is already mapped but section extends beyond mapped " | ||||
Show All 11 Lines | DeviceTy::getTargetPointer(void *HstPtrBegin, void *HstPtrBase, int64_t Size, | ||||
bool HasPresentModifier, bool HasHoldModifier, | bool HasPresentModifier, bool HasHoldModifier, | ||||
AsyncInfoTy &AsyncInfo) { | AsyncInfoTy &AsyncInfo) { | ||||
void *TargetPointer = nullptr; | void *TargetPointer = nullptr; | ||||
bool IsHostPtr = false; | bool IsHostPtr = false; | ||||
bool IsNew = false; | bool IsNew = false; | ||||
DataMapMtx.lock(); | DataMapMtx.lock(); | ||||
LookupResult LR = lookupMapping(HstPtrBegin, Size); | LookupResult LR = lookupMapping(HstPtrBase, HstPtrBegin, Size); | ||||
auto Entry = LR.Entry; | auto Entry = LR.Entry; | ||||
// Check if the pointer is contained. | // Check if the pointer is contained. | ||||
// If a variable is mapped to the device manually by the user - which would | // If a variable is mapped to the device manually by the user - which would | ||||
// lead to the IsContained flag to be true - then we must ensure that the | // lead to the IsContained flag to be true - then we must ensure that the | ||||
// device address is returned even under unified memory conditions. | // device address is returned even under unified memory conditions. | ||||
if (LR.Flags.IsContained || | if (LR.Flags.IsContained || | ||||
((LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter) && IsImplicit)) { | ((LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter) && IsImplicit) || | ||||
(LR.Flags.OnlyBaseFound && !Size)) { | |||||
auto &HT = *LR.Entry; | auto &HT = *LR.Entry; | ||||
const char *RefCountAction; | const char *RefCountAction; | ||||
assert(HT.getTotalRefCount() > 0 && "expected existing RefCount > 0"); | assert(HT.getTotalRefCount() > 0 && "expected existing RefCount > 0"); | ||||
if (UpdateRefCount) { | if (UpdateRefCount) { | ||||
// After this, RefCount > 1. | // After this, RefCount > 1. | ||||
HT.incRefCount(HasHoldModifier); | HT.incRefCount(HasHoldModifier); | ||||
RefCountAction = " (incremented)"; | RefCountAction = " (incremented)"; | ||||
} else { | } else { | ||||
// It might have been allocated with the parent, but it's still new. | // It might have been allocated with the parent, but it's still new. | ||||
IsNew = HT.getTotalRefCount() == 1; | IsNew = HT.getTotalRefCount() == 1; | ||||
RefCountAction = " (update suppressed)"; | RefCountAction = " (update suppressed)"; | ||||
} | } | ||||
const char *DynRefCountAction = HasHoldModifier ? "" : RefCountAction; | const char *DynRefCountAction = HasHoldModifier ? "" : RefCountAction; | ||||
const char *HoldRefCountAction = HasHoldModifier ? RefCountAction : ""; | const char *HoldRefCountAction = HasHoldModifier ? RefCountAction : ""; | ||||
uintptr_t Ptr = HT.TgtPtrBegin + ((uintptr_t)HstPtrBegin - HT.HstPtrBegin); | |||||
uintptr_t Ptr = 0; | |||||
if (LR.Flags.OnlyBaseFound) | |||||
// Return the implied device base | |||||
Ptr = HT.TgtPtrBegin - (HT.HstPtrBegin - HT.HstPtrBase); | |||||
else | |||||
// Return the device address corresponding to HstPtrBegin | |||||
Ptr = HT.TgtPtrBegin + ((uintptr_t)HstPtrBegin - HT.HstPtrBegin); | |||||
INFO(OMP_INFOTYPE_MAPPING_EXISTS, DeviceID, | INFO(OMP_INFOTYPE_MAPPING_EXISTS, DeviceID, | ||||
"Mapping exists%s with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD | "Mapping exists%s with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD | ||||
", Size=%" PRId64 ", DynRefCount=%s%s, HoldRefCount=%s%s, Name=%s\n", | ", Size=%" PRId64 ", DynRefCount=%s%s, HoldRefCount=%s%s, Name=%s\n", | ||||
(IsImplicit ? " (implicit)" : ""), DPxPTR(HstPtrBegin), DPxPTR(Ptr), | (IsImplicit ? " (implicit)" : ""), DPxPTR(HstPtrBegin), DPxPTR(Ptr), | ||||
Size, HT.dynRefCountToStr().c_str(), DynRefCountAction, | Size, HT.dynRefCountToStr().c_str(), DynRefCountAction, | ||||
HT.holdRefCountToStr().c_str(), HoldRefCountAction, | HT.holdRefCountToStr().c_str(), HoldRefCountAction, | ||||
(HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown"); | (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown"); | ||||
TargetPointer = (void *)Ptr; | TargetPointer = (void *)Ptr; | ||||
} else if ((LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter) && !IsImplicit) { | } else if ((LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter) && !IsImplicit) { | ||||
// Explicit extension of mapped data - not allowed. | // Explicit extension of mapped data - not allowed. | ||||
MESSAGE("explicit extension not allowed: host address specified is " DPxMOD | MESSAGE("explicit extension not allowed: host address specified is " DPxMOD | ||||
" (%" PRId64 | " (%" PRId64 | ||||
" bytes), but device allocation maps to host at " DPxMOD | " bytes), but device allocation maps to host at " DPxMOD | ||||
" (%" PRId64 " bytes)", | " (%" PRId64 " bytes)", | ||||
DPxPTR(HstPtrBegin), Size, DPxPTR(Entry->HstPtrBegin), | DPxPTR(HstPtrBegin), Size, DPxPTR(Entry->HstPtrBegin), | ||||
Entry->HstPtrEnd - Entry->HstPtrBegin); | Entry->HstPtrEnd - Entry->HstPtrBegin); | ||||
if (HasPresentModifier) | if (HasPresentModifier) | ||||
MESSAGE("device mapping required by 'present' map type modifier does not " | MESSAGE("device mapping required by 'present' map type modifier does not " | ||||
"exist for host address " DPxMOD " (%" PRId64 " bytes)", | "exist for host address " DPxMOD " (%" PRId64 " bytes)", | ||||
DPxPTR(HstPtrBegin), Size); | DPxPTR(HstPtrBegin), Size); | ||||
} else if (LR.Flags.OnlyBaseFound && Size) { | |||||
// If we only found the base address but a size has been provided, it | |||||
// means that the user tried to map another distinct chunk of an already | |||||
// partially-mapped object, which is illegal. | |||||
MESSAGE("Found record of existing mapping with the requested base address " | |||||
Lint: Pre-merge checks clang-format: please reformat the code - MESSAGE("Found record of existing mapping with the requested base address " - DPxMOD " but disjoint mapped data, mapping of two distinct chunks " - "of the same object is not allowed.", DPxPTR(HstPtrBase)); + MESSAGE("Found record of existing mapping with the requested base " + "address " DPxMOD + " but disjoint mapped data, mapping of two distinct chunks " + "of the same object is not allowed.", + DPxPTR(HstPtrBase)); Lint: Pre-merge checks: clang-format: please reformat the code
```
- MESSAGE("Found record of existing mapping with… | |||||
DPxMOD " but disjoint mapped data, mapping of two distinct chunks " | |||||
"of the same object is not allowed.", DPxPTR(HstPtrBase)); | |||||
} else if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY && | } else if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY && | ||||
!HasCloseModifier) { | !HasCloseModifier) { | ||||
// If unified shared memory is active, implicitly mapped variables that are | // If unified shared memory is active, implicitly mapped variables that are | ||||
// not privatized use host address. Any explicitly mapped variables also use | // not privatized use host address. Any explicitly mapped variables also use | ||||
// host address where correctness is not impeded. In all other cases maps | // host address where correctness is not impeded. In all other cases maps | ||||
// are respected. | // are respected. | ||||
// In addition to the mapping rules above, the close map modifier forces the | // In addition to the mapping rules above, the close map modifier forces the | ||||
// mapping of the variable to the device. | // mapping of the variable to the device. | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | DeviceTy::getTargetPointer(void *HstPtrBegin, void *HstPtrBase, int64_t Size, | ||||
return {{IsNew, IsHostPtr}, Entry, TargetPointer}; | return {{IsNew, IsHostPtr}, Entry, TargetPointer}; | ||||
} | } | ||||
// Used by targetDataBegin, targetDataEnd, targetDataUpdate and target. | // Used by targetDataBegin, targetDataEnd, targetDataUpdate and target. | ||||
// Return the target pointer begin (where the data will be moved). | // Return the target pointer begin (where the data will be moved). | ||||
// Decrement the reference counter if called from targetDataEnd. | // Decrement the reference counter if called from targetDataEnd. | ||||
TargetPointerResultTy | TargetPointerResultTy | ||||
DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size, bool &IsLast, | DeviceTy::getTgtPtrBegin(void *HstPtrBegin, void *HstPtrBase, int64_t Size, | ||||
bool UpdateRefCount, bool UseHoldRefCount, | bool &IsLast, bool UpdateRefCount, | ||||
bool &IsHostPtr, bool MustContain, bool ForceDelete) { | bool UseHoldRefCount, bool &IsHostPtr, | ||||
bool MustContain, bool ForceDelete) { | |||||
void *TargetPointer = NULL; | void *TargetPointer = NULL; | ||||
bool IsNew = false; | bool IsNew = false; | ||||
IsHostPtr = false; | IsHostPtr = false; | ||||
IsLast = false; | IsLast = false; | ||||
DataMapMtx.lock(); | DataMapMtx.lock(); | ||||
LookupResult lr = lookupMapping(HstPtrBegin, Size); | LookupResult lr = lookupMapping(HstPtrBase, HstPtrBegin, Size); | ||||
if (lr.Flags.IsContained || | if (lr.Flags.IsContained || | ||||
(!MustContain && (lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter))) { | (!MustContain && (lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter)) || | ||||
lr.Flags.OnlyBaseFound) { | |||||
auto &HT = *lr.Entry; | auto &HT = *lr.Entry; | ||||
// We do not zero the total reference count here. deallocTgtPtr does that | // We do not zero the total reference count here. deallocTgtPtr does that | ||||
// atomically with removing the mapping. Otherwise, before this thread | // atomically with removing the mapping. Otherwise, before this thread | ||||
// removed the mapping in deallocTgtPtr, another thread could retrieve the | // removed the mapping in deallocTgtPtr, another thread could retrieve the | ||||
// mapping, increment and decrement back to zero, and then both threads | // mapping, increment and decrement back to zero, and then both threads | ||||
// would try to remove the mapping, resulting in a double free. | // would try to remove the mapping, resulting in a double free. | ||||
IsLast = HT.decShouldRemove(UseHoldRefCount, ForceDelete); | IsLast = HT.decShouldRemove(UseHoldRefCount, ForceDelete); | ||||
const char *RefCountAction; | const char *RefCountAction; | ||||
Show All 12 Lines | if (lr.Flags.IsContained || | ||||
} else if (IsLast) { | } else if (IsLast) { | ||||
RefCountAction = " (deferred final decrement)"; | RefCountAction = " (deferred final decrement)"; | ||||
} else { | } else { | ||||
HT.decRefCount(UseHoldRefCount); | HT.decRefCount(UseHoldRefCount); | ||||
RefCountAction = " (decremented)"; | RefCountAction = " (decremented)"; | ||||
} | } | ||||
const char *DynRefCountAction = UseHoldRefCount ? "" : RefCountAction; | const char *DynRefCountAction = UseHoldRefCount ? "" : RefCountAction; | ||||
const char *HoldRefCountAction = UseHoldRefCount ? RefCountAction : ""; | const char *HoldRefCountAction = UseHoldRefCount ? RefCountAction : ""; | ||||
uintptr_t tp = HT.TgtPtrBegin + ((uintptr_t)HstPtrBegin - HT.HstPtrBegin); | |||||
uintptr_t tp = 0; | |||||
if (lr.Flags.OnlyBaseFound) | |||||
// Return the implied device base | |||||
tp = HT.TgtPtrBegin - (HT.HstPtrBegin - HT.HstPtrBase); | |||||
else | |||||
// Return the device address corresponding to HstPtrBegin | |||||
tp = HT.TgtPtrBegin + ((uintptr_t)HstPtrBegin - HT.HstPtrBegin); | |||||
INFO(OMP_INFOTYPE_MAPPING_EXISTS, DeviceID, | INFO(OMP_INFOTYPE_MAPPING_EXISTS, DeviceID, | ||||
"Mapping exists with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD ", " | "Mapping exists with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD ", " | ||||
"Size=%" PRId64 ", DynRefCount=%s%s, HoldRefCount=%s%s\n", | "Size=%" PRId64 ", DynRefCount=%s%s, HoldRefCount=%s%s\n", | ||||
DPxPTR(HstPtrBegin), DPxPTR(tp), Size, HT.dynRefCountToStr().c_str(), | DPxPTR(HstPtrBegin), DPxPTR(tp), Size, HT.dynRefCountToStr().c_str(), | ||||
DynRefCountAction, HT.holdRefCountToStr().c_str(), HoldRefCountAction); | DynRefCountAction, HT.holdRefCountToStr().c_str(), HoldRefCountAction); | ||||
TargetPointer = (void *)tp; | TargetPointer = (void *)tp; | ||||
} else if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) { | } else if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) { | ||||
// If the value isn't found in the mapping and unified shared memory | // If the value isn't found in the mapping and unified shared memory | ||||
Show All 9 Lines | DeviceTy::getTgtPtrBegin(void *HstPtrBegin, void *HstPtrBase, int64_t Size, | ||||
DataMapMtx.unlock(); | DataMapMtx.unlock(); | ||||
return {{IsNew, IsHostPtr}, lr.Entry, TargetPointer}; | return {{IsNew, IsHostPtr}, lr.Entry, TargetPointer}; | ||||
} | } | ||||
// Return the target pointer begin (where the data will be moved). | // Return the target pointer begin (where the data will be moved). | ||||
// Lock-free version called when loading global symbols from the fat binary. | // Lock-free version called when loading global symbols from the fat binary. | ||||
void *DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size) { | void *DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size) { | ||||
uintptr_t hp = (uintptr_t)HstPtrBegin; | uintptr_t hp = (uintptr_t)HstPtrBegin; | ||||
LookupResult lr = lookupMapping(HstPtrBegin, Size); | LookupResult lr = lookupMapping(nullptr, HstPtrBegin, Size); | ||||
if (lr.Flags.IsContained || lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter) { | if (lr.Flags.IsContained || lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter) { | ||||
auto &HT = *lr.Entry; | auto &HT = *lr.Entry; | ||||
uintptr_t tp = HT.TgtPtrBegin + (hp - HT.HstPtrBegin); | uintptr_t tp = HT.TgtPtrBegin + (hp - HT.HstPtrBegin); | ||||
return (void *)tp; | return (void *)tp; | ||||
} | } | ||||
return NULL; | return NULL; | ||||
} | } | ||||
int DeviceTy::deallocTgtPtr(void *HstPtrBegin, int64_t Size, | int DeviceTy::deallocTgtPtr(void *HstPtrBegin, int64_t Size, | ||||
bool HasHoldModifier) { | bool HasHoldModifier) { | ||||
// Check if the pointer is contained in any sub-nodes. | // Check if the pointer is contained in any sub-nodes. | ||||
int Ret = OFFLOAD_SUCCESS; | int Ret = OFFLOAD_SUCCESS; | ||||
DataMapMtx.lock(); | DataMapMtx.lock(); | ||||
LookupResult lr = lookupMapping(HstPtrBegin, Size); | LookupResult lr = lookupMapping(nullptr, HstPtrBegin, Size); | ||||
if (lr.Flags.IsContained || lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter) { | if (lr.Flags.IsContained || lr.Flags.ExtendsBefore || lr.Flags.ExtendsAfter) { | ||||
auto &HT = *lr.Entry; | auto &HT = *lr.Entry; | ||||
if (HT.decRefCount(HasHoldModifier) == 0) { | if (HT.decRefCount(HasHoldModifier) == 0) { | ||||
DP("Deleting tgt data " DPxMOD " of size %" PRId64 "\n", | DP("Deleting tgt data " DPxMOD " of size %" PRId64 "\n", | ||||
DPxPTR(HT.TgtPtrBegin), Size); | DPxPTR(HT.TgtPtrBegin), Size); | ||||
deleteData((void *)HT.TgtPtrBegin); | deleteData((void *)HT.TgtPtrBegin); | ||||
INFO(OMP_INFOTYPE_MAPPING_CHANGED, DeviceID, | INFO(OMP_INFOTYPE_MAPPING_CHANGED, DeviceID, | ||||
"Removing map entry with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD | "Removing map entry with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
int32_t DeviceTy::deleteData(void *TgtPtrBegin) { | int32_t DeviceTy::deleteData(void *TgtPtrBegin) { | ||||
return RTL->data_delete(RTLDeviceID, TgtPtrBegin); | return RTL->data_delete(RTLDeviceID, TgtPtrBegin); | ||||
} | } | ||||
// Submit data to device | // Submit data to device | ||||
int32_t DeviceTy::submitData(void *TgtPtrBegin, void *HstPtrBegin, int64_t Size, | int32_t DeviceTy::submitData(void *TgtPtrBegin, void *HstPtrBegin, int64_t Size, | ||||
AsyncInfoTy &AsyncInfo) { | AsyncInfoTy &AsyncInfo) { | ||||
if (getInfoLevel() & OMP_INFOTYPE_DATA_TRANSFER) { | if (getInfoLevel() & OMP_INFOTYPE_DATA_TRANSFER) { | ||||
LookupResult LR = lookupMapping(HstPtrBegin, Size); | LookupResult LR = lookupMapping(nullptr, HstPtrBegin, Size); | ||||
auto *HT = &*LR.Entry; | auto *HT = &*LR.Entry; | ||||
INFO(OMP_INFOTYPE_DATA_TRANSFER, DeviceID, | INFO(OMP_INFOTYPE_DATA_TRANSFER, DeviceID, | ||||
"Copying data from host to device, HstPtr=" DPxMOD ", TgtPtr=" DPxMOD | "Copying data from host to device, HstPtr=" DPxMOD ", TgtPtr=" DPxMOD | ||||
", Size=%" PRId64 ", Name=%s\n", | ", Size=%" PRId64 ", Name=%s\n", | ||||
DPxPTR(HstPtrBegin), DPxPTR(TgtPtrBegin), Size, | DPxPTR(HstPtrBegin), DPxPTR(TgtPtrBegin), Size, | ||||
(HT && HT->HstPtrName) ? getNameFromMapping(HT->HstPtrName).c_str() | (HT && HT->HstPtrName) ? getNameFromMapping(HT->HstPtrName).c_str() | ||||
: "unknown"); | : "unknown"); | ||||
} | } | ||||
if (!AsyncInfo || !RTL->data_submit_async || !RTL->synchronize) | if (!AsyncInfo || !RTL->data_submit_async || !RTL->synchronize) | ||||
return RTL->data_submit(RTLDeviceID, TgtPtrBegin, HstPtrBegin, Size); | return RTL->data_submit(RTLDeviceID, TgtPtrBegin, HstPtrBegin, Size); | ||||
else | else | ||||
return RTL->data_submit_async(RTLDeviceID, TgtPtrBegin, HstPtrBegin, Size, | return RTL->data_submit_async(RTLDeviceID, TgtPtrBegin, HstPtrBegin, Size, | ||||
AsyncInfo); | AsyncInfo); | ||||
} | } | ||||
// Retrieve data from device | // Retrieve data from device | ||||
int32_t DeviceTy::retrieveData(void *HstPtrBegin, void *TgtPtrBegin, | int32_t DeviceTy::retrieveData(void *HstPtrBegin, void *TgtPtrBegin, | ||||
int64_t Size, AsyncInfoTy &AsyncInfo) { | int64_t Size, AsyncInfoTy &AsyncInfo) { | ||||
if (getInfoLevel() & OMP_INFOTYPE_DATA_TRANSFER) { | if (getInfoLevel() & OMP_INFOTYPE_DATA_TRANSFER) { | ||||
LookupResult LR = lookupMapping(HstPtrBegin, Size); | LookupResult LR = lookupMapping(nullptr, HstPtrBegin, Size); | ||||
auto *HT = &*LR.Entry; | auto *HT = &*LR.Entry; | ||||
INFO(OMP_INFOTYPE_DATA_TRANSFER, DeviceID, | INFO(OMP_INFOTYPE_DATA_TRANSFER, DeviceID, | ||||
"Copying data from device to host, TgtPtr=" DPxMOD ", HstPtr=" DPxMOD | "Copying data from device to host, TgtPtr=" DPxMOD ", HstPtr=" DPxMOD | ||||
", Size=%" PRId64 ", Name=%s\n", | ", Size=%" PRId64 ", Name=%s\n", | ||||
DPxPTR(TgtPtrBegin), DPxPTR(HstPtrBegin), Size, | DPxPTR(TgtPtrBegin), DPxPTR(HstPtrBegin), Size, | ||||
(HT && HT->HstPtrName) ? getNameFromMapping(HT->HstPtrName).c_str() | (HT && HT->HstPtrName) ? getNameFromMapping(HT->HstPtrName).c_str() | ||||
: "unknown"); | : "unknown"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |
clang-format: please reformat the code