OSDN Git Service

[OpenMP] Move memory manager to plugin and make it a common interface
authorShilei Tian <tianshilei1992@gmail.com>
Tue, 12 Jan 2021 02:33:25 +0000 (21:33 -0500)
committerShilei Tian <tianshilei1992@gmail.com>
Tue, 12 Jan 2021 02:33:42 +0000 (21:33 -0500)
commit0871d6d51648dd2a8009ddff59936ea9e3fe871b
tree6c92a5a0f620366badcbd30dad21fdebd04a5f83
parent905623b64df0c865d4dddc4a60aff9751fbaa0e0
[OpenMP] Move memory manager to plugin and make it a common interface

The lifetime of `libomptarget` and its opened plugins are not aligned
and it's hard for `libomptarget` to determine when the plugins are destroyed.
As a result, some issues (see D94256 for details) occur on some platforms.
Actually, if we take target memory as target resources, same as other resources,
such as CUDA streams, in each plugin, then the memory manager should also be in
the plugin. Also considering some platforms may want to opt out the feature, it
makes sense to move the memory manager to plugin, make it a common interface, and
let plguin developers determine whether they need it. This is what this patch does.
CUDA plugin is taken as example to show how to integrate it. In this way, we can
also get a bonus that different thresholds can be set for different platforms.

Reviewed By: jdoerfert, JonChesterfield

Differential Revision: https://reviews.llvm.org/D94379
openmp/libomptarget/plugins/common/CMakeLists.txt
openmp/libomptarget/plugins/common/MemoryManager/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins/common/MemoryManager/MemoryManager.h [new file with mode: 0644]
openmp/libomptarget/plugins/cuda/CMakeLists.txt
openmp/libomptarget/plugins/cuda/src/rtl.cpp
openmp/libomptarget/src/CMakeLists.txt
openmp/libomptarget/src/MemoryManager.cpp [deleted file]
openmp/libomptarget/src/MemoryManager.h [deleted file]
openmp/libomptarget/src/device.cpp
openmp/libomptarget/src/device.h