Skip to content

Conversation

@davidd-amd
Copy link
Contributor

@davidd-amd davidd-amd commented Oct 22, 2025

Motivation

This PR modernizes the rocBLAS and Tensile CMake build systems to adopt current best practices and target-centric design patterns. The legacy build system relied heavily on directory-scoped commands, global state manipulation, and script-based patterns that created build fragility and hindered consumability.

Key Drivers:

  • Superbuild Integration: Enable clean integration into ROCm superbuild ecosystem by making rocBLAS/Tensile easily consumable via find_package() or add_subdirectory()
  • Technical Debt Elimination: Remove legacy patterns including directory-scoped commands (include_directories, link_directories), CMAKE_*_FLAGS modifications, and global state manipulation
  • Developer Experience: Provide one-command builds via CMakePresets.json, faster onboarding, and simplified CI/CD workflows
  • Portability: Support multi-config generators (Ninja Multi-Config, Visual Studio) and cross-compilation compatibility
  • Maintainability: Create a readable, explicit build system where all properties attach directly to targets with clear transitive dependency propagation

End State: A target-centric build system where all build properties (compile flags, include directories, link libraries) attach to targets rather than directories, enabling proper usage requirement propagation and eliminating hidden global state.

Technical Details

This refactor encompasses 78 commits transforming the entire CMake infrastructure across rocBLAS and Tensile projects.

Core Modernization Changes

1. Target-Centric Design

  • Eliminated all directory-scoped commands:
    • Replaced include_directories() with target_include_directories()
    • Replaced link_directories() and link_libraries() with target_link_libraries()
    • Replaced add_definitions() with target_compile_definitions()
  • All target_link_libraries() calls now use PUBLIC/PRIVATE/INTERFACE keywords for correct usage requirement propagation
  • Dependencies flow transitively through target linkage rather than manual propagation

2. Build System Structure

  • Reorganized CMakeLists.txt hierarchy with subdirectory-specific build logic:
    • library/src/blas1/, library/src/blas2/, library/src/blas3/ subdirectories
    • clients/common/blas1/, clients/common/blas2/, etc. for client utilities
    • Improved modularity and separation of concerns

3. Configuration Management

  • Introduced CMakePresets.json for both rocBLAS and Tensile:
    • Provides configure, build, and workflow presets
    • Enables one-command developer workflows
    • Standardizes build configurations across environments
  • Created backwards compatibility CMake module:
    • rocblas_shim.cmake - Backward compatibility layer for legacy option names

4. Dependency Management

  • Removed hard-coded paths (e.g., /opt/rocm) in favor of find_package() with CMAKE_PREFIX_PATH
  • Custom OpenMP target to accommodate rocm-omp and gomp
  • Tensile integration pattern with proper subdirectory configuration and module path setup

5. Symbol Visibility and Library Configuration

  • Preserved symbol visibility controls for shared libraries

6. Simplifies and enables best practices

  • Removed CMAKE_*_FLAGS modifications (respects user/developer control)
  • Replaced CMAKE_BUILD_TYPE checks with generator expressions ($<CONFIG:Debug>)
  • Eliminated file(GLOB) for source files in favor of explicit listing
  • Removed variables for collecting sources/targets/flags
  • Eliminated add_dependencies() calls
  • Removed environment variable checks (HIP_PLATFORM) in favor of explicit options

7. Language and Compiler Support

  • enable_language() calls at project level

8. Testing and Client Infrastructure

  • Restructured client build system with explicit build and usage requirements
  • Updated sample and benchmark target configuration
  • OpenMP support through dedicated helper targets

Key File Changes

Root Level:

  • projects/rocblas/CMakeLists.txt - Complete modernization of project structure
  • projects/rocblas/CMakePresets.json - New preset-based configuration system
  • shared/tensile/CMakePresets.json - Tensile preset configuration

Build Configuration:

  • cmake/build-options.cmake - Centralized option definitions
  • cmake/rocblas_shim.cmake - Backward compatibility layer
  • cmake/toolchain-options.cmake - Compiler configuration
  • cmake/rocblas_supported_architectures.cmake - GPU architecture handling

