Skip to content

Commit 3781ec0

Browse files
authored
Merge branch 'main' into windows-ci-setup-2
2 parents ef79594 + 825ce26 commit 3781ec0

27 files changed

+312
-99
lines changed

.github/workflows/build_linux_packages.yml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,26 @@ jobs:
8080
cmake --build build --target therock-archives therock-dist
8181
kill %1
8282
83-
# - name: Build Tarballs
84-
# run: |
85-
# (cd build && cpack -G TXZ)
83+
- name: Test Packaging
84+
run: |
85+
ctest --test-dir build --output-on-failure
8686
8787
- name: Report
8888
if: ${{ !cancelled() }}
8989
run: |
90-
ls -lh build
90+
echo "Full SDK du:"
91+
echo "------------"
92+
du -h -d 1 build/dist/rocm
93+
echo "Artifact Archives:"
94+
echo "------------------"
95+
ls -lh build/artifacts/*.tar.xz
96+
echo "Artifacts:"
97+
echo "----------"
98+
du -h -d 1 build/artifacts
99+
echo "CCache Stats:"
100+
echo "-------------"
91101
ccache -s
92102
93-
# - name: Upload runtime artifacts
94-
# uses: actions/upload-artifact@v4
95-
# if: ${{ !cancelled() }}
96-
# with:
97-
# name: TheRock-runtime-linux-x86_64-tarball
98-
# path: |
99-
# build/TheRock-amdgpu-runtime-*.tar.xz
100-
# if-no-files-found: warn
101-
102-
# - name: Upload compiler artifacts
103-
# uses: actions/upload-artifact@v4
104-
# if: ${{ !cancelled() }}
105-
# with:
106-
# name: TheRock-compiler-linux-x86_64-tarball
107-
# path: |
108-
# build/TheRock-amdgpu-compiler*.tar.xz
109-
# if-no-files-found: warn
110-
111103
- name: Save cache
112104
uses: actions/cache/save@v4
113105
if: always()

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ endif()
1212
project(THEROCK)
1313

1414
cmake_policy(SET CMP0135 NEW)
15+
enable_testing()
1516

1617
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1718
include(CMakeDependentOption)
@@ -124,6 +125,7 @@ else()
124125
# TODO(#36): Enable more project builds on Windows and/or make the full list configurable.
125126
endif()
126127

128+
add_subdirectory(examples)
127129

128130
# ################################################################################
129131
# # Testing

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ pip install CppHeaderParser
1717
```
1818
sudo apt install \
1919
repo git-lfs libnuma-dev ninja-build cmake g++ pkg-config libdrm-dev \
20-
libelf-dev xxd libgl1-mesa-dev
20+
libelf-dev xxd libgl1-mesa-dev libbz2-dev libsqlite3-dev libgtest-dev
21+
2122
```
2223

2324
# Checkout Sources

base/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
################################################################################
2+
# aux-overlay
3+
################################################################################
4+
5+
therock_cmake_subproject_declare(therock-aux-overlay
6+
EXTERNAL_SOURCE_DIR "aux-overlay"
7+
)
8+
therock_cmake_subproject_activate(therock-aux-overlay)
9+
110
################################################################################
211
# rocm-cmake
312
################################################################################
@@ -123,4 +132,5 @@ therock_provide_artifact(base
123132
rocm-cmake
124133
rocm-core
125134
rocm-half
135+
therock-aux-overlay
126136
)

base/artifact.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,10 @@ include = "libexec/**"
3636
include = [
3737
"share/rocprofiler-register/tests/**",
3838
]
39+
40+
# therock-aux-overlay
41+
[components.lib."base/aux-overlay/stage"]
42+
default_patterns = false
43+
include = [
44+
"**/*",
45+
]

