From b37d422e3f2061ae55b3f3ba3c5d0b322b6128b4 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Wed, 5 Feb 2025 20:45:15 -0800 Subject: [PATCH] Add test project which finds and validates CMake packages and config. Includes some tweaks discovered along the way. --- examples/cpp-sdk-user/CMakeLists.txt | 31 +++++++++++++++++++ examples/cpp-sdk-user/README.md | 5 +++ .../cmake/validate_rocm_sdk.cmake | 12 +++++++ math-libs/artifact-blas.toml | 6 ++++ 4 files changed, 54 insertions(+) create mode 100644 examples/cpp-sdk-user/CMakeLists.txt create mode 100644 examples/cpp-sdk-user/README.md create mode 100644 examples/cpp-sdk-user/cmake/validate_rocm_sdk.cmake diff --git a/examples/cpp-sdk-user/CMakeLists.txt b/examples/cpp-sdk-user/CMakeLists.txt new file mode 100644 index 0000000..3f16b86 --- /dev/null +++ b/examples/cpp-sdk-user/CMakeLists.txt @@ -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) diff --git a/examples/cpp-sdk-user/README.md b/examples/cpp-sdk-user/README.md new file mode 100644 index 0000000..6d76c39 --- /dev/null +++ b/examples/cpp-sdk-user/README.md @@ -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. diff --git a/examples/cpp-sdk-user/cmake/validate_rocm_sdk.cmake b/examples/cpp-sdk-user/cmake/validate_rocm_sdk.cmake new file mode 100644 index 0000000..fef11e8 --- /dev/null +++ b/examples/cpp-sdk-user/cmake/validate_rocm_sdk.cmake @@ -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() diff --git a/math-libs/artifact-blas.toml b/math-libs/artifact-blas.toml index 79ee513..6d27e12 100644 --- a/math-libs/artifact-blas.toml +++ b/math-libs/artifact-blas.toml @@ -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"]