Page MenuHomePhabricator

[Libomptarget][NFC] Move global Libomptarget state to a struct
ClosedPublic

Authored by atmnpatel on Oct 30 2020, 9:12 PM.

Details

Summary

Presently, there a number of global variables in libomptarget (devices, RTLs, tables, mutexes, etc.), that are not placed within a struct. This patch places them into a struct `PluginManager`. All of the functions that act on this data remain free. This may/will be succeeded by more patches that encapsulate the global libomptarget state.

Diff Detail

Event Timeline

atmnpatel created this revision.Oct 30 2020, 9:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 30 2020, 9:12 PM
atmnpatel requested review of this revision.Oct 30 2020, 9:12 PM

I believe this patch is the first one of a series to refactor the libomptarget. I suggest to add your plan into the description. Otherwise, I didn't see any "encapsulation" from this patch. All members in the new class can still be accessed casually.

Thought I'd commented on this but can't see it. I like the change - one global instance holding all the state is much better than scattering the variables around.

It lends itself to a later change supporting N independent copies of the library, e.g. to facilitate testing.

openmp/libomptarget/src/rtl.cpp
34

I might have g

openmp/libomptarget/src/rtl.cpp
34

I might have g

*one with a global instance by value, instead of heap allocation, but this is better if we can later drop the singleton.

JonChesterfield accepted this revision.Nov 1 2020, 10:18 AM
This revision is now accepted and ready to land.Nov 1 2020, 10:18 AM
jdoerfert added inline comments.Nov 1 2020, 10:26 AM
openmp/libomptarget/src/device.h
237

Documentation for the struct and all its member please, doxygen style.

atmnpatel retitled this revision from [Libomptarget][NFC] Encapsulate Global Libomptarget State to [Libomptarget][NFC] Move global Libomptarget state to a struct.Nov 2 2020, 12:59 PM
atmnpatel edited the summary of this revision. (Show Details)
atmnpatel updated this revision to Diff 302380.Nov 2 2020, 1:02 PM
atmnpatel marked an inline comment as done.
  • Updated title, revision summary, and commit message
  • Added documentation for struct and members

@JonChesterfield, we'll address supporting multiple independent copies for testing next :)

This revision was landed with ongoing or failed builds.Nov 2 2020, 9:12 PM
This revision was automatically updated to reflect the committed changes.
ye-luo added a subscriber: ye-luo.Dec 28 2020, 6:35 PM
ye-luo added inline comments.
openmp/libomptarget/src/rtl.cpp
34

Lack of documentation for PM. Is it a singleton? Should be mentioned.