This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][NFCI] Use RAII lock guards in libomptarget where possible
ClosedPublic

Authored by jdoerfert on Mar 5 2022, 2:27 PM.

Diff Detail

Event Timeline

jdoerfert created this revision.Mar 5 2022, 2:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2022, 2:27 PM
jdoerfert requested review of this revision.Mar 5 2022, 2:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2022, 2:27 PM
Herald added a subscriber: sstefan1. · View Herald Transcript
JonChesterfield accepted this revision.Mar 5 2022, 3:38 PM

Great, thanks!

This revision is now accepted and ready to land.Mar 5 2022, 3:38 PM
This revision was landed with ongoing or failed builds.Mar 6 2022, 6:00 PM
This revision was automatically updated to reflect the committed changes.
ronlieb reopened this revision.Mar 6 2022, 6:52 PM
ronlieb added a subscriber: ronlieb.

This set of commits seems to have broken the amdgpu buildbot, test(s) are hanging.
see

https://lab.llvm.org/buildbot/#/builders/193/builds/8002

and a force run to see if the previous hang was spurious, seems reproducible.

https://lab.llvm.org/buildbot/#/builders/193/builds/8003

it would be helpful to revert the change(s) seems like 4 commits came in ?
then we (Jon and I) could work the issues with you in the morning on Monday.
unless of course you have a fix ready to land.

thank you

This revision is now accepted and ready to land.Mar 6 2022, 6:52 PM

Reverted to check what the problem is.

Found one error in the existing code but can believe there are more. We could split this patch into two, one replacing the DIY LockGuard with std::lock_guard and clang-format the thing, then a second replacing manual locking with uses of lock guard. Would be the same behaviour as this patch but make it easier to find the change in behaviour by inspection.

openmp/libomptarget/src/omptarget.cpp
206

Before this patch we left PendingGlobalsMtx locked here on the return. That's surely a bug, and I guess we don't hit it often because it's on a failure path. Fixed by this patch, which sadly seems to deadlock somewhere else.

protze.joachim added inline comments.
openmp/libomptarget/src/device.cpp
447

This unlock is gone without translating the lock to raii lock guard.

jdoerfert added inline comments.Mar 7 2022, 5:22 PM
openmp/libomptarget/src/device.cpp
447

Good catch :)

openmp/libomptarget/src/omptarget.cpp
206

Agreed.

jdoerfert updated this revision to Diff 413669.Mar 7 2022, 5:24 PM

Fixed rebase faux pas, thanks @protze.joachim