Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion build2cmake/src/templates/cuda/kernel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,21 @@ if(GPU_LANG STREQUAL "CUDA")
list(APPEND SRC {{'"${' + kernel_name + '_SRC}"'}})
{% if supports_hipify %}
elseif(GPU_LANG STREQUAL "HIP")
hip_archs_loose_intersection({{kernel_name}}_ARCHS "{{ rocm_archs|join(";") }}" ${ROCM_ARCHS})
hip_archs_loose_intersection({{kernel_name}}_ARCHS "{{ rocm_archs|join(";") }}" "${ROCM_ARCHS}")
message(STATUS "Archs for kernel {{kernel_name}}: {{ '${' + kernel_name + '_ARCHS}'}}")

foreach(_KERNEL_SRC {{'${' + kernel_name + '_SRC}'}})
if(_KERNEL_SRC MATCHES ".*\\.(cu|hip)$")
foreach(_ROCM_ARCH {{ '${' + kernel_name + '_ARCHS}'}})
set_property(
SOURCE ${_KERNEL_SRC}
APPEND PROPERTY
COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:HIP>:--offload-arch=${_ROCM_ARCH}>"
)
endforeach()
endif()
endforeach()

list(APPEND SRC {{'"${' + kernel_name + '_SRC}"'}})
{% endif %}
endif()
Expand Down
10 changes: 4 additions & 6 deletions build2cmake/src/templates/cuda/preamble.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ message(STATUS "FetchContent base directory: ${FETCHCONTENT_BASE_DIR}")

set(CUDA_SUPPORTED_ARCHS "{{ cuda_supported_archs }}")

set(HIP_SUPPORTED_ARCHS "gfx906;gfx908;gfx90a;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101")
set(HIP_SUPPORTED_ARCHS "gfx906;gfx908;gfx90a;gfx942;gfx950;gfx1030;gfx1100;gfx1101;gfx1200;gfx1201")
Comment on lines 12 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we not have the same thing as cuda, i mean cuda_supported_archs ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How cuda_supported_archs is set up now is not ideal other. We should fix both at the same time in a different PR.


include(${CMAKE_CURRENT_LIST_DIR}/cmake/utils.cmake)

Expand Down Expand Up @@ -85,11 +85,9 @@ if(GPU_LANG STREQUAL "CUDA")

add_compile_definitions(CUDA_KERNEL)
elseif(GPU_LANG STREQUAL "HIP")
set(ROCM_ARCHS "${HIP_SUPPORTED_ARCHS}")
# TODO: remove this once we can set specific archs per source file set.
override_gpu_arches(GPU_ARCHES
${GPU_LANG}
"${${GPU_LANG}_SUPPORTED_ARCHS}")
override_gpu_arches(GPU_ARCHES HIP ${HIP_SUPPORTED_ARCHS})
set(ROCM_ARCHS ${GPU_ARCHES})
message(STATUS "ROCM supported target architectures: ${ROCM_ARCHS}")

add_compile_definitions(ROCM_KERNEL)
else()
Expand Down
16 changes: 14 additions & 2 deletions build2cmake/src/templates/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function (hipify_sources_target OUT_SRCS NAME ORIG_SRCS)
set(HIP_SRCS)
foreach (SRC ${SRCS})
get_source_file_property(include_dirs "${SRC}" INCLUDE_DIRECTORIES)
get_source_file_property(compile_options "${SRC}" COMPILE_OPTIONS)
string(REGEX REPLACE "\.cu$" "\.hip" SRC ${SRC})
string(REGEX REPLACE "cuda" "hip" SRC ${SRC})

Expand All @@ -84,6 +85,12 @@ function (hipify_sources_target OUT_SRCS NAME ORIG_SRCS)
PROPERTIES INCLUDE_DIRECTORIES "${include_dirs}")
endif()

if(compile_options)
set_source_files_properties(
${SRC}
PROPERTIES COMPILE_OPTIONS "${compile_options}")
endif()

list(APPEND HIP_SRCS "${CMAKE_CURRENT_BINARY_DIR}/${SRC}")
endforeach()

Expand Down Expand Up @@ -516,8 +523,13 @@ function (define_gpu_extension_target GPU_MOD_NAME)
endif()

if (GPU_ARCHITECTURES)
set_target_properties(${GPU_MOD_NAME} PROPERTIES
${GPU_LANGUAGE}_ARCHITECTURES "${GPU_ARCHITECTURES}")
if (GPU_LANGUAGE STREQUAL "HIP")
# Clear target architectures, we are passing arch flags per source file.
set_property(TARGET ${GPU_MOD_NAME} PROPERTY HIP_ARCHITECTURES off)
else()
set_target_properties(${GPU_MOD_NAME} PROPERTIES
${GPU_LANGUAGE}_ARCHITECTURES "${GPU_ARCHITECTURES}")
endif()
endif()

set_property(TARGET ${GPU_MOD_NAME} PROPERTY CXX_STANDARD 17)
Expand Down
Loading