This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][Libomptarget] Rename & move g_executables to private
ClosedPublic

Authored by pdhaliwal on May 17 2021, 1:25 AM.

Details

Summary

This patch moves g_executables to private member of Runtime class
and is renamed to HSAExecutables following LLVM naming convention.

This movement required making Runtime::Initialize and Runtime::Finalize
non-static. Verified the correctness of this change by running
libomptarget tests on gfx906.

Diff Detail

Unit TestsFailed

Event Timeline

pdhaliwal created this revision.May 17 2021, 1:25 AM
pdhaliwal requested review of this revision.May 17 2021, 1:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2021, 1:25 AM
JonChesterfield added a comment.EditedMay 17 2021, 2:41 AM

There's one massive object in rtl.cpp that holds a lot of global state. That object would look a lot simpler if it used a vector of struct instead of of multiple vectors, but ultimately there's just a lot of book keeping that currently seems to be necessary. Restricting all globals to a single instance gives us a credible chance of getting init/dtor/locking right.

For the state that can't be eliminated, it probably all needs to end up there. The runtime singleton changed above has been incrementally cut down to a single variable, Environment env_;, and static functions that can be renamed to free functions. I don't remember a reason for leaving env_ in place, likely I had to stop partway through deleting members and do something else.

My preference would be to move (& rename seems good) g_executables out of global scope and into the rtl.cpp object, and delete this runtime class and object entirely. What do you think?

openmp/libomptarget/plugins/amdgpu/impl/rt.h
47

^ singleton

Removing Runtime class does make sense. Moving a global out of system.cpp to rtl.cpp will likely trigger more changes, but, that should be manageable.

pdhaliwal updated this revision to Diff 345830.May 17 2021, 4:35 AM

Move g_executables to rtl.cpp

JonChesterfield accepted this revision.EditedMay 17 2021, 6:55 AM

Ok, looks reasonable. There's a comment on the above comment, but could equally just drop the comment. Vector of hsa_executable is probably obvious enough for naming.

openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
331 ↗(On Diff #345830)

This is per loaded code object, not per device. Kernel information is a bit misleading, it's whatever HSA chose to abstract over the code object.

548 ↗(On Diff #345830)

This handling of errors isn't ideal, but matches the current behaviour closely enough

This revision is now accepted and ready to land.May 17 2021, 6:55 AM
pdhaliwal updated this revision to Diff 345886.May 17 2021, 8:08 AM

Removed comment.

pdhaliwal marked an inline comment as done.May 17 2021, 8:09 AM

I will submit this to main in my morning.

This revision was landed with ongoing or failed builds.May 17 2021, 10:43 PM
This revision was automatically updated to reflect the committed changes.
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
548 ↗(On Diff #345830)

revised this in passing for D102346