@@ -22,98 +22,53 @@ endif()
22
22
# If we are bootstrapping hsa via external project we need to use find_library
23
23
# as it will not be installed.
24
24
if (DEFINED LIBOMPTARGET_EXTERNAL_PROJECT_HSA_PATH )
25
- find_library (HSA_RUNTIME hsa-runtime64 HINTS ${CMAKE_BINARY_DIR} /../../runtimes/rocr-runtime-prefix/src/rocr-runtime-build ${CMAKE_INSTALL_PREFIX} )
25
+ find_library (HSA_RUNTIME hsa-runtime64
26
+ HINTS
27
+ ${CMAKE_BINARY_DIR} /../../runtimes/rocr-runtime-prefix/src/rocr-runtime-build
28
+ ${CMAKE_INSTALL_PREFIX}
29
+ PATHS
30
+ ${LIBOMPTARGET_EXTERNAL_PROJECT_HSA_PATH}
31
+ )
26
32
else ()
27
33
# As of rocm-3.7, hsa is installed with cmake packages and kmt is found via hsa
28
34
find_package (hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm )
29
35
endif ()
30
36
31
- # Check for COMGr package , ASan requires COMGr with minimum version 2.4
32
- if (SANITIZER_AMDGPU )
33
- add_definitions (-DSANITIZER_AMDGPU=1 )
34
- find_package (amd_comgr QUIET 2.4.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm )
35
- endif ()
36
-
37
37
if (NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)|(aarch64)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux" ))
38
38
libomptarget_say ("Not building AMDGPU NextGen plugin: only support AMDGPU in Linux x86_64, ppc64le, or aarch64 hosts" )
39
39
return ()
40
40
endif ()
41
41
42
- ################################################################################
43
- # Define the suffix for the runtime messaging dumps.
44
- add_definitions (-DTARGET_NAME=AMDGPU )
42
+ # Create the library and add the default arguments.
43
+ add_target_library (omptarget.rtl.amdgpu AMDGPU )
45
44
46
- # Define debug prefix. TODO: This should be automatized in the Debug.h but it
47
- # requires changing the original plugins.
48
- add_definitions (-DDEBUG_PREFIX= "TARGET AMDGPU RTL" )
45
+ target_sources (omptarget.rtl.amdgpu PRIVATE src/rtl.cpp )
46
+ target_include_directories (omptarget.rtl.amdgpu PRIVATE
47
+ ${CMAKE_CURRENT_SOURCE_DIR} /utils )
48
+ target_link_libraries (omptarget.rtl.amdgpu PRIVATE
49
+ -Wl,--whole-archive amdgcn_hostexec_services -Wl,--no-whole-archive )
49
50
50
- set (LIBOMPTARGET_DLOPEN_LIBHSA OFF )
51
- option (LIBOMPTARGET_FORCE_DLOPEN_LIBHSA "Build with dlopened libhsa" ${LIBOMPTARGET_DLOPEN_LIBHSA} )
52
-
53
- if (DEFINED HSA_RUNTIME AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBHSA )
54
- libomptarget_say ("Building AMDGPU NextGen plugin linked against libhsa" )
55
- set (LIBOMPTARGET_EXTRA_SOURCE )
56
- set (LIBOMPTARGET_DEP_LIBRARIES ${HSA_RUNTIME} )
57
- elseif (${hsa-runtime64_FOUND} AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBHSA )
58
- libomptarget_say ("Building AMDGPU NextGen plugin linked against libhsa" )
59
- set (LIBOMPTARGET_EXTRA_SOURCE )
60
- set (LIBOMPTARGET_DEP_LIBRARIES hsa-runtime64::hsa-runtime64 )
61
- else ()
62
- libomptarget_say ("Building AMDGPU NextGen plugin for dlopened libhsa" )
63
- include_directories (dynamic_hsa )
64
- set (LIBOMPTARGET_EXTRA_SOURCE dynamic_hsa/hsa.cpp )
65
- set (LIBOMPTARGET_DEP_LIBRARIES )
51
+ # Check for COMGr package , ASan requires COMGr with minimum version 2.4
52
+ if (SANITIZER_AMDGPU )
53
+ target_compile_definitions (omptarget.rtl.amdgpu PRIVATE SANITIZER_AMDGPU=1 )
54
+ find_package (amd_comgr QUIET 2.4.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm )
66
55
endif ()
67
56
68
- if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
69
- # On FreeBSD, the 'environ' symbol is undefined at link time, but resolved by
70
- # the dynamic linker at runtime. Therefore, allow the symbol to be undefined
71
- # when creating a shared library.
72
- set (LDFLAGS_UNDEFINED "-Wl,--allow-shlib-undefined" )
57
+ option (LIBOMPTARGET_FORCE_DLOPEN_LIBHSA "Build with dlopened libhsa" OFF )
58
+ if (DEFINED HSA_RUNTIME AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBHSA )
59
+ libomptarget_say ("Building AMDGPU plugin linked against libhsa" )
60
+ target_link_libraries (omptarget.rtl.amdgpu PRIVATE ${HSA_RUNTIME} )
61
+ get_filename_component (library_path ${HSA_RUNTIME} DIRECTORY )
62
+ target_include_directories (omptarget.rtl.amdgpu PRIVATE ${library_path} /../include )
63
+ elseif (hsa-runtime64_FOUND AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBHSA )
64
+ libomptarget_say ("Building AMDGPU plugin linked against libhsa" )
65
+ target_link_libraries (omptarget.rtl.amdgpu PRIVATE hsa-runtime64::hsa-runtime64 )
73
66
else ()
74
- set (LDFLAGS_UNDEFINED "-Wl,-z,defs" )
67
+ libomptarget_say ("Building AMDGPU plugin for dlopened libhsa" )
68
+ target_include_directories (omptarget.rtl.amdgpu PRIVATE dynamic_hsa )
69
+ target_sources (omptarget.rtl.amdgpu PRIVATE dynamic_hsa/hsa.cpp )
75
70
endif ()
76
71
77
- add_llvm_library (omptarget.rtl.amdgpu SHARED
78
- src/rtl.cpp
79
- ${LIBOMPTARGET_EXTRA_SOURCE}
80
-
81
- ADDITIONAL_HEADER_DIRS
82
- ${LIBOMPTARGET_INCLUDE_DIR}
83
- ${CMAKE_CURRENT_SOURCE_DIR} /utils
84
-
85
- LINK_COMPONENTS
86
- Support
87
- Object
88
-
89
- LINK_LIBS
90
- PRIVATE
91
- OMPT
92
- PluginCommon
93
- ${LIBOMPTARGET_DEP_LIBRARIES}
94
- ${OPENMP_PTHREAD_LIB}
95
- -Wl,--whole-archive amdgcn_hostexec_services -Wl,--no-whole-archive
96
- ${LDFLAGS_UNDEFINED}
97
-
98
- NO_INSTALL_RPATH
99
- BUILDTREE_ONLY
100
- )
101
- add_dependencies (omptarget.rtl.amdgpu amdgcn_hostexec_services )
102
-
103
- if (LIBOMP_HAVE_VERSION_SCRIPT_FLAG )
104
- target_link_libraries (
105
- omptarget.rtl.amdgpu
106
- PRIVATE
107
- "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR} /../exports" )
108
- endif ()
109
-
110
- target_include_directories (
111
- omptarget.rtl.amdgpu
112
- PRIVATE
113
- ${LIBOMPTARGET_INCLUDE_DIR}
114
- ${CMAKE_CURRENT_SOURCE_DIR} /utils
115
- )
116
-
117
72
# Configure testing for the AMDGPU plugin. We will build tests if we could a
118
73
# functional AMD GPU on the system, or if manually specifies by the user.
119
74
option (LIBOMPTARGET_FORCE_AMDGPU_TESTS "Build AMDGPU libomptarget tests" OFF )
@@ -130,7 +85,6 @@ endif()
130
85
131
86
# Install plugin under the lib destination folder.
132
87
install (TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR} " )
133
-
134
88
if (NOT DEFINED CMAKE_INSTALL_RPATH )
135
89
set_target_properties (omptarget.rtl.amdgpu PROPERTIES
136
90
INSTALL_RPATH "$ORIGIN" )
0 commit comments