Skip to content

Commit

Permalink
Merge branch 'main' into eliasj42/windows-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
amd-chrissosa authored Feb 12, 2025
2 parents f08a4cb + b013fbe commit 017642c
Show file tree
Hide file tree
Showing 76 changed files with 2,655 additions and 740 deletions.
41 changes: 17 additions & 24 deletions .github/workflows/build_linux_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,39 +75,32 @@ jobs:
cmake -B build -GNinja . \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DTHEROCK_AMDGPU_FAMILIES=gfx110X-dgpu \
-DTHEROCK_PACKAGE_VERSION="${package_version}"
-DTHEROCK_PACKAGE_VERSION="${package_version}" \
-DTHEROCK_VERBOSE=ON
./build_tools/watch_top_processes.sh &
cmake --build build --target therock-archives
cmake --build build --target therock-archives therock-dist
kill %1
# - name: Build Tarballs
# run: |
# (cd build && cpack -G TXZ)
- name: Test Packaging
run: |
ctest --test-dir build --output-on-failure
- name: Report
if: ${{ !cancelled() }}
run: |
ls -lh build
echo "Full SDK du:"
echo "------------"
du -h -d 1 build/dist/rocm
echo "Artifact Archives:"
echo "------------------"
ls -lh build/artifacts/*.tar.xz
echo "Artifacts:"
echo "----------"
du -h -d 1 build/artifacts
echo "CCache Stats:"
echo "-------------"
ccache -s
# - name: Upload runtime artifacts
# uses: actions/upload-artifact@v4
# if: ${{ !cancelled() }}
# with:
# name: TheRock-runtime-linux-x86_64-tarball
# path: |
# build/TheRock-amdgpu-runtime-*.tar.xz
# if-no-files-found: warn

# - name: Upload compiler artifacts
# uses: actions/upload-artifact@v4
# if: ${{ !cancelled() }}
# with:
# name: TheRock-compiler-linux-x86_64-tarball
# path: |
# build/TheRock-amdgpu-compiler*.tar.xz
# if-no-files-found: warn

- name: Save cache
uses: actions/cache/save@v4
if: always()
Expand Down
97 changes: 93 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ endif()
project(THEROCK)

cmake_policy(SET CMP0135 NEW)
enable_testing()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CMakeDependentOption)
include(ExternalProject)
include(therock_amdgpu_targets)
include(therock_artifacts)
include(therock_features)
include(therock_subproject)
include(therock_job_pools)

Expand All @@ -30,15 +32,15 @@ set(THEROCK_BACKGROUND_BUILD_JOBS "0" CACHE STRING "Number of jobs to reserve fo

set(THEROCK_PACKAGE_VERSION "git" CACHE STRING "Sets the package version string")
set(ROCM_GIT_DIR "${THEROCK_SOURCE_DIR}/sources" CACHE PATH "Directory of rocm-org repo checkout")
# Disable compatibility symlinks created in default ROCM cmake project wide
set(ROCM_SYMLINK_LIBS OFF)
message(STATUS "ROCM_GIT_DIR is set to: ${ROCM_GIT_DIR}")

set(THEROCK_ARTIFACT_ARCHIVE_SUFFIX "" CACHE STRING "Suffix to add to artifact archive file stem names")
set(THEROCK_ARTIFACT_ARCHIVE_TYPES "tar.xz" CACHE STRING "List of artifact archive types to generate")

# Library specific enable flags.
option(THEROCK_ENABLE_RCCL "Enable the comm_libs/rccl sub-project" ON)
option(THEROCK_ENABLE_MATH_LIBS "Enable building of math libraries" ON)
cmake_dependent_option(THEROCK_ENABLE_ML_LIBS "Enables building of ML frameworks" ON THEROCK_ENABLE_MATH_LIBS OFF)
# Overall build settings.
option(THEROCK_VERBOSE "Enables verbose CMake statuses" OFF)

# Initialize the install directory.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Expand All @@ -50,6 +52,91 @@ set(ROCM_MAJOR_VERSION 6)
set(ROCM_MINOR_VERSION 3)
set(ROCM_PATCH_VERSION 1)

################################################################################
# Feature selection
# Each feature added via therock_add_feature produces a boolean cache variable
# like `THEROCK_ENABLE_${feature_name}` that takes its default value from the
# `THEROCK_ENABLE_${group_name}` if a GROUP is present.
################################################################################
option(THEROCK_ENABLE_ALL "Enables building of all feature groups" ON)
cmake_dependent_option(THEROCK_ENABLE_CORE "Enable building of core libraries" ON "THEROCK_ENABLE_ALL" OFF)
cmake_dependent_option(THEROCK_ENABLE_COMM_LIBS "Enable building of comm libraries" ON "THEROCK_ENABLE_ALL" OFF)
cmake_dependent_option(THEROCK_ENABLE_MATH_LIBS "Enable building of math libraries" ON "THEROCK_ENABLE_ALL" OFF)
cmake_dependent_option(THEROCK_ENABLE_ML_LIBS "Enable building of ML libraries" ON "THEROCK_ENABLE_ALL" OFF)
option(THEROCK_RESET_FEATURES "One-shot flag which forces all feature flags to their default state for this configuration run" OFF)

# Base Features.
therock_add_feature(COMPILER
GROUP ALL
DESCRIPTION "Enables the AMDGPU+host compiler toolchain"
)
therock_add_feature(HIPIFY
GROUP ALL
DESCRIPTION "Enables the hipify tool"
REQUIRES COMPILER
)

# Core Features.
therock_add_feature(CORE_RUNTIME
GROUP CORE
DESCRIPTION "Enables the core device runtime and tools"
)
therock_add_feature(HIP_RUNTIME
GROUP CORE
DESCRIPTION "Enables the HIP runtime"
REQUIRES COMPILER CORE_RUNTIME
)

# Comm-libs Features.
therock_add_feature(RCCL
GROUP COMM_LIBS
DESCRIPTION "Enables rccl"
REQUIRES COMPILER HIP_RUNTIME HIPIFY
)

# Math-libs Features.
therock_add_feature(PRIM
GROUP MATH_LIBS
DESCRIPTION "Enables prim libraries (rocprim)"
REQUIRES COMPILER HIP_RUNTIME
)
therock_add_feature(BLAS
GROUP MATH_LIBS
DESCRIPTION "Enables blas libraries (hipblaslt, rocblas, hipblas)"
REQUIRES COMPILER HIP_RUNTIME
)
therock_add_feature(RAND
GROUP MATH_LIBS
DESCRIPTION "Enables rand libraries (hiprand, rocrand)"
REQUIRES COMPILER HIP_RUNTIME
)
therock_add_feature(FFT
GROUP MATH_LIBS
DESCRIPTION "Enables fft libraries"
REQUIRES COMPILER HIP_RUNTIME RAND
)
therock_add_feature(SOLVER
GROUP MATH_LIBS
DESCRIPTION "Enables solver libraries (hipsolver, rocsolver)"
REQUIRES COMPILER HIP_RUNTIME BLAS PRIM
)
therock_add_feature(SPARSE
GROUP MATH_LIBS
DESCRIPTION "Enables sparse libraries (hipsparse, rocsparse)"
REQUIRES COMPILER HIP_RUNTIME BLAS PRIM
)

# ML-Libs Features.
therock_add_feature(MIOPEN
GROUP ML_LIBS
DESCRIPTION "Enables the MIOpen project (with minimal deps defaults to ON)"
REQUIRES COMPILER HIP_RUNTIME BLAS RAND
)

# Finalize all feature flags.
therock_finalize_features()
therock_report_features()

################################################################################
# GPU target selection
#
Expand Down Expand Up @@ -122,6 +209,7 @@ else()
# TODO(#36): Enable more project builds on Windows and/or make the full list configurable.
endif()

add_subdirectory(examples)

# ################################################################################
# # Testing
Expand All @@ -144,3 +232,4 @@ endif()
# Finalization
################################################################################
therock_subproject_merge_compile_commands()
therock_create_dist()
66 changes: 36 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pip install CppHeaderParser
```
sudo apt install \
repo git-lfs libnuma-dev ninja-build cmake g++ pkg-config libdrm-dev \
libelf-dev xxd libgl1-mesa-dev
libelf-dev xxd libgl1-mesa-dev libbz2-dev libsqlite3-dev libgtest-dev
```

# Checkout Sources
Expand Down Expand Up @@ -78,45 +79,50 @@ cmake -B build -GNinja . -DTHEROCK_AMDGPU_FAMILIES=gfx110X-dgpu
# Or if iterating and wishing to cache:
# cmake -Bbuild -GNinja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .
cmake --build build
# Install per component.
cmake --install build --component amdgpu-runtime
cmake --install build --component amdgpu-runtime-dev
cmake --install build --component amdgpu-compiler
# Create archives.
(cd build && cpack -G TBZ2)
```

## Sanity Checks
## Feature Flags

The following does not replace a robust test suite. However, it will tell you
whether the toolchain you have just crafted is viable at all (as in can load
and enumerate devices).

```
./build/dlopen-hip install/lib/libamdhip64.so
```
By default, the project builds everything available. The following group flags
allow enable/disable of selected subsets:

HIP enabled IREE can also be used to enumerate:
- `-DTHEROCK_ENABLE_ALL=OFF`: Disables all optional components.
- `-DTHEROCK_ENABLE_CORE=OFF`: Disables all core components.
- `-DTHEROCK_ENABLE_COMM_LIBS=OFF`: Disables all communication libraries.
- `-DTHEROCK_ENABLE_MATH_LIBS=OFF`: Disables all math libraries.
- `-DTHEROCK_ENABLE_ML_LIBS=OFF`: Disables all ML libraries.

```
LD_LIBRARY_PATH=install/lib iree-run-module --dump_devices=hip
```
Individual features can be controlled separately (typically in combination with
`-DTHEROCK_ENABLE_ALL=OFF` or `-DTHEROCK_RESET_FEATURES=ON` to force a
minimal build):

# Development Notes
- `-DTHEROCK_ENABLE_COMPILER=ON`: Enables the GPU+host compiler toolchain.
- `-DTHEROCK_ENABLE_HIPIFY=ON`: Enables the hipify tool.
- `-DTHEROCK_ENABLE_CORE_RUNTIME=ON`: Enables the core runtime components and tools.
- `-DTHEROCK_ENABLE_HIP_RUNTIME=ON`: Enables the HIP runtime components.
- `-DTHEROCK_ENABLE_RCCL=ON`: Enables RCCL.
- `-DTHEROCK_ENABLE_PRIM=ON`: Enables the PRIM library.
- `-DTHEROCK_ENABLE_BLAS=ON`: Enables the BLAS libraries.
- `-DTHEROCK_ENABLE_RAND=ON`: Enables the RAND libraries.
- `-DTHEROCK_ENABLE_SOLVER=ON`: Enables the SOLVER libraries.
- `-DTHEROCK_ENABLE_SPARSE=ON`: Enables the SPARSE libraries.
- `-DTHEROCK_ENABLE_MIOPEN=ON`: Enables MIOpen.

## Building in a manylinux container
Enabling any features will implicitly enable its *minimum* dependencies. Some
libraries (like MIOpen) have a number of *optional* dependencies, which must
be enabled manually if enabling/disabling individual features.

Our CI builds run in such a container, and it can be useful to run locally.
A report of enabled/disabled features and flags will be printed on every
CMake configure.

```
docker run --rm -it -v $PWD:$PWD --entrypoint /bin/bash ghcr.io/nod-ai/manylinux_ghr_x86_64:main
```
## Sanity Checks

Packages needed:
Tests of the integrity of the build are enabled by default and can be run
with ctest:

```
yum install -y numactl-devel elfutils-libelf-devel vim-common git-lfs
pip install CppHeaderParser
ctest --test-dir build
```

Testing functionality on an actual GPU is in progress and will be documented
separately.
12 changes: 11 additions & 1 deletion base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
################################################################################
# aux-overlay
################################################################################

therock_cmake_subproject_declare(therock-aux-overlay
EXTERNAL_SOURCE_DIR "aux-overlay"
)
therock_cmake_subproject_activate(therock-aux-overlay)

################################################################################
# rocm-cmake
################################################################################
Expand All @@ -6,7 +15,7 @@ therock_cmake_subproject_declare(rocm-cmake
EXTERNAL_SOURCE_DIR "rocm-cmake"
)
therock_cmake_subproject_provide_package(rocm-cmake
ROCmCMakeBuildToolsConfig share/rocmcmakebuildtools/cmake)
ROCmCMakeBuildTools share/rocmcmakebuildtools/cmake)
therock_cmake_subproject_provide_package(rocm-cmake
ROCM share/rocm/cmake)
therock_cmake_subproject_activate(rocm-cmake)
Expand Down Expand Up @@ -123,4 +132,5 @@ therock_provide_artifact(base
rocm-cmake
rocm-core
rocm-half
therock-aux-overlay
)
7 changes: 7 additions & 0 deletions base/artifact.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ include = "libexec/**"
include = [
"share/rocprofiler-register/tests/**",
]

# therock-aux-overlay
[components.lib."base/aux-overlay/stage"]
default_patterns = false
include = [
"**/*",
]
25 changes: 25 additions & 0 deletions base/aux-overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Auxiliary Overlay
#
# This project contains some odds and ends needed in order to complete
# assembly of a full SDK. This includes:
#
# * Various redirect files to account for where things live in the tree from
# a user perspective.
# * Symlinks to account for distribution-level layout changes.
# * Other hacks as needed.

