Skip to content
Merged
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
50 changes: 38 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,6 @@ else()
endif()
endif()

#-------------------------------------------------------------------------------
# HIP Default Target Configuration.
#
# HIP does not have a stable instruction set like NVIDIA PTX; it requires
# binaries specific to a target chip. We have tests that generate and run
# deployable code which need to specify the proper target chip.
#-------------------------------------------------------------------------------

set(IREE_HIP_TEST_TARGET_CHIP "" CACHE STRING
"Target chip for HIP tests that need to compile device code. \
Defaults to empty string to disable tests.")

#-------------------------------------------------------------------------------
# Runtime HAL Driver Options
# By default, all runtime drivers supported by the current platform which do
Expand Down Expand Up @@ -418,6 +406,44 @@ if(IREE_HAL_EXECUTABLE_PLUGIN_SYSTEM_LIBRARY)
message(STATUS " - system-library")
endif()

#-------------------------------------------------------------------------------
# HIP Default Target Configuration.
#
# HIP does not have a stable instruction set like NVIDIA PTX; it requires
# binaries specific to a target chip. We have tests that generate and run
# deployable code which need to specify the proper target chip.
#-------------------------------------------------------------------------------

# When ROCm is detected on the build host and a corresponding HAL driver is enabled,
# force the user to make a conscious decision to enable or disable ROCm testing.
# It's hard to enable automatically for a given target
# chip because that would rely too much on guessing what the target chip is.
# But silently continuing with ROCm testing disabled by default has also been
# surprising.
if ((IREE_HAL_DRIVER_HIP OR IREE_HAL_DRIVER_AMDGPU) AND NOT DEFINED CACHE{IREE_HIP_TEST_TARGET_CHIP})
find_program(_ROCMINFO_COMMAND rocminfo)
Copy link
Member

Choose a reason for hiding this comment

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

You could try using offload-arch (formerly amdgpu-arch) instead, as that is more generic, available on Windows too, and produces more machine-friendly output

Copy link
Member

Choose a reason for hiding this comment

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

I don't have offload-arch in my installation (rocm 7.0), and amdgpu-arch have llvm version suffixes, which would make it a bit tricky to select...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wait this is great but the only place I can see offload-arch is in my LLVM directory from a tarball. AFAICS, if I hadn't switched to a llvm tarball as my toolchain (e.g. if I were still using the system toolchain) I wouldn't have this program at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a amdgpu-arch under /opt/rocm-7.0.x but not in PATH - it's in some LLVM toolchain subdir.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Normally I'd be thrilled to switch to building offload-arch ourselves from the LLVM tree but here I need this information early in configure.

Copy link
Collaborator Author

@bjacob bjacob Oct 30, 2025

Choose a reason for hiding this comment

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

Available on Windows too

Is rocminfo not available on Windows?

Copy link
Member

Choose a reason for hiding this comment

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

Both have offload-arch / amdgpu-arch.

Windows has hipinfo.

Linux has rocminfo and rocm_agent_enumerator.

I'm still figuring out how to eventually turn that into something sane.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No urgency on merging this .... this PR is just cherries on cakes.

One safe but kinda suboptimal resolution is to just build the offload-arch target from our llvm-project tree. Then give up on producing a configure-time diagnostic and instead produce a ctest-time diagnostic, which also removes the assumption that build host == test host.

if (_ROCMINFO_COMMAND)
execute_process(COMMAND ${_ROCMINFO_COMMAND} OUTPUT_VARIABLE _ROCMINFO_OUTPUT)
string(REGEX MATCH "Name:[ ]*gfx[0-9]+" _ROCMINFO_OUTPUT_NAME_LINE "${_ROCMINFO_OUTPUT}")
string(REGEX MATCH "gfx[0-9]+" _ROCMINFO_GFX_NAME "${_ROCMINFO_OUTPUT_NAME_LINE}")
if (_ROCMINFO_GFX_NAME)
# This needs to be FATAL_ERROR not SEND_ERROR, else the set(CACHE) below
# will prematurely hide this error in case cmake is run again without
# addressing the issue.
# Also note that in the unusual case of multiple devices with distinct
# architectures, we only detected one of them, so the message needs to
# be conservative.
message(FATAL_ERROR "At least one ROCm device detected, with architecture: ${_ROCMINFO_GFX_NAME}.\n"
"Explicitly either enable or disable ROCm testing.\n"
"To enable ROCm testing for ${_ROCMINFO_GFX_NAME}:\n cmake -DIREE_HIP_TEST_TARGET_CHIP=${_ROCMINFO_GFX_NAME}\n"
"To disable ROCm testing:\n cmake -DIREE_HIP_TEST_TARGET_CHIP=\n" )
endif()
endif()
endif()
set(IREE_HIP_TEST_TARGET_CHIP "" CACHE STRING
"Target chip for HIP tests that need to compile device code. \
Defaults to empty string to disable tests.")

#-------------------------------------------------------------------------------
# Compiler Target Options
# We try to keep the default build as simple as possible and disable heavy targets.
Expand Down
Loading