Skip to content

Commit 60cc1b8

Browse files
committed
HIP CI
1 parent 3cacb43 commit 60cc1b8

File tree

8 files changed

+156
-37
lines changed

8 files changed

+156
-37
lines changed

.github/workflows/cuda.yml

+58-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
Tests:
15-
name: CUDA Tests
14+
Tests-gmake:
15+
name: CUDA Tests & GNU Make
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
@@ -27,3 +27,59 @@ jobs:
2727
2828
cd Tests/GPU
2929
make -j4 USE_CUDA=TRUE CUDA_ARCH=80
30+
31+
Tests-cmake:
32+
name: CUDA Tests & CMake
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Dependencies
37+
run: |
38+
.github/workflows/dependencies/dependencies_nvcc.sh
39+
- name: Tests
40+
run: |
41+
export PATH=/usr/local/cuda/bin:${PATH}
42+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
43+
which nvcc || echo "nvcc not in PATH!"
44+
45+
mkdir build
46+
cd build
47+
cmake .. \
48+
-DCMAKE_INSTALL_PREFIX=../cuda_installdir \
49+
-DENABLE_CUDA=ON \
50+
-DCMAKE_CUDA_ARCHITECTURES=80 \
51+
-DENABLE_TESTS=ON
52+
make -j4 VERBOSE=ON
53+
make install
54+
55+
Tutorials-cmake:
56+
name: CUDA Tests & CMake
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- name: Dependencies
61+
run: |
62+
.github/workflows/dependencies/dependencies_nvcc.sh
63+
- name: Tests
64+
run: |
65+
export PATH=/usr/local/cuda/bin:${PATH}
66+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
67+
which nvcc || echo "nvcc not in PATH!"
68+
69+
mkdir build
70+
cd build
71+
cmake .. \
72+
-DCMAKE_INSTALL_PREFIX=../cuda_installdir \
73+
-DENABLE_CUDA=ON \
74+
-DCMAKE_CUDA_ARCHITECTURES=80
75+
make -j4 VERBOSE=ON
76+
make install
77+
78+
cd ../Tutorials/libamrexpr
79+
mkdir build
80+
cd build
81+
cmake .. \
82+
-DCMAKE_PREFIX_PATH=$(realpath ../../../cuda_installdir)
83+
-DENABLE_CUDA=ON \
84+
-DCMAKE_CUDA_ARCHITECTURES=80
85+
make -j4 VERBOSE=ON

.github/workflows/gcc.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
Tests:
15-
name: GCC Tests
14+
Tests-gmake:
15+
name: GCC Tests & GNU Make
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
@@ -33,7 +33,7 @@ jobs:
3333
make -j4 USE_CPU=TRUE
3434
./main.gnu.ex
3535
36-
Tutorials:
36+
Tutorials-gmake:
3737
name: GCC libamrexpr & GNU Make
3838
runs-on: ubuntu-latest
3939
steps:
@@ -62,6 +62,7 @@ jobs:
6262
.github/workflows/dependencies/dependencies_gcc.sh
6363
- name: Tests
6464
run: |
65+
cmake --version
6566
mkdir build
6667
cd build
6768
cmake .. -DCMAKE_CXX_COMPILER=g++ -DENABLE_TESTS=ON

.github/workflows/hip.yml

