Skip to content

Commit

Permalink
Add test project which finds and validates CMake packages and config.
Browse files Browse the repository at this point in the history
Includes some tweaks discovered along the way.
  • Loading branch information
stellaraccident committed Feb 6, 2025
1 parent 7ba9eba commit b37d422
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/cpp-sdk-user/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Build with:
# cmake -GNinja -S. -Bbuild -DCMAKE_PREFIX_PATH=path/to/rocm
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed. Please create a separate build directory.")
endif()

cmake_minimum_required(VERSION 3.25)

project(rocm-cpp-sdk-user)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Because we use this project as a test, we include validation that the found
# packages are sound. Users do not need to include this or call any of the
# `validate_*` functions.
include(validate_rocm_sdk)

# TODO: Don't require HIP_PLATFORM https://github.com/nod-ai/TheRock/issues/68
set(HIP_PLATFORM "amd")
find_package(hip CONFIG REQUIRED)
validate_hip_package_found()

find_package(hipsparse CONFIG REQUIRED)
find_package(rocsolver CONFIG REQUIRED)
find_package(rocprim CONFIG REQUIRED)
find_package(rocrand CONFIG REQUIRED)

find_package(rccl CONFIG REQUIRED)
find_package(hipblaslt CONFIG REQUIRED)
find_package(hipblas CONFIG REQUIRED)
find_package(miopen CONFIG REQUIRED)
5 changes: 5 additions & 0 deletions examples/cpp-sdk-user/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ROCM SDK User Example

This example shows a CMake project with the supported way to depend on various
ROCM libraries and tools from C++. We attempt to keep this up to date and
build/test it as part of the overall project.
12 changes: 12 additions & 0 deletions examples/cpp-sdk-user/cmake/validate_rocm_sdk.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function(validate_hip_package_found)
if(NOT hip_FOUND)
message(FATAL_ERROR "'hip' package is not found")
endif()

message(STATUS "**** HIP Configuration:")
string(APPEND CMAKE_MESSAGE_INDENT "* ")
message(STATUS "VERSION: ${hip_VERSION}")
message(STATUS "INCLUDE: ${hip_INCLUDE_DIRS}")
message(STATUS "LIBRARIES: ${hip_LIBRARIES}")
message(STATUS "GPU_TARGETS: ${GPU_TARGETS}")
endfunction()
6 changes: 6 additions & 0 deletions math-libs/artifact-blas.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# hipBLAS-common
[components.dbg."math-libs/hipBLAS-common/stage"]
[components.dev."math-libs/hipBLAS-common/stage"]
[components.doc."math-libs/hipBLAS-common/stage"]
[components.lib."math-libs/hipBLAS-common/stage"]

# hipBLAS
[components.dbg."math-libs/hipBLAS/stage"]
[components.dev."math-libs/hipBLAS/stage"]
Expand Down

0 comments on commit b37d422

Please sign in to comment.