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
23 changes: 23 additions & 0 deletions emulation/rocjitsu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ HIP kernel tests and RCCL daemon tests require an ROCm installation.
They are disabled automatically when `hipcc` or `libhsa-runtime64` is
not found.

Floating-point mode tests run in 16 batches to share process startup and
GoogleTest registration. Per-case fixtures and assertions are unchanged.
Run all batches with:

```bash
ctest --test-dir build -L '^fp-mode$' --output-on-failure
```

Each batch writes per-case GoogleTest results under `build/tests/gtest-results/`.
Installed tests use the same batches and write results under `gtest-results/`
in the installed test directory. The launcher removes each batch's previous XML
before starting GoogleTest to avoid stale results after a crash or timeout.
Cleanup errors fail the batch before GoogleTest starts.
If the launcher cannot start or finish cleanup, an older report may remain;
use CTest's status alongside the XML.
CTest batches ignore an inherited `GTEST_FILTER` and suppress passing-case output;
failure diagnostics and per-case XML are retained. To select individual cases or
a family, run the dedicated executable with a GoogleTest filter:

```bash
build/tests/rocjitsu_fp_mode_tests --gtest_filter='BinaryF32/ValuFpModeTest.*'
```

## Running HIP workloads

```bash
Expand Down
32 changes: 32 additions & 0 deletions emulation/rocjitsu/cmake/rj_run_gtest_shard.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2026 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.22)

foreach(_required IN ITEMS TEST_EXECUTABLE TEST_OUTPUT_FILE)
if(NOT DEFINED ${_required} OR "${${_required}}" STREQUAL "")
message(FATAL_ERROR "${_required} is required")
endif()
endforeach()

# GoogleTest writes XML only when the batch finishes. Clear the old report before
# starting the test process.
get_filename_component(TEST_OUTPUT_FILE "${TEST_OUTPUT_FILE}" ABSOLUTE)
get_filename_component(_output_dir "${TEST_OUTPUT_FILE}" DIRECTORY)
file(MAKE_DIRECTORY "${_output_dir}")
# EXISTS and rm -f can mistake inaccessible paths for missing files. TOUCH fails
# on access errors and lets non-forced rm handle an initially absent report.
if(NOT EXISTS "${TEST_OUTPUT_FILE}" AND NOT IS_SYMLINK "${TEST_OUTPUT_FILE}")
file(TOUCH "${TEST_OUTPUT_FILE}")
endif()
execute_process(
COMMAND "${CMAKE_COMMAND}" -E rm -- "${TEST_OUTPUT_FILE}"
COMMAND_ERROR_IS_FATAL ANY
)

execute_process(
COMMAND
"${TEST_EXECUTABLE}" "--gtest_filter=*" --gtest_brief=1
"--gtest_output=xml:${TEST_OUTPUT_FILE}"
COMMAND_ERROR_IS_FATAL ANY
)
50 changes: 48 additions & 2 deletions emulation/rocjitsu/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ if(RJ_INSTALL_TESTS)

install(FILES "${RJ_INSTALL_CTEST_FILE}" DESTINATION ${RJ_INSTALL_TEST_DIR})
install(
FILES "${PROJECT_SOURCE_DIR}/cmake/rj_run_filtered_gtest.cmake"
FILES
"${PROJECT_SOURCE_DIR}/cmake/rj_run_filtered_gtest.cmake"
"${PROJECT_SOURCE_DIR}/cmake/rj_run_gtest_shard.cmake"
DESTINATION ${RJ_INSTALL_TEST_DIR}
)
install(
Expand Down Expand Up @@ -656,7 +658,6 @@ add_executable(
atomic_semantics_and_decode_test.cpp
isa_target_registry_test.cpp
pseudo_scalar_exec_test.cpp
valu_fp_mode_test.cpp
scalar_scc_test.cpp
vskip_test.cpp
cdna3_predicate_mask_test.cpp
Expand Down Expand Up @@ -850,6 +851,51 @@ rj_add_gtest_tests(
"-*Benchmark*:*RequestExitWakesAllPartitions*:*DispatchedWaitSurvivesAConcurrentFinalClose*:*EffectiveConfigTest.ReadsNativeLaunchConfigHandoff"
)

# GoogleTest registers every parameter before applying its filter. Keep the FP
# matrices in their own executable so unrelated tests do not pay that cost.
add_executable(rocjitsu_fp_mode_tests valu_fp_mode_test.cpp)
target_link_libraries(
rocjitsu_fp_mode_tests
PRIVATE
${RJ_OBJECT_LIBS}
util
flatbuffers
Threads::Threads
GTest::gtest_main
)
rj_configure_target(rocjitsu_fp_mode_tests TEST)
if(RJ_INSTALL_TESTS)
rj_install_test_target(rocjitsu_fp_mode_tests)
endif()

# Batching amortizes registration, and GoogleTest assigns new cases to shards
# automatically without maintaining per-case filters.
set(_rj_fp_mode_shards 16)
math(EXPR _rj_fp_mode_last_shard "${_rj_fp_mode_shards} - 1")
foreach(_shard RANGE 0 ${_rj_fp_mode_last_shard})
set(_shard_env
"GTEST_TOTAL_SHARDS=${_rj_fp_mode_shards}"
"GTEST_SHARD_INDEX=${_shard}"
)
set(_shard_output "gtest-results/rocjitsu_fp_mode_${_shard}.xml")
rj_add_test(
NAME "ValuFpModeTest.Shard${_shard}"
COMMAND
"${CMAKE_COMMAND}"
"-DTEST_EXECUTABLE=$<TARGET_FILE:rocjitsu_fp_mode_tests>"
"-DTEST_OUTPUT_FILE=${_shard_output}" -P
"${PROJECT_SOURCE_DIR}/cmake/rj_run_gtest_shard.cmake"
ENVIRONMENT ${_shard_env}
INSTALL_COMMAND
"${CMAKE_COMMAND}"
"-DTEST_EXECUTABLE=bin/rocjitsu_fp_mode_tests"
"-DTEST_OUTPUT_FILE=${_shard_output}" -P
"rj_run_gtest_shard.cmake"
INSTALL_ENVIRONMENT ${_shard_env}
LABELS fp-mode
)
endforeach()

# RequestExitWakesAllPartitions may require several runs to show regression
# (deadlock). Run 30 times with a 10 second timeout to boost chances of seeing
# the failures. Usually fails within the first 5 times and 30 passing tests
Expand Down
Loading