Skip to content

Makefile testing Add Makefile CI: configure-based dependency detection, build, and test - #442

Merged
sshi-amd merged 49 commits into
ROCm:amd-stagingfrom
sshi-amd:makefile-testing-v2
Apr 24, 2026
Merged

sshi-amd merged 49 commits into
ROCm:amd-stagingfrom
sshi-amd:makefile-testing-v2

Conversation

@sshi-amd

@sshi-amd sshi-amd commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Mirror of #441 with a different implementation approach. Adds a Makefile build path to CI alongside the existing CMake/CTest flow, so the standalone make workflow stays exercised on every commit.

Technical Details

A Scripts/configure.sh script probes the system for external libraries (FFmpeg, OpenCV, GLFW3, Vulkan, libdw, amd_comgr, glslangValidator) via pkg-config and link tests, then writes a config.mk at the repo root. Each leaf Makefile that has external dependencies declares them (REQUIRED_DEPS := GLFW3) and includes Common/require_deps.mk, which sets SKIP_BUILD := 1 when any required dependency is missing. Examples without external dependencies are unaffected.

This PR scope (PR1): configure + Make build only. The Make-native test target and dependency-aware skip mechanism are deferred to a follow-up PR per review feedback.

Added

  • Scripts/configure.sh — pkg-config + link-test probe for FFmpeg, OpenCV, GLFW3, Vulkan, libdw, amd_comgr, glslangValidator. Writes config.mk at repo root.
  • Common/require_deps.mk — leaf Makefiles declare REQUIRED_DEPS; build is skipped if any are missing. Has an inline pkg-config fallback so leaf Makefiles still work standalone without a prior configure.sh run.
  • Tools/ROCgdb/.gitignore — was missing entirely, allowed rocgdb-matmul to slip into the tree.

