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
4 changes: 2 additions & 2 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 4.0.0)
VERSION 4.1.0)

# --------------------------------------------------------------------------------------------------------
# Library switches
Expand Down Expand Up @@ -99,7 +99,7 @@ include("cmake/cpm.cmake")

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

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@4.0.0") # Use the latest release version
CPMAddPackage("gh:viennatools/viennaray@4.1.0") # Use the latest release version
```

* With a local installation
Expand Down
1 change: 0 additions & 1 deletion gpu/examples/trenchTriangles.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "gpu/raygTraceTriangle.hpp"

#include <cuda_runtime.h>
#include <omp.h>

// #define COUNT_RAYS
Expand Down
17 changes: 9 additions & 8 deletions include/viennaray/gpu/raygDiskGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,21 @@ struct DiskGeometry {
CudaBuffer outputBuffer;
outputBuffer.alloc(blasBufferSizes.outputSizeInBytes);

optixAccelBuild(context.optix, 0, &accelOptions, diskInput.data(),
numBuildInputs, tempBuffer.dPointer(),
tempBuffer.sizeInBytes, outputBuffer.dPointer(),
outputBuffer.sizeInBytes, &asHandle, &emitDesc, 1);
cuCtxSynchronize();
OPTIX_CHECK(optixAccelBuild(
context.optix, 0, &accelOptions, diskInput.data(), numBuildInputs,
tempBuffer.dPointer(), tempBuffer.sizeInBytes, outputBuffer.dPointer(),
outputBuffer.sizeInBytes, &asHandle, &emitDesc, 1));
context.sync();

// perform compaction
uint64_t compactedSize;
compactedSizeBuffer.download(&compactedSize, 1);

asBuffer.alloc(compactedSize);
optixAccelCompact(context.optix, 0, asHandle, asBuffer.dPointer(),
asBuffer.sizeInBytes, &asHandle);
cuCtxSynchronize();
OPTIX_CHECK(optixAccelCompact(context.optix, 0, asHandle,
asBuffer.dPointer(), asBuffer.sizeInBytes,
&asHandle));
context.sync();

// clean up
outputBuffer.free(); // << the UNcompacted, temporary output buffer
Expand Down
17 changes: 9 additions & 8 deletions include/viennaray/gpu/raygLineGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,21 @@ struct LineGeometry {
CudaBuffer outputBuffer;
outputBuffer.alloc(blasBufferSizes.outputSizeInBytes);

optixAccelBuild(context.optix, 0, &accelOptions, lineInput.data(),
numBuildInputs, tempBuffer.dPointer(),
tempBuffer.sizeInBytes, outputBuffer.dPointer(),
outputBuffer.sizeInBytes, &asHandle, &emitDesc, 1);
cuCtxSynchronize();
OPTIX_CHECK(optixAccelBuild(
context.optix, 0, &accelOptions, lineInput.data(), numBuildInputs,
tempBuffer.dPointer(), tempBuffer.sizeInBytes, outputBuffer.dPointer(),
outputBuffer.sizeInBytes, &asHandle, &emitDesc, 1));
context.sync();

// perform compaction
uint64_t compactedSize;
compactedSizeBuffer.download(&compactedSize, 1);

asBuffer.alloc(compactedSize);
optixAccelCompact(context.optix, 0, asHandle, asBuffer.dPointer(),
asBuffer.sizeInBytes, &asHandle);
cuCtxSynchronize();
OPTIX_CHECK(optixAccelCompact(context.optix, 0, asHandle,
asBuffer.dPointer(), asBuffer.sizeInBytes,
&asHandle));
context.sync();

// clean up
outputBuffer.free(); // << the UNcompacted, temporary output buffer
Expand Down
14 changes: 6 additions & 8 deletions include/viennaray/gpu/raygTrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,9 @@ template <class T, int D> class Trace {
VIENNACORE_LOG_WARNING(
"Passed cell data does not match number of elements.");
}
cellDataBuffer_ = passedCellDataBuffer;
#ifndef NDEBUG
// In debug mode, we set the buffer as reference to avoid accidental frees
cellDataBuffer_.isRef = true;
#endif
cellDataBuffer_ = passedCellDataBuffer; // note: this is a reference, and
// does not own the memory, so no
// free() in destructor
numCellData_ = numData;
}

Expand Down Expand Up @@ -397,7 +395,7 @@ template <class T, int D> class Trace {
}
directCallablePGs_.clear();
for (auto &s : streams_) {
CUDA_CHECK(cuStreamDestroy(s));
context_->ch.cuStreamDestroy_(s);
}
}

Expand Down Expand Up @@ -429,7 +427,7 @@ template <class T, int D> class Trace {
// each particle gets its own stream
streams_.resize(particles_.size());
for (size_t i = 0; i < particles_.size(); i++) {
CUDA_CHECK(cuStreamCreate(&streams_[i], CU_STREAM_DEFAULT));
context_->ch.cuStreamCreate_(&streams_[i], CU_STREAM_DEFAULT);
}

return numFluxes_;
Expand Down Expand Up @@ -469,7 +467,7 @@ template <class T, int D> class Trace {
return;

for (auto &s : streams_) {
CUDA_CHECK(cuStreamSynchronize(s));
context_->ch.cuStreamSynchronize_(s);
}
isSynced_ = true;
}
Expand Down
19 changes: 11 additions & 8 deletions include/viennaray/gpu/raygTriangleGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ struct TriangleGeometry {
// device pointers
CUdeviceptr d_geoVertices = geometryVertexBuffer.dPointer();
CUdeviceptr d_geoIndices = geometryIndexBuffer.dPointer();
assert((d_geoVertices != 0) && (d_geoIndices != 0) &&
"Device pointers for geometry vertices and indices cannot be null!");

triangleInput[0].triangleArray.vertexFormat = OPTIX_VERTEX_FORMAT_FLOAT3;
triangleInput[0].triangleArray.vertexStrideInBytes = sizeof(Vec3Df);
Expand Down Expand Up @@ -160,20 +162,21 @@ struct TriangleGeometry {
CudaBuffer outputBuffer;
outputBuffer.alloc(blasBufferSizes.outputSizeInBytes);

optixAccelBuild(context.optix, 0, &accelOptions, triangleInput.data(),
numBuildInputs, tempBuffer.dPointer(),
tempBuffer.sizeInBytes, outputBuffer.dPointer(),
outputBuffer.sizeInBytes, &asHandle, &emitDesc, 1);
cuCtxSynchronize();
OPTIX_CHECK(optixAccelBuild(
context.optix, 0, &accelOptions, triangleInput.data(), numBuildInputs,
tempBuffer.dPointer(), tempBuffer.sizeInBytes, outputBuffer.dPointer(),
outputBuffer.sizeInBytes, &asHandle, &emitDesc, 1));
context.sync();

// perform compaction
uint64_t compactedSize;
compactedSizeBuffer.download(&compactedSize, 1);

asBuffer.alloc(compactedSize);
optixAccelCompact(context.optix, 0, asHandle, asBuffer.dPointer(),
asBuffer.sizeInBytes, &asHandle);
cuCtxSynchronize();
OPTIX_CHECK(optixAccelCompact(context.optix, 0, asHandle,
asBuffer.dPointer(), asBuffer.sizeInBytes,
&asHandle));
context.sync();

// clean up
outputBuffer.free(); // << the UNcompacted, temporary output buffer
Expand Down
Loading