cmake_minimum_required(VERSION 3.25)

project(therock-aux-overlay)

if(NOT WIN32)
add_custom_target(symlinks ALL
COMMAND "${CMAKE_COMMAND}" -E create_symlink "lib/llvm" "${CMAKE_CURRENT_BINARY_DIR}/llvm"
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/llvm"
DESTINATION .
)
endif()

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/overlay/" DESTINATION ".")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redirect to llvm/lib/cmake
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake")
2 changes: 2 additions & 0 deletions base/aux-overlay/overlay/lib/cmake/clang/ClangConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redirect to llvm/lib/cmake
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/clang/ClangConfig.cmake")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redirect to llvm/lib/cmake
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/clang/ClangConfigVersion.cmake")
2 changes: 2 additions & 0 deletions base/aux-overlay/overlay/lib/cmake/lld/LLDConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redirect to llvm/lib/cmake
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/lld/LLDConfig.cmake")
2 changes: 2 additions & 0 deletions base/aux-overlay/overlay/lib/cmake/lld/LLDConfigVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redirect to llvm/lib/cmake
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/lld/LLDConfigVersion.cmake")
2 changes: 2 additions & 0 deletions base/aux-overlay/overlay/lib/cmake/llvm/LLVMConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redirect to llvm/lib/cmake
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/llvm/LLVMConfig.cmake")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Redirect to llvm/lib/cmake
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/llvm/LLVMConfigVersion.cmake")
Loading

0 comments on commit 017642c

Please sign in to comment.