From 60cc1b83e522961b3e5587ff5b9b2d595d07ec55 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Sat, 21 Sep 2024 22:09:08 -0700 Subject: [PATCH] HIP CI --- .github/workflows/cuda.yml | 60 ++++++++++++++++++++++++++++- .github/workflows/gcc.yml | 7 ++-- .github/workflows/hip.yml | 57 ++++++++++++++++++++++++++- .github/workflows/intel.yml | 6 +-- CMakeLists.txt | 28 +++++++------- README.md | 8 +--- Tests/GPU/CMakeLists.txt | 5 +++ Tutorials/libamrexpr/CMakeLists.txt | 22 +++++++---- 8 files changed, 156 insertions(+), 37 deletions(-) diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index f7bb047..aac137b 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -11,8 +11,8 @@ concurrency: cancel-in-progress: true jobs: - Tests: - name: CUDA Tests + Tests-gmake: + name: CUDA Tests & GNU Make runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -27,3 +27,59 @@ jobs: cd Tests/GPU make -j4 USE_CUDA=TRUE CUDA_ARCH=80 + + Tests-cmake: + name: CUDA Tests & CMake + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Dependencies + run: | + .github/workflows/dependencies/dependencies_nvcc.sh + - name: Tests + run: | + export PATH=/usr/local/cuda/bin:${PATH} + export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH} + which nvcc || echo "nvcc not in PATH!" + + mkdir build + cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=../cuda_installdir \ + -DENABLE_CUDA=ON \ + -DCMAKE_CUDA_ARCHITECTURES=80 \ + -DENABLE_TESTS=ON + make -j4 VERBOSE=ON + make install + + Tutorials-cmake: + name: CUDA Tests & CMake + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Dependencies + run: | + .github/workflows/dependencies/dependencies_nvcc.sh + - name: Tests + run: | + export PATH=/usr/local/cuda/bin:${PATH} + export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH} + which nvcc || echo "nvcc not in PATH!" + + mkdir build + cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=../cuda_installdir \ + -DENABLE_CUDA=ON \ + -DCMAKE_CUDA_ARCHITECTURES=80 + make -j4 VERBOSE=ON + make install + + cd ../Tutorials/libamrexpr + mkdir build + cd build + cmake .. \ + -DCMAKE_PREFIX_PATH=$(realpath ../../../cuda_installdir) + -DENABLE_CUDA=ON \ + -DCMAKE_CUDA_ARCHITECTURES=80 + make -j4 VERBOSE=ON diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index c13e983..32b6849 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -11,8 +11,8 @@ concurrency: cancel-in-progress: true jobs: - Tests: - name: GCC Tests + Tests-gmake: + name: GCC Tests & GNU Make runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -33,7 +33,7 @@ jobs: make -j4 USE_CPU=TRUE ./main.gnu.ex - Tutorials: + Tutorials-gmake: name: GCC libamrexpr & GNU Make runs-on: ubuntu-latest steps: @@ -62,6 +62,7 @@ jobs: .github/workflows/dependencies/dependencies_gcc.sh - name: Tests run: | + cmake --version mkdir build cd build cmake .. -DCMAKE_CXX_COMPILER=g++ -DENABLE_TESTS=ON diff --git a/.github/workflows/hip.yml b/.github/workflows/hip.yml index c1d9453..a2bc9a7 100644 --- a/.github/workflows/hip.yml +++ b/.github/workflows/hip.yml @@ -11,8 +11,8 @@ concurrency: cancel-in-progress: true jobs: - Tests: - name: HIP Tests + Tests-gmake: + name: HIP Tests & GNU Make runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 @@ -27,3 +27,56 @@ jobs: cd Tests/GPU make -j4 USE_HIP=TRUE AMD_ARCH=gfx90a + Tests-cmake: + name: HIP Tests & CMake + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Dependencies + run: | + .github/workflows/dependencies/dependencies_hip.sh + - name: Tests + run: | + export PATH=/opt/rocm/bin:$PATH + hipcc --version + + mkdir build + cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=../hip_installdir \ + -DENABLE_HIP=ON \ + -DCMAKE_HIP_ARCHITECTURES=gfx90a \ + -DENABLE_TESTS=ON + make -j4 VERBOSE=ON + make install + + Tutorials-cmake: + name: HIP Tests & CMake + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Dependencies + run: | + .github/workflows/dependencies/dependencies_hip.sh + - name: Tests + run: | + export PATH=/opt/rocm/bin:$PATH + hipcc --version + + mkdir build + cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=../hip_installdir \ + -DENABLE_HIP=ON \ + -DCMAKE_HIP_ARCHITECTURES=gfx90a + make -j4 VERBOSE=ON + make install + + cd ../Tutorials/libamrexpr + mkdir build + cd build + cmake .. \ + -DCMAKE_PREFIX_PATH=$(realpath ../../../hip_installdir) + -DENABLE_HIP=ON \ + -DCMAKE_HIP_ARCHITECTURES=gfx90a + make -j4 VERBOSE=ON diff --git a/.github/workflows/intel.yml b/.github/workflows/intel.yml index b8bd502..0c3809c 100644 --- a/.github/workflows/intel.yml +++ b/.github/workflows/intel.yml @@ -11,8 +11,8 @@ concurrency: cancel-in-progress: true jobs: - Tests: - name: Intel CPU Tests + Tests-gmake: + name: Intel Tests & GNU Make runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -37,7 +37,7 @@ jobs: make -j4 USE_CPU=TRUE COMP=intel ./main.intel.ex - Tutorials: + Tutorials-gmake: name: Intel libamrexpr & GNU Make runs-on: ubuntu-latest steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ca0f0b..9a7ea78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,6 @@ option(ENABLE_HIP "Enable HIP support" OFF) if (ENABLE_HIP) set(AMREXPR_USE_GPU 1) set(AMREXPR_USE_HIP 1) - find_package(hip REQUIRED) enable_language(HIP) endif() @@ -50,15 +49,18 @@ target_include_directories(amrexpr PUBLIC $ $) +get_target_property(amrexpr_sources amrexpr SOURCES) +list(FILTER amrexpr_sources INCLUDE REGEX "\\.cpp$") + if (ENABLE_CUDA) - get_target_property(_sources amrexpr SOURCES) - list(FILTER _sources INCLUDE REGEX "\\.cpp$") - set_source_files_properties(${_sources} PROPERTIES LANGUAGE CUDA) - if (NOT DEFINED CUDA_ARCHITECTURES) + set_source_files_properties(${amrexpr_sources} PROPERTIES LANGUAGE CUDA) + if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(STATUS "No CUDA architectures specified. Native will be used.") - set_target_properties(amrexpr PROPERTIES CUDA_ARCHITECTURES native) + set(CMAKE_CUDA_ARCHITECTURES native) endif() - set_target_properties(amrexpr PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + set_target_properties(amrexpr PROPERTIES + CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES} + CUDA_SEPARABLE_COMPILATION ON) target_compile_features(amrexpr PUBLIC cuda_std_17) target_compile_options(amrexpr PUBLIC $<$:-m64> @@ -69,6 +71,12 @@ if (ENABLE_CUDA) endif() if (ENABLE_HIP) + set_source_files_properties(${amrexpr_sources} PROPERTIES LANGUAGE HIP) + if (NOT DEFINED CMAKE_HIP_ARCHITECTURES) + message(STATUS "No HIP architectures specified. 'gfx90a' will be used.") + set(CMAKE_HIP_ARCHITECTURES gfx90a) + endif() + set_target_properties(amrexpr PROPERTIES HIP_ARCHITECTURES ${CMAKE_HIP_ARCHITECTURES}) target_compile_features(amrexpr PUBLIC hip_std_17) endif() @@ -87,12 +95,6 @@ set(amrexpr_FIND_DEPENDENCIES "") if (ENABLE_CUDA) set(amrexpr_FIND_DEPENDENCIES "${amrexpr_FIND_DEPENDENCIES}\nfind_dependency(CUDAToolkit REQUIRED)") endif() -if (ENABLE_HIP) - set(amrexpr_FIND_DEPENDENCIES "${amrexpr_FIND_DEPENDENCIES}\nfind_dependency(hip REQUIRED)") -endif() -if (ENABLE_SYCL) - # Adjust SYCL dependency find commands if necessary -endif() include(CMakePackageConfigHelpers) diff --git a/README.md b/README.md index a1c53d3..5299bc8 100644 --- a/README.md +++ b/README.md @@ -102,13 +102,9 @@ the GPU architecture in the configure step. For example $ cmake -S . -B build -DCMAKE_INSTALL_PREFIX= \ -DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80 -# Nvidia GPU w/ compute capability 8.0 -$ cmake -S . -B build -DCMAKE_INSTALL_PREFIX= \ - -DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80 - -# Nvidia GPU w/ compute capability 8.0 +# AMD MI250X GPU, gfx90a architecture $ cmake -S . -B build -DCMAKE_INSTALL_PREFIX= \ - -DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80 + -DENABLE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx908 ``` ## Copyright Notice diff --git a/Tests/GPU/CMakeLists.txt b/Tests/GPU/CMakeLists.txt index 3563823..7bb168c 100644 --- a/Tests/GPU/CMakeLists.txt +++ b/Tests/GPU/CMakeLists.txt @@ -16,4 +16,9 @@ if (ENABLE_CUDA) target_compile_options(test_gpu PRIVATE $) endif() +if (ENABLE_HIP) + set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP) + target_compile_options(test_gpu PRIVATE $) +endif() + add_test(NAME test_gpu COMMAND test_gpu) diff --git a/Tutorials/libamrexpr/CMakeLists.txt b/Tutorials/libamrexpr/CMakeLists.txt index 8b36dce..e409272 100644 --- a/Tutorials/libamrexpr/CMakeLists.txt +++ b/Tutorials/libamrexpr/CMakeLists.txt @@ -25,10 +25,6 @@ if (ENABLE_CUDA) find_package(CUDAToolkit REQUIRED) endif() -if (ENABLE_HIP) - find_package(hip REQUIRED) -endif() - if (ENABLE_SYCL) set(CMAKE_CXX_COMPILER icpx) endif() @@ -39,13 +35,23 @@ add_executable(parser_test main.cpp) if (ENABLE_CUDA) set_source_files_properties(main.cpp PROPERTIES LANGUAGE CUDA) - if (NOT DEFINED CUDA_ARCHITECTURES) + if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES) message(STATUS "No CUDA architectures specified. Native will be used.") - set_target_properties(parser_test PROPERTIES CUDA_ARCHITECTURES native) + set(CMAKE_CUDA_ARCHITECTURES native) + endif() + set_target_properties(parser_test PROPERTIES + CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES} + CUDA_SEPARABLE_COMPILATION ON) +endif() + +if (ENABLE_HIP) + set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP) + if (NOT DEFINED CMAKE_HIP_ARCHITECTURES) + message(STATUS "No HIP architectures specified. 'gfx90a' will be used.") + set(CMAKE_HIP_ARCHITECTURES gfx90a) endif() set_target_properties(parser_test PROPERTIES - CUDA_SEPARABLE_COMPILATION ON - ) + HIP_ARCHITECTURES ${CMAKE_HIP_ARCHITECTURES}) endif() target_link_libraries(parser_test PRIVATE amrexpr::amrexpr)