Skip to content

Commit e2e334e

Browse files
authored
fixed compilation targets on cmake (#182)
* fixed compilation targets on cmake * moved gpu target generation
1 parent 7a5c6f8 commit e2e334e

File tree

1 file changed

+37
-40
lines changed

1 file changed

+37
-40
lines changed

CMakeLists.txt

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,43 @@ include(ROCMCheckTargetIds)
9292

9393
rocm_setup_version(VERSION ${VERSION_STRING})
9494

95+
#############################################################################
96+
# SET GPU ARCHITECTURES
97+
#############################################################################
98+
include(cmake/rocm_local_targets.cmake)
99+
100+
set(DEFAULT_GPUS
101+
gfx90a:xnack-;
102+
gfx90a:xnack+;
103+
gfx942:xnack-;
104+
gfx942:xnack+;
105+
gfx950:xnack-;
106+
gfx950:xnack+)
107+
108+
if (BUILD_LOCAL_GPU_TARGET_ONLY)
109+
message(STATUS "Building only for local GPU target")
110+
if (COMMAND rocm_local_targets)
111+
rocm_local_targets(DEFAULT_GPUS)
112+
else()
113+
message(WARNING "Unable to determine local GPU targets. Falling back to default GPUs.")
114+
endif()
115+
endif()
116+
117+
set(DEFAULT_GPU_TARGETS "${DEFAULT_GPUS}" CACHE STRING
118+
"Target default GPUs if GPU_TARGETS is not defined.")
119+
120+
if (COMMAND rocm_check_target_ids)
121+
message(STATUS "Checking for ROCm support for GPU targets: " "${DEFAULT_GPU_TARGETS}")
122+
rocm_check_target_ids(SUPPORTED_GPUS TARGETS ${DEFAULT_GPU_TARGETS})
123+
else()
124+
message(WARNING "Unable to check for supported GPU targets.")
125+
set(SUPPORTED_GPUS ${DEFAULT_GPU_TARGETS})
126+
endif()
127+
128+
set(GPU_TARGETS "${SUPPORTED_GPUS}" CACHE STRING "GPU architectures to compile for")
129+
130+
message(STATUS "Compiling for ${GPU_TARGETS}")
131+
95132
###############################################################################
96133
# CREATE ROCSHMEM LIBRARY
97134
###############################################################################
@@ -100,46 +137,6 @@ if (NOT BUILD_TESTS_ONLY)
100137
add_library(roc::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
101138
add_subdirectory(src)
102139

103-
#############################################################################
104-
# SET GPU ARCHITECTURES
105-
#############################################################################
106-
include(cmake/rocm_local_targets.cmake)
107-
108-
set(DEFAULT_GPUS
109-
gfx90a:xnack-;
110-
gfx90a:xnack+;
111-
gfx942:xnack-;
112-
gfx942:xnack+;
113-
gfx950:xnack-;
114-
gfx950:xnack+)
115-
116-
if (BUILD_LOCAL_GPU_TARGET_ONLY)
117-
message(STATUS "Building only for local GPU target")
118-
if (COMMAND rocm_local_targets)
119-
rocm_local_targets(DEFAULT_GPUS)
120-
else()
121-
message(WARNING "Unable to determine local GPU targets. Falling back to default GPUs.")
122-
endif()
123-
endif()
124-
125-
set(GPU_TARGETS "${DEFAULT_GPUS}" CACHE STRING
126-
"Target default GPUs if GPU_TARGETS is not defined.")
127-
128-
if (COMMAND rocm_check_target_ids)
129-
message(STATUS "Checking for ROCm support for GPU targets: " "${GPU_TARGETS}")
130-
rocm_check_target_ids(SUPPORTED_GPUS TARGETS ${GPU_TARGETS})
131-
else()
132-
message(WARNING "Unable to check for supported GPU targets.")
133-
set(SUPPORTED_GPUS ${GPU_TARGETS})
134-
endif()
135-
136-
set(COMPILING_TARGETS "${SUPPORTED_GPUS}" CACHE STRING "GPU targets to compile for.")
137-
message(STATUS "Compiling for ${COMPILING_TARGETS}")
138-
139-
foreach (target ${COMPILING_TARGETS})
140-
list(APPEND offload_flags --offload-arch=${target})
141-
endforeach()
142-
143140
#############################################################################
144141
# PACKAGE DEPENDENCIES
145142
#############################################################################

0 commit comments

Comments
 (0)