This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][Offloading] Refined return value of `DeviceTy::getOrAllocTgtPtr`
ClosedPublic

Authored by tianshilei1992 on Jun 16 2021, 6:55 AM.

Details

Summary

DeviceTy::getOrAllocTgtPtr just returns a target pointer. In addition,
two bool values (IsNew and IsHostPtr) are passed by reference to make the
change in the function available in callee.

In this patch, a struct, which contains the target pointer, two flags, and an
iterator to the map table entry corresponding to the queried host pointer, will
be returned. In addition to make the logic clearer regarding the two bool values,
this paves the way for the next patch to fix the data race in bug49334.cpp by
attaching an event to the map table entry (and that's why we need the iterator).

Diff Detail

Event Timeline

tianshilei1992 created this revision.Jun 16 2021, 6:55 AM
tianshilei1992 requested review of this revision.Jun 16 2021, 6:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2021, 6:55 AM
grokos added a subscriber: grokos.Jun 17 2021, 12:47 AM
grokos added inline comments.
openmp/libomptarget/src/device.cpp
194–195

contains --> containing

283

I think emplace returns an iterator to the newly emplaced element. You can set Entry equal to the return value of this emplace, thus sparing a lookup a couple of lines below.

openmp/libomptarget/src/device.cpp
283

Thanks for the information. Yes, that will be better.

Can you rebase this patch? I tried to apply to main and test, but there are couple of conflicts for device.cpp.

tianshilei1992 marked 2 inline comments as done.Jun 23 2021, 10:06 AM

remove unrelated change

grokos accepted this revision.Jun 30 2021, 4:24 PM

I think this is good to go now. Thanks! Maybe you can wait for some of the initial reviewers to accept the patch as well or just go ahead and commit.

This revision is now accepted and ready to land.Jun 30 2021, 4:24 PM
This revision was landed with ongoing or failed builds.Jul 1 2021, 9:32 AM
This revision was automatically updated to reflect the committed changes.