This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][libomptarget] Add utility class for reference counting
ClosedPublic

Authored by kevinsala on Dec 11 2022, 8:39 AM.

Details

Summary

The AMDGPU NextGen plugin will use this class for counting the references of some device resources.

Diff Detail

Event Timeline

kevinsala created this revision.Dec 11 2022, 8:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 11 2022, 8:39 AM
kevinsala requested review of this revision.Dec 11 2022, 8:39 AM

@jdoerfert @jhuber6 @tianshilei1992 do you think this can be useful for libomptarget at some point? If not, I'll move it to the AMDGPU plugin directly

tianshilei1992 added inline comments.Dec 11 2022, 8:49 AM
openmp/libomptarget/include/Utilities.h
151

Maybe memory order can be a template argument as well?

We'll probably need something like this in libomptarget if I ever get around to finishing D131089.

kevinsala added inline comments.Dec 11 2022, 9:00 AM
openmp/libomptarget/include/Utilities.h
151

Sure. I'll set std::memory_order_relaxed by default.

kevinsala updated this revision to Diff 481917.Dec 11 2022, 9:12 AM

Add memory order as class template parameter.

kevinsala marked an inline comment as done.Dec 11 2022, 9:12 AM
tianshilei1992 accepted this revision.Dec 11 2022, 9:43 AM

LGTM with one nit. Not sure if we need an access function (just read the value).

openmp/libomptarget/include/Utilities.h
145

increase or inc sounds better as it is already the member function of RefCountTy.

150

ditto

This revision is now accepted and ready to land.Dec 11 2022, 9:43 AM

Adding function to get current refcount value.

kevinsala set the repository for this revision to rG LLVM Github Monorepo.Dec 11 2022, 10:28 AM

Renaming function names.

kevinsala marked 2 inline comments as done.Dec 11 2022, 10:34 AM