[Openmp-commits] [openmp] [OpenMP][NFC] Flatten plugin-nextgen/common folder sturcture (PR #73725)

Johannes Doerfert via Openmp-commits openmp-commits at lists.llvm.org
Tue Nov 28 16:41:37 PST 2023


https://github.com/jdoerfert created https://github.com/llvm/llvm-project/pull/73725

For historic reasons we had it setup that there was
`  plugin-nextgen/common/PluginInterface/<sources + headers>`
which is not what we do anywhere else.
Now it looks like the rest:
```
  plugin-nextgen/common/include/<headers>
  plugin-nextgen/common/src/<sources>
```
As part of this, `dlwrap.h` was moved into common/include (as `DLWrap.h`)
since it is exclusively used by the plugins.

>From 0b5436a6ba8abb4ae96445fd8d7a311a67d5461c Mon Sep 17 00:00:00 2001
From: Johannes Doerfert <johannes at jdoerfert.de>
Date: Tue, 28 Nov 2023 16:36:36 -0800
Subject: [PATCH] [OpenMP][NFC] Flatten plugin-nextgen/common folder sturcture

For historic reasons we had it setup that there was
  plugin-nextgen/common/PluginInterface/<sources + headers>
which is not what we do anywhere else.
Now it looks like the rest:
  plugin-nextgen/common/include/<headers>
  plugin-nextgen/common/src/<sources>
As part of this, dlwrap.h was moved into common/include (as DLWrap.h)
since it is exclusively used by the plugins.
---
 openmp/libomptarget/include/dlwrap.h          | 286 ------------------
 .../plugins-nextgen/CMakeLists.txt            |   2 +-
 .../plugins-nextgen/amdgpu/CMakeLists.txt     |   2 +-
 .../amdgpu/dynamic_hsa/hsa.cpp                |   2 +-
 .../plugins-nextgen/common/CMakeLists.txt     |  91 +++++-
 .../common/PluginInterface/CMakeLists.txt     |  98 ------
 .../GlobalHandler.h                           |   0
 .../common/{PluginInterface => include}/JIT.h |   0
 .../MemoryManager.h                           |   0
 .../PluginInterface.h                         |   0
 .../common/{PluginInterface => include}/RPC.h |   0
 .../GlobalHandler.cpp                         |   0
 .../common/{PluginInterface => src}/JIT.cpp   |   0
 .../PluginInterface.cpp                       |   0
 .../common/{PluginInterface => src}/RPC.cpp   |   0
 .../{PluginInterface => src}/Utils/ELF.cpp    |   0
 .../{PluginInterface => src}/Utils/ELF.h      |   0
 .../plugins-nextgen/cuda/CMakeLists.txt       |   2 +-
 .../cuda/dynamic_cuda/cuda.cpp                |   2 +-
 19 files changed, 95 insertions(+), 390 deletions(-)
 delete mode 100644 openmp/libomptarget/include/dlwrap.h
 delete mode 100644 openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => include}/GlobalHandler.h (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => include}/JIT.h (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => include}/MemoryManager.h (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => include}/PluginInterface.h (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => include}/RPC.h (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => src}/GlobalHandler.cpp (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => src}/JIT.cpp (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => src}/PluginInterface.cpp (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => src}/RPC.cpp (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => src}/Utils/ELF.cpp (100%)
 rename openmp/libomptarget/plugins-nextgen/common/{PluginInterface => src}/Utils/ELF.h (100%)