base/aux-overlay/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Auxiliary Overlay
2+
#
3+
# This project contains some odds and ends needed in order to complete
4+
# assembly of a full SDK. This includes:
5+
#
6+
# * Various redirect files to account for where things live in the tree from
7+
# a user perspective.
8+
# * Symlinks to account for distribution-level layout changes.
9+
# * Other hacks as needed.
10+
11+
cmake_minimum_required(VERSION 3.25)
12+
13+
project(therock-aux-overlay)
14+
15+
if(NOT WIN32)
16+
add_custom_target(symlinks ALL
17+
COMMAND "${CMAKE_COMMAND}" -E create_symlink "lib/llvm" "${CMAKE_CURRENT_BINARY_DIR}/llvm"
18+
)
19+
install(FILES
20+
"${CMAKE_CURRENT_BINARY_DIR}/llvm"
21+
DESTINATION .
22+
)
23+
endif()
24+
25+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/overlay/" DESTINATION ".")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Redirect to llvm/lib/cmake
2+
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Redirect to llvm/lib/cmake
2+
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/clang/ClangConfig.cmake")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Redirect to llvm/lib/cmake
2+
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/clang/ClangConfigVersion.cmake")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Redirect to llvm/lib/cmake
2+
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/lld/LLDConfig.cmake")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Redirect to llvm/lib/cmake
2+
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/lld/LLDConfigVersion.cmake")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Redirect to llvm/lib/cmake
2+
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/llvm/LLVMConfig.cmake")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Redirect to llvm/lib/cmake
2+
include("${CMAKE_CURRENT_LIST_DIR}/../../llvm/lib/cmake/llvm/LLVMConfigVersion.cmake")

build_tools/fileset_tool.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ def do_artifact(args):
261261
"components" : dict of covered component names
262262
"{component_name}": dict of build/ relative paths to materialize
263263
"{stage_directory}":
264+
"default_patterns": bool (default True) whether component default
265+
patterns are used
264266
"include": str or list[str] of include patterns
265267
"exclude": str or list[str] of exclude patterns
266268
"optional": if true and the directory does not exist, it
@@ -291,6 +293,7 @@ def do_artifact(args):
291293

292294
all_basedir_relpaths = []
293295
for basedir_relpath, basedir_record in component_record.items():
296+
use_default_patterns = basedir_record.get("default_patterns", True)
294297
basedir = args.root_dir / Path(basedir_relpath)
295298
optional = basedir_record.get("optional")
296299
if optional and not basedir.exists():
@@ -299,15 +302,17 @@ def do_artifact(args):
299302

300303
# Includes.
301304
includes = _dup_list_or_str(basedir_record.get("include"))
302-
includes.extend(
303-
ComponentDefaults.ALL.get(component_name, ComponentDefaults()).includes
304-
)
305+
if use_default_patterns:
306+
includes.extend(
307+
ComponentDefaults.ALL.get(component_name, ComponentDefaults()).includes
308+
)
305309

306310
# Excludes.
307311
excludes = _dup_list_or_str(basedir_record.get("exclude"))
308-
excludes.extend(
309-
ComponentDefaults.ALL.get(component_name, ComponentDefaults()).excludes
310-
)
312+
if use_default_patterns:
313+
excludes.extend(
314+
ComponentDefaults.ALL.get(component_name, ComponentDefaults()).excludes
315+
)
311316

312317
pm = PatternMatcher(
313318
includes=includes,

cmake/therock_artifacts.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ function(therock_create_dist)
139139
)
140140

141141
set(_dist_target_name "therock-dist-${_dist_name}")
142-
add_custom_target("${_dist_target_name}" DEPENDS "${_stamp_file}")
142+
add_custom_target("${_dist_target_name}" ALL DEPENDS "${_stamp_file}")
143143
if(NOT TARGET therock-dist)
144-
add_custom_target(therock-dist)
144+
add_custom_target(therock-dist ALL)
145145
endif()
146146
add_dependencies(therock-dist "${_dist_target_name}")
147147
endfunction()

compiler/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ therock_provide_artifact(amd-llvm
137137
run
138138
SUBPROJECT_DEPS
139139
amd-llvm
140+
amd-comgr
141+
hipcc
140142
)
141143

