This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][libomptarget] Improve plugin resource managers
ClosedPublic

Authored by kevinsala on Jul 18 2023, 9:28 AM.

Details

Summary

This patch improves the resource managers in the plugins by properly handling
the errors. Until now, errors when creating and destroying resources were not
propagated and were directly handled inside the resource managers. Now, all
errors are propagated as in the rest of the plugin infrastructure.

The code is now ready to implement the request/return of multiple resources in
a single getResource/returnResource call.

Diff Detail

Event Timeline

kevinsala created this revision.Jul 18 2023, 9:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 9:28 AM
kevinsala requested review of this revision.Jul 18 2023, 9:28 AM
jhuber6 added inline comments.Jul 18 2023, 12:48 PM
openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
1191

Don't need std::tie anymore, C++17 structured bindings should work.

1221–1228

Any reason we can't do this?

kevinsala updated this revision to Diff 543884.Jul 25 2023, 2:10 AM
kevinsala marked an inline comment as done.
kevinsala added inline comments.
openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
1191

I think structured bindings do not allow re-using the variables. To re-use them, I believe we still need std::tie.

Glad to see more error traps.

openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
173

Can we use ResourceTy& to express a true reference? Why do we need to use pointer to emulate reference which C++ already has.

kevinsala added inline comments.Jul 25 2023, 9:12 AM
openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
173

AMDGPUResourceRef objects (and any object derived from GenericDeviceResourceRef) are constructed as empty references. The resource is not created in the constructor, but later in the create() function (if actually called). So, initially, the handle is nullptr.

I believe class data members that are references must be initialized in the class constructor referencing a valid object. They cannot be re-assigned either.

ye-luo accepted this revision.Jul 25 2023, 9:23 AM
ye-luo added inline comments.
openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
173

Got it.

This revision is now accepted and ready to land.Jul 25 2023, 9:23 AM
jhuber6 accepted this revision.Jul 27 2023, 7:07 AM