[OpenMP][libomptarget] New plugin infrastructure and new CUDA plugin
authorKevin Sala <kevin.sala@bsc.es>
Thu, 27 Oct 2022 18:01:16 +0000 (18:01 +0000)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 27 Oct 2022 18:10:14 +0000 (18:10 +0000)
commit846904195bd603628ee3670d7dc0ca84e3e3bba4
tree0912eb2f6d21a55acb90e85ee8dafbea4219393c
parent7f93ae808634e33e4dc9bce753c909aa5f9a6eb4
[OpenMP][libomptarget] New plugin infrastructure and new CUDA plugin

This patch adds a new infrastructure for OpenMP target plugins. It also implements the CUDA and GenericELF64bit plugins under this new infrastructure. We place the sources in a separate directory named plugins-nextgen, and we build the new plugins as different plugin libraries. The original plugins, which remain untouched, will be used by default. However, the user can change this behavior at run-time through the boolean envar LIBOMPTARGET_NEXTGEN_PLUGINS. If enabled, the libomptarget will try to load the NextGen version of each plugin, falling back to the original if they are not present or valid.

The idea of this new plugin infrastructure is to implement the common parts of target plugins in generic classes (defined in files inside plugins-next/common/PluginInterface folder), and then, each specific plugin defines its own specific classes inheriting from the common ones. In this way, most logic remains on the common interface while reducing the plugin-specific source code. It is also beneficial in the sense that now most code and behavior are the same across the different plugins. As an example, we define classes for a plugin, a device, a device image, a stream manager, etc. The plugin object (a single instance per plugin library) holds different device objects (i.e., one per available device), while these latter are the responsible for managing its own resources.

Most code on this patch is based on the changes made by @jdoerfert (Johannes Doerfert)

Reviewed By: jhuber6, jdoerfert

Differential Revision: https://reviews.llvm.org/D134396
22 files changed:
llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
openmp/libomptarget/CMakeLists.txt
openmp/libomptarget/include/Utilities.h [new file with mode: 0644]
openmp/libomptarget/include/rtl.h
openmp/libomptarget/plugins-nextgen/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/aarch64/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.h [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/exports [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/ppc64/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/ppc64le/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/x86_64/CMakeLists.txt [new file with mode: 0644]
openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.h
openmp/libomptarget/src/rtl.cpp
openmp/libomptarget/test/lit.cfg