Add build configuration with CUDA on Linux

Change-Id: I3144a44692a7a129857b65ed84fb2a5637b25b5d
This commit is contained in:
Dmitriy Korchemkin
2022-11-28 21:48:07 +03:00
parent 06bfe6ffac
commit 2fd81de12d
2 changed files with 20 additions and 5 deletions
+16 -3
View File
@@ -4,7 +4,7 @@ on: [push, pull_request]
jobs:
build:
name: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}
name: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.gpu}}
runs-on: ubuntu-latest
container: ${{matrix.os}}
defaults:
@@ -25,6 +25,9 @@ jobs:
lib:
- shared
- static
gpu:
- cuda
- no-cuda
steps:
- uses: actions/checkout@v2
@@ -46,13 +49,21 @@ jobs:
libsuitesparse-dev \
ninja-build
- name: Setup CUDA toolkit
if: matrix.gpu == 'cuda'
run: |
apt-get install -y \
nvidia-cuda-dev \
nvidia-cuda-toolkit
- name: Cache Build
id: cache-build
uses: actions/cache@v2
with:
path: ${{env.CCACHE_DIR}}
key: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{github.run_id}}
restore-keys: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-
key: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.gpu}}-${{github.run_id}}
restore-keys: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.gpu}}-
- name: Setup Environment
if: matrix.build_type == 'Release'
@@ -63,6 +74,7 @@ jobs:
run: |
cmake -S . -B build_${{matrix.build_type}} \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DUSE_CUDA=${{matrix.gpu == 'cuda'}} \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_C_COMPILER_LAUNCHER=$(which ccache) \
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
@@ -74,6 +86,7 @@ jobs:
--config ${{matrix.build_type}}
- name: Test
if: matrix.gpu == 'no-cuda'
run: |
cd build_${{matrix.build_type}}/
ctest --config ${{matrix.build_type}} \
+4 -2
View File
@@ -30,7 +30,8 @@
#include "cuda_runtime.h"
namespace ceres::internal {
namespace ceres {
namespace internal {
// As the CUDA Toolkit documentation says, "although arbitrary in this case, is
// a common choice". This is determined by the warp size, max block size, and
@@ -122,4 +123,5 @@ void CudaDtDxpy(double* y,
CudaDtDxpyKernel<<<num_blocks, kCudaBlockSize, 0, stream>>>(y, D, x, size);
}
} // namespace ceres::internal
} // namespace internal
} // namespace ceres