+55-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
Tests:
15-
name: HIP Tests
14+
Tests-gmake:
15+
name: HIP Tests & GNU Make
1616
runs-on: ubuntu-20.04
1717
steps:
1818
- uses: actions/checkout@v4
@@ -27,3 +27,56 @@ jobs:
2727
cd Tests/GPU
2828
make -j4 USE_HIP=TRUE AMD_ARCH=gfx90a
2929
30+
Tests-cmake:
31+
name: HIP Tests & CMake
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Dependencies
36+
run: |
37+
.github/workflows/dependencies/dependencies_hip.sh
38+
- name: Tests
39+
run: |
40+
export PATH=/opt/rocm/bin:$PATH
41+
hipcc --version
42+
43+
mkdir build
44+
cd build
45+
cmake .. \
46+
-DCMAKE_INSTALL_PREFIX=../hip_installdir \
47+
-DENABLE_HIP=ON \
48+
-DCMAKE_HIP_ARCHITECTURES=gfx90a \
49+
-DENABLE_TESTS=ON
50+
make -j4 VERBOSE=ON
51+
make install
52+
53+
Tutorials-cmake:
54+
name: HIP Tests & CMake
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
- name: Dependencies
59+
run: |
60+
.github/workflows/dependencies/dependencies_hip.sh
61+
- name: Tests
62+
run: |
63+
export PATH=/opt/rocm/bin:$PATH
64+
hipcc --version
65+
66+
mkdir build
67+
cd build
68+
cmake .. \
69+
-DCMAKE_INSTALL_PREFIX=../hip_installdir \
70+
-DENABLE_HIP=ON \
71+
-DCMAKE_HIP_ARCHITECTURES=gfx90a
72+
make -j4 VERBOSE=ON
73+
make install
74+
75+
cd ../Tutorials/libamrexpr
76+
mkdir build
77+
cd build
78+
cmake .. \
79+
-DCMAKE_PREFIX_PATH=$(realpath ../../../hip_installdir)
80+
-DENABLE_HIP=ON \
81+
-DCMAKE_HIP_ARCHITECTURES=gfx90a
82+
make -j4 VERBOSE=ON

.github/workflows/intel.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
Tests:
15-
name: Intel CPU Tests
14+
Tests-gmake:
15+
name: Intel Tests & GNU Make
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
@@ -37,7 +37,7 @@ jobs:
3737
make -j4 USE_CPU=TRUE COMP=intel
3838
./main.intel.ex
3939
40-
Tutorials:
40+
Tutorials-gmake:
4141
name: Intel libamrexpr & GNU Make
4242
runs-on: ubuntu-latest
4343
steps:

CMakeLists.txt

+15-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ option(ENABLE_HIP "Enable HIP support" OFF)
2626
if (ENABLE_HIP)
2727
set(AMREXPR_USE_GPU 1)
2828
set(AMREXPR_USE_HIP 1)
29-
find_package(hip REQUIRED)
3029
enable_language(HIP)
3130
endif()
3231

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