Modified

  • ~390 leaf Makefiles: 28 of them declare REQUIRED_DEPS and wrap their build rules in ifneq ($(SKIP_BUILD),1). The rest are unchanged in behaviour (touched only by the merge from upstream's ROCM_PATH rename).
  • Dockerfiles/almalinux-8.Dockerfile — adds pkgconf-pkg-config (was missing, so every pkg-config probe failed on AlmaLinux 8) and extends PKG_CONFIG_PATH to include /usr/local/lib(64)/pkgconfig for source-built FFmpeg / GLFW.
  • .github/workflows/build-rocm-examples-reusable.yml — adds a Makefile build step before CMake configure, plus separate "Collect Makefile build artifacts" / "Upload Makefile build artifacts" steps so Makefile-built binaries ship as their own artifact.
  • Makefile (root) — make configure shortcut that calls Scripts/configure.sh.
  • HIP-Doc/Programming-Guide/Porting-CUDA-code-to-HIP/identifying_host_device_compilation_pass/Makefile — fixed wrong EXAMPLE := (was hip_calling_global_functions, a copy-paste from a sibling; now matches its CMakeLists' example_name).
  • Per-directory .gitignore corrections in two warp_size_reduction dirs whose entries were swapped.

Removed

  • 5 previously committed build artifacts that had slipped past mismatched .gitignore entries: hip_template_warp_size_reduction, hip_warp_size_reduction, hip_calling_global_functions, graphgen, rocgdb-matmul.

Workflow changes

  • Adds: Makefile build, Collect Makefile build artifacts, Upload Makefile build artifacts.
  • The CMake configure / build / ctest steps are gated with if: !cancelled() so the CMake side still runs to completion if the Makefile build fails (for visibility).

Deferred to follow-up PR

  • Make-native test target on each leaf Makefile (depends on the build target; encodes test command, args, timeout).
  • Cascading make test from the root Makefile.
  • Directory-level skip list for the Make test runner (replaces the ctest-coupled approach from earlier iterations of this branch).

Test Plan

  • Latest CI run on this branch: https://github.com/sshi-amd/rocm-examples/actions/runs/24851555033
  • Tarball jobs (Ubuntu 22.04, AlmaLinux 8, SLES 15.7): Make build + CMake build + ctest all run; only failure is two upstream rccl tests (rccl_device_api, rccl_send_recv) that already fail on amd-staging.
  • Wheel jobs hit a known upstream rocDecode SDK mismatch (ROCDEC_ERR / TOSTR macros undefined) that affects both the CMake and Makefile build paths equally; not introduced by this PR.

Test Result

  • Tarball: Makefile build green on all three distros, ctest matches amd-staging baseline (same 2 rccl failures).
  • Wheel: Both build paths fail at the same upstream rocDecode source mismatch; CI noise is identical to what amd-staging produces on the same commit.

Added/Updated documentation?

  • Yes
  • No, does not apply to this PR.

Included Visual Studio files?

  • Yes
  • No, does not apply to this PR.

Submission Checklist

  • New examples contain proper CMake and Make files. (no new examples; existing Makefiles updated)
  • I have updated relevant CI workflows and the new examples are being built and tested in CI.
  • Check and guard against unsupported ASICs if relevant dependent libraries have limited support. (handled via REQUIRED_DEPS / SKIP_BUILD)
  • Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

sshi-amd and others added 30 commits March 11, 2026 18:13
Signed-off-by: zichguan-amd <zichuan.guan@amd.com>
(cherry picked from commit b185e37)
- Replace HIP_ARCHITECTURES (unused by individual example Makefiles) with
  CXXFLAGS="--offload-arch=..." which is how hipcc receives the target arch
- Add if: cancelled guard so Makefile build runs even when ctest fails,
  preventing test failures from masking Makefile build results

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace hardcoded `ROCM_INSTALL_DIR ?= /opt/rocm` with
`ROCM_INSTALL_DIR := $(or $(ROCM_PATH),/opt/rocm)` across all 378
leaf Makefiles. This allows TheRock CI to set ROCM_PATH in the
environment while preserving /opt/rocm as the default fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Makefile build unconditionally tried to compile all libraries,
failing when optional dependencies (rocALUTION, MIVisionX, rocAL,
hipTensor, MIGraphX, rocCV) aren't installed in the CI environment.
Add wildcard header checks to mirror the CMake find_package() behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add RPP to conditional header checks (rpp/rpp.h missing in wheel env)
- Skip rocProfiler-SDK openmp_target example when ENABLE_OPENMP=OFF
  (wheel installs lack amdllvm needed for OpenMP offloading)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Set HIPCC_COMPILE_FLAGS_APPEND env var in CI to ensure all hipcc
compilations target the correct GPU architecture. This fixes ~370 leaf
Makefiles that don't pass --offload-arch, without affecting g++/amdclang++
examples since only hipcc reads this env var.

Guard openmp_target behind an amdclang++ existence check so tarball
installs that lack amdclang++ don't fail the Makefile build.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Skip opengl_interop, vulkan_interop, and sobel_filter when glfw3/vulkan
pkg-config packages are not available. Guard rocDecode and rocJPEG behind
header existence checks, matching the pattern used for other optional
libraries like hipTensor, MIGraphX, and rocAL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pkg-config is not installed in SLES and AlmaLinux CI containers, causing
make to exit with code 2. Use $(wildcard ...) header detection instead,
matching the pattern already used in Libraries/Makefile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two failures in the Makefile build step:

1. rocDecode examples link against FFmpeg (-lavcodec, -lavformat,
   -lavutil) which is not installed in CI containers. The rocdecode
   header check alone is insufficient — also check for FFmpeg headers
   before including rocDecode in the build.

2. rocProfiler-SDK/code_object_tracing fails with undefined symbol
   pthread_join — add missing -lpthread to the link command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add configure.sh and Common/require_deps.mk to detect external
dependencies (FFmpeg, OpenCV, GLFW3, Vulkan, glslangValidator) before
build. Each leaf Makefile declares REQUIRED_DEPS and cleanly skips when
dependencies are missing, preventing link-time failures in CI.

- configure.sh: probes deps via pkg-config with fallbacks, writes config.mk
- require_deps.mk: checks REQUIRED_DEPS, sets SKIP_BUILD=1 if unmet
- run_makefile_tests.sh: finds and runs Makefile-built executables with
  timeout and skip-file support
- Update 27 leaf Makefiles (rocDecode, rocCV, RPP, opengl/vulkan_interop,
  sobel_filter) to use the new dependency gating
- Remove FFmpeg guard from Libraries/Makefile (let leaves decide)
- Update CI workflow: run configure.sh before make, run Makefile tests
  before CMake build
- Fix rocProfiler-SDK/code_object_tracing: add -lpthread to ILDLIBS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The code_object_isa_decode example links -ldw and -lamd_comgr which
are not available in all CI containers (e.g. AlmaLinux). Add LIBDW
and AMD_COMGR to the configure detection system and skip the example
when either is missing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show (N/total) counter for each test like ctest does, e.g.:
  (1/42) RUN     hip_device_query
  (1/42) PASS    hip_device_query
  (2/42) SKIP    rccl_allgather

Also print total test count and skip file info upfront, and show
a single summary line at the end.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Run each test from its own directory so data files (test.jpg,
  graph4096.txt, etc.) are found via relative paths
- Support TEST_ARGS variable in Makefiles for tests needing arguments
  (e.g. hip_bfs requires graph4096.txt as input)
- Add AlmaLinux 8 skip entries for GLIBC_2.34 incompatible binaries
  (warp_size_reduction) and missing hipSPARSELt Tensile libraries

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Only run Makefile-built tests that are also registered as ctest tests.
This ensures the Makefile test runner exercises exactly the same set of
examples that CMake validates, avoiding failures from examples that
need special arguments, scripts, or aren't meant to run standalone.

- Add --allow-file option to run_makefile_tests.sh: filters Makefile
  executables to only those present in the allow list
- Move Makefile tests step after ctest in CI workflow
- Extract ctest test names via `ctest -N` and pass as the allow file

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rocdecode_rocdec_decode requires -i <frames_dir> which is only
available via ROCDECODE_TEST_FRAMES_DIR set during CMake configure.
Add a MAKEFILE_SKIP_TESTS list to generate_skip_tests.py and a
--makefile flag to include these skips. The CI Makefile tests step
now regenerates the skip list with --makefile before running.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On SLES 15.7 the FFmpeg development headers exist at
/usr/include/libavcodec/avcodec.h but the shared libraries are not
installed, causing link failures. The header-only fallback in both
configure.sh and require_deps.mk now also verifies the library is
in ldconfig before reporting the dependency as available.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The header-only fallback (checking /usr/include for headers) causes
false positives on SLES where dev headers exist but libraries don't.
Rely solely on pkg-config, which only succeeds when dev packages are
properly installed with both headers and linkable libraries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…add -lstdc++fs

rocdec_decode had inline pkg-config FFmpeg detection that bypassed the
configure system. On SLES, pkg-config found .pc files but libraries
couldn't actually be linked. Now uses HAVE_FFMPEG from config.mk/
require_deps.mk instead.

Also adds -lstdc++fs to rocdec_decode and video_to_sequence for
std::experimental::filesystem symbols needed on older toolchains.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ev packages

On SLES, FFmpeg .pc files exist (runtime packages) but the actual
libraries cannot be linked (-dev packages missing). pkg-config --exists
succeeds but linking fails. Now both configure.sh and the require_deps.mk
fallback verify that pkg-config libraries can actually be linked by
compiling a trivial C program with the reported -l flags.

Also integrates rocdec_decode with the configure system (HAVE_FFMPEG)
instead of its own inline pkg-config detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The SLES wheel containers may not have cc/gcc. Try multiple compilers
in order, including the ROCm-bundled clang as last resort. If no
compiler is found, conservatively report the dependency as missing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…format/-lavutil

On SLES tarball, FFmpeg is installed under /usr/local/lib. pkg-config
returns -L/usr/local/lib along with the -l flags, but the Makefiles
were hardcoding just -lavcodec -lavformat -lavutil without the -L path.
The ROCm linker (ld.lld) doesn't search /usr/local/lib by default, so
linking failed. Now all 8 rocDecode Makefiles use $(FFMPEG_LIBS) which
includes the correct -L path from pkg-config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace `ctest -N` + grep/sed (which listed *registered* tests) with
`ctest --output-junit` + a Python script that parses the JUnit XML to
extract tests that ctest *actually ran*. This ensures true parity
between CMake and Makefile test sets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ails)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sshi-amd and others added 5 commits March 24, 2026 15:04
- Move Test summary step after Makefile tests so it covers both
- Add CMake and Makefile test results to the GitHub step summary
- Upload Makefile test output as a separate artifact
- Remove duplicate skipped-tests output from ctest step (now in summary)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collect Makefile-built executables into a staging directory and upload
them as a separate artifact, matching the CMake build artifact upload.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ensures subsequent steps (CMake, tests, uploads) still run even if the
Makefile build fails, while still marking the workflow as failed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move CMake and Makefile build uploads to the same location, after both
CMake and Makefile builds finish, so artifacts are logically grouped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sshi-amd
sshi-amd requested review from a team as code owners March 24, 2026 20:46

@zichguan-amd zichguan-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry for the late review, here's some general comment:

  1. copyright year should be 2026
  2. let's remove the ctest-related script and logic
  3. some binary files are included in the PR, please remove that and check if gitignore is properly configured
  4. scripts should be in the Scripts folder

As of testing design, it would be great if we can keep the Make testing independent of ctest. The configuration logics for dependency detection is great, just need to decouple the testing part. So, I'm more leaning toward this PR than the other approach. What I'm looking for is:

  1. leaf Makefiles should be runnable standalone
  2. CI only orchestrates, testing logic should be handled by Make (test command, args, timeout, etc)

This PR is good with 1. For number 2, we could require a test target that depends on the build target for each leaf Makefile and cascade the test target from root level so that we can simply run make test to build and run the tests. Test target can be a no-op for targets that don't build.
For skipping tests, I'm not sure if it's easy to do within Make, but we could have a list of directories to skip and only build & test others at leaf Makefile level by iterating through Makefiles.

Lemme know what you think and we can discuss offline. This might be too many changes. We can get the configure and build part merged in first due to time constraints.

@sshi-amd

Copy link
Copy Markdown
Contributor Author

Sounds good, going to attempt to implement the changes today. Let's hope its not too challenging so that I may finish before my term ends. I'll make sure to update EOD.

@zichguan-amd

Copy link
Copy Markdown
Collaborator

Lemme know if you need any help, really want to get this merged for you even if it's only partial solution.

- Bump copyright 2025 -> 2026 in new files (Scripts/configure.sh,
  Common/require_deps.mk).
- Remove committed build artifacts (hip_template_warp_size_reduction,
  hip_warp_size_reduction, hip_calling_global_functions, graphgen,
  rocgdb-matmul) and fix the per-directory .gitignore entries that
  were missing or named the wrong binary, allowing those files to be
  committed. Adds Tools/ROCgdb/.gitignore.
- Move configure.sh -> Scripts/configure.sh; update root Makefile
  configure target and CI workflow path. Script now writes config.mk
  to the repo root regardless of its own location.
- Strip the ctest-coupled Makefile testing layer:
  - Delete run_makefile_tests.sh and
    .github/build_tools/parse_ctest_results.py.
  - Revert .github/build_tools/generate_skip_tests.py to amd-staging
    (drops MAKEFILE_SKIP_TESTS / --makefile flag).
  - Drop "Makefile tests" and "Upload Makefile test logs" workflow
    steps; revert Test summary to the amd-staging form.
  - The Makefile build, artifact collection, and Makefile-build
    artifact upload steps are kept.
- Drop the unused TEST_ARGS line from
  HIP-Doc/Tutorials/Programming-Patterns/bfs/Makefile.

Make-native test target and dependency-aware skip mechanism are
deferred to a follow-up PR.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
sshi-amd and others added 2 commits April 23, 2026 14:14
- Workflow "Collect Makefile build artifacts" step was exiting 1 on the
  very first parent Makefile (e.g. ./Makefile, ./Applications/Makefile)
  that doesn't declare EXAMPLE :=. Under bash --noprofile --norc -e -o
  pipefail, grep returning 1 (no match) propagated through the
  pipeline in $(...), and set -e killed the script before any leaf
  binary was copied. Append || true so the assignment yields an empty
  example_name and the iteration is skipped, letting the loop continue.
- AlmaLinux 8 Dockerfile was missing pkg-config, so Scripts/configure.sh
  couldn't detect FFmpeg/OpenCV/GLFW3/Vulkan via pkg-config and every
  REQUIRED_DEPS check failed. Added pkgconf-pkg-config to the dnf
  install list and extended PKG_CONFIG_PATH with /usr/local/lib(64)/
  pkgconfig so source-built FFmpeg and GLFW are discovered.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Resolves 378 leaf-Makefile conflicts produced by upstream PR ROCm#440 which
renamed ROCM_INSTALL_DIR -> ROCM_PATH and changed the assignment style
from `:=` with `$(or ...)` to `?=`. Every conflict block was identical
in shape, so the resolution is uniform: take upstream's ROCM_PATH form.

Additional follow-up renames not covered by upstream's PR:
- Common/require_deps.mk: rename internal ROCM_INSTALL_DIR -> ROCM_PATH
  in the amd_comgr fallback detection block.
- Libraries/Makefile: same rename in the parent dispatch Makefile.
- .github/workflows/build-rocm-examples-reusable.yml: drop redundant
  `ROCM_INSTALL_DIR=${ROCM_PATH}` env exports and the
  `make ROCM_INSTALL_DIR=...` argument; ROCM_PATH is already exported
  in the env and consumed directly by the leaf Makefiles.

REQUIRED_DEPS / SKIP_BUILD wrappers added by this branch are preserved
unchanged where they auto-merged cleanly.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@sshi-amd
sshi-amd requested a review from zichguan-amd April 23, 2026 20:47

@zichguan-amd zichguan-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Otherwise LGTM

Comment thread README.md Resolved
sshi-amd and others added 2 commits April 23, 2026 17:00
…kefile

The Makefile declared EXAMPLE := hip_calling_global_functions (a copy-paste
from the sibling example), so `make` produced a binary with the wrong name
and the directory's correct .gitignore (hip_identifying_host_device_compilation_pass)
didn't match it — which is how the binary slipped into git in the first place.

An earlier cleanup commit on this branch flipped .gitignore to match the
broken Makefile name; reverting that and fixing the Makefile to match the
CMakeLists' example_name (hip_identifying_host_device_compilation_pass)
instead. Per review feedback from @zichguan-amd.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@sshi-amd
sshi-amd requested a review from zichguan-amd April 23, 2026 21:06
@sshi-amd

Copy link
Copy Markdown
Contributor Author

Updated the PR description (part 1 of 2 PRs for testing)

@zichguan-amd zichguan-amd left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Fix the linting and CI failure for Makefile build and this can be merged. Thanks!

@zichguan-amd

Copy link
Copy Markdown
Collaborator

Couple tests failing with hipcc not found

2026-04-23T21:06:30.2684138Z make[2]: *** [Makefile:50: rocgdb-matmul] Error 127
2026-04-23T21:06:30.2684449Z make[1]: *** [Makefile:39: ROCgdb] Error 2
2026-04-23T21:06:30.2684745Z make[1]: *** Waiting for unfinished jobs....
2026-04-23T21:06:30.2685064Z make[4]: /opt/rocm/bin/hipcc: Command not found
2026-04-23T21:06:30.2685493Z make[4]: /opt/rocm/bin/hipcc: Command not found
2026-04-23T21:06:30.2685822Z make[4]: *** [Makefile:54: hip_image_convolution] Error 127
2026-04-23T21:06:30.2686187Z make[4]: *** [Makefile:54: hip_histogram_atomics] Error 127
2026-04-23T21:06:30.2686514Z make[4]: /opt/rocm/bin/hipcc: Command not found
2026-04-23T21:06:30.2686853Z make[4]: *** [Makefile:63: hip_bfs] Error 127
2026-04-23T21:06:30.2687153Z make[4]: /opt/rocm/bin/hipcc: Command not found
2026-04-23T21:06:30.2687454Z make[3]: *** [Makefile:36: bfs] Error 2
2026-04-23T21:06:30.2687757Z make[3]: *** Waiting for unfinished jobs....
2026-04-23T21:06:30.2688085Z make[3]: *** [Makefile:36: histogram_atomics] Error 2
2026-04-23T21:06:30.2688427Z make[3]: *** [Makefile:36: image_convolution] Error 2
2026-04-23T21:06:30.2688756Z make[4]: *** [Makefile:54: hip_kmeans] Error 127
2026-04-23T21:06:30.2689074Z make[3]: /opt/rocm/bin/hipcc: Command not found
2026-04-23T21:06:30.2689418Z make[3]: *** [Makefile:57: rccl_allgather] Error 127

Some ROCM_PATH change might have been missed

sshi-amd and others added 4 commits April 23, 2026 17:49
These leaf Makefiles were missed by upstream PR ROCm#440 (which renamed
ROCM_INSTALL_DIR -> ROCM_PATH and switched := to ?= for env override
support). They kept `ROCM_PATH := /opt/rocm` (hard assignment), so
the CI's exported ROCM_PATH=/therock-tarball/install was overridden
back to /opt/rocm and the build invoked /opt/rocm/bin/hipcc which
doesn't exist in the runner container, surfacing as:

  make[2]: /opt/rocm/bin/hipcc: Command not found
  make[1]: *** [Makefile:39: ROCgdb] Error 2

