Skip to content

Feature/cmake hip spirv clean#160

Draft
sriasapu wants to merge 12 commits intoORNL:masterfrom
sriasapu:feature/cmake-hip-spirv-clean
Draft

Feature/cmake hip spirv clean#160
sriasapu wants to merge 12 commits intoORNL:masterfrom
sriasapu:feature/cmake-hip-spirv-clean

Conversation

@sriasapu
Copy link
Copy Markdown

@sriasapu sriasapu commented Apr 7, 2026

Summary

  • CMake support for HIP-only builds, optional HIP + SPIR-V (amdgcnspirv-style offload), and skip lists (string + optional file).
  • Default full-stack behavior is unchanged when all HECBENCH_ENABLE_* options stay ON and skip lists are empty.
  • No CMake-time editing of benchmark Makefiles (CMake targets do not use them).

Motivation

  • Integrators (superbuilds, CI) need HIP-only trees and SPIR-V compile/link flags without conflicting per-target gfx HIP_ARCHITECTURES / --offload-arch=${HECBENCH_HIP_ARCH}.
  • Skip lists are easier to maintain in a file (one benchmark id per line) than in one long cache string.

Changes

CMakeLists.txt

  • HECBENCH_ENABLE_HIP_ONLY — HIP-only discovery; warns if other model cache vars still look enabled.
  • HECBENCH_ENABLE_SPIRV, HECBENCH_SPIRV_TARGET — SPIR-V mode; default HECBENCH_HIP_EXTRA_CFLAGS / HECBENCH_HIP_LDFLAGS when unset.
  • HECBENCH_HIP_EXTRA_CFLAGS, HECBENCH_HIP_LDFLAGS — global HIP compile/link options (HIP language only).
  • CMAKE_HIP_ARCHITECTURESHECBENCH_SPIRV_TARGET if SPIR-V, else HECBENCH_HIP_ARCH.
  • HECBENCH_SKIP_BENCHMARKS, HECBENCH_SKIP_BENCHMARKS_FILE — merged skip list with # comments in the file.
  • check_language(HIP) / enable_language(HIP) when HIP is on but the HIP compiler was not set at first project().
  • find_package(OpenMP REQUIRED) — drop dead else after REQUIRED.
  • Extended configure status output for HIP / SPIR-V / extras.

src/CMakeLists.txt

  • add_subdirectory only if the benchmark’s model matches an enabled HECBENCH_ENABLE_*.
  • Skip list parsing + merge from HECBENCH_SKIP_BENCHMARKS_FILE.

cmake/modules/BenchmarkMacros.cmake

  • SPIR-V: omit per-target gfx HIP_ARCHITECTURES and --offload-arch=${HECBENCH_HIP_ARCH}; add -Wno-#warnings for HIP only.

Example

cmake -S . -B build \
  -DHECBENCH_ENABLE_HIP_ONLY=ON \
  -DHECBENCH_ENABLE_SPIRV=ON \
  -DCMAKE_HIP_COMPILER=/path/to/clang++ \
  -DHECBENCH_HIP_ARCH=gfx942
cmake --build build

Copy link
Copy Markdown

@marbre marbre left a comment

Choose a reason for hiding this comment

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

I am not familiar with HeCBench but I see several major issues here. Leaving some comments as I was asked to but it requires a more careful evaluation of those familiar with the project.

In addition to my other comments my main concern is about Makefile patching. Each benchmark is added via add_subdirectory and has it's own CMakeLists.txt. CMake generates a proper target and never invokes the manually written Makefile. Thus patching those Makefiles accomplished nothing for the CMake build as Makefiles get generated via CMake (if not using Ninja).

I think you rather want to use the CMake based build and there may be adjustments needed, but the Makefile patching isn't part of this.

@sriasapu sriasapu requested a review from marbre April 7, 2026 14:40
Comment on lines +541 to +542
# Parse user-provided skip list once and reuse during benchmark discovery.
set(_hecbench_skip_benchmarks "${HECBENCH_SKIP_BENCHMARKS}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I still don't see the motivation for this. If a user does not want to build all targets they can simply skip passing --target all. What you instead want might be a custom target. This could be created from a positive list instead. However, I would propose to avoid the regex approach.

CMakeLists.txt Outdated
else()
set(CMAKE_HIP_ARCHITECTURES "${HECBENCH_HIP_ARCH}")
endif()
find_package(HIP MODULE QUIET)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If HIP is enabled, and the below message states this, you don't want to silently fail on find_package(HIP) do you?

CMakeLists.txt Outdated
else()
message(WARNING "OpenMP requested but not found - OpenMP benchmarks will be skipped")
set(HECBENCH_ENABLE_OPENMP OFF)
message(STATUS "OpenMP enabled")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why is this dropped? This seems unrelated to your PR thus I'd suggest to not touch it.

CMakeLists.txt Outdated
include(CheckLanguage)
check_language(HIP)
if(CMAKE_HIP_COMPILER)
enable_language(HIP)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not adding HIP conditionally to LANGUAGES e.g. via project(LANGUAGES C CXX ${HIP_OPTIONAL}?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants