Skip to content

Commit

Permalink
HIP CI
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Sep 22, 2024
1 parent 3cacb43 commit 60cc1b8
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 37 deletions.
60 changes: 58 additions & 2 deletions .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
7 changes: 4 additions & 3 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
57 changes: 55 additions & 2 deletions .github/workflows/hip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions .github/workflows/intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
28 changes: 15 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -50,15 +49,18 @@ target_include_directories(amrexpr PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<INSTALL_INTERFACE:include>)

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
$<$<COMPILE_LANGUAGE:CUDA>:-m64>
Expand All @@ -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()

Expand All @@ -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)

Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,9 @@ the GPU architecture in the configure step. For example
$ cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<installation_direction> \
-DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80

# Nvidia GPU w/ compute capability 8.0
$ cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<installation_direction> \
-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=<installation_direction> \
-DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80
-DENABLE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx908
```

## Copyright Notice
Expand Down
5 changes: 5 additions & 0 deletions Tests/GPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ if (ENABLE_CUDA)
target_compile_options(test_gpu PRIVATE $<TARGET_PROPERTY:amrexpr>)
endif()

if (ENABLE_HIP)
set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP)
target_compile_options(test_gpu PRIVATE $<TARGET_PROPERTY:amrexpr>)
endif()

add_test(NAME test_gpu COMMAND test_gpu)
22 changes: 14 additions & 8 deletions Tutorials/libamrexpr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)

0 comments on commit 60cc1b8

Please sign in to comment.