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

via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 29 07:57:05 PST 2023


Author: Johannes Doerfert
Date: 2023-11-29T07:57:01-08:00
New Revision: db96a9c3b7f1855a586c23328bfa073dde6f1352

URL: https://github.com/llvm/llvm-project/commit/db96a9c3b7f1855a586c23328bfa073dde6f1352
DIFF: https://github.com/llvm/llvm-project/commit/db96a9c3b7f1855a586c23328bfa073dde6f1352.diff

LOG: [OpenMP][NFC] Flatten plugin-nextgen/common folder sturcture (#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.

Added: 
    openmp/libomptarget/plugins-nextgen/common/include/DLWrap.h
    openmp/libomptarget/plugins-nextgen/common/include/GlobalHandler.h
    openmp/libomptarget/plugins-nextgen/common/include/JIT.h
    openmp/libomptarget/plugins-nextgen/common/include/MemoryManager.h
    openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h
    openmp/libomptarget/plugins-nextgen/common/include/RPC.h
    openmp/libomptarget/plugins-nextgen/common/src/GlobalHandler.cpp
    openmp/libomptarget/plugins-nextgen/common/src/JIT.cpp
    openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
    openmp/libomptarget/plugins-nextgen/common/src/RPC.cpp
    openmp/libomptarget/plugins-nextgen/common/src/Utils/ELF.cpp
    openmp/libomptarget/plugins-nextgen/common/src/Utils/ELF.h

Modified: 
    openmp/libomptarget/plugins-nextgen/CMakeLists.txt
    openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
    openmp/libomptarget/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp
    openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
    openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt
    openmp/libomptarget/plugins-nextgen/cuda/dynamic_cuda/cuda.cpp

Removed: 
    openmp/libomptarget/include/dlwrap.h
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.h
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/MemoryManager.h
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/RPC.cpp
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/RPC.h
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/Utils/ELF.cpp
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/Utils/ELF.h


################################################################################
diff  --git a/openmp/libomptarget/plugins-nextgen/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/CMakeLists.txt
index a27dd0a4ca9186c..af2e5ef770f7e3c 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/include/dlwrap.h b/openmp/libomptarget/plugins-nextgen/common/include/DLWrap.h
similarity index 98%
rename from openmp/libomptarget/include/dlwrap.h
rename to openmp/libomptarget/plugins-nextgen/common/include/DLWrap.h
index 2784bd8594c1c96..8934e7e701021bc 100644
--- a/openmp/libomptarget/include/dlwrap.h
+++ b/openmp/libomptarget/plugins-nextgen/common/include/DLWrap.h
@@ -1,4 +1,4 @@
-//===------- dlwrap.h - Convenience wrapper around dlopen/dlsym  -- C++ -*-===//
+//===-- Shared/DLWrap.h - Convenience wrapper for 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.
@@ -38,8 +38,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef DLWRAP_H_INCLUDED
-#define DLWRAP_H_INCLUDED
+#ifndef OMPTARGET_SHARED_DLWRAP_H
+#define OMPTARGET_SHARED_DLWRAP_H
 
 #include <array>
 #include <cstddef>
@@ -283,4 +283,4 @@ template <size_t Requested, size_t Required> constexpr void verboseAssert() {
                                           x9, x10);                            \
   }
 
-#endif
+#endif // OMPTARGET_SHARED_DLWRAP_H

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