Page MenuHomePhabricator

[libomptarget][amdgpu] Precisely manage hsa lifetime
ClosedPublic

Authored by JonChesterfield on Sep 9 2021, 8:30 AM.

Details

Summary

The hsa library must be initialized before any calls into it and
destructed after the last call into it. There have been a number of bugs in
this area related to member variables which would like to use raii to manage
resources acquired from hsa.

This patch moves the init/shutdown of hsa into a class, such that when used as
the first member variable (could be a base), the lifetime of other member
variables are reliably scoped within it. This will allow other classes to use
raii reliably when used as member variables within the global.

Diff Detail

Event Timeline

JonChesterfield created this revision.Sep 9 2021, 8:30 AM
JonChesterfield requested review of this revision.Sep 9 2021, 8:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2021, 8:30 AM
pdhaliwal added inline comments.Sep 9 2021, 8:44 AM
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
844–845

This can be removed.

  • Drop second shutdown call
JonChesterfield marked an inline comment as done.Sep 9 2021, 9:09 AM
JonChesterfield added inline comments.
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
844–845

Thanks!

JonChesterfield marked an inline comment as done.Sep 9 2021, 9:10 AM
pdhaliwal accepted this revision.Sep 9 2021, 9:25 AM

Looks good! Thanks.

This revision is now accepted and ready to land.Sep 9 2021, 9:25 AM
This revision was landed with ongoing or failed builds.Sep 9 2021, 9:28 AM
This revision was automatically updated to reflect the committed changes.