Skip to content

Commit 4785e86

Browse files
committed
Compile CUDA in CI
1 parent a34c034 commit 4785e86

File tree

2 files changed

+76
-31
lines changed

2 files changed

+76
-31
lines changed

.github/workflows/cuda.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
paths:
8+
- '.github/workflows/cuda.yml'
9+
- 'cmake/**'
10+
- 'src/**'
11+
- 'tests/**'
12+
- 'python/**'
13+
- 'CMakeLists.txt'
14+
15+
env:
16+
CTEST_OUTPUT_ON_FAILURE: ON
17+
CTEST_PARALLEL_LEVEL: 2
18+
19+
jobs:
20+
Build:
21+
name: CUDA (${{ matrix.config }})
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
config:
27+
- Debug
28+
# - Release # cannot run multiple cuda-toolkit jobs in parallel
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/[email protected]
32+
with:
33+
fetch-depth: 10
34+
35+
- name: Dependencies
36+
run: |
37+
sudo apt-get install ccache
38+
echo 'CACHE_PATH=~/.cache/ccache' >> "$GITHUB_ENV"
39+
40+
- uses: Jimver/[email protected]
41+
id: cuda-toolkit
42+
with:
43+
cuda: '12.3.2'
44+
45+
- name: Get number of CPU cores
46+
uses: SimenB/[email protected]
47+
id: cpu-cores
48+
49+
- name: Cache Build
50+
id: cache-build
51+
uses: actions/[email protected]
52+
with:
53+
path: ${{ env.CACHE_PATH }}
54+
key: ${{ runner.os }}-${{ matrix.config }}-cache
55+
56+
- name: Prepare ccache
57+
run: |
58+
ccache --max-size=1.0G
59+
ccache -V && ccache --show-config
60+
ccache --show-stats && ccache --zero-stats
61+
62+
- name: Configure
63+
run: |
64+
mkdir -p build
65+
cd build
66+
cmake .. \
67+
-DIPC_TOOLKIT_WITH_CUDA=ON \
68+
-DSCALABLE_CCD_CUDA_ARCHITECTURES=75 \
69+
-DIPC_TOOLKIT_BUILD_TESTS=ON \
70+
-DIPC_TOOLKIT_BUILD_PYTHON=ON \
71+
-DCMAKE_BUILD_TYPE=${{ matrix.config }}
72+
73+
- name: Build
74+
run: |
75+
cmake --build build -j ${{ steps.cpu-cores.outputs.count }}
76+
ccache --show-stats

CMakeLists.txt

-31
Original file line numberDiff line numberDiff line change
@@ -211,37 +211,6 @@ endif()
211211
# Use C++17
212212
target_compile_features(ipc_toolkit PUBLIC cxx_std_17)
213213

214-
################################################################################
215-
# CUDA
216-
################################################################################
217-
218-
if(IPC_TOOLKIT_WITH_CUDA)
219-
include(CheckLanguage)
220-
check_language(CUDA)
221-
if(CMAKE_CUDA_COMPILER)
222-
enable_language(CUDA)
223-
else()
224-
message(FATAL_ERROR "No CUDA support found!")
225-
endif()
226-
227-
# We need to explicitly state that we need all CUDA files in the particle
228-
# library to be built with -dc as the member functions could be called by
229-
# other libraries and executables.
230-
set_target_properties(ipc_toolkit PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
231-
232-
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
233-
set(CMAKE_CUDA_ARCHITECTURES "native")
234-
else()
235-
include(FindCUDA/select_compute_arch)
236-
CUDA_DETECT_INSTALLED_GPUS(CUDA_ARCH_LIST)
237-
string(STRIP "${CUDA_ARCH_LIST}" CUDA_ARCH_LIST)
238-
string(REPLACE " " ";" CUDA_ARCH_LIST "${CUDA_ARCH_LIST}")
239-
string(REPLACE "." "" CUDA_ARCH_LIST "${CUDA_ARCH_LIST}")
240-
set(CMAKE_CUDA_ARCHITECTURES ${CUDA_ARCH_LIST})
241-
endif()
242-
set_target_properties(scalable_ccd PROPERTIES CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}")
243-
endif()
244-
245214
################################################################################
246215
# Tests
247216
################################################################################

0 commit comments

Comments
 (0)