Skip to content

Commit db96a9c

Browse files
authored
[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.
1 parent 672b3d0 commit db96a9c

File tree

19 files changed

+99
-108
lines changed

19 files changed

+99
-108
lines changed

openmp/libomptarget/plugins-nextgen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
4747

4848
LINK_LIBS
4949
PRIVATE
50-
PluginInterface
50+
PluginCommon
5151
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
5252
${OPENMP_PTHREAD_LIB}
5353

openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ add_llvm_library(omptarget.rtl.amdgpu SHARED
8080

8181
LINK_LIBS
8282
PRIVATE
83-
PluginInterface
83+
PluginCommon
8484
${LIBOMPTARGET_DEP_LIBRARIES}
8585
${OPENMP_PTHREAD_LIB}
8686
${LDFLAGS_UNDEFINED}

openmp/libomptarget/plugins-nextgen/amdgpu/dynamic_hsa/hsa.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "Shared/Debug.h"
1717

18-
#include "dlwrap.h"
18+
#include "DLWrap.h"
1919
#include "hsa.h"
2020
#include "hsa_ext_amd.h"
2121
#include <memory>

openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,94 @@
1010
#
1111
##===----------------------------------------------------------------------===##
1212

13+
# NOTE: Don't try to build `PluginInterface` using `add_llvm_library` because we
14+
# don't want to export `PluginInterface` while `add_llvm_library` requires that.
15+
add_library(PluginCommon OBJECT
16+
src/PluginInterface.cpp
17+
src/GlobalHandler.cpp
18+
src/JIT.cpp
19+
src/RPC.cpp
20+
src/Utils/ELF.cpp
21+
)
22+
23+
# Only enable JIT for those targets that LLVM can support.
24+
string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" TargetsSupported)
25+
foreach(Target ${TargetsSupported})
26+
target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${Target}")
27+
endforeach()
28+
29+
# This is required when using LLVM libraries.
30+
llvm_update_compile_flags(PluginCommon)
31+
32+
if (LLVM_LINK_LLVM_DYLIB)
33+
set(llvm_libs LLVM)
34+
else()
35+
llvm_map_components_to_libnames(llvm_libs
36+
${LLVM_TARGETS_TO_BUILD}
37+
AggressiveInstCombine
38+
Analysis
39+
BinaryFormat
40+
BitReader
41+
BitWriter
42+
CodeGen
43+
Core
44+
Extensions
45+
InstCombine
46+
Instrumentation
47+
IPO
48+
IRReader
49+
Linker
50+
MC
51+
Object
52+
Passes
53+
Remarks
54+
ScalarOpts
55+
Support
56+
Target
57+
TargetParser
58+
TransformUtils
59+
Vectorize
60+
)
61+
endif()
62+
63+
target_link_libraries(PluginCommon
64+
PUBLIC
65+
${llvm_libs}
66+
)
67+
68+
# Include the RPC server from the `libc` project if availible.
69+
if(TARGET llvmlibc_rpc_server AND ${LIBOMPTARGET_GPU_LIBC_SUPPORT})
70+
target_link_libraries(PluginCommon PRIVATE llvmlibc_rpc_server)
71+
target_compile_definitions(PluginCommon PRIVATE LIBOMPTARGET_RPC_SUPPORT)
72+
elseif(${LIBOMPTARGET_GPU_LIBC_SUPPORT})
73+
find_library(llvmlibc_rpc_server NAMES llvmlibc_rpc_server
74+
PATHS ${LIBOMPTARGET_LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
75+
if(llvmlibc_rpc_server)
76+
target_link_libraries(PluginCommon PRIVATE llvmlibc_rpc_server)
77+
target_compile_definitions(PluginCommon PRIVATE LIBOMPTARGET_RPC_SUPPORT)
78+
endif()
79+
endif()
80+
81+
if ((OMPT_TARGET_DEFAULT) AND (LIBOMPTARGET_OMPT_SUPPORT))
82+
target_link_libraries(PluginCommon PUBLIC OMPT)
83+
endif()
84+
85+
# Define the TARGET_NAME and DEBUG_PREFIX.
86+
target_compile_definitions(PluginCommon PRIVATE
87+
TARGET_NAME="PluginInterface"
88+
DEBUG_PREFIX="PluginInterface"
89+
)
90+
91+
target_include_directories(PluginCommon
92+
PRIVATE
93+
${LIBOMPTARGET_INCLUDE_DIR}
94+
PUBLIC
95+
${CMAKE_CURRENT_SOURCE_DIR}/include
96+
)
97+
98+
set_target_properties(PluginCommon PROPERTIES
99+
POSITION_INDEPENDENT_CODE ON
100+
CXX_VISIBILITY_PRESET protected)
101+
13102
add_subdirectory(OMPT)
14-
add_subdirectory(PluginInterface)
103+

openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt

Lines changed: 0 additions & 98 deletions
This file was deleted.

openmp/libomptarget/include/dlwrap.h renamed to openmp/libomptarget/plugins-nextgen/common/include/DLWrap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===------- dlwrap.h - Convenience wrapper around dlopen/dlsym -- C++ -*-===//
1+
//===-- Shared/DLWrap.h - Convenience wrapper for dlopen/dlsym --*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -38,8 +38,8 @@
3838
//
3939
//===----------------------------------------------------------------------===//
4040

41-
#ifndef DLWRAP_H_INCLUDED
42-
#define DLWRAP_H_INCLUDED
41+
#ifndef OMPTARGET_SHARED_DLWRAP_H
42+
#define OMPTARGET_SHARED_DLWRAP_H
4343

4444
#include <array>
4545
#include <cstddef>
@@ -283,4 +283,4 @@ template <size_t Requested, size_t Required> constexpr void verboseAssert() {
283283
x9, x10); \
284284
}
285285

286-
#endif
286+
#endif // OMPTARGET_SHARED_DLWRAP_H

openmp/libomptarget/plugins-nextgen/cuda/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ add_llvm_library(omptarget.rtl.cuda SHARED
3434
Object
3535

3636
LINK_LIBS PRIVATE
37-
PluginInterface
37+
PluginCommon
3838
${OPENMP_PTHREAD_LIB}
3939

4040
NO_INSTALL_RPATH

openmp/libomptarget/plugins-nextgen/cuda/dynamic_cuda/cuda.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
#include "Shared/Debug.h"
1717

18+
#include "DLWrap.h"
1819
#include "cuda.h"
19-
#include "dlwrap.h"
2020

2121
#include <memory>
2222
#include <string>

0 commit comments

Comments
 (0)