Skip to content

Commit c93c75a

Browse files
committed
Update Cmake infra to run HIP CXX tests using top-level cmake
1 parent 650f542 commit c93c75a

File tree

3 files changed

+227
-140
lines changed

3 files changed

+227
-140
lines changed

cmake/Options.cmake

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,24 @@ if(FLASHINFER_ENABLE_HIP AND FLASHINFER_ENABLE_CUDA)
112112
endif()
113113

114114
# Handle CUDA architectures
115-
if(FLASHINFER_CUDA_ARCHITECTURES)
116-
message(STATUS "CMAKE_CUDA_ARCHITECTURES set to ${FLASHINFER_CUDA_ARCHITECTURES}.")
117-
else()
118-
# No user-provided architectures, try to detect the CUDA archs based on where
119-
# the project is being built
120-
set(detected_archs "")
121-
detect_cuda_architectures(detected_archs)
122-
if(detected_archs)
123-
set(FLASHINFER_CUDA_ARCHITECTURES ${detected_archs} CACHE STRING
124-
"CUDA architectures" FORCE)
125-
message(STATUS "Setting FLASHINFER_CUDA_ARCHITECTURES to detected values: ${FLASHINFER_CUDA_ARCHITECTURES}")
115+
if(FLASHINFER_ENABLE_CUDA)
116+
if(FLASHINFER_CUDA_ARCHITECTURES)
117+
message(STATUS "CMAKE_CUDA_ARCHITECTURES set to ${FLASHINFER_CUDA_ARCHITECTURES}.")
126118
else()
127-
# No architectures detected, use safe defaults
128-
set(FLASHINFER_CUDA_ARCHITECTURES "75;80;86" CACHE STRING
129-
"CUDA architectures to compile for" FORCE)
130-
message(STATUS "No architectures detected, using defaults: ${FLASHINFER_CUDA_ARCHITECTURES}")
119+
# No user-provided architectures, try to detect the CUDA archs based on where
120+
# the project is being built
121+
set(detected_archs "")
122+
detect_cuda_architectures(detected_archs)
123+
if(detected_archs)
124+
set(FLASHINFER_CUDA_ARCHITECTURES ${detected_archs} CACHE STRING
125+
"CUDA architectures" FORCE)
126+
message(STATUS "Setting FLASHINFER_CUDA_ARCHITECTURES to detected values: ${FLASHINFER_CUDA_ARCHITECTURES}")
127+
else()
128+
# No architectures detected, use safe defaults
129+
set(FLASHINFER_CUDA_ARCHITECTURES "75;80;86" CACHE STRING
130+
"CUDA architectures to compile for" FORCE)
131+
message(STATUS "No architectures detected, using defaults: ${FLASHINFER_CUDA_ARCHITECTURES}")
132+
endif()
131133
endif()
132134
endif()
133135

cmake/utils/ConfigureTargets.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cmake-format: off
22
# Common configuration function for tests and benchmarks
33
function(configure_flashinfer_target)
4-
set(options IS_GTEST IS_BENCHMARK)
4+
set(options IS_GTEST IS_BENCHMARK IS_HIP)
55
set(oneValueArgs TARGET_NAME)
66
set(multiValueArgs SOURCES LINK_LIBS COMPILE_FLAGS INCLUDE_DIRS)
77

@@ -27,6 +27,14 @@ function(configure_flashinfer_target)
2727
# Create executable target
2828
add_executable(${arg_TARGET_NAME} EXCLUDE_FROM_ALL ${arg_SOURCES})
2929

30+
if(arg_IS_HIP)
31+
set_source_files_properties(${arg_SOURCES} PROPERTIES LANGUAGE HIP)
32+
foreach(flag ${FLASHINFER_HIPCC_FLAGS})
33+
target_compile_options(decode_kernels
34+
PRIVATE $<$<COMPILE_LANGUAGE:HIP>:${flag}>)
35+
endforeach()
36+
endif()
37+
3038
# Add all include directories
3139
target_include_directories(
3240
${arg_TARGET_NAME}

0 commit comments

Comments
 (0)