Library:

  • library/CMakeLists.txt - Main library target definition
  • library/src/CMakeLists.txt - Source organization
  • library/src/blas{1,2,3}/CMakeLists.txt - BLAS level-specific sources
  • library/include/CMakeLists.txt - Header management

Clients:

  • clients/CMakeLists.txt - Client infrastructure
  • clients/common/CMakeLists.txt - Shared client utilities
  • clients/benchmarks/CMakeLists.txt - Benchmark targets
  • clients/gtest/CMakeLists.txt - Unit test infrastructure
  • clients/samples/CMakeLists.txt - Sample executables

Test Plan

Validation Approach

1. Build System Validation

  • Successfully configured and built rocBLAS with both previous (develop) and modernized build systems
  • Verified build across multiple configurations:
    • Debug and Release builds
    • Static and shared library builds
    • With and without Tensile device library
    • Client, test, and benchmark builds

2. Preset System Verification

  • Validated all configure presets in CMakePresets.json
  • Tested workflow presets for common developer tasks
  • Confirmed one-command build workflows function correctly

3. Backward Compatibility

  • Verified rocblas_shim.cmake correctly maps legacy options to new options
  • Tested deprecation warnings for renamed options
  • Confirmed conflict detection for incompatible option combinations

4. Dependency Propagation

  • Verified transitive dependency propagation through target linkage
  • Confirmed no manual include directory propagation required
  • Tested HIP, OpenMP, and threading library integration

5. Cross-Language Support

  • Built and executed Fortran test clients
  • Verified proper C++ runtime linkage for Fortran executables
  • Tested sample executables with various language combinations

6. Installation and Packaging

  • Verified make install creates proper installation layout
  • Confirmed *Config.cmake and *ConfigVersion.cmake file generation
  • Tested downstream consumption via find_package(rocblas)

VALIDATION_EXECUTIVE_SUMMARY.md

@davidd-amd davidd-amd force-pushed the users/davidd-amd/tensile-rocblas-cmake-update branch from 18dd77a to 4d8315d Compare November 19, 2025 15:33
@davidd-amd davidd-amd force-pushed the users/davidd-amd/tensile-rocblas-cmake-update branch from 9c6da26 to 1a92ca7 Compare November 20, 2025 17:33
@davidd-amd davidd-amd force-pushed the users/davidd-amd/tensile-rocblas-cmake-update branch from 1a92ca7 to 46e8f49 Compare November 20, 2025 19:38
Comment on lines +7 to +8
add_library(rocblas-omp-shim INTERFACE)
add_library(rocblas::omp-shim ALIAS rocblas-omp-shim)
Copy link
Contributor

@bstefanuk bstefanuk Nov 20, 2025

Choose a reason for hiding this comment

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

Nice pattern.

Suggested change
add_library(rocblas-omp-shim INTERFACE)
add_library(rocblas::omp-shim ALIAS rocblas-omp-shim)
add_library(rocblas-omp-interface INTERFACE)
add_library(rocblas::omp-interface ALIAS rocblas-omp-interface)

Nit: "shim" feels a bit jargony here, it makes sense because it's a thin adapter layer, but "interface" feels clear and doesn't clash with the similarly named rocblas_shim, which is.. different.

@davidd-amd davidd-amd force-pushed the users/davidd-amd/tensile-rocblas-cmake-update branch from 41e1651 to 1a47a88 Compare November 23, 2025 18:39
@davidd-amd davidd-amd force-pushed the users/davidd-amd/tensile-rocblas-cmake-update branch from 1a47a88 to 76e0a11 Compare November 23, 2025 20:53
@davidd-amd davidd-amd force-pushed the users/davidd-amd/tensile-rocblas-cmake-update branch from df4a78e to 1de97b3 Compare November 24, 2025 16:22
@davidd-amd davidd-amd force-pushed the users/davidd-amd/tensile-rocblas-cmake-update branch from 424c8a4 to 9344136 Compare November 24, 2025 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants