From 066078ac64b49eed5d22e258332e5f701faaeedf Mon Sep 17 00:00:00 2001 From: Wentao Liu Date: Sat, 28 Sep 2024 16:10:07 +0800 Subject: [PATCH] CI: add cuda build --- .github/workflows/cuda-build.yml | 47 ++++++++++++++++++++++++++ CMakeLists.txt | 9 +++-- README.md | 4 ++- src/pbrt/wavefront_integrators/path.cu | 4 +-- 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/cuda-build.yml diff --git a/.github/workflows/cuda-build.yml b/.github/workflows/cuda-build.yml new file mode 100644 index 0000000..3db0eb6 --- /dev/null +++ b/.github/workflows/cuda-build.yml @@ -0,0 +1,47 @@ +name: cuda-build + +on: + push: + branches: [ "*" ] + pull_request: + branches: [ "*" ] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + cuda-build: + strategy: + fail-fast: false + matrix: + cuda: [ '12.5.0' ] + + name: GPU build (CUDA ${{ matrix.cuda }}) + + runs-on: ubuntu-latest + steps: + - uses: jimver/cuda-toolkit@v0.2.17 + id: cuda-toolkit + with: + cuda: ${{ matrix.cuda }} + method: 'network' + sub-packages: '[ "nvcc" ]' + + - name: check NVCC + run: nvcc -V + + - name: install dependencies + run: + sudo apt install -y cmake libglu1-mesa-dev libpng-dev libx11-dev xorg-dev + + - uses: actions/checkout@v4 + with: + submodules: true + + - name: build + run: + mkdir build; + cd build; + cmake ..; + make -j; diff --git a/CMakeLists.txt b/CMakeLists.txt index c3cacf0..d5bf530 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,6 @@ if (NOT CMAKE_CUDA_COMPILER) # required by CLion endif () -message("CUDA compiler: ${CMAKE_CUDA_COMPILER}") - set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -28,6 +26,13 @@ endif () enable_language(CUDA) include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") +message(STATUS "nvcc path: ${CMAKE_CUDA_COMPILER}") +message(STATUS "nvcc version = ${CMAKE_CUDA_COMPILER_VERSION}") + +if (${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS "12.5.0") + message(FATAL_ERROR "you need NVCC >= 12.5.0 to build this project (required by cuda::std::optional)") +endif () + add_subdirectory("src/ext") include_directories("src/ext/glad-3.3-core/include") diff --git a/README.md b/README.md index b8c63ec..fadbc5e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # pbrt-minus +[![cuda-build](https://github.com/w3ntao/pbrt-minus/actions/workflows/cuda-build.yml/badge.svg)](https://github.com/w3ntao/pbrt-minus/actions/workflows/cuda-build.yml) + A simpler, less performant, physically based, GPU ray tracer rewritten from PBRT-v4. @@ -20,7 +22,7 @@ A simpler, less performant, physically based, GPU ray tracer rewritten from PBRT Debian/Ubuntu: ``` -$ sudo apt install -y libglu1-mesa-dev libpng-dev libx11-dev xorg-dev +$ sudo apt install -y cmake libglu1-mesa-dev libpng-dev libx11-dev xorg-dev ``` Setting up for other distros should be similar. diff --git a/src/pbrt/wavefront_integrators/path.cu b/src/pbrt/wavefront_integrators/path.cu index bb1a933..4f9f765 100644 --- a/src/pbrt/wavefront_integrators/path.cu +++ b/src/pbrt/wavefront_integrators/path.cu @@ -314,7 +314,7 @@ __global__ void generate_new_path(const IntegratorBase *base, const Filter *filt template __global__ void gpu_evaluate_material(const WavefrontPathIntegrator *integrator, PathState *path_state, Queues *queues) { - uint material_counter = NAN; + uint material_counter = UINT_MAX; uint *material_queue = nullptr; switch (material_type) { @@ -480,7 +480,7 @@ PBRT_GPU void WavefrontPathIntegrator::sample_bsdf(uint path_idx, PathState *pat template void WavefrontPathIntegrator::evaluate_material() { - uint material_counter = NAN; + uint material_counter = UINT_MAX; switch (material_type) { case (Material::Type::coated_conductor): { material_counter = queues.coated_conductor_material_counter;