Skip to content

Commit 1b56fdc

Browse files
authored
ci: align relocatable package flow with RVS reference (#287)
* ci: align relocatable package flow with RVS reference Brings TransferBench's TheRock-SDK-based package build into closer parity with the ROCmValidationSuite reference flow: - CMakeLists.txt: auto-compute patch version from `git describe --tags --match v<MAJOR>.<MINOR>.*` (commits since the last matching tag), falling back to the hardcoded patch when no tag is reachable. No behavior change today since no v1.66.* tag exists yet; once one is created, builds become 1.66.<commits-since>. - CMakeLists.txt: move relocatable RPATH defaults out of build_packages_local.sh and into the BUILD_RELOCATABLE_PACKAGE block so plain `cmake -DBUILD_RELOCATABLE_PACKAGE=ON ..` produces the same RPATH as a packaged build. RPATH list now includes /opt/rocm/lib/llvm, /opt/rocm/core-<MAJOR>/lib, and the matching llvm path. - build_packages_local.sh: package release tag now follows the RVS format (`r<libpatch>.<yyyymmdd>` for default builds, `r<libpatch>.<yyyymmdd>.<src-branch>.<commit>` for PRs, GITHUB_RUN_NUMBER for release/* branches). UTC date captured once so long builds can't straddle midnight. Drops the over-permissive `rel*` prefix matcher. - build_packages_local.sh: drop the now-redundant -DCMAKE_INSTALL_RPATH / -DCMAKE_SKIP_RPATH / -DCMAKE_INSTALL_RPATH_USE_LINK_PATH flags (CMakeLists.txt is now the single source of truth). - docs/install/INSTALL_TGZ.rst: new user-facing TGZ install guide covering ROCm pre-install, runtime deps, extraction, PATH / LD_LIBRARY_PATH setup, and persistent profile.d configuration. - docs/install/install.rst: cross-link to the new TGZ doc. - README_BUILD_PACKAGES.md: replace the inline TGZ install snippet with a link to the new doc plus a minimal smoke test for CI maintainers. * docs: drop --help (does not exist on develop) for plain TransferBench Address @gilbertlee-amd review on PR #287: --help doesn't exist. In candidate we already introduce the "help" preset [...]. For CI moving forward, we likely want to use ./TransferBench smoketest. However, that's also in candidate branch still. On develop today, running TransferBench with no arguments prints version, usage, the available preset list, and the detected topology then exits 0 (Client.cpp:41 — `if (argc <= 1)` branch). That is a valid load-time smoke test for the binary. Replace `TransferBench --help` with `TransferBench` in: - .github/workflows/README_BUILD_PACKAGES.md (CI maintainer smoke test) - docs/install/INSTALL_TGZ.rst (end-user verify step) Add a forward-looking note in the README that once the `help` and `smoketest` presets graduate from candidate to develop, the smoke test should switch to `TransferBench smoketest`.
1 parent a76e516 commit 1b56fdc

5 files changed

Lines changed: 228 additions & 17 deletions

File tree

.github/workflows/README_BUILD_PACKAGES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,26 @@ sudo rpm -i --replacefiles --nodeps build/amdrocm7-transferbench-*.rpm
9393

9494
### Any Linux (TGZ — relocatable install tree, requires ROCm runtime on target)
9595

96+
End-user instructions (pre-install ROCm, runtime dependencies, extract,
97+
`PATH` / `LD_LIBRARY_PATH`, troubleshooting) live in the project docs at
98+
[docs/install/INSTALL_TGZ.rst](../../docs/install/INSTALL_TGZ.rst).
99+
100+
Quick smoke test from the repo root after a successful build:
101+
96102
```bash
97103
sudo mkdir -p /opt/rocm/extras-7
98104
sudo tar -xzf build/amdrocm7-transferbench-*.tar.gz -C /opt/rocm/extras-7 --strip-components=1
99105
export PATH=/opt/rocm/extras-7/bin:$PATH
106+
# With no args, TransferBench prints version, usage, available presets,
107+
# and detected topology — a fast end-to-end check that the binary loads
108+
# its ROCm libs correctly.
100109
TransferBench
101110
```
102111

112+
> Once the `help` and `smoketest` presets land on `develop` (currently on
113+
> `candidate`), prefer `TransferBench help` for usage and `TransferBench
114+
> smoketest` for a real correctness check.
115+
103116
## S3 upload (OIDC)
104117

105118
S3 upload runs only when:

CMakeLists.txt

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,41 @@ if (NOT CMAKE_TOOLCHAIN_FILE)
99
message(STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")
1010
endif()
1111

12-
set(VERSION_STRING "1.66.02")
12+
set(TRANSFERBENCH_VERSION_MAJOR 1)
13+
set(TRANSFERBENCH_VERSION_MINOR 66)
14+
set(TRANSFERBENCH_VERSION_PATCH_FALLBACK "02")
15+
16+
# Auto-compute patch from git: count commits since the last v<MAJOR>.<MINOR>.* tag.
17+
# Falls back to TRANSFERBENCH_VERSION_PATCH_FALLBACK when git is unavailable,
18+
# this is not a git checkout, or no matching tag exists. Mirrors the RVS flow.
19+
set(TRANSFERBENCH_VERSION_PATCH "${TRANSFERBENCH_VERSION_PATCH_FALLBACK}")
20+
find_package(Git QUIET)
21+
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
22+
execute_process(
23+
COMMAND "${GIT_EXECUTABLE}" describe --tags --abbrev=0 --match
24+
"v${TRANSFERBENCH_VERSION_MAJOR}.${TRANSFERBENCH_VERSION_MINOR}.*"
25+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
26+
OUTPUT_VARIABLE _tb_last_tag
27+
OUTPUT_STRIP_TRAILING_WHITESPACE
28+
RESULT_VARIABLE _tb_describe_rc
29+
ERROR_QUIET)
30+
if(_tb_describe_rc EQUAL 0 AND _tb_last_tag)
31+
execute_process(
32+
COMMAND "${GIT_EXECUTABLE}" rev-list --count "${_tb_last_tag}..HEAD"
33+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
34+
OUTPUT_VARIABLE _tb_commit_count
35+
OUTPUT_STRIP_TRAILING_WHITESPACE
36+
RESULT_VARIABLE _tb_count_rc
37+
ERROR_QUIET)
38+
if(_tb_count_rc EQUAL 0 AND _tb_commit_count MATCHES "^[0-9]+$")
39+
set(TRANSFERBENCH_VERSION_PATCH "${_tb_commit_count}")
40+
endif()
41+
endif()
42+
endif()
43+
44+
set(VERSION_STRING
45+
"${TRANSFERBENCH_VERSION_MAJOR}.${TRANSFERBENCH_VERSION_MINOR}.${TRANSFERBENCH_VERSION_PATCH}")
46+
message(STATUS "TransferBench version: ${VERSION_STRING}")
1347
project(TransferBench VERSION ${VERSION_STRING} LANGUAGES CXX)
1448

1549
## Load CMake modules
@@ -272,6 +306,22 @@ if(BUILD_RELOCATABLE_PACKAGE)
272306
set(ROCM_MAJOR_VERSION "7")
273307
endif()
274308

309+
# Relocatable RPATH (matches the RVS reference flow). Mirrors what
310+
# build_packages_local.sh used to inject via -DCMAKE_INSTALL_RPATH=, so
311+
# plain `cmake -DBUILD_RELOCATABLE_PACKAGE=ON ..` now produces the same
312+
# RPATH as a CI/packaged build.
313+
set(CMAKE_SKIP_RPATH FALSE)
314+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
315+
set(CMAKE_INSTALL_RPATH
316+
"\$ORIGIN:\$ORIGIN/../lib:/opt/rocm/extras-${ROCM_MAJOR_VERSION}/lib:/opt/rocm/lib:/opt/rocm/lib/llvm/lib:/opt/rocm/core-${ROCM_MAJOR_VERSION}/lib:/opt/rocm/core-${ROCM_MAJOR_VERSION}/lib/llvm/lib")
317+
set(CMAKE_BUILD_RPATH "${CMAKE_INSTALL_RPATH}")
318+
# Strip implicit SDK-from-build-host paths on install so the ephemeral
319+
# $HOME/rocm-sdk/install path the CI script uses does not leak into the
320+
# packaged binary's RPATH.
321+
if(NOT CMAKE_VERSION VERSION_LESS "3.16")
322+
set(CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH TRUE)
323+
endif()
324+
275325
install(TARGETS TransferBench RUNTIME DESTINATION bin COMPONENT devel)
276326

277327
set(CPACK_PACKAGE_NAME "amdrocm${ROCM_MAJOR_VERSION}-transferbench")

build_packages_local.sh

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,29 +167,38 @@ printf -v ROCM_LIBPATCH_VERSION '%02d%02d' "${ROCM_MAJOR}" "${ROCM_MINOR}"
167167
export ROCM_MAJOR ROCM_MINOR ROCM_LIBPATCH_VERSION
168168
log "ROCm major=${ROCM_MAJOR} minor=${ROCM_MINOR} libpatch=${ROCM_LIBPATCH_VERSION}"
169169

170-
# Package release string: branch.commit for dev, run_number for release branches
170+
# Package release string. Format mirrors the RVS reference flow:
171+
# default (push/schedule/dispatch/local): r<libpatch>.<yyyymmdd>
172+
# pull request: r<libpatch>.<yyyymmdd>.<src-branch>.<commit>
173+
# release/* branch (non-PR): ${GITHUB_RUN_NUMBER} (fallback 1)
171174
GIT_BRANCH="${GITHUB_REF_NAME:-$(git -C "${REPO_ROOT}" rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)}"
172175
GIT_COMMIT="$(git -C "${REPO_ROOT}" rev-parse --short HEAD 2>/dev/null || echo unknown)"
173-
if [[ "${GIT_BRANCH}" == rel* ]] || [[ "${GIT_BRANCH}" == release/* ]]; then
174-
PKG_RELEASE="${GITHUB_RUN_NUMBER}"
176+
BUILD_DATE_UTC="$(date -u +%Y%m%d)"
177+
178+
# Collapse non-alphanumerics into single dots and trim — DEB/RPM release
179+
# fields reject most punctuation.
180+
sanitize_release() {
181+
local s
182+
s="$(printf '%s' "$1" | sed -E 's/[^[:alnum:]]+/./g; s/^\.+//; s/\.+$//')"
183+
printf '%s' "${s:-unknown}"
184+
}
185+
186+
if [[ "${GITHUB_EVENT_NAME:-}" == "pull_request" ]]; then
187+
PR_BRANCH="$(sanitize_release "${GITHUB_HEAD_REF:-${GIT_BRANCH}}")"
188+
PKG_RELEASE="r${ROCM_LIBPATCH_VERSION}.${BUILD_DATE_UTC}.${PR_BRANCH}.${GIT_COMMIT}"
189+
elif [[ "${GIT_BRANCH}" == release/* ]]; then
190+
PKG_RELEASE="${GITHUB_RUN_NUMBER:-1}"
175191
else
176-
# Sanitize: DEB/RPM release fields disallow many punctuation chars.
177-
# Collapse anything that's not [A-Za-z0-9] into a single dot, then trim.
178-
SAFE_BRANCH="$(printf '%s' "${GIT_BRANCH}" | sed -E 's/[^[:alnum:]]+/./g; s/^\.+//; s/\.+$//')"
179-
SAFE_BRANCH="${SAFE_BRANCH:-unknown}"
180-
PKG_RELEASE="${SAFE_BRANCH}.${GIT_COMMIT}"
192+
PKG_RELEASE="r${ROCM_LIBPATCH_VERSION}.${BUILD_DATE_UTC}"
181193
fi
182194
export CPACK_DEBIAN_PACKAGE_RELEASE="${CPACK_DEBIAN_PACKAGE_RELEASE:-$PKG_RELEASE}"
183195
export CPACK_RPM_PACKAGE_RELEASE="${CPACK_RPM_PACKAGE_RELEASE:-$PKG_RELEASE}"
184196
log "Package release tag: ${PKG_RELEASE}"
185197

186198
# -------- configure --------
187199
INSTALL_PREFIX="/opt/rocm/extras-${ROCM_MAJOR}"
188-
# Relocatable RPATH: $ORIGIN-relative + install prefix + the conventional
189-
# install-time ROCm locations. Do NOT embed ${ROCM_PATH} (the ephemeral
190-
# build-time SDK download path) — that would leak CI paths into the
191-
# packaged binary and break relocatability.
192-
RPATH_LIST="\$ORIGIN:\$ORIGIN/../lib:${INSTALL_PREFIX}/lib:/opt/rocm/lib:/opt/rocm/lib64"
200+
# Relocatable RPATH defaults live in CMakeLists.txt under
201+
# if(BUILD_RELOCATABLE_PACKAGE); enabling that option below activates them.
193202

194203
log "Configuring CMake..."
195204
rm -rf "${BUILD_DIR}"
@@ -204,9 +213,6 @@ CMAKE_ARGS=(
204213
-DHIP_PLATFORM=amd
205214
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}"
206215
-DCPACK_PACKAGING_INSTALL_PREFIX="${INSTALL_PREFIX}"
207-
-DCMAKE_SKIP_RPATH=FALSE
208-
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE
209-
-DCMAKE_INSTALL_RPATH="${RPATH_LIST}"
210216
-DCMAKE_VERBOSE_MAKEFILE=ON
211217
-DBUILD_RELOCATABLE_PACKAGE=ON
212218
-DBUILD_LOCAL_GPU_TARGET_ONLY=OFF

docs/install/INSTALL_TGZ.rst

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
:orphan:
2+
3+
.. meta::
4+
:description: Install the relocatable TransferBench TGZ archive on any Linux distribution
5+
:keywords: TransferBench, TGZ, tarball, install, relocatable
6+
7+
.. _install-transferbench-tgz:
8+
9+
------------------------------------------------
10+
Installing TransferBench from the TGZ archive
11+
------------------------------------------------
12+
13+
The TransferBench TGZ archive (``amdrocm<MAJOR>-transferbench-*.tar.gz``) is a
14+
relocatable install tree that works on any Linux distribution where a
15+
compatible ROCm runtime is already present. Use it when you cannot or do not
16+
want to install the DEB or RPM package — for example on a distribution
17+
without a native ROCm package, or inside a non-root container.
18+
19+
The TGZ ships only the ``TransferBench`` binary and its supporting files. It
20+
does **not** bundle ROCm; the host system must already provide the ROCm
21+
runtime libraries (``hsa-rocr`` and the HIP runtime).
22+
23+
Pre-install: ROCm
24+
-----------------
25+
26+
Install ROCm on the target system before extracting the TGZ. Follow the
27+
official AMD documentation:
28+
29+
* `ROCm documentation <https://rocm.docs.amd.com/>`_
30+
* `Linux install guide <https://rocm.docs.amd.com/projects/install-on-linux/en/latest/>`_
31+
32+
After installing, ``ROCM_PATH`` (typically ``/opt/rocm``) must be set
33+
correctly and the ROCm libraries must be loadable by the dynamic linker.
34+
35+
Install runtime dependencies
36+
----------------------------
37+
38+
The DEB and RPM packages declare these runtime dependencies; TGZ users must
39+
install them manually on the target host.
40+
41+
.. list-table::
42+
:header-rows: 1
43+
:widths: 30 70
44+
45+
* - Family
46+
- Required packages
47+
* - Debian / Ubuntu
48+
- ``numactl``, ``libnuma1``, plus the ROCm runtime (``hsa-rocr``)
49+
* - RHEL / Rocky / AlmaLinux
50+
- ``numactl``, plus the ROCm runtime (``hsa-rocr``)
51+
52+
Install commands:
53+
54+
.. code-block:: bash
55+
56+
# Ubuntu / Debian
57+
sudo apt update && sudo apt install -y numactl libnuma1
58+
59+
# RHEL / Rocky / AlmaLinux
60+
sudo dnf install -y numactl
61+
62+
The ROCm packages (``hsa-rocr`` and friends) come from the ROCm repo
63+
configured in the pre-install step above.
64+
65+
Extract the TGZ
66+
---------------
67+
68+
Extract the archive into ``/opt/rocm/extras-<MAJOR>``, where ``<MAJOR>`` is
69+
the ROCm major version the package was built against (encoded in the package
70+
name, for example ``amdrocm7-transferbench-*.tar.gz`` → major ``7``).
71+
72+
.. code-block:: bash
73+
74+
# Example for ROCm major 7 — match your package
75+
sudo mkdir -p /opt/rocm/extras-7
76+
sudo tar -xzf amdrocm7-transferbench-*.tar.gz -C /opt/rocm/extras-7 --strip-components=1
77+
78+
The ``--strip-components=1`` option discards the top-level directory inside
79+
the tarball so files land directly under ``/opt/rocm/extras-7/{bin,lib,...}``.
80+
81+
Configure ``PATH`` and ``LD_LIBRARY_PATH``
82+
------------------------------------------
83+
84+
Point the shell at the extracted prefix and your ROCm install. Copy and paste
85+
the block as one unit (replace paths with your real ``ROCM_PATH`` and major
86+
version):
87+
88+
.. code-block:: bash
89+
90+
export ROCM_PATH=/opt/rocm # or your real ROCm root
91+
export PATH=/opt/rocm/extras-7/bin:$ROCM_PATH/bin:$PATH
92+
export LD_LIBRARY_PATH=/opt/rocm/extras-7/lib:$ROCM_PATH/lib:$ROCM_PATH/lib/llvm/lib:$LD_LIBRARY_PATH
93+
94+
The ``TransferBench`` binary embeds an ``RPATH`` covering ``$ORIGIN``,
95+
``$ORIGIN/../lib``, ``/opt/rocm/extras-<MAJOR>/lib``, ``/opt/rocm/lib``,
96+
``/opt/rocm/lib/llvm/lib``, ``/opt/rocm/core-<MAJOR>/lib``, and
97+
``/opt/rocm/core-<MAJOR>/lib/llvm/lib``. The ``LD_LIBRARY_PATH`` export above
98+
is mainly defensive — useful if your ROCm tree lives somewhere non-standard
99+
or if you want to override which copy of a library is loaded for
100+
troubleshooting.
101+
102+
Verify the install
103+
------------------
104+
105+
.. code-block:: bash
106+
107+
TransferBench
108+
109+
Run with no arguments, ``TransferBench`` prints its version, usage, the
110+
list of available preset benchmarks, and the detected GPU/CPU topology,
111+
then exits. Seeing that output confirms the binary loaded its ROCm
112+
libraries correctly.
113+
114+
If the binary fails to load a shared library, inspect:
115+
116+
.. code-block:: bash
117+
118+
ldd /opt/rocm/extras-7/bin/TransferBench
119+
readelf -d /opt/rocm/extras-7/bin/TransferBench | grep -E 'RPATH|RUNPATH'
120+
121+
Make a persistent shell setup
122+
-----------------------------
123+
124+
To avoid re-exporting every shell, drop the variables into a profile script:
125+
126+
.. code-block:: bash
127+
128+
sudo tee /etc/profile.d/transferbench.sh >/dev/null <<'EOF'
129+
export ROCM_PATH=/opt/rocm
130+
export PATH=/opt/rocm/extras-7/bin:$ROCM_PATH/bin:$PATH
131+
export LD_LIBRARY_PATH=/opt/rocm/extras-7/lib:$ROCM_PATH/lib:$ROCM_PATH/lib/llvm/lib:$LD_LIBRARY_PATH
132+
EOF
133+
sudo chmod 0644 /etc/profile.d/transferbench.sh
134+
135+
Log out and back in (or ``source /etc/profile.d/transferbench.sh``) for the
136+
changes to apply.

docs/install/install.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,9 @@ TransferBench looks for NVCC in ``/usr/local/cuda`` by default. To modify the lo
8383
.. code-block:: bash
8484
8585
CUDA_PATH=/usr/local/cuda make
86+
87+
Installing from the relocatable TGZ archive
88+
-------------------------------------------
89+
90+
If you want to install a pre-built TransferBench binary on a system where
91+
you cannot install the DEB or RPM package, see :ref:`install-transferbench-tgz`.

0 commit comments

Comments
 (0)