diff --git a/.github/rocm/6.2.4.txt b/.github/rocm/6.2.4.txt new file mode 100644 index 0000000..6de4820 --- /dev/null +++ b/.github/rocm/6.2.4.txt @@ -0,0 +1 @@ +https://repo.radeon.com/amdgpu-install/6.2.4/ubuntu/noble/amdgpu-install_6.2.60204-1_all.deb diff --git a/.github/rocm/6.3.4.txt b/.github/rocm/6.3.4.txt new file mode 100644 index 0000000..a2343a8 --- /dev/null +++ b/.github/rocm/6.3.4.txt @@ -0,0 +1 @@ +https://repo.radeon.com/amdgpu-install/6.3.4/ubuntu/noble/amdgpu-install_6.3.60304-1_all.deb diff --git a/.github/rocm/6.4.4.txt b/.github/rocm/6.4.4.txt new file mode 100644 index 0000000..0b54ea8 --- /dev/null +++ b/.github/rocm/6.4.4.txt @@ -0,0 +1 @@ +https://repo.radeon.com/amdgpu-install/6.4.4/ubuntu/noble/amdgpu-install_6.4.60404-1_all.deb diff --git a/.github/rocm/7.0.3.txt b/.github/rocm/7.0.3.txt new file mode 100644 index 0000000..b6137bd --- /dev/null +++ b/.github/rocm/7.0.3.txt @@ -0,0 +1 @@ +https://repo.radeon.com/amdgpu-install/7.0.3/ubuntu/noble/amdgpu-install_7.0.3.70003-1_all.deb diff --git a/.github/rocm/7.2.0.txt b/.github/rocm/7.2.0.txt new file mode 100644 index 0000000..5a124c1 --- /dev/null +++ b/.github/rocm/7.2.0.txt @@ -0,0 +1 @@ +https://repo.radeon.com/amdgpu-install/7.2/ubuntu/noble/amdgpu-install_7.2.70200-1_all.deb diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d66f2d3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,96 @@ +name: test + +on: + pull_request: + + push: + branches: + - main + + workflow_call: + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + build-cuda: + name: CUDA ${{ matrix.cuda }} + runs-on: ubuntu-24.04 + container: + image: nvidia/cuda:${{ matrix.cuda }}-devel-ubuntu24.04 + strategy: + fail-fast: false + matrix: + cuda: ["12.6.3", "12.8.1", "12.9.1", "13.0.2", "13.1.1"] + steps: + - name: Checkout code + uses: actions/checkout@v6 + - name: Install build dependencies + run: | + apt-get update + apt-get install --yes cmake + - name: Configure + run: | + cmake -S . -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ + -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \ + -DHIPPER_TEST_PLATFORM=CUDA \ + -DCMAKE_CUDA_ARCHITECTURES=80 + - name: Build + run: | + cmake --build build + - name: Install + run: | + cmake --install build + + build-hip: + name: ROCm ${{ matrix.rocm }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + # 7.1.1 skipped because the repository did not work + rocm: ["6.2.4", "6.3.4", "6.4.4", "7.0.3", "7.2.0"] + steps: + - name: Checkout code + uses: actions/checkout@v6 + - name: Find ROCm repository + id: set-rocm-repo + run: | + rocmfile=./.github/rocm/${{ matrix.rocm }}.txt + if [[ -f $rocmfile ]]; then + rocmdeb=$(cat $rocmfile) + echo "rocmdeb=$rocmdeb" >> $GITHUB_OUTPUT + else + echo "Unknown ROCm version" && exit 1 + fi + - name: Install ROCm + run: | + wget ${{ steps.set-rocm-repo.outputs.rocmdeb }} -O amdgpu-install.deb + sudo apt-get install --yes ./amdgpu-install.deb + sudo apt-get update + sudo apt-get install --yes rocm-hip-sdk + + sudo tee --append /etc/ld.so.conf.d/rocm.conf < $) -# add tests -if(HIPPER_TEST) - enable_testing() - add_subdirectory(tests) -endif() - # install headers if(HIPPER_INSTALL) include(CMakePackageConfigHelpers) @@ -54,3 +48,9 @@ if(HIPPER_INSTALL) NAMESPACE hipper:: DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/hipper) endif() + +# add tests +if(HIPPER_TEST_PLATFORM) + enable_testing() + add_subdirectory(tests) +endif() diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 12da96d..177569e 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -125,4 +125,3 @@ enforcement ladder](https://github.com/mozilla/diversity). For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. - diff --git a/doc/runtime.md b/doc/runtime.md index 10d7e61..21a4f3b 100644 --- a/doc/runtime.md +++ b/doc/runtime.md @@ -376,4 +376,3 @@ | `cudaProfilerStop` | `hipProfilerStop` | `hipper::profilerStop`\* | \*: feature only available with `HIPPER_USE_DEPRECATED`. - diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2959b6e..ce5931c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,6 +2,15 @@ # Copyright (c) 2021, Auburn University # This file is released under the Modified BSD License. +# enable the language used for testing +if(HIPPER_TEST_PLATFORM STREQUAL "CUDA") + enable_language(CUDA) +elseif(HIPPER_TEST_PLATFORM STREQUAL "HIP") + enable_language(HIP) +else() + message(FATAL_ERROR "HIPPER_TEST_PLATFORM value ${HIPPER_TEST_PLATFORM} not recognized, must be CUDA or HIP") +endif() + # the list of all source files set(HIPPER_TEST_FILES test_hipper.cc @@ -14,14 +23,11 @@ set(HIPPER_TEST_LABELS CUB ) -# look for catch quietly, and pull down v2.12.2 if not found -if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) -endif() -find_package(Catch2 QUIET) +# look for catch quietly, and pull down v2.13.10 if not found +find_package(Catch2 2 QUIET) if(NOT Catch2_FOUND) message(STATUS "Downloading Catch2...") - set(url https://github.com/catchorg/Catch2/releases/download/v2.12.2/catch.hpp) + set(url https://github.com/catchorg/Catch2/releases/download/v2.13.10/catch.hpp) file(DOWNLOAD ${url} "${CMAKE_CURRENT_BINARY_DIR}/catch2/catch.hpp" STATUS status) list(GET status 0 error) if(error) @@ -31,8 +37,13 @@ if(NOT Catch2_FOUND) find_package(Catch2 REQUIRED) endif() -# set full path to files for use in subdirectories -list(TRANSFORM HIPPER_TEST_FILES PREPEND "${CMAKE_CURRENT_LIST_DIR}/") +add_executable(test_hipper ${HIPPER_TEST_FILES}) +if (HIPPER_TEST_PLATFORM STREQUAL "HIP") + set_source_files_properties(${HIPPER_TEST_FILES} PROPERTIES LANGUAGE HIP) +endif() +target_link_libraries(test_hipper PRIVATE hipper::hipper Catch2::Catch2) +target_compile_definitions(test_hipper PRIVATE HIPPER_${HIPPER_TEST_PLATFORM}) -add_subdirectory(cuda) -add_subdirectory(hip) +foreach(label ${HIPPER_TEST_LABELS}) + add_test(NAME hipper-${label} COMMAND test_hipper "[${label}]") +endforeach() diff --git a/tests/cuda/CMakeLists.txt b/tests/cuda/CMakeLists.txt deleted file mode 100644 index c6ebd23..0000000 --- a/tests/cuda/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) 2020, Michael P. Howard -# Copyright (c) 2021, Auburn University -# This file is released under the Modified BSD License. - -include(CheckLanguage) -check_language(CUDA) -if(NOT CMAKE_CUDA_COMPILER) - message(STATUS "No CUDA compiler, skipping CUDA tests.") - return() -else() - enable_language(CUDA) -endif() - -add_executable(test_hipper_cuda ${HIPPER_TEST_FILES}) -target_link_libraries(test_hipper_cuda PRIVATE hipper::hipper Catch2::Catch2) -target_compile_definitions(test_hipper_cuda PRIVATE HIPPER_CUDA) - -# set cuda architectures for build -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) - set_property(TARGET test_hipper_cuda PROPERTY CUDA_ARCHITECTURES 60-real 70) -else() - set(CUDA_ARCHITECTURES "60;70") - set(TEST_NVCC_OPTIONS ) - foreach(_arch ${CUDA_ARCHITECTURES}) - set(TEST_NVCC_OPTIONS "${TEST_NVCC_OPTIONS} -gencode=arch=compute_${_arch},code=sm_${_arch}") - endforeach() - set(_sorted_arches ${CUDA_ARCHITECTURES}) - list(SORT _sorted_arches) - list(REVERSE _sorted_arches) - list(GET _sorted_arches 0 _max_arch) - set(TEST_NVCC_OPTIONS "${TEST_NVCC_OPTIONS} -gencode=arch=compute_${_max_arch},code=compute_${_max_arch}") - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${TEST_NVCC_OPTIONS}") -endif() - -foreach(label ${HIPPER_TEST_LABELS}) - add_test(NAME hipper-cuda-${label} COMMAND test_hipper_cuda "[${label}]") -endforeach() diff --git a/tests/hip/CMakeLists.txt b/tests/hip/CMakeLists.txt deleted file mode 100644 index 263039b..0000000 --- a/tests/hip/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2020, Michael P. Howard -# Copyright (c) 2021, Auburn University -# This file is released under the Modified BSD License. - -if(NOT DEFINED HIP_PATH) - if(NOT DEFINED ENV{HIP_PATH}) - set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed") - else() - set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed") - endif() -endif() -set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH}) - -find_package(HIP QUIET) -if(NOT HIP_FOUND) - message(STATUS "No HIP compiler, skipping HIP tests.") - return() -endif() - -hip_add_executable(test_hipper_hip ${HIPPER_TEST_FILES}) -target_link_libraries(test_hipper_hip PRIVATE hipper::hipper Catch2::Catch2) -target_compile_definitions(test_hipper_hip PRIVATE HIPPER_HIP) - -foreach(label ${HIPPER_TEST_LABELS}) - add_test(NAME hipper-hip-${label} COMMAND test_hipper_hip "[${label}]") -endforeach() diff --git a/tests/test_cub.cu b/tests/test_cub.cu index 3dafe4f..2c4465b 100644 --- a/tests/test_cub.cu +++ b/tests/test_cub.cu @@ -23,11 +23,11 @@ TEST_CASE("CUB operations", "[CUB]") // size temporary memory void *tmp = NULL; size_t tmp_bytes = 0; - hipper::cub::DeviceReduce::Sum(tmp,tmp_bytes,a,total,N); + static_cast(hipper::cub::DeviceReduce::Sum(tmp,tmp_bytes,a,total,N)); REQUIRE_SUCCESS(hipper::mallocManaged(reinterpret_cast(&tmp), tmp_bytes)); // take sum - hipper::cub::DeviceReduce::Sum(tmp,tmp_bytes,a,total,N); + static_cast(hipper::cub::DeviceReduce::Sum(tmp,tmp_bytes,a,total,N)); REQUIRE_SUCCESS(hipper::deviceSynchronize()); // check output