This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][OMPT] Fix reported target pointer for data alloc callback
ClosedPublic

Authored by mhalk on Aug 15 2023, 9:51 AM.

Details

Summary

This patch fixes: https://github.com/llvm/llvm-project/issues/64671
DataOp EMI callbacks would not report the correct target pointer.
This is now alleviated by passing a void** into the function which
emits the actual callback, then evaluating that pointer.

Note: Since this is only done after the pointer has been properly
updated, only endpoint=2 callbacks will show a non-null value.

Diff Detail

Event Timeline

mhalk created this revision.Aug 15 2023, 9:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2023, 9:51 AM
mhalk requested review of this revision.Aug 15 2023, 9:51 AM
Herald added a project: Restricted Project. · View Herald Transcript

If using void** as solution is despised, we could add an updateArguments method to InterfaceRAII.
That would replace the current tuple holding the arguments with a new, provided one.

void updateArguments(ArgsTy... NewArgs) {
  Arguments = std::make_tuple(NewArgs...);
}

We would then call updateArguments, after the actual data allocation.
So, the EMI callback where endpoint=2 will have the actual pointer value available.

void *DeviceTy::allocData(int64_t Size, void *HstPtr, int32_t Kind) {
  [...]
  TargetPtr = RTL->data_alloc(RTLDeviceID, Size, HstPtr, Kind);

  OMPT_IF_BUILT(TargetDataAllocRAII.updateArguments(
      RTLDeviceID, HstPtr, TargetPtr, Size,
      /* CodePtr */ OMPT_GET_RETURN_ADDRESS(0));)

  return TargetPtr;
}
jdoerfert accepted this revision.Aug 15 2023, 11:16 AM

Why not just a reference? Anyway, this is fine too.

This revision is now accepted and ready to land.Aug 15 2023, 11:16 AM

Why not just a reference? Anyway, this is fine too.

Thanks Johannes!

If you don't mind to elaborate w.r.t. the "reference", could you explain, please?
I'm curious -- sounds more robust to me.