Skip to content

[Offload] Introduce ATTACH map-type support for pointer attachment. #149036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions offload/libomptarget/omptarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,10 @@ int processAttachEntries(DeviceTy &Device, AttachInfoTy &AttachInfo,
return IsNewlyAllocated;
};

// Only process ATTACH if base/begin was newly allocated OR ALWAYS flag is
// set
if (!IsAttachAlways && !WasNewlyAllocated(HstPtr, "pointer") &&
!WasNewlyAllocated(HstPteeBegin, "pointee")) {
// Only process ATTACH if either the pointee or the pointer was newly
// allocated, or the ALWAYS flag is set.
if (!IsAttachAlways && !WasNewlyAllocated(HstPteeBegin, "pointee") &&
!WasNewlyAllocated(HstPtr, "pointer")) {
DP("Skipping ATTACH entry %zu: neither pointer nor pointee was newly "
"allocated and no ALWAYS flag\n",
EntryIdx);
Expand Down Expand Up @@ -821,19 +821,22 @@ int processAttachEntries(DeviceTy &Device, AttachInfoTy &AttachInfo,
return TPR;
};

// Get device version of the pointer (e.g., &p)
// Get device version of the pointee (e.g., &p[10]) first, as we can
// release its TPR after extracting the pointer value.
void *TgtPteeBegin;
if (auto PteeTPROpt = LookupTargetPointer(HstPteeBegin, 0, "pointee"))
TgtPteeBegin = PteeTPROpt->TargetPointer;
else
continue;

// Get device version of the pointer (e.g., &p) next. We need to keep its
// TPR for use in shadow-pointer handling during pointer-attachment.
auto PtrTPROpt = LookupTargetPointer(HstPtr, PtrSize, "pointer");
if (!PtrTPROpt)
continue;
TargetPointerResultTy &PtrTPR = *PtrTPROpt;
void **TgtPtrBase = reinterpret_cast<void **>(PtrTPR.TargetPointer);

// Get device version of the pointee (e.g., &p[10])
auto PteeTPROpt = LookupTargetPointer(HstPteeBegin, 0, "pointee");
if (!PteeTPROpt)
continue;
void *TgtPteeBegin = PteeTPROpt->TargetPointer;

// Insert a data-fence before the first pointer-attachment.
if (IsFirstPointerAttachment) {
IsFirstPointerAttachment = false;
Expand Down