52+
get_target_property(amrexpr_sources amrexpr SOURCES)
53+
list(FILTER amrexpr_sources INCLUDE REGEX "\\.cpp$")
54+
5355
if (ENABLE_CUDA)
54-
get_target_property(_sources amrexpr SOURCES)
55-
list(FILTER _sources INCLUDE REGEX "\\.cpp$")
56-
set_source_files_properties(${_sources} PROPERTIES LANGUAGE CUDA)
57-
if (NOT DEFINED CUDA_ARCHITECTURES)
56+
set_source_files_properties(${amrexpr_sources} PROPERTIES LANGUAGE CUDA)
57+
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
5858
message(STATUS "No CUDA architectures specified. Native will be used.")
59-
set_target_properties(amrexpr PROPERTIES CUDA_ARCHITECTURES native)
59+
set(CMAKE_CUDA_ARCHITECTURES native)
6060
endif()
61-
set_target_properties(amrexpr PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
61+
set_target_properties(amrexpr PROPERTIES
62+
CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}
63+
CUDA_SEPARABLE_COMPILATION ON)
6264
target_compile_features(amrexpr PUBLIC cuda_std_17)
6365
target_compile_options(amrexpr PUBLIC
6466
$<$<COMPILE_LANGUAGE:CUDA>:-m64>
@@ -69,6 +71,12 @@ if (ENABLE_CUDA)
6971
endif()
7072

7173
if (ENABLE_HIP)
74+
set_source_files_properties(${amrexpr_sources} PROPERTIES LANGUAGE HIP)
75+
if (NOT DEFINED CMAKE_HIP_ARCHITECTURES)
76+
message(STATUS "No HIP architectures specified. 'gfx90a' will be used.")
77+
set(CMAKE_HIP_ARCHITECTURES gfx90a)
78+
endif()
79+
set_target_properties(amrexpr PROPERTIES HIP_ARCHITECTURES ${CMAKE_HIP_ARCHITECTURES})
7280
target_compile_features(amrexpr PUBLIC hip_std_17)
7381
endif()
7482

@@ -87,12 +95,6 @@ set(amrexpr_FIND_DEPENDENCIES "")
8795
if (ENABLE_CUDA)
8896
set(amrexpr_FIND_DEPENDENCIES "${amrexpr_FIND_DEPENDENCIES}\nfind_dependency(CUDAToolkit REQUIRED)")
8997
endif()
90-
if (ENABLE_HIP)
91-
set(amrexpr_FIND_DEPENDENCIES "${amrexpr_FIND_DEPENDENCIES}\nfind_dependency(hip REQUIRED)")
92-
endif()
93-
if (ENABLE_SYCL)
94-
# Adjust SYCL dependency find commands if necessary
95-
endif()
9698

9799
include(CMakePackageConfigHelpers)
98100

README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,9 @@ the GPU architecture in the configure step. For example
102102
$ cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<installation_direction> \
103103
-DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80
104104

105-
# Nvidia GPU w/ compute capability 8.0
106-
$ cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<installation_direction> \
107-
-DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80
108-
109-
# Nvidia GPU w/ compute capability 8.0
105+
# AMD MI250X GPU, gfx90a architecture
110106
$ cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<installation_direction> \
111-
-DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80
107+
-DENABLE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx908
112108
```
113109

114110
## Copyright Notice

Tests/GPU/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ if (ENABLE_CUDA)
1616
target_compile_options(test_gpu PRIVATE $<TARGET_PROPERTY:amrexpr>)
1717
endif()
1818

19+
if (ENABLE_HIP)
20+
set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP)
21+
target_compile_options(test_gpu PRIVATE $<TARGET_PROPERTY:amrexpr>)
22+
endif()
23+
1924
add_test(NAME test_gpu COMMAND test_gpu)

Tutorials/libamrexpr/CMakeLists.txt

+14-8
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ if (ENABLE_CUDA)
2525
find_package(CUDAToolkit REQUIRED)
2626
endif()
2727

28-
if (ENABLE_HIP)
29-
find_package(hip REQUIRED)
30-
endif()
31-
3228
if (ENABLE_SYCL)
3329
set(CMAKE_CXX_COMPILER icpx)
3430
endif()
@@ -39,13 +35,23 @@ add_executable(parser_test main.cpp)
3935

4036
if (ENABLE_CUDA)
4137
set_source_files_properties(main.cpp PROPERTIES LANGUAGE CUDA)
42-
if (NOT DEFINED CUDA_ARCHITECTURES)
38+
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
4339
message(STATUS "No CUDA architectures specified. Native will be used.")
44-
set_target_properties(parser_test PROPERTIES CUDA_ARCHITECTURES native)
40+
set(CMAKE_CUDA_ARCHITECTURES native)
41+
endif()
42+
set_target_properties(parser_test PROPERTIES
43+
CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}
44+
CUDA_SEPARABLE_COMPILATION ON)
45+
endif()
46+
47+
if (ENABLE_HIP)
48+
set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP)
49+
if (NOT DEFINED CMAKE_HIP_ARCHITECTURES)
50+
message(STATUS "No HIP architectures specified. 'gfx90a' will be used.")
51+
set(CMAKE_HIP_ARCHITECTURES gfx90a)
4552
endif()
4653
set_target_properties(parser_test PROPERTIES
47-
CUDA_SEPARABLE_COMPILATION ON
48-
)
54+
HIP_ARCHITECTURES ${CMAKE_HIP_ARCHITECTURES})
4955
endif()
5056

5157
target_link_libraries(parser_test PRIVATE amrexpr::amrexpr)

0 commit comments

Comments
 (0)