[Openmp-commits] [PATCH] D94256: [OpenMP] Fixed the issue that memory manager calls plugin interface to release buffered memory even after the plugin has been destroyed
Shilei Tian via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Jan 7 12:30:01 PST 2021
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, JonChesterfield, manorom, protze.joachim.
Herald added subscribers: guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.
Currently on some platforms the program might crash when the program
exits. It is because the memory manager calls plugin interface to release its
buffered memory and the plugin has already been destroyed. After some search
online, it seems that loaded dynamic libraries will be destroyed in the reverse
order of loading, which means by no means, those plugin libraries loaded by
`dlopen` will be destroyed before `libomtarget`. We need something to tell the
`RTLInfoTy` that the hold plugin is not valid anymore so don't call those
interfaces. This is done by registering a callback function in the plugin so that
it will be called when the plugin starts to destroy itself. The callback function
for now only does one thing: invalidate the `RTLInfoTy`. We can add more features
in the future if needed. For now we only check the validity when invoking
`data_delete`. Not sure whether need to do the check for every use. The check is
wrapped into a macro `UNLIKELY` to tell the compiler this branch is unlikely to
be taken to hopefully optimize the performance.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94256
Files:
openmp/libomptarget/include/omptargetplugin.h
openmp/libomptarget/plugins/cuda/src/rtl.cpp
openmp/libomptarget/plugins/exports
openmp/libomptarget/src/MemoryManager.cpp
openmp/libomptarget/src/rtl.cpp
openmp/libomptarget/src/rtl.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94256.315205.patch
Type: text/x-patch
Size: 6360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210107/da03f6b3/attachment-0001.bin>
More information about the Openmp-commits
mailing list