Affected categories: HIP-Doc/Tutorials/Programming-Patterns (bfs,
histogram_atomics, image_convolution, kmeans, matrix_multiplication),
Libraries/{MIGraphX, MIVisionX, RCCL, RPP, rocAL, rocCV, rocJPEG,
hipBLASLt/gemm_clamp_bias}, Tools/ROCgdb.

Bulk-replaced with `?= /opt/rocm` so ROCM_PATH from env wins. Same
fix that upstream PR ROCm#440 applied to the rest of the tree.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Markdown lint (markdownlint-cli2) caught one MD012/no-multiple-blanks
violation at README.md:63 introduced by the previous documentation
update. Collapse to a single blank line.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Missed by the previous sweep because this Makefile uses
`ROCM_PATH   := /opt/rocm` (multiple spaces around :=) instead of
the single-space form the grep pattern was matching.

Same problem as the prior 48-file fix: hard `:=` assignment
overrode the env-provided ROCM_PATH=/therock-tarball/install in CI,
so the build invoked /opt/rocm/bin/hipcc which doesn't exist.

Verified no other variants remain via lenient regex:
  grep -nE '^ROCM_PATH[[:space:]]*:=[[:space:]]*/' '*/Makefile'

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
SLES 15.7 ships GCC 7.5 by default; std::experimental::filesystem
implementation lives in a separate libstdc++fs there, so linking
rocDecode examples that use it (directly or via the shared
roc_video_dec.cpp from the SDK) needs an extra -lstdc++fs flag.
Ubuntu 22.04 (GCC 11) and AlmaLinux 8 (gcc-toolset-13) have it
in libstdc++ proper and don't need the flag.