diff --git a/openmp/libomptarget/include/dlwrap.h b/openmp/libomptarget/include/dlwrap.h
deleted file mode 100644
index 2784bd8594c1c96..000000000000000
--- a/openmp/libomptarget/include/dlwrap.h
+++ /dev/null
@@ -1,286 +0,0 @@
-//===------- dlwrap.h - Convenience wrapper around dlopen/dlsym  -- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// The openmp plugins depend on extern libraries. These can be used via:
-//  - bitcode file statically linked
-//  - (relocatable) object file statically linked
-//  - static library
-//  - dynamic library, linked at build time
-//  - dynamic library, loaded at application run time by dlopen
-//
-// This file factors out most boilerplate for using a dlopened library.
-// - Function symbols are generated that are statically linked against
-// - The dlopen can be done implicitly when initializing the library
-// - dlsym lookups are done once and cached
-// - The abstraction is very thin to permit varied uses of the library
-//
-// Given int foo(char, double, void*);, writing DLWRAP(foo, 3) will expand to:
-// int foo(char x0, double x1, void* x2) {
-//   constexpr size_t index = id();
-//   void * dlsymResult = pointer(index);
-//   return ((int (*)(char, double, void*))dlsymResult)(x0, x1, x2);
-// }
-//
-// Multiple calls to DLWRAP(symbol_name, arity) with bespoke
-// initialization code that can use the thin abstraction:
-// namespace dlwrap {
-//   static size_t size();
-//   static const char *symbol(size_t);
-//   static void **pointer(size_t);
-// }
-// will compile to an object file that only exposes the symbols that the
-// dynamic library would do, with the right function types.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef DLWRAP_H_INCLUDED
-#define DLWRAP_H_INCLUDED
-
-#include <array>
-#include <cstddef>
-#include <tuple>
-#include <type_traits>
-
-// Where symbol is a function, these expand to some book keeping and an
-// implementation of that function
-#define DLWRAP(SYMBOL, ARITY) DLWRAP_IMPL(SYMBOL, ARITY)
-#define DLWRAP_INTERNAL(SYMBOL, ARITY) DLWRAP_INTERNAL_IMPL(SYMBOL, ARITY)
-
-// For example, given a prototype:
-// int foo(char, double);
-//
-// DLWRAP(foo, 2) expands to:
-//
-// namespace dlwrap {
-// struct foo_Trait : public dlwrap::trait<decltype(&foo)> {
-//   using T = dlwrap::trait<decltype(&foo)>;
-//   static T::FunctionType get() {
-//     constexpr size_t Index = getIndex();
-//     void *P = *dlwrap::pointer(Index);
-//     return reinterpret_cast<T::FunctionType>(P);
-//   }
-// };
-// }
-// int foo(char x0, double x1) { return dlwrap::foo_Trait::get()(x0, x1); }
-//
-// DLWRAP_INTERNAL is similar, except the function it expands to is:
-// static int dlwrap_foo(char x0, double x1) { ... }
-// so that the function pointer call can be wrapped in library-specific code
-//
-// DLWRAP_INITIALIZE() declares static functions:
-#define DLWRAP_INITIALIZE()                                                    \
-  namespace dlwrap {                                                           \
-  static size_t size();                                                        \
-  static const char *symbol(size_t); /* get symbol name in [0, size()) */      \
-  static void **                                                               \
-      pointer(size_t); /* get pointer to function pointer in [0, size()) */    \
-  }
-
-// DLWRAP_FINALIZE() implements the functions from DLWRAP_INITIALIZE
-#define DLWRAP_FINALIZE() DLWRAP_FINALIZE_IMPL()
-
-// Implementation details follow.
-
-namespace dlwrap {
-
-// Extract return / argument types from address of function symbol
-template <typename F> struct trait;
-template <typename R, typename... Ts> struct trait<R (*)(Ts...)> {
-  constexpr static const size_t nargs = sizeof...(Ts);
-  typedef R ReturnType;
-  template <size_t i> struct arg {
-    typedef typename std::tuple_element<i, std::tuple<Ts...>>::type type;
-  };
-
-  typedef R (*FunctionType)(Ts...);
-};
-
-namespace type {
-// Book keeping is by type specialization
-
-template <size_t S> struct count {
-  static constexpr size_t N = count<S - 1>::N;
-};
-
-template <> struct count<0> { static constexpr size_t N = 0; };
-
-// Get a constexpr size_t ID, starts at zero
-#define DLWRAP_ID() (dlwrap::type::count<__LINE__>::N)
-
-// Increment value returned by DLWRAP_ID
-#define DLWRAP_INC()                                                           \
-  template <> struct dlwrap::type::count<__LINE__> {                           \
-    static constexpr size_t N = 1 + dlwrap::type::count<__LINE__ - 1>::N;      \
-  }
-
-template <size_t N> struct symbol;
-#define DLWRAP_SYMBOL(SYMBOL, ID)                                              \
-  template <> struct dlwrap::type::symbol<ID> {                                \
-    static constexpr const char *call() { return #SYMBOL; }                    \
-  }
-} // namespace type
-
-template <size_t N, size_t... Is>
-constexpr std::array<const char *, N> static getSymbolArray(
-    std::index_sequence<Is...>) {
-  return {{dlwrap::type::symbol<Is>::call()...}};
-}
-
-template <size_t Requested, size_t Required> constexpr void verboseAssert() {
-  static_assert(Requested == Required, "Arity Error");
-}
-
-} // namespace dlwrap
-
-#define DLWRAP_INSTANTIATE(SYM_DEF, SYM_USE, ARITY)                            \
-  DLWRAP_INSTANTIATE_##ARITY(SYM_DEF, SYM_USE,                                 \
-                             dlwrap::trait<decltype(&SYM_USE)>)
-
-#define DLWRAP_FINALIZE_IMPL()                                                 \
-  static size_t dlwrap::size() { return DLWRAP_ID(); }                         \
-  static const char *dlwrap::symbol(size_t i) {                                \
-    static constexpr const std::array<const char *, DLWRAP_ID()>               \
-        dlwrap_symbols = getSymbolArray<DLWRAP_ID()>(                          \
-            std::make_index_sequence<DLWRAP_ID()>());                          \
-    return dlwrap_symbols[i];                                                  \
-  }                                                                            \
-  static void **dlwrap::pointer(size_t i) {                                    \
-    static std::array<void *, DLWRAP_ID()> dlwrap_pointers;                    \
-    return &dlwrap_pointers.data()[i];                                         \
-  }
-
-#define DLWRAP_COMMON(SYMBOL, ARITY)                                           \
-  DLWRAP_INC();                                                                \
-  DLWRAP_SYMBOL(SYMBOL, DLWRAP_ID() - 1);                                      \
-  namespace dlwrap {                                                           \
-  struct SYMBOL##_Trait : public dlwrap::trait<decltype(&SYMBOL)> {            \
-    using T = dlwrap::trait<decltype(&SYMBOL)>;                                \
-    static T::FunctionType get() {                                             \
-      verboseAssert<ARITY, trait<decltype(&SYMBOL)>::nargs>();                 \
-      constexpr size_t Index = DLWRAP_ID() - 1;                                \
-      void *P = *dlwrap::pointer(Index);                                       \
-      return reinterpret_cast<T::FunctionType>(P);                             \
-    }                                                                          \
-  };                                                                           \
-  }
-
-#define DLWRAP_IMPL(SYMBOL, ARITY)                                             \
-  DLWRAP_COMMON(SYMBOL, ARITY)                                                 \
-  DLWRAP_INSTANTIATE(SYMBOL, SYMBOL, ARITY)
-
-#define DLWRAP_INTERNAL_IMPL(SYMBOL, ARITY)                                    \
-  DLWRAP_COMMON(SYMBOL, ARITY)                                                 \
-  static DLWRAP_INSTANTIATE(dlwrap_##SYMBOL, SYMBOL, ARITY)
-
-#define DLWRAP_INSTANTIATE_0(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF() { return dlwrap::SYM_USE##_Trait::get()(); }
-#define DLWRAP_INSTANTIATE_1(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0);                                 \
-  }
-#define DLWRAP_INSTANTIATE_2(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1);                             \
-  }
-#define DLWRAP_INSTANTIATE_3(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2);                         \
-  }
-#define DLWRAP_INSTANTIATE_4(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2,                  \
-                        typename T::template arg<3>::type x3) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2, x3);                     \
-  }
-#define DLWRAP_INSTANTIATE_5(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2,                  \
-                        typename T::template arg<3>::type x3,                  \
-                        typename T::template arg<4>::type x4) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2, x3, x4);                 \
-  }
-#define DLWRAP_INSTANTIATE_6(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2,                  \
-                        typename T::template arg<3>::type x3,                  \
-                        typename T::template arg<4>::type x4,                  \
-                        typename T::template arg<5>::type x5) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2, x3, x4, x5);             \
-  }
-
-#define DLWRAP_INSTANTIATE_7(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2,                  \
-                        typename T::template arg<3>::type x3,                  \
-                        typename T::template arg<4>::type x4,                  \
-                        typename T::template arg<5>::type x5,                  \
-                        typename T::template arg<6>::type x6) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2, x3, x4, x5, x6);         \
-  }
-
-#define DLWRAP_INSTANTIATE_8(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2,                  \
-                        typename T::template arg<3>::type x3,                  \
-                        typename T::template arg<4>::type x4,                  \
-                        typename T::template arg<5>::type x5,                  \
-                        typename T::template arg<6>::type x6,                  \
-                        typename T::template arg<7>::type x7) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2, x3, x4, x5, x6, x7);     \
-  }
-#define DLWRAP_INSTANTIATE_9(SYM_DEF, SYM_USE, T)                              \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2,                  \
-                        typename T::template arg<3>::type x3,                  \
-                        typename T::template arg<4>::type x4,                  \
-                        typename T::template arg<5>::type x5,                  \
-                        typename T::template arg<6>::type x6,                  \
-                        typename T::template arg<7>::type x7,                  \
-                        typename T::template arg<8>::type x8) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2, x3, x4, x5, x6, x7, x8); \
-  }
-#define DLWRAP_INSTANTIATE_10(SYM_DEF, SYM_USE, T)                             \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2,                  \
-                        typename T::template arg<3>::type x3,                  \
-                        typename T::template arg<4>::type x4,                  \
-                        typename T::template arg<5>::type x5,                  \
-                        typename T::template arg<6>::type x6,                  \
-                        typename T::template arg<7>::type x7,                  \
-                        typename T::template arg<8>::type x8,                  \
-                        typename T::template arg<9>::type x9) {                \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2, x3, x4, x5, x6, x7, x8,  \
-                                          x9);                                 \
-  }
-#define DLWRAP_INSTANTIATE_11(SYM_DEF, SYM_USE, T)                             \
-  T::ReturnType SYM_DEF(typename T::template arg<0>::type x0,                  \
-                        typename T::template arg<1>::type x1,                  \
-                        typename T::template arg<2>::type x2,                  \
-                        typename T::template arg<3>::type x3,                  \
-                        typename T::template arg<4>::type x4,                  \
-                        typename T::template arg<5>::type x5,                  \
-                        typename T::template arg<6>::type x6,                  \
-                        typename T::template arg<7>::type x7,                  \
-                        typename T::template arg<8>::type x8,                  \
-                        typename T::template arg<9>::type x9,                  \
-                        typename T::template arg<10>::type x10) {              \
-    return dlwrap::SYM_USE##_Trait::get()(x0, x1, x2, x3, x4, x5, x6, x7, x8,  \
-                                          x9, x10);                            \
-  }
-
-#endif
diff --git a/openmp/libomptarget/plugins-nextgen/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/CMakeLists.txt
index a27dd0a4ca9186c..5a904130de55f78 100644
--- a/openmp/libomptarget/plugins-nextgen/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/CMakeLists.txt
@@ -47,7 +47,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
 
         LINK_LIBS
         PRIVATE
