Skip to content

Adding TBB to sysdeps#4410

Open
ajanicijamd wants to merge 25 commits intomainfrom
users/ajanicijamd/therock-add-tbb-to-sysdeps-2
Open

Adding TBB to sysdeps#4410
ajanicijamd wants to merge 25 commits intomainfrom
users/ajanicijamd/therock-add-tbb-to-sysdeps-2

Conversation

@ajanicijamd
Copy link
Copy Markdown
Contributor

@ajanicijamd ajanicijamd commented Apr 8, 2026

Motivation

  • Provide Threading Building Blocks (TBB) as an optional Linux sysdep under lib/rocm_sysdeps, consistent with other bundled third-party sysdeps.
  • rocprofiler-systems previously built its own TBB (ROCPROFSYS_BUILD_TBB=ON). That can duplicate work and does not align with TheRock’s portable layout. This PR turns that off and consumes therock-tbb via ${THEROCK_BUNDLED_TBB}.
  • Aligns with tracking work: AIPROFSYST-22; see also TheRock#1902, TheRock#1905.

Technical Details

  • Topology: New artifact sysdeps-tbb in BUILD_TOPOLOGY.toml (optional third-party sysdep pattern). rocprofiler-systems depends on sysdeps-tbb so ROCPROFSYS implicitly requires THEROCK_ENABLE_SYSDEPS_TBB when features are finalized.
  • oneTBB build: third-party/sysdeps/linux/tbb/ fetches oneTBB 2022.3.0 (mirrored tarball + URL_HASH). Custom install uses Ninja, TBB_TEST=OFF, install under lib/rocm_sysdeps.
  • Namespacing: patch_source.sh rewrites upstream CMake so shared libraries use rocm_sysdeps_* OUTPUT_NAME to avoid clashing with system TBB.
  • Profiler integration: profiler/CMakeLists.txtROCPROFSYS_BUILD_TBB=OFF, ${THEROCK_BUNDLED_TBB} in RUNTIME_DEPS, INSTALL_RPATH_DIRS include lib/rocm_sysdeps/lib. post_hook_rocprofiler-systems.cmake sets THEROCK_INSTALL_RPATH_ORIGIN for Dyninst-related targets so $ORIGIN/../rocm_sysdeps/lib resolves correctly from lib/rocprofiler-systems.
  • Artifacts: third-party/sysdeps/linux/artifact-tbb.toml describes stage components for packaging. build_tools/install_rocm_from_artifacts.py adds sysdeps-tbb for --rocprofiler-systems to ensure optional dependencies are installed for testing.

Test Plan

  • Build TheRock and run rocprofiler-systems tests
  • Run a test script to verify behaviour:
    • librocm_sysdeps_tbb*.so* / libtbb*.so* are present under dist/rocm/lib/rocm_sysdeps/lib.
    • Those libraries do not appear under dist/rocm/lib/rocprofiler-systems (no TBB leaked from the profiler subtree).
    • Scan the install folder, dist/rocm, for each ELF that NEEDED librocm_sysdeps_tbb* / libtbb*, ldd must resolve TBB from dist/rocm/lib/rocm_sysdeps/lib.
    • Scan the RUNPATH of installed rocprofiler-systems libraries in dist/rocm/lib/rocprofiler-systems/lib* and dist/rocm/lib/librocprof-sys*; each library must include $ORIGIN/../rocm_sysdeps/lib or $ORIGIN/rocm_sysdeps/lib, respectively.

Test Result

Built successful, tests pass, metadata is correct.

Submission Checklist

Copy link
Copy Markdown
Member

@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.

Some early feedback even though this is still a draft. Bundled sysdep might not be the right place. Is this linked statically or dynamically to rocprofiler?

Comment thread third-party/sysdeps/linux/tbb/CMakeLists.txt Outdated
Comment thread profiler/CMakeLists.txt Outdated
@ajanicijamd ajanicijamd marked this pull request as ready for review April 8, 2026 23:57
@dgaliffiAMD
Copy link
Copy Markdown
Contributor

Please update the description's "motivation" and "technical details". Refer to #4399 for guidance.

Comment thread third-party/sysdeps/linux/CMakeLists.txt Outdated
Comment thread third-party/sysdeps/linux/CMakeLists.txt Outdated
Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt Outdated
Comment thread third-party/sysdeps/linux/artifact.toml Outdated
Comment thread profiler/CMakeLists.txt
@dgaliffiAMD dgaliffiAMD added the test:rocprofiler-systems For pull requests, runs full tests for only rocprofiler-systems and other labeled projects. label Apr 9, 2026
Comment thread profiler/CMakeLists.txt Outdated
@dgaliffiAMD dgaliffiAMD force-pushed the users/ajanicijamd/therock-add-tbb-to-sysdeps-2 branch from 147fb10 to ebb1ffc Compare April 21, 2026 22:38
…source directory, and installation paths for ROCm sysdeps. Adjusted package provision path for TBB.
@dgaliffiAMD
Copy link
Copy Markdown
Contributor

I found an issue with the installation of the TBB and pushed a fix. We still have a problem with the installation rpaths, as the Dyninst libraries cannot find the TBB libraries in their new location.

Add `../llvm/lib` and `../rocm_sysdeps/lib`, so libraries under `rocprofiler-systems/lib` can find their dependent libraries.
@dgaliffiAMD dgaliffiAMD marked this pull request as draft April 28, 2026 14:05
@dgaliffiAMD
Copy link
Copy Markdown
Contributor

Moving to draft to address requirements after rebasing.

dgaliffiAMD and others added 4 commits April 28, 2026 17:00
TBB was added as a core sysdep but should follow the optional sysdep
pattern established in fa6c993: gated behind THEROCK_ENABLE_SYSDEPS_TBB,
with its own artifact descriptor and BUILD_TOPOLOGY entry.

- Move add_subdirectory(tbb) and therock_provide_artifact(sysdeps-tbb)
  inside an THEROCK_ENABLE_SYSDEPS_TBB guard in linux/CMakeLists.txt
- Remove TBB from the core sysdeps artifact.toml; add artifact-tbb.toml
- Gate THEROCK_BUNDLED_TBB in root CMakeLists.txt behind the same flag
- Add sysdeps-tbb entry to BUILD_TOPOLOGY.toml (required by topology validator)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
TBB's own anonymous .def version scripts are incompatible with a named
version script; the linker rejects mixing the two. version.lds is not used.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
dgaliffiAMD and others added 5 commits April 29, 2026 00:46
The tbb sub-project build does not use Python.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Prevents the glob loop from running on a literal pattern if no
matching libraries exist.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Verify that OUTPUT_NAME was actually injected after each sed. If a
future oneTBB version changes the CMake layout, the build will fail
immediately with a clear message instead of producing wrong library
names.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Dyninst links against librocm_sysdeps_tbb.so.12 at runtime. The
sysdeps-tbb artifact is optional and not part of the core sysdeps
bundle, so it must be fetched explicitly alongside rocprofiler-systems.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@dgaliffiAMD dgaliffiAMD marked this pull request as ready for review April 30, 2026 18:25
@dgaliffiAMD
Copy link
Copy Markdown
Contributor

Moving back to "open" now that I believe the concerns have been addressed. I have also updated the description and made TBB an optional sysdep, following the pattern of other such dependencies (ex., #4647)

@dgaliffiAMD dgaliffiAMD requested a review from marbre April 30, 2026 18:29
Comment thread requirements-test.txt Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:rocprofiler-systems For pull requests, runs full tests for only rocprofiler-systems and other labeled projects.

Projects

Status: TODO

Development

Successfully merging this pull request may close these issues.

3 participants