Skip to content

Commit

Permalink
CI: add cuda build
Browse files Browse the repository at this point in the history
  • Loading branch information
w3ntao committed Sep 28, 2024
1 parent ec935bc commit 066078a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/cuda-build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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;
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.


Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/pbrt/wavefront_integrators/path.cu
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ __global__ void generate_new_path(const IntegratorBase *base, const Filter *filt
template <Material::Type material_type>
__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) {
Expand Down Expand Up @@ -480,7 +480,7 @@ PBRT_GPU void WavefrontPathIntegrator::sample_bsdf(uint path_idx, PathState *pat

template <Material::Type material_type>
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;
Expand Down

0 comments on commit 066078a

Please sign in to comment.