llvm-project
531 строка · 22.5 Кб
1//===-- OpenMP/Mapping.cpp - OpenMP/OpenACC pointer mapping impl. ---------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//===----------------------------------------------------------------------===//
10
11#include "OpenMP/Mapping.h"12
13#include "PluginManager.h"14#include "Shared/Debug.h"15#include "Shared/Requirements.h"16#include "device.h"17
18/// Dump a table of all the host-target pointer pairs on failure
19void dumpTargetPointerMappings(const ident_t *Loc, DeviceTy &Device,20bool toStdOut) {21MappingInfoTy::HDTTMapAccessorTy HDTTMap =22Device.getMappingInfo().HostDataToTargetMap.getExclusiveAccessor();23if (HDTTMap->empty()) {24DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID,25"OpenMP Host-Device pointer mappings table empty\n");26return;27}28
29SourceInfo Kernel(Loc);30DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID,31"OpenMP Host-Device pointer mappings after block at %s:%d:%d:\n",32Kernel.getFilename(), Kernel.getLine(), Kernel.getColumn());33DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID,34"%-18s %-18s %s %s %s %s\n", "Host Ptr", "Target Ptr", "Size (B)",35"DynRefCount", "HoldRefCount", "Declaration");36for (const auto &It : *HDTTMap) {37HostDataToTargetTy &HDTT = *It.HDTT;38SourceInfo Info(HDTT.HstPtrName);39DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID,40DPxMOD " " DPxMOD " %-8" PRIuPTR " %-11s %-12s %s at %s:%d:%d\n",41DPxPTR(HDTT.HstPtrBegin), DPxPTR(HDTT.TgtPtrBegin),42HDTT.HstPtrEnd - HDTT.HstPtrBegin,43HDTT.dynRefCountToStr().c_str(), HDTT.holdRefCountToStr().c_str(),44Info.getName(), Info.getFilename(), Info.getLine(),45Info.getColumn());46}47}
48
49int MappingInfoTy::associatePtr(void *HstPtrBegin, void *TgtPtrBegin,50int64_t Size) {51HDTTMapAccessorTy HDTTMap = HostDataToTargetMap.getExclusiveAccessor();52
53// Check if entry exists54auto It = HDTTMap->find(HstPtrBegin);55if (It != HDTTMap->end()) {56HostDataToTargetTy &HDTT = *It->HDTT;57std::lock_guard<HostDataToTargetTy> LG(HDTT);58// Mapping already exists59bool IsValid = HDTT.HstPtrEnd == (uintptr_t)HstPtrBegin + Size &&60HDTT.TgtPtrBegin == (uintptr_t)TgtPtrBegin;61if (IsValid) {62DP("Attempt to re-associate the same device ptr+offset with the same "63"host ptr, nothing to do\n");64return OFFLOAD_SUCCESS;65}66REPORT("Not allowed to re-associate a different device ptr+offset with "67"the same host ptr\n");68return OFFLOAD_FAIL;69}70
71// Mapping does not exist, allocate it with refCount=INF72const HostDataToTargetTy &NewEntry =73*HDTTMap74->emplace(new HostDataToTargetTy(75/*HstPtrBase=*/(uintptr_t)HstPtrBegin,76/*HstPtrBegin=*/(uintptr_t)HstPtrBegin,77/*HstPtrEnd=*/(uintptr_t)HstPtrBegin + Size,78/*TgtAllocBegin=*/(uintptr_t)TgtPtrBegin,79/*TgtPtrBegin=*/(uintptr_t)TgtPtrBegin,80/*UseHoldRefCount=*/false, /*Name=*/nullptr,81/*IsRefCountINF=*/true))82.first->HDTT;83DP("Creating new map entry: HstBase=" DPxMOD ", HstBegin=" DPxMOD84", HstEnd=" DPxMOD ", TgtBegin=" DPxMOD ", DynRefCount=%s, "85"HoldRefCount=%s\n",86DPxPTR(NewEntry.HstPtrBase), DPxPTR(NewEntry.HstPtrBegin),87DPxPTR(NewEntry.HstPtrEnd), DPxPTR(NewEntry.TgtPtrBegin),88NewEntry.dynRefCountToStr().c_str(), NewEntry.holdRefCountToStr().c_str());89(void)NewEntry;90
91// Notify the plugin about the new mapping.92return Device.notifyDataMapped(HstPtrBegin, Size);93}
94
95int MappingInfoTy::disassociatePtr(void *HstPtrBegin) {96HDTTMapAccessorTy HDTTMap = HostDataToTargetMap.getExclusiveAccessor();97
98auto It = HDTTMap->find(HstPtrBegin);99if (It == HDTTMap->end()) {100REPORT("Association not found\n");101return OFFLOAD_FAIL;102}103// Mapping exists104HostDataToTargetTy &HDTT = *It->HDTT;105std::lock_guard<HostDataToTargetTy> LG(HDTT);106
107if (HDTT.getHoldRefCount()) {108// This is based on OpenACC 3.1, sec 3.2.33 "acc_unmap_data", L3656-3657:109// "It is an error to call acc_unmap_data if the structured reference110// count for the pointer is not zero."111REPORT("Trying to disassociate a pointer with a non-zero hold reference "112"count\n");113return OFFLOAD_FAIL;114}115
116if (HDTT.isDynRefCountInf()) {117DP("Association found, removing it\n");118void *Event = HDTT.getEvent();119delete &HDTT;120if (Event)121Device.destroyEvent(Event);122HDTTMap->erase(It);123return Device.notifyDataUnmapped(HstPtrBegin);124}125
126REPORT("Trying to disassociate a pointer which was not mapped via "127"omp_target_associate_ptr\n");128return OFFLOAD_FAIL;129}
130
131LookupResult MappingInfoTy::lookupMapping(HDTTMapAccessorTy &HDTTMap,132void *HstPtrBegin, int64_t Size,133HostDataToTargetTy *OwnedTPR) {134
135uintptr_t HP = (uintptr_t)HstPtrBegin;136LookupResult LR;137
138DP("Looking up mapping(HstPtrBegin=" DPxMOD ", Size=%" PRId64 ")...\n",139DPxPTR(HP), Size);140
141if (HDTTMap->empty())142return LR;143
144auto Upper = HDTTMap->upper_bound(HP);145
146if (Size == 0) {147// specification v5.1 Pointer Initialization for Device Data Environments148// upper_bound satisfies149// std::prev(upper)->HDTT.HstPtrBegin <= hp < upper->HDTT.HstPtrBegin150if (Upper != HDTTMap->begin()) {151LR.TPR.setEntry(std::prev(Upper)->HDTT, OwnedTPR);152// the left side of extended address range is satisified.153// hp >= LR.TPR.getEntry()->HstPtrBegin || hp >=154// LR.TPR.getEntry()->HstPtrBase155LR.Flags.IsContained = HP < LR.TPR.getEntry()->HstPtrEnd ||156HP < LR.TPR.getEntry()->HstPtrBase;157}158
159if (!LR.Flags.IsContained && Upper != HDTTMap->end()) {160LR.TPR.setEntry(Upper->HDTT, OwnedTPR);161// the right side of extended address range is satisified.162// hp < LR.TPR.getEntry()->HstPtrEnd || hp < LR.TPR.getEntry()->HstPtrBase163LR.Flags.IsContained = HP >= LR.TPR.getEntry()->HstPtrBase;164}165} else {166// check the left bin167if (Upper != HDTTMap->begin()) {168LR.TPR.setEntry(std::prev(Upper)->HDTT, OwnedTPR);169// Is it contained?170LR.Flags.IsContained = HP >= LR.TPR.getEntry()->HstPtrBegin &&171HP < LR.TPR.getEntry()->HstPtrEnd &&172(HP + Size) <= LR.TPR.getEntry()->HstPtrEnd;173// Does it extend beyond the mapped region?174LR.Flags.ExtendsAfter = HP < LR.TPR.getEntry()->HstPtrEnd &&175(HP + Size) > LR.TPR.getEntry()->HstPtrEnd;176}177
178// check the right bin179if (!(LR.Flags.IsContained || LR.Flags.ExtendsAfter) &&180Upper != HDTTMap->end()) {181LR.TPR.setEntry(Upper->HDTT, OwnedTPR);182// Does it extend into an already mapped region?183LR.Flags.ExtendsBefore = HP < LR.TPR.getEntry()->HstPtrBegin &&184(HP + Size) > LR.TPR.getEntry()->HstPtrBegin;185// Does it extend beyond the mapped region?186LR.Flags.ExtendsAfter = HP < LR.TPR.getEntry()->HstPtrEnd &&187(HP + Size) > LR.TPR.getEntry()->HstPtrEnd;188}189
190if (LR.Flags.ExtendsBefore) {191DP("WARNING: Pointer is not mapped but section extends into already "192"mapped data\n");193}194if (LR.Flags.ExtendsAfter) {195DP("WARNING: Pointer is already mapped but section extends beyond mapped "196"region\n");197}198}199
200return LR;201}
202
203TargetPointerResultTy MappingInfoTy::getTargetPointer(204HDTTMapAccessorTy &HDTTMap, void *HstPtrBegin, void *HstPtrBase,205int64_t TgtPadding, int64_t Size, map_var_info_t HstPtrName, bool HasFlagTo,206bool HasFlagAlways, bool IsImplicit, bool UpdateRefCount,207bool HasCloseModifier, bool HasPresentModifier, bool HasHoldModifier,208AsyncInfoTy &AsyncInfo, HostDataToTargetTy *OwnedTPR, bool ReleaseHDTTMap) {209
210LookupResult LR = lookupMapping(HDTTMap, HstPtrBegin, Size, OwnedTPR);211LR.TPR.Flags.IsPresent = true;212
213// Release the mapping table lock only after the entry is locked by214// attaching it to TPR. Once TPR is destroyed it will release the lock215// on entry. If it is returned the lock will move to the returned object.216// If LR.Entry is already owned/locked we avoid trying to lock it again.217
218// Check if the pointer is contained.219// If a variable is mapped to the device manually by the user - which would220// lead to the IsContained flag to be true - then we must ensure that the221// device address is returned even under unified memory conditions.222if (LR.Flags.IsContained ||223((LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter) && IsImplicit)) {224const char *RefCountAction;225if (UpdateRefCount) {226// After this, reference count >= 1. If the reference count was 0 but the227// entry was still there we can reuse the data on the device and avoid a228// new submission.229LR.TPR.getEntry()->incRefCount(HasHoldModifier);230RefCountAction = " (incremented)";231} else {232// It might have been allocated with the parent, but it's still new.233LR.TPR.Flags.IsNewEntry = LR.TPR.getEntry()->getTotalRefCount() == 1;234RefCountAction = " (update suppressed)";235}236const char *DynRefCountAction = HasHoldModifier ? "" : RefCountAction;237const char *HoldRefCountAction = HasHoldModifier ? RefCountAction : "";238uintptr_t Ptr = LR.TPR.getEntry()->TgtPtrBegin +239((uintptr_t)HstPtrBegin - LR.TPR.getEntry()->HstPtrBegin);240INFO(OMP_INFOTYPE_MAPPING_EXISTS, Device.DeviceID,241"Mapping exists%s with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD242", Size=%" PRId64 ", DynRefCount=%s%s, HoldRefCount=%s%s, Name=%s\n",243(IsImplicit ? " (implicit)" : ""), DPxPTR(HstPtrBegin), DPxPTR(Ptr),244Size, LR.TPR.getEntry()->dynRefCountToStr().c_str(), DynRefCountAction,245LR.TPR.getEntry()->holdRefCountToStr().c_str(), HoldRefCountAction,246(HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");247LR.TPR.TargetPointer = (void *)Ptr;248} else if ((LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter) && !IsImplicit) {249// Explicit extension of mapped data - not allowed.250MESSAGE("explicit extension not allowed: host address specified is " DPxMOD251" (%" PRId64252" bytes), but device allocation maps to host at " DPxMOD253" (%" PRId64 " bytes)",254DPxPTR(HstPtrBegin), Size, DPxPTR(LR.TPR.getEntry()->HstPtrBegin),255LR.TPR.getEntry()->HstPtrEnd - LR.TPR.getEntry()->HstPtrBegin);256if (HasPresentModifier)257MESSAGE("device mapping required by 'present' map type modifier does not "258"exist for host address " DPxMOD " (%" PRId64 " bytes)",259DPxPTR(HstPtrBegin), Size);260} else if ((PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY &&261!HasCloseModifier) ||262(PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY)) {263
264// If unified shared memory is active, implicitly mapped variables that are265// not privatized use host address. Any explicitly mapped variables also use266// host address where correctness is not impeded. In all other cases maps267// are respected.268// In addition to the mapping rules above, the close map modifier forces the269// mapping of the variable to the device.270if (Size) {271INFO(OMP_INFOTYPE_MAPPING_CHANGED, Device.DeviceID,272"Return HstPtrBegin " DPxMOD " Size=%" PRId64 " for unified shared "273"memory\n",274DPxPTR((uintptr_t)HstPtrBegin), Size);275DP("Return HstPtrBegin " DPxMOD " Size=%" PRId64 " for unified shared "276"memory\n",277DPxPTR((uintptr_t)HstPtrBegin), Size);278LR.TPR.Flags.IsPresent = false;279LR.TPR.Flags.IsHostPointer = true;280LR.TPR.TargetPointer = HstPtrBegin;281}282} else if (HasPresentModifier) {283DP("Mapping required by 'present' map type modifier does not exist for "284"HstPtrBegin=" DPxMOD ", Size=%" PRId64 "\n",285DPxPTR(HstPtrBegin), Size);286MESSAGE("device mapping required by 'present' map type modifier does not "287"exist for host address " DPxMOD " (%" PRId64 " bytes)",288DPxPTR(HstPtrBegin), Size);289} else if (Size) {290// If it is not contained and Size > 0, we should create a new entry for it.291LR.TPR.Flags.IsNewEntry = true;292uintptr_t TgtAllocBegin =293(uintptr_t)Device.allocData(TgtPadding + Size, HstPtrBegin);294uintptr_t TgtPtrBegin = TgtAllocBegin + TgtPadding;295// Release the mapping table lock only after the entry is locked by296// attaching it to TPR.297LR.TPR.setEntry(HDTTMap298->emplace(new HostDataToTargetTy(299(uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin,300(uintptr_t)HstPtrBegin + Size, TgtAllocBegin,301TgtPtrBegin, HasHoldModifier, HstPtrName))302.first->HDTT);303INFO(OMP_INFOTYPE_MAPPING_CHANGED, Device.DeviceID,304"Creating new map entry with HstPtrBase=" DPxMOD305", HstPtrBegin=" DPxMOD ", TgtAllocBegin=" DPxMOD306", TgtPtrBegin=" DPxMOD307", Size=%ld, DynRefCount=%s, HoldRefCount=%s, Name=%s\n",308DPxPTR(HstPtrBase), DPxPTR(HstPtrBegin), DPxPTR(TgtAllocBegin),309DPxPTR(TgtPtrBegin), Size,310LR.TPR.getEntry()->dynRefCountToStr().c_str(),311LR.TPR.getEntry()->holdRefCountToStr().c_str(),312(HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");313LR.TPR.TargetPointer = (void *)TgtPtrBegin;314
315// Notify the plugin about the new mapping.316if (Device.notifyDataMapped(HstPtrBegin, Size))317return TargetPointerResultTy{};318} else {319// This entry is not present and we did not create a new entry for it.320LR.TPR.Flags.IsPresent = false;321}322
323// All mapping table modifications have been made. If the user requested it we324// give up the lock.325if (ReleaseHDTTMap)326HDTTMap.destroy();327
328// If the target pointer is valid, and we need to transfer data, issue the329// data transfer.330if (LR.TPR.TargetPointer && !LR.TPR.Flags.IsHostPointer && HasFlagTo &&331(LR.TPR.Flags.IsNewEntry || HasFlagAlways) && Size != 0) {332DP("Moving %" PRId64 " bytes (hst:" DPxMOD ") -> (tgt:" DPxMOD ")\n", Size,333DPxPTR(HstPtrBegin), DPxPTR(LR.TPR.TargetPointer));334
335int Ret = Device.submitData(LR.TPR.TargetPointer, HstPtrBegin, Size,336AsyncInfo, LR.TPR.getEntry());337if (Ret != OFFLOAD_SUCCESS) {338REPORT("Copying data to device failed.\n");339// We will also return nullptr if the data movement fails because that340// pointer points to a corrupted memory region so it doesn't make any341// sense to continue to use it.342LR.TPR.TargetPointer = nullptr;343} else if (LR.TPR.getEntry()->addEventIfNecessary(Device, AsyncInfo) !=344OFFLOAD_SUCCESS)345return TargetPointerResultTy{};346} else {347// If not a host pointer and no present modifier, we need to wait for the348// event if it exists.349// Note: Entry might be nullptr because of zero length array section.350if (LR.TPR.getEntry() && !LR.TPR.Flags.IsHostPointer &&351!HasPresentModifier) {352void *Event = LR.TPR.getEntry()->getEvent();353if (Event) {354int Ret = Device.waitEvent(Event, AsyncInfo);355if (Ret != OFFLOAD_SUCCESS) {356// If it fails to wait for the event, we need to return nullptr in357// case of any data race.358REPORT("Failed to wait for event " DPxMOD ".\n", DPxPTR(Event));359return TargetPointerResultTy{};360}361}362}363}364
365return std::move(LR.TPR);366}
367
368TargetPointerResultTy MappingInfoTy::getTgtPtrBegin(369void *HstPtrBegin, int64_t Size, bool UpdateRefCount, bool UseHoldRefCount,370bool MustContain, bool ForceDelete, bool FromDataEnd) {371HDTTMapAccessorTy HDTTMap = HostDataToTargetMap.getExclusiveAccessor();372
373LookupResult LR = lookupMapping(HDTTMap, HstPtrBegin, Size);374
375LR.TPR.Flags.IsPresent = true;376
377if (LR.Flags.IsContained ||378(!MustContain && (LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter))) {379LR.TPR.Flags.IsLast =380LR.TPR.getEntry()->decShouldRemove(UseHoldRefCount, ForceDelete);381
382if (ForceDelete) {383LR.TPR.getEntry()->resetRefCount(UseHoldRefCount);384assert(LR.TPR.Flags.IsLast ==385LR.TPR.getEntry()->decShouldRemove(UseHoldRefCount) &&386"expected correct IsLast prediction for reset");387}388
389// Increment the number of threads that is using the entry on a390// targetDataEnd, tracking the number of possible "deleters". A thread may391// come to own the entry deletion even if it was not the last one querying392// for it. Thus, we must track every query on targetDataEnds to ensure only393// the last thread that holds a reference to an entry actually deletes it.394if (FromDataEnd)395LR.TPR.getEntry()->incDataEndThreadCount();396
397const char *RefCountAction;398if (!UpdateRefCount) {399RefCountAction = " (update suppressed)";400} else if (LR.TPR.Flags.IsLast) {401LR.TPR.getEntry()->decRefCount(UseHoldRefCount);402assert(LR.TPR.getEntry()->getTotalRefCount() == 0 &&403"Expected zero reference count when deletion is scheduled");404if (ForceDelete)405RefCountAction = " (reset, delayed deletion)";406else407RefCountAction = " (decremented, delayed deletion)";408} else {409LR.TPR.getEntry()->decRefCount(UseHoldRefCount);410RefCountAction = " (decremented)";411}412const char *DynRefCountAction = UseHoldRefCount ? "" : RefCountAction;413const char *HoldRefCountAction = UseHoldRefCount ? RefCountAction : "";414uintptr_t TP = LR.TPR.getEntry()->TgtPtrBegin +415((uintptr_t)HstPtrBegin - LR.TPR.getEntry()->HstPtrBegin);416INFO(OMP_INFOTYPE_MAPPING_EXISTS, Device.DeviceID,417"Mapping exists with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD ", "418"Size=%" PRId64 ", DynRefCount=%s%s, HoldRefCount=%s%s\n",419DPxPTR(HstPtrBegin), DPxPTR(TP), Size,420LR.TPR.getEntry()->dynRefCountToStr().c_str(), DynRefCountAction,421LR.TPR.getEntry()->holdRefCountToStr().c_str(), HoldRefCountAction);422LR.TPR.TargetPointer = (void *)TP;423} else if (PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY ||424PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY) {425// If the value isn't found in the mapping and unified shared memory426// is on then it means we have stumbled upon a value which we need to427// use directly from the host.428DP("Get HstPtrBegin " DPxMOD " Size=%" PRId64 " for unified shared "429"memory\n",430DPxPTR((uintptr_t)HstPtrBegin), Size);431LR.TPR.Flags.IsPresent = false;432LR.TPR.Flags.IsHostPointer = true;433LR.TPR.TargetPointer = HstPtrBegin;434} else {435// OpenMP Specification v5.2: if a matching list item is not found, the436// pointer retains its original value as per firstprivate semantics.437LR.TPR.Flags.IsPresent = false;438LR.TPR.Flags.IsHostPointer = false;439LR.TPR.TargetPointer = HstPtrBegin;440}441
442return std::move(LR.TPR);443}
444
445// Return the target pointer begin (where the data will be moved).
446void *MappingInfoTy::getTgtPtrBegin(HDTTMapAccessorTy &HDTTMap,447void *HstPtrBegin, int64_t Size) {448uintptr_t HP = (uintptr_t)HstPtrBegin;449LookupResult LR = lookupMapping(HDTTMap, HstPtrBegin, Size);450if (LR.Flags.IsContained || LR.Flags.ExtendsBefore || LR.Flags.ExtendsAfter) {451uintptr_t TP =452LR.TPR.getEntry()->TgtPtrBegin + (HP - LR.TPR.getEntry()->HstPtrBegin);453return (void *)TP;454}455
456return NULL;457}
458
459int MappingInfoTy::eraseMapEntry(HDTTMapAccessorTy &HDTTMap,460HostDataToTargetTy *Entry, int64_t Size) {461assert(Entry && "Trying to delete a null entry from the HDTT map.");462assert(Entry->getTotalRefCount() == 0 &&463Entry->getDataEndThreadCount() == 0 &&464"Trying to delete entry that is in use or owned by another thread.");465
466INFO(OMP_INFOTYPE_MAPPING_CHANGED, Device.DeviceID,467"Removing map entry with HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD468", Size=%" PRId64 ", Name=%s\n",469DPxPTR(Entry->HstPtrBegin), DPxPTR(Entry->TgtPtrBegin), Size,470(Entry->HstPtrName) ? getNameFromMapping(Entry->HstPtrName).c_str()471: "unknown");472
473if (HDTTMap->erase(Entry) == 0) {474REPORT("Trying to remove a non-existent map entry\n");475return OFFLOAD_FAIL;476}477
478return OFFLOAD_SUCCESS;479}
480
481int MappingInfoTy::deallocTgtPtrAndEntry(HostDataToTargetTy *Entry,482int64_t Size) {483assert(Entry && "Trying to deallocate a null entry.");484
485DP("Deleting tgt data " DPxMOD " of size %" PRId64 " by freeing allocation "486"starting at " DPxMOD "\n",487DPxPTR(Entry->TgtPtrBegin), Size, DPxPTR(Entry->TgtAllocBegin));488
489void *Event = Entry->getEvent();490if (Event && Device.destroyEvent(Event) != OFFLOAD_SUCCESS) {491REPORT("Failed to destroy event " DPxMOD "\n", DPxPTR(Event));492return OFFLOAD_FAIL;493}494
495int Ret = Device.deleteData((void *)Entry->TgtAllocBegin);496
497// Notify the plugin about the unmapped memory.498Ret |= Device.notifyDataUnmapped((void *)Entry->HstPtrBegin);499
500delete Entry;501
502return Ret;503}
504
505static void printCopyInfoImpl(int DeviceId, bool H2D, void *SrcPtrBegin,506void *DstPtrBegin, int64_t Size,507HostDataToTargetTy *HT) {508
509INFO(OMP_INFOTYPE_DATA_TRANSFER, DeviceId,510"Copying data from %s to %s, %sPtr=" DPxMOD ", %sPtr=" DPxMOD511", Size=%" PRId64 ", Name=%s\n",512H2D ? "host" : "device", H2D ? "device" : "host", H2D ? "Hst" : "Tgt",513DPxPTR(H2D ? SrcPtrBegin : DstPtrBegin), H2D ? "Tgt" : "Hst",514DPxPTR(H2D ? DstPtrBegin : SrcPtrBegin), Size,515(HT && HT->HstPtrName) ? getNameFromMapping(HT->HstPtrName).c_str()516: "unknown");517}
518
519void MappingInfoTy::printCopyInfo(520void *TgtPtrBegin, void *HstPtrBegin, int64_t Size, bool H2D,521HostDataToTargetTy *Entry, MappingInfoTy::HDTTMapAccessorTy *HDTTMapPtr) {522auto HDTTMap =523HostDataToTargetMap.getExclusiveAccessor(!!Entry || !!HDTTMapPtr);524LookupResult LR;525if (!Entry) {526LR = lookupMapping(HDTTMapPtr ? *HDTTMapPtr : HDTTMap, HstPtrBegin, Size);527Entry = LR.TPR.getEntry();528}529printCopyInfoImpl(Device.DeviceID, H2D, HstPtrBegin, TgtPtrBegin, Size,530Entry);531}
532