-        PluginInterface
+	PluginCommon
         ${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
         ${OPENMP_PTHREAD_LIB}
 
diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
index af967bc386f67dc..bbf8c0a50f85c4b 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
@@ -80,7 +80,7 @@ add_llvm_library(omptarget.rtl.amdgpu SHARED
 
   LINK_LIBS
   PRIVATE
-  PluginInterface
+  PluginCommon
   ${LIBOMPTARGET_DEP_LIBRARIES}
   ${OPENMP_PTHREAD_LIB}
   ${LDFLAGS_UNDEFINED}
diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp
index faeb4ea77d6d4b7..cb82180b9a27e89 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp
@@ -15,7 +15,7 @@
 
 #include "Shared/Debug.h"
 
-#include "dlwrap.h"
+#include "DLWrap.h"
 #include "hsa.h"
 #include "hsa_ext_amd.h"
 #include <memory>
diff --git a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
index f0645d0d1753817..5b332ed3d2f4173 100644
--- a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
@@ -10,5 +10,94 @@
 #
 ##===----------------------------------------------------------------------===##
 
+# NOTE: Don't try to build `PluginInterface` using `add_llvm_library` because we
+# don't want to export `PluginInterface` while `add_llvm_library` requires that.
+add_library(PluginCommon OBJECT
+  src/PluginInterface.cpp
+  src/GlobalHandler.cpp
+  src/JIT.cpp
+  src/RPC.cpp
+  src/Utils/ELF.cpp
+)
+
+# Only enable JIT for those targets that LLVM can support.
+string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" TargetsSupported)
+foreach(Target ${TargetsSupported})
+	target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${Target}")
+endforeach()
+
+# This is required when using LLVM libraries.
+llvm_update_compile_flags(PluginCommon)
+
+if (LLVM_LINK_LLVM_DYLIB)
+  set(llvm_libs LLVM)
+else()
+  llvm_map_components_to_libnames(llvm_libs
+    ${LLVM_TARGETS_TO_BUILD}
+    AggressiveInstCombine
+    Analysis
+    BinaryFormat
+    BitReader
+    BitWriter
+    CodeGen
+    Core
+    Extensions
+    InstCombine
+    Instrumentation
+    IPO
+    IRReader
+    Linker
+    MC
+    Object
+    Passes
+    Remarks
+    ScalarOpts
+    Support
+    Target
+    TargetParser
+    TransformUtils
+    Vectorize
+  )
+endif()
+
+target_link_libraries(PluginCommon
+  PUBLIC
+    ${llvm_libs}
+)
+
+# Include the RPC server from the `libc` project if availible.
+if(TARGET llvmlibc_rpc_server AND ${LIBOMPTARGET_GPU_LIBC_SUPPORT})
+	target_link_libraries(PluginCommon PRIVATE llvmlibc_rpc_server)
+	target_compile_definitions(PluginCommon PRIVATE LIBOMPTARGET_RPC_SUPPORT)
+elseif(${LIBOMPTARGET_GPU_LIBC_SUPPORT})
+  find_library(llvmlibc_rpc_server NAMES llvmlibc_rpc_server
+               PATHS ${LIBOMPTARGET_LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
+  if(llvmlibc_rpc_server)
+		target_link_libraries(PluginCommon PRIVATE llvmlibc_rpc_server)
+		target_compile_definitions(PluginCommon PRIVATE LIBOMPTARGET_RPC_SUPPORT)
+  endif()
+endif()
+
+if ((OMPT_TARGET_DEFAULT) AND (LIBOMPTARGET_OMPT_SUPPORT))
+	target_link_libraries(PluginCommon PUBLIC OMPT)
+endif()
+
+# Define the TARGET_NAME and DEBUG_PREFIX.
+target_compile_definitions(PluginCommon PRIVATE
+  TARGET_NAME="PluginInterface"
+  DEBUG_PREFIX="PluginInterface"
+)
+
+target_include_directories(PluginCommon
+  PRIVATE
+  ${LIBOMPTARGET_INCLUDE_DIR}
+  PUBLIC
+  ${CMAKE_CURRENT_SOURCE_DIR}/include
+)
+
+set_target_properties(PluginCommon PROPERTIES
+  POSITION_INDEPENDENT_CODE ON
+  CXX_VISIBILITY_PRESET protected)
+
 add_subdirectory(OMPT)
-add_subdirectory(PluginInterface)
+
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
deleted file mode 100644
index 84a7dc8ea72ddc3..000000000000000
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
+++ /dev/null
@@ -1,98 +0,0 @@
-##===----------------------------------------------------------------------===##
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-##===----------------------------------------------------------------------===##
-#
-# Common parts which can be used by all plugins
-#
-##===----------------------------------------------------------------------===##
-
-# NOTE: Don't try to build `PluginInterface` using `add_llvm_library` because we
-# don't want to export `PluginInterface` while `add_llvm_library` requires that.
-add_library(PluginInterface OBJECT
-  PluginInterface.cpp
-  GlobalHandler.cpp
-  JIT.cpp
-  RPC.cpp
-  Utils/ELF.cpp
-)
-
-# Only enable JIT for those targets that LLVM can support.
-string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" TargetsSupported)
-foreach(Target ${TargetsSupported})
-  target_compile_definitions(PluginInterface PRIVATE "LIBOMPTARGET_JIT_${Target}")
-endforeach()
-
-# This is required when using LLVM libraries.
-llvm_update_compile_flags(PluginInterface)
-
-if (LLVM_LINK_LLVM_DYLIB)
-  set(llvm_libs LLVM)
-else()
-  llvm_map_components_to_libnames(llvm_libs
-    ${LLVM_TARGETS_TO_BUILD}
-    AggressiveInstCombine
-    Analysis
-    BinaryFormat
-    BitReader
-    BitWriter
-    CodeGen
-    Core
-    Extensions
-    InstCombine
-    Instrumentation
-    IPO
-    IRReader
-    Linker
-    MC
-    Object
-    Passes
-    Remarks
-    ScalarOpts
-    Support
-    Target
-    TargetParser
-    TransformUtils
-    Vectorize
-  )
-endif()
-
-target_link_libraries(PluginInterface
-  PUBLIC
-    ${llvm_libs}
-)
-
-# Include the RPC server from the `libc` project if availible.
-if(TARGET llvmlibc_rpc_server AND ${LIBOMPTARGET_GPU_LIBC_SUPPORT})
-  target_link_libraries(PluginInterface PRIVATE llvmlibc_rpc_server)
-  target_compile_definitions(PluginInterface PRIVATE LIBOMPTARGET_RPC_SUPPORT)
-elseif(${LIBOMPTARGET_GPU_LIBC_SUPPORT})
-  find_library(llvmlibc_rpc_server NAMES llvmlibc_rpc_server
-               PATHS ${LIBOMPTARGET_LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
-  if(llvmlibc_rpc_server)
-    target_link_libraries(PluginInterface PRIVATE llvmlibc_rpc_server)
-    target_compile_definitions(PluginInterface PRIVATE LIBOMPTARGET_RPC_SUPPORT)
-  endif()
-endif()
-
-if ((OMPT_TARGET_DEFAULT) AND (LIBOMPTARGET_OMPT_SUPPORT))
-  target_link_libraries(PluginInterface PUBLIC OMPT)
-endif()
-
-# Define the TARGET_NAME and DEBUG_PREFIX.
-target_compile_definitions(PluginInterface PRIVATE
-  TARGET_NAME="PluginInterface"
-  DEBUG_PREFIX="PluginInterface"
-)
-
-target_include_directories(PluginInterface
-  INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
-  PRIVATE ${LIBOMPTARGET_INCLUDE_DIR}
-)
-
-set_target_properties(PluginInterface PROPERTIES
-  POSITION_INDEPENDENT_CODE ON
-  CXX_VISIBILITY_PRESET protected)
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.h b/openmp/libomptarget/plugins-nextgen/common/include/GlobalHandler.h
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.h
rename to openmp/libomptarget/plugins-nextgen/common/include/GlobalHandler.h
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h b/openmp/libomptarget/plugins-nextgen/common/include/JIT.h
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h
rename to openmp/libomptarget/plugins-nextgen/common/include/JIT.h
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/MemoryManager.h b/openmp/libomptarget/plugins-nextgen/common/include/MemoryManager.h
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/MemoryManager.h
rename to openmp/libomptarget/plugins-nextgen/common/include/MemoryManager.h
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h b/openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
rename to openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/RPC.h b/openmp/libomptarget/plugins-nextgen/common/include/RPC.h
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/RPC.h
rename to openmp/libomptarget/plugins-nextgen/common/include/RPC.h
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp b/openmp/libomptarget/plugins-nextgen/common/src/GlobalHandler.cpp
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp
rename to openmp/libomptarget/plugins-nextgen/common/src/GlobalHandler.cpp
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp b/openmp/libomptarget/plugins-nextgen/common/src/JIT.cpp
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
rename to openmp/libomptarget/plugins-nextgen/common/src/JIT.cpp
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
rename to openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/RPC.cpp b/openmp/libomptarget/plugins-nextgen/common/src/RPC.cpp
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/RPC.cpp
rename to openmp/libomptarget/plugins-nextgen/common/src/RPC.cpp
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/Utils/ELF.cpp b/openmp/libomptarget/plugins-nextgen/common/src/Utils/ELF.cpp
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/Utils/ELF.cpp
rename to openmp/libomptarget/plugins-nextgen/common/src/Utils/ELF.cpp
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/Utils/ELF.h b/openmp/libomptarget/plugins-nextgen/common/src/Utils/ELF.h
similarity index 100%
rename from openmp/libomptarget/plugins-nextgen/common/PluginInterface/Utils/ELF.h
rename to openmp/libomptarget/plugins-nextgen/common/src/Utils/ELF.h
diff --git a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
index 3e1d11ac365df64..95b288cab311496 100644
--- a/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
@@ -34,7 +34,7 @@ add_llvm_library(omptarget.rtl.cuda SHARED
   Object
 
   LINK_LIBS PRIVATE
-  PluginInterface
+  PluginCommon
   ${OPENMP_PTHREAD_LIB}
 
   NO_INSTALL_RPATH
diff --git a/openmp/libomptarget/plugins-nextgen/cuda/dynamic_cuda/cuda.cpp b/openmp/libomptarget/plugins-nextgen/cuda/dynamic_cuda/cuda.cpp
index f99dc780c38e443..56c4404ac2d5c18 100644
--- a/openmp/libomptarget/plugins-nextgen/cuda/dynamic_cuda/cuda.cpp
+++ b/openmp/libomptarget/plugins-nextgen/cuda/dynamic_cuda/cuda.cpp
@@ -15,8 +15,8 @@
 
 #include "Shared/Debug.h"
 
+#include "DLWrap.h"
 #include "cuda.h"
-#include "dlwrap.h"
 
 #include <memory>
 #include <string>



More information about the Openmp-commits mailing list