Skip to content
Open
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
32 changes: 28 additions & 4 deletions superbench/benchmarks/micro_benchmarks/rocm_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,35 @@ else()
set(HIP_PATH $ENV{HIP_PATH})
endif()

# Turn off CMAKE_HIP_ARCHITECTURES Feature if cmake version is 3.21+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21.0)
set(CMAKE_HIP_ARCHITECTURES OFF)
# Set HIP architectures from the AMDGPU_TARGETS environment variable if available.
# Accepts the common separators a user might pass: whitespace, ',', or ';'
# (e.g. "gfx908 gfx90a gfx942", "gfx908,gfx90a", or "gfx908;gfx90a").
# In this repository's micro-benchmarks, AMDGPU_TARGETS is what actually drives
# --offload-arch selection, via ROCm's hip-config-amd.cmake and hipcc (the C++
# compiler). CMAKE_HIP_ARCHITECTURES is set (when supported by CMake >= 3.21)
# for compatibility with projects that enable the CMake HIP language, but is
# not required for these CXX-only projects.
set(_amdgpu_targets_raw "$ENV{AMDGPU_TARGETS}")
string(STRIP "${_amdgpu_targets_raw}" _amdgpu_targets_stripped)
# Collapse runs of any common separator (spaces, tabs, CR/LF, ',', ';') into a
# single ';' so the result is a well-formed CMake list with no empty elements.
string(REGEX REPLACE "[ \t\r\n,;]+" ";" HIP_ARCH_LIST "${_amdgpu_targets_stripped}")
if(NOT HIP_ARCH_LIST STREQUAL "")
# Use a normal (non-cache) directory-scoped variable so we do not pollute
# the global CMake cache or override AMDGPU_TARGETS in nested projects.
# The env var is re-read on every reconfigure, so this still wins over
# stale state when the user changes AMDGPU_TARGETS.
set(AMDGPU_TARGETS ${HIP_ARCH_LIST})
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21.0)
set(CMAKE_HIP_ARCHITECTURES ${HIP_ARCH_LIST})
endif()
message(STATUS "Using AMDGPU_TARGETS from environment: ${HIP_ARCH_LIST}")
else()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21.0)
set(CMAKE_HIP_ARCHITECTURES OFF)
endif()
message(STATUS "AMDGPU_TARGETS not set (or empty), relying on hipcc auto-detection")
endif()
message(STATUS "CMAKE HIP ARCHITECTURES: ${CMAKE_HIP_ARCHITECTURES}")

if(EXISTS ${HIP_PATH})
# Search for hip in common locations
Expand Down
Loading