Mirrors what Common/FindFilesystem.cmake does for the CMake build:
probe with the system C++ compiler, set CXX_FS_LIB to either
"-lstdc++fs" or empty depending on what links cleanly.

Apply uniformly to all 10 rocDecode leaf Makefiles. Replaces the
prior one-off `-lstdc++fs` literal in video_decode_batch/Makefile
(commit 66e13e6e8) so all rocDecode leaves use the same probe.

Surfaced by SLES tarball CI failures on PR ROCm#442:
  ld.lld: error: undefined symbol: std::experimental::filesystem::
  v1::__cxx11::directory_iterator::directory_iterator(...)

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@sshi-amd
sshi-amd merged commit 0062ec4 into ROCm:amd-staging Apr 24, 2026
41 of 55 checks passed
sshi-amd added a commit to sshi-amd/rocm-examples that referenced this pull request Apr 24, 2026
Closes the testing half of the Make-build CI work that was deferred from
PR1 (ROCm#442). With this commit `make test` from the repo root builds and
runs every leaf example that registered an add_test in CMake, matching
the existing CMake/CTest coverage. CI just orchestrates; all test
command/args/timeout logic lives in the Makefiles.

Per mentor (@zichguan-amd) design:

- Each leaf Makefile gains a `test:` target depending on its build target.
  Default invocation: `./$(EXAMPLE) $(TEST_ARGS)`. Most leaves set no args.
- bfs sets `TEST_ARGS := graph4096.txt` (mirrors its CMake add_test).
- Leaves whose CMakeLists has no add_test() get an empty no-op `test:`
  (HIP-Basic/{opengl_interop,vulkan_interop,static_device_library} and
  Libraries/MIVisionX/{canny,mv_objdetect,opencv_orb} and three rocDecode
  examples that don't register).
- REQUIRED_DEPS leaves (~28) extend their existing SKIP_BUILD `else`
  no-op block with `test:` alongside `all:`/`clean:`.

Cascade: each parent Makefile (root + ~80 intermediates) declares
`SKIP_FROM_TEST :=` and:

    test: TARGET=test
    test: $(filter-out $(SKIP_FROM_TEST),$(EXAMPLES))

So `make test` cascades through the tree, skipping any subdirs the
parent has explicitly excluded.

`Libraries/rocDecode/Makefile` populates `SKIP_FROM_TEST := $(EXAMPLES)`:
all rocDecode examples need test data (videos under
`$(ROCM_PATH)/share/rocdecode/`) that ctest currently guards behind
`if(EXISTS …)` checks. Encoding that conditional logic in Make is doable
but noisy; deferring to a follow-up. The leaf rocDecode Makefiles still
have working `test:` targets so they can be run standalone via
`cd Libraries/rocDecode/<example> && make test`.

Out of scope (per plan, can land later):

- Per-GPU-arch test skipping (`generate_skip_tests.py` is still used by
  the existing ctest step; PR2's per-directory `SKIP_FROM_TEST` is
  coarser).
- Reduction tutorial gtest binaries (`Tutorials/reduction/test/*.hip`)
  — no Makefile builds them today.

Workflow: adds `Makefile test` step after the existing test steps and
`Upload Makefile test logs` artifact upload. Both gated with
`if: !cancelled()` to mirror the rest of the test-side steps.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
sshi-amd added a commit that referenced this pull request Apr 24, 2026
* Add Make-native `test` target across all examples

Closes the testing half of the Make-build CI work that was deferred from
PR1 (#442). With this commit `make test` from the repo root builds and
runs every leaf example that registered an add_test in CMake, matching
the existing CMake/CTest coverage. CI just orchestrates; all test
command/args/timeout logic lives in the Makefiles.

Per mentor (@zichguan-amd) design:

- Each leaf Makefile gains a `test:` target depending on its build target.
  Default invocation: `./$(EXAMPLE) $(TEST_ARGS)`. Most leaves set no args.
- bfs sets `TEST_ARGS := graph4096.txt` (mirrors its CMake add_test).
- Leaves whose CMakeLists has no add_test() get an empty no-op `test:`
  (HIP-Basic/{opengl_interop,vulkan_interop,static_device_library} and
  Libraries/MIVisionX/{canny,mv_objdetect,opencv_orb} and three rocDecode
  examples that don't register).
- REQUIRED_DEPS leaves (~28) extend their existing SKIP_BUILD `else`
  no-op block with `test:` alongside `all:`/`clean:`.

Cascade: each parent Makefile (root + ~80 intermediates) declares
`SKIP_FROM_TEST :=` and:

    test: TARGET=test
    test: $(filter-out $(SKIP_FROM_TEST),$(EXAMPLES))

So `make test` cascades through the tree, skipping any subdirs the
parent has explicitly excluded.

`Libraries/rocDecode/Makefile` populates `SKIP_FROM_TEST := $(EXAMPLES)`:
all rocDecode examples need test data (videos under
`$(ROCM_PATH)/share/rocdecode/`) that ctest currently guards behind
`if(EXISTS …)` checks. Encoding that conditional logic in Make is doable
but noisy; deferring to a follow-up. The leaf rocDecode Makefiles still
have working `test:` targets so they can be run standalone via
`cd Libraries/rocDecode/<example> && make test`.

Out of scope (per plan, can land later):

- Per-GPU-arch test skipping (`generate_skip_tests.py` is still used by
  the existing ctest step; PR2's per-directory `SKIP_FROM_TEST` is
  coarser).
- Reduction tutorial gtest binaries (`Tutorials/reduction/test/*.hip`)
  — no Makefile builds them today.

Workflow: adds `Makefile test` step after the existing test steps and
`Upload Makefile test logs` artifact upload. Both gated with
`if: !cancelled()` to mirror the rest of the test-side steps.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Convert 19 remaining hard-coded -lstdc++fs to find_filesystem.mk probe

Same conversion as the rocDecode leaves: replace literal `-lstdc++fs`
with `$(CXX_FS_LIB)` and include `Common/find_filesystem.mk`. Keeps
all leaves consistent and surfaces what's actually needed via probe
rather than blanket-adding the flag everywhere.

Affected:
- Applications/fdtd
- HIP-Basic/module_api
- HIP-Doc/.../linker_apis_file
- Libraries/rocJPEG/{rocjpeg_decode, rocjpeg_decode_batched, rocjpeg_decode_perf}
- Libraries/rocProfiler-SDK/{api_buffered_tracing, code_object_isa_decode,
  code_object_tracing, external_correlation_id_request, intercept_table,
  openmp_target, pc_sampling, thread_trace,
  counter_collection/{buffer, buffer_device_serialization, device_profiling,
                      device_profiling_sync, print_functional_counters}}

These currently work on all three CI distros (libstdc++fs is available
as either a stub or the real lib), so this is hygiene rather than a
bug fix. Aligns with the rocDecode probe conversion in the parent
Make-test-target commit.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Fix two PR2 bugs surfaced by latest CI run

1. linker_apis_file/Makefile was missing COMMON_INCLUDE_DIR. The
   prior hygiene cleanup (commit converting hard-coded -lstdc++fs to
   the Common/find_filesystem.mk probe) added an `include
   $(COMMON_INCLUDE_DIR)/find_filesystem.mk` line, but this leaf
   never defined COMMON_INCLUDE_DIR (its example doesn't reference
   any common headers). The include silently failed, make exited 2,
   parent cascade reported `Error 2`. Add the missing definition.

2. Workflow "Makefile test" step now passes
   HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" so leaf
   Makefiles using it (e.g. assembly_to_executable's multi-arch
   build) target only the matrix's arch instead of falling back
   to their full hardcoded default list. Without this, the
   `--cuda-device-only -S --offload-arch=<X>` recipe collided
   with CI's HIPCC_COMPILE_FLAGS_APPEND=--offload-arch=gfx1100
   env, producing two `--offload-arch` flags and:
     clang++: error: cannot specify -o when generating multiple
              output files

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Fix HIP-Graphs/Makefile orphaned EXAMPLES continuation

The PR2 parent-Makefile updater script regex didn't account for
trailing whitespace on the last line of the EXAMPLES continuation
in the original (`  graph_creation   \n`), so the regex stopped
matching after `graph_capture \` and inserted SKIP_FROM_TEST in
the middle of the multi-line assignment. Result:

  EXAMPLES := \
    graph_capture \

  SKIP_FROM_TEST :=
    graph_creation       ← orphaned, "missing separator" at line 27

Restore the continuation so EXAMPLES contains both children.
HIP-Graphs is the only Makefile that hit this — verified with
`make -n` from each parent: 0 syntax errors tree-wide.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* rocDecode: align Make `test` recipes with ctest invocations

For the 7 rocDecode leaves whose CMake `add_test` actually passes
positional args, replace the bare `./$(EXAMPLE) $(TEST_ARGS)` template
with custom recipes that mirror ctest exactly:

- Single-variant leaves (rocdec_decode, video_decode_mem,
  video_decode_perf, video_decode_batch): probe `[ -e <test data> ]`
  and skip cleanly with a "Skipping (not found)" message if the
  ctest data path doesn't exist, mirroring CMake's `if(EXISTS …)`
  register-time guard. Otherwise run the binary with the same
  `-i <path>` (and `-t 2` for batch) ctest passes.
- Multi-variant leaves: ctest registers one test per codec.
  - video_decode      → HEVC, AVC, AV1, VP9 mp4
  - video_decode_raw  → HEVC, AVC, AV1, VP9 raw bitstreams
  - video_decode_rgb  → default + `-resize 640x360`
  Recipe loops through every variant ctest registers, runs each one
  whose input file exists, skips the rest, and returns the worst
  exit code (so a failing AVC doesn't mask a failing AV1 the way
  fail-fast `&&` would).

Per @zichguan-amd review feedback that "TEST_ARGS might need to be
aligned with ctest". TEST_ARGS as a single-string knob doesn't map
cleanly to multi-variant ctest tests; a custom recipe with `$(ROCM_PATH)`
deferred-expanded at use time is the closer parity.

These 7 leaves are still parent-skipped via Libraries/rocDecode/
Makefile's `SKIP_FROM_TEST := $(EXAMPLES)` so the root `make test`
cascade doesn't try them in CI. They become useful when run
standalone (`cd Libraries/rocDecode/<example> && make test`) on a
machine with the rocDecode test data installed under
`$(ROCM_PATH)/share/rocdecode/`.

README also gains a short paragraph documenting the env / CLI
override pattern (`TEST_ARGS=foo make test`).

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* README: drop `$` prefix from shell examples (MD014)

markdownlint-cli2 MD014/commands-show-output was firing on the
two TEST_ARGS override examples introduced in the prior commit:

  $ make test TEST_ARGS="--size=8192 --verbose"
  $ TEST_ARGS="-i /path/to/video.mp4" make test

The `$` prompt prefix is meant for examples that show command
output; for bare invocations it's just noise that markdownlint
flags. Drop it.

The earlier `$` prefixes (lines 56-58, the git/cd/configure
chain) are inside bullet list items and aren't flagged.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
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.

3 participants