Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(
ViennaRay
LANGUAGES CXX
VERSION 3.9.1)
VERSION 3.10.0)

# --------------------------------------------------------------------------------------------------------
# Library switches
Expand Down Expand Up @@ -74,6 +74,7 @@ if(VIENNARAY_GPU_DOUBLE_PRECISION)
endif()

if(VIENNARAY_PRINT_PROGRESS)
message(STATUS "[ViennaRay] Enabling progress printing")
target_compile_definitions(${PROJECT_NAME} INTERFACE VIENNARAY_PRINT_PROGRESS)
endif()

Expand All @@ -98,7 +99,7 @@ include("cmake/cpm.cmake")

CPMAddPackage(
NAME ViennaCore
VERSION 1.8.0
VERSION 1.9.0
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore"
OPTIONS "VIENNACORE_USE_GPU ${VIENNARAY_USE_GPU}")

Expand Down Expand Up @@ -149,12 +150,9 @@ endif()
# Setup GPU
# --------------------------------------------------------------------------------------------------------

# If CUDA or OptiX is not found in ViennaCore, VIENNACORE_PTX_DIR is not set
if(VIENNARAY_USE_GPU AND VIENNACORE_PTX_DIR)
if(VIENNARAY_USE_GPU)
message(STATUS "[ViennaRay] Enabling GPU support")
add_subdirectory(gpu)
target_include_directories(${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gpu/include>)
endif()

# --------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ We recommend using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to consum
* Installation with CPM

```cmake
CPMAddPackage("gh:viennatools/viennaray@3.8.5") # Use the latest release version
CPMAddPackage("gh:viennatools/viennaray@3.10.0") # Use the latest release version
```

* With a local installation
Expand Down
151 changes: 0 additions & 151 deletions cmake/generate_ptx.cmake

This file was deleted.

9 changes: 5 additions & 4 deletions examples/disk2D/disk2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ int main() {
// however the boundary condition in direction of the tracing direction will
// not be used. Possible choices are: PERIODIC, REFLECTIVE, IGNORE
BoundaryCondition boundaryConds[D];
boundaryConds[0] = BoundaryCondition::PERIODIC; // x
boundaryConds[1] = BoundaryCondition::PERIODIC; // y
boundaryConds[0] = BoundaryCondition::PERIODIC_BOUNDARY; // x
boundaryConds[1] = BoundaryCondition::PERIODIC_BOUNDARY; // y

// ParticleType: The particle types provides the sticking probability and
// the reflection process for each surface hit. This class can be user
// defined, but has to interface the rayParticle<NumericType> class and
// provide the functions: initNew(...), surfaceCollision(...),
// surfaceReflection(...).
auto particle =
std::make_unique<DiffuseParticle<NumericType, D>>(0.5, "flux");
NumericType stickingProbability = 0.1;
auto particle = std::make_unique<DiffuseParticle<NumericType, D>>(
stickingProbability, "flux");

TraceDisk<NumericType, D> rayTracer;
rayTracer.setGeometry(points, normals, gridDelta);
Expand Down
11 changes: 6 additions & 5 deletions examples/disk3D/disk3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ int main() {
// however the boundary condition in direction of the tracing direction will
// not be used. Possible choices are: PERIODIC, REFLECTIVE, IGNORE
BoundaryCondition boundaryConds[D];
boundaryConds[0] = BoundaryCondition::PERIODIC; // x
boundaryConds[1] = BoundaryCondition::PERIODIC; // y
boundaryConds[2] = BoundaryCondition::PERIODIC; // z
boundaryConds[0] = BoundaryCondition::PERIODIC_BOUNDARY; // x
boundaryConds[1] = BoundaryCondition::PERIODIC_BOUNDARY; // y
boundaryConds[2] = BoundaryCondition::PERIODIC_BOUNDARY; // z

// ParticleType: The particle types provides the sticking probability and
// the reflection process for each surface hit. This class can be user
// defined, but has to interface the rayParticle<NumericType> class and
// provide the functions: initNew(...), surfaceCollision(...),
// surfaceReflection(...).
auto particle =
std::make_unique<DiffuseParticle<NumericType, D>>(0.1, "flux");
NumericType stickingProbability = 0.1;
auto particle = std::make_unique<DiffuseParticle<NumericType, D>>(
stickingProbability, "flux");

TraceDisk<NumericType, D> rayTracer;
rayTracer.setGeometry(points, normals, gridDelta);
Expand Down
5 changes: 3 additions & 2 deletions examples/triangle2D/triangle2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ int main() {
TraceTriangle<NumericType, D> tracer;
tracer.setGeometry(lineMesh);

auto particle =
std::make_unique<DiffuseParticle<NumericType, D>>(0.1, "flux");
NumericType stickingProbability = 0.1;
auto particle = std::make_unique<DiffuseParticle<NumericType, D>>(
stickingProbability, "flux");
tracer.setParticleType(particle);
tracer.setNumberOfRaysPerPoint(5000);

Expand Down
5 changes: 3 additions & 2 deletions examples/triangle3D/triangle3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ int main() {
TraceTriangle<NumericType, D> tracer;
tracer.setGeometry(mesh);

auto particle =
std::make_unique<DiffuseParticle<NumericType, D>>(0.1, "flux");
NumericType stickingProbability = 0.1;
auto particle = std::make_unique<DiffuseParticle<NumericType, D>>(
stickingProbability, "flux");
tracer.setParticleType(particle);
tracer.setNumberOfRaysPerPoint(2000);

Expand Down
61 changes: 34 additions & 27 deletions gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
project(ViennaRay-GPU)

option(VIENNARAY_ENABLE_OPTIXIR_SUPPORT
"Enable support for generating OptiX-IR targeted input files" ON)

if(CUDA_VERSION VERSION_LESS 11.7)
if(VIENNARAY_ENABLE_OPTIXIR_SUPPORT)
message(
SEND_ERROR "VIENNARAY_ENABLE_OPTIXIR_SUPPORT is not supported in CUDA versions less than 11.7"
)
endif()
endif()

if(VIENNARAY_ENABLE_OPTIXIR_SUPPORT)
option(VIENNARAY_GENERATE_OPTIXIR "Generate Optix-IR OptiX shaders" ON)
option(VIENNARAY_GENERATE_PTX "Generate PTX OptiX shaders" OFF)
else()
option(VIENNARAY_GENERATE_OPTIXIR "Generate Optix-IR OptiX shaders" OFF)
option(VIENNARAY_GENERATE_PTX "Generate PTX OptiX shaders" ON)
endif()

#### Set variables
set(VIENNARAY_GPU_INCLUDE
"${PROJECT_SOURCE_DIR}/include"
CACHE STRING "ViennaRay GPU headers.")
set(VIENNARAY_CUDA_KERNELS
"${PROJECT_SOURCE_DIR}/kernels/normKernels.cu"
"${PROJECT_SOURCE_DIR}/gpu/kernels/normKernels.cu"
CACHE STRING "ViennaRay CUDA kernel source files.")
set(VIENNARAY_PIPELINE_DIR
"${PROJECT_SOURCE_DIR}/pipelines"
"${PROJECT_SOURCE_DIR}/gpu/pipelines"
CACHE STRING "ViennaRay pipeline directory.")
include("../cmake/generate_ptx.cmake")

# Incldue directories for PTX and optix-ir compilation (force cache to update with new entries)
if(NOT VIENNARAY_PASSED_FIRST_CONFIGURE)
set(VIENNACORE_NVCC_INCLUDE_DIRS
${VIENNACORE_NVCC_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include/viennaray/gpu
CACHE STRING "PTX include directories" FORCE)
if(VIENNARAY_GPU_DOUBLE_PRECISION)
set(VIENNACORE_NVCC_DEFINES
${VIENNACORE_NVCC_DEFINES} "VIENNARAY_GPU_DOUBLE_PRECISION=1"
CACHE STRING "PTX compile definitions" FORCE)
endif()
endif()

# Add the general pipelines and callable wrapper
viennacore_add_optixir(GeneralPipelineDisk ${VIENNARAY_PIPELINE_DIR}/GeneralPipelineDisk.cu)
viennacore_add_optixir(GeneralPipelineTriangle ${VIENNARAY_PIPELINE_DIR}/GeneralPipelineTriangle.cu)
viennacore_add_optixir(GeneralPipelineLine ${VIENNARAY_PIPELINE_DIR}/GeneralPipelineLine.cu)
viennacore_add_optixir(ViennaRayCallableWrapper ${VIENNARAY_PIPELINE_DIR}/CallableWrapper.cu)

# Add the norm kernels
viennacore_add_ptx(normKernels ${VIENNARAY_CUDA_KERNELS})

# CMake target to collect all GPU dependencies for tests and examples
set(VIENNARAY_GPU_DEPENDENCIES
GeneralPipelineDisk GeneralPipelineTriangle GeneralPipelineLine normKernels
CACHE STRING "ViennaRay GPU dependencies.")
# Install PTX files
install(DIRECTORY "${VIENNACORE_NVCC_PTX_DIR}/" DESTINATION "lib/ptx")

if(VIENNARAY_BUILD_EXAMPLES)
message(STATUS "[ViennaRay] Adding GPU Examples")
Expand All @@ -40,3 +43,7 @@ if(VIENNARAY_BUILD_TESTS)
message(STATUS "[ViennaRay] Adding GPU Tests")
add_subdirectory(tests)
endif()

set(VIENNARAY_PASSED_FIRST_CONFIGURE
ON
CACHE INTERNAL "Indicates whether the first configure has been passed.")
17 changes: 11 additions & 6 deletions gpu/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ project(ViennaRay-GPU_Examples)

add_custom_target(ViennaRay-GPU_Examples ALL)

add_gpu_executable(GPU_trenchTriangles target_name trenchTriangles.cpp)
add_executable(GPU_trenchTriangles trenchTriangles.cpp)
target_link_libraries(GPU_trenchTriangles PRIVATE ViennaRay)
configure_file(${CMAKE_SOURCE_DIR}/examples/triangle3D/trenchMesh.dat
${CMAKE_CURRENT_BINARY_DIR}/trenchMesh.dat COPYONLY)
add_dependencies(ViennaRay-GPU_Examples ${target_name})
add_dependencies(ViennaRay-GPU_Examples GPU_trenchTriangles)

add_gpu_executable(GPU_trenchDisks target_name trenchDisks.cpp)
add_executable(GPU_trenchDisks trenchDisks.cpp)
target_link_libraries(GPU_trenchDisks PRIVATE ViennaRay)
configure_file(${CMAKE_SOURCE_DIR}/examples/disk3D/trenchGrid3D.dat
${CMAKE_CURRENT_BINARY_DIR}/trenchGrid3D.dat COPYONLY)
add_dependencies(ViennaRay-GPU_Examples ${target_name})
add_dependencies(ViennaRay-GPU_Examples GPU_trenchDisks)

add_gpu_executable(GPU_trenchLines target_name trenchLines.cpp)
add_executable(GPU_trenchLines trenchLines.cpp)
target_link_libraries(GPU_trenchLines PRIVATE ViennaRay)
configure_file(${CMAKE_SOURCE_DIR}/examples/triangle2D/lineMesh.dat
${CMAKE_CURRENT_BINARY_DIR}/lineMesh.dat COPYONLY)
add_dependencies(ViennaRay-GPU_Examples ${target_name})
add_dependencies(ViennaRay-GPU_Examples GPU_trenchLines)

add_dependencies(ViennaRay-GPU_Examples ${VIENNARAY_GPU_DEPENDENCIES} ViennaRayCallableWrapper)
7 changes: 3 additions & 4 deletions gpu/examples/trenchDisks.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <raygTraceDisk.hpp>
#include <gpu/raygTraceDisk.hpp>

#include <omp.h>

Expand All @@ -11,8 +11,7 @@ int main() {
using NumericType = float;
Logger::setLogLevel(LogLevel::DEBUG);

auto context = DeviceContext::createContext("../../lib/ptx", 0);
// relative to build directory
auto context = DeviceContext::createContext();

// Read stored geometry grid
NumericType gridDelta;
Expand Down Expand Up @@ -43,7 +42,7 @@ int main() {
gpu::TraceDisk<NumericType, D> tracer(context);
tracer.setGeometry(mesh);
tracer.setMaterialIds(materialIds);
tracer.setCallables("CallableWrapper", context->modulePath);
tracer.setCallables("ViennaRayCallableWrapper", context->modulePath);
tracer.setParticleCallableMap({pMap, cMap});
tracer.setNumberOfRaysPerPoint(1000);
tracer.insertNextParticle(particle);
Expand Down
Loading