142144
therock_provide_artifact(hipify

compiler/pre_hook_amd-llvm.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ set(PACKAGE_VENDOR "AMD" CACHE STRING "Vendor" FORCE)
2323
set(LLVM_EXTERNAL_AMDDEVICE_LIBS_SOURCE_DIR "${ROCM_GIT_DIR}/llvm-project/amd/device-libs")
2424
set(LLVM_EXTERNAL_PROJECTS "amddevice-libs" CACHE STRING "Enable extra projects" FORCE)
2525

26+
# TODO2: This mechanism has races in certain situations, failing to create a
27+
# symlink. Revisit once devicemanager code is made more robust.
2628
# TODO: Arrange for the devicelibs to be installed to the clange resource dir
2729
# by default. This corresponds to the layout for ROCM>=7. However, not all
2830
# code (specifically the AMDDeviceLibs.cmake file) has adapted to the new
2931
# location, so we have to also make them available at amdgcn. There are cache
3032
# options to manage this transition but they require knowing the clange resource
3133
# dir. In order to avoid drift, we just fixate that too. This can all be
3234
# removed in a future version.
33-
set(CLANG_RESOURCE_DIR "../lib/clang/${LLVM_VERSION_MAJOR}" CACHE STRING "Resource dir" FORCE)
34-
set(ROCM_DEVICE_LIBS_BITCODE_INSTALL_LOC_NEW "lib/clang/${LLVM_VERSION_MAJOR}/amdgcn" CACHE STRING "New devicelibs loc" FORCE)
35-
set(ROCM_DEVICE_LIBS_BITCODE_INSTALL_LOC_OLD "amdgcn" CACHE STRING "Old devicelibs loc" FORCE)
35+
# set(CLANG_RESOURCE_DIR "../lib/clang/${LLVM_VERSION_MAJOR}" CACHE STRING "Resource dir" FORCE)
36+
# set(ROCM_DEVICE_LIBS_BITCODE_INSTALL_LOC_NEW "lib/clang/${LLVM_VERSION_MAJOR}/amdgcn" CACHE STRING "New devicelibs loc" FORCE)
37+
# set(ROCM_DEVICE_LIBS_BITCODE_INSTALL_LOC_OLD "amdgcn" CACHE STRING "Old devicelibs loc" FORCE)
3638

3739
# Disable default RPath handling on Linux and enforce our own project-wide:
3840
# * Executables and libraries can always search their adjacent lib directory

examples/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
add_test(
2+
NAME therock-examples-cpp-sdk-user
3+
COMMAND
4+
"${CMAKE_COMMAND}" -E env "CMAKE_PREFIX_PATH=${THEROCK_BINARY_DIR}/dist/rocm" --
5+
"${CMAKE_COMMAND}"
6+
"-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/cpp-sdk-user"
7+
"-DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/cpp-sdk-user"
8+
"-DGENERATOR=${CMAKE_GENERATOR}"
9+
-P "${CMAKE_CURRENT_SOURCE_DIR}/clean_configure_test_project.cmake"
10+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if(EXISTS "${BINARY_DIR}")
2+
message(STATUS "Removing build dir ${BINARY_DIR}")
3+
file(REMOVE_RECURSE "${BINARY_DIR}")
4+
endif()
5+
6+
execute_process(
7+
COMMAND "${CMAKE_CTEST_COMMAND}" --build-and-test
8+
"${SOURCE_DIR}"
9+
"${BINARY_DIR}"
10+
--build-generator "${GENERATOR}"
11+
--test-command "${CMAKE_CTEST_COMMAND}" --output-on-failure
12+
RESULT_VARIABLE CMD_RESULT
13+
)
14+
15+
if(CMD_RESULT)
16+
message(FATAL_ERROR "Failed to execute test process")
17+
endif()

examples/cpp-sdk-user/CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Build with:
2+
# cmake -GNinja -S. -Bbuild -DCMAKE_PREFIX_PATH=path/to/rocm
3+
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
4+
message(FATAL_ERROR "In-source builds are not allowed. Please create a separate build directory.")
5+
endif()
6+
7+
cmake_minimum_required(VERSION 3.25)
8+
9+
project(rocm-cpp-sdk-user)
10+
enable_testing()
11+
12+
set(CMAKE_CXX_STANDARD 17)
13+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
14+
15+
# Because we use this project as a test, we include validation that the found
16+
# packages are sound. Users do not need to include this or call any of the
17+
# `validate_*` functions.
18+
include(validate_rocm_sdk)
19+
20+
# TODO: Don't require HIP_PLATFORM https://github.com/nod-ai/TheRock/issues/68
21+
set(HIP_PLATFORM "amd")
22+
find_package(hip CONFIG REQUIRED)
23+
validate_hip_package_found()
24+
25+
find_package(hipsparse CONFIG REQUIRED)
26+
find_package(rocsolver CONFIG REQUIRED)
27+
find_package(rocprim CONFIG REQUIRED)
28+
find_package(rocrand CONFIG REQUIRED)
29+
30+
find_package(rccl CONFIG REQUIRED)
31+
find_package(hipblaslt CONFIG REQUIRED)
32+
find_package(hipblas CONFIG REQUIRED)
33+
find_package(miopen CONFIG REQUIRED)
34+
35+
add_executable(
36+
hip-host-test
37+
hip-host-test.cpp
38+
)
39+
target_link_libraries(hip-host-test PRIVATE hip::host)
40+
add_test(NAME hip-host-test COMMAND hip-host-test)

examples/cpp-sdk-user/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# ROCM SDK User Example
2+
3+
This example shows a CMake project with the supported way to depend on various
4+
ROCM libraries and tools from C++. We attempt to keep this up to date and
5+
build/test it as part of the overall project.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function(validate_hip_package_found)
2+
if(NOT hip_FOUND)
3+
message(FATAL_ERROR "'hip' package is not found")
4+
endif()
5+
6+
message(STATUS "**** HIP Configuration:")
7+
string(APPEND CMAKE_MESSAGE_INDENT "* ")
8+
message(STATUS "VERSION: ${hip_VERSION}")
9+
message(STATUS "INCLUDE: ${hip_INCLUDE_DIRS}")
10+
message(STATUS "LIBRARIES: ${hip_LIBRARIES}")
11+
message(STATUS "GPU_TARGETS: ${GPU_TARGETS}")
12+
endfunction()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <hip/hip_runtime_api.h>
2+
3+
#include <iostream>
4+
5+
int main(int argc, char **argv) {
6+
int runtime_version;
7+
auto err = hipRuntimeGetVersion(&runtime_version);
8+
if (err != hipSuccess) {
9+
std::cerr << "Error getting runtime version: " << err << "\n";
10+
return 2;
11+
}
12+
std::cout << "HIP runtime version: " << runtime_version << "\n";
13+
err = hipInit(0);
14+
if (err != hipSuccess) {
15+
// Since this is primarily run on CI to verify that linkage works, we
16+
// just ignore any error (this lets us run the test on machines that
17+
// lack a GPU).
18+
std::cerr << "Error initializing HIP: " << err << " (ignored)\n";
19+
}
20+
return 0;
21+
}

math-libs/artifact-blas.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# hipBLAS-common
2+
[components.dbg."math-libs/hipBLAS-common/stage"]
3+
[components.dev."math-libs/hipBLAS-common/stage"]
4+
[components.doc."math-libs/hipBLAS-common/stage"]
5+
[components.lib."math-libs/hipBLAS-common/stage"]
6+
17
# hipBLAS
28
[components.dbg."math-libs/hipBLAS/stage"]
39
[components.dev."math-libs/hipBLAS/stage"]

ml-libs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ therock_cmake_subproject_declare(MIOpen
1212
-DMIOPEN_USE_COMPOSABLEKERNEL=OFF # TODO: enable
1313
-DMIOPEN_USE_MLIR=OFF # TODO: enable
1414
-DMIOPEN_BUILD_DRIVER=OFF # TODO: enable
15+
-DMIOPEN_USE_ROCTRACER=OFF # TODO: enable
1516
COMPILER_TOOLCHAIN
1617
amd-hip
1718
BUILD_DEPS

0 commit comments

Comments
 (0)