Skip to content

Commit

Permalink
Fixes (initializers, handle exceptions in dtors)
Browse files Browse the repository at this point in the history
  • Loading branch information
johguenther committed Oct 17, 2023
1 parent 6af29ba commit 935eecd
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 26 deletions.
6 changes: 3 additions & 3 deletions modules/cpu/camera/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ struct OSPRAY_SDK_INTERFACE Camera
// Data members //

// if motionBlur in local camera space; otherwise in world-space:
vec3f pos; // position of the camera
vec3f dir; // main direction of the camera
vec3f up; // up direction of the camera
vec3f pos{0.f, 0.f, 0.f}; // position of the camera
vec3f dir{0.f, 0.f, 1.f}; // main direction of the camera
vec3f up{0.f, 1.f, 0.f}; // up direction of the camera

float nearClip{1e-6f}; // near clipping distance
// definition of the image region, may even be outside of [0..1]^2
Expand Down
3 changes: 1 addition & 2 deletions modules/cpu/fb/SparseFB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ SparseFrameBuffer::SparseFrameBuffer(api::ISPCDevice &device,
FFO_FB_SPARSE),
device(device),
useTaskAccumIDs((channels & OSP_FB_ACCUM) || overrideUseTaskAccumIDs),
totalTiles(divRoundUp(size, vec2i(TILE_SIZE))),
numRenderTasks(0)
totalTiles(divRoundUp(size, vec2i(TILE_SIZE)))
{
if (size.x <= 0 || size.y <= 0) {
throw std::runtime_error(
Expand Down
2 changes: 1 addition & 1 deletion modules/cpu/fb/SparseFB.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ struct OSPRAY_SDK_INTERFACE SparseFrameBuffer

// Total number of render tasks that the framebuffer is divided into,
// including those not owned by this sparsefb
vec2i numRenderTasks;
vec2i numRenderTasks{0};

// holds error per task for each tile, stored in tiled order.
// The SparseFB doesn't do its own error refinement since it doesn't have
Expand Down
7 changes: 6 additions & 1 deletion modules/mpi/common/maml/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <chrono>
#include <iostream>

#include "common/OSPCommon.h"
#include "rkcommon/memory/malloc.h"
#include "rkcommon/tasking/async.h"
#include "rkcommon/tasking/tasking_system_init.h"
Expand All @@ -30,7 +31,11 @@ Context::Context(bool enableCompression) : compressMessages(enableCompression)

Context::~Context()
{
stop();
try {
stop();
} catch (const std::exception &e) {
ospray::handleError(OSP_UNKNOWN_ERROR, e.what());
}
}

/*! register a new incoing-message handler. if any message comes in
Expand Down
41 changes: 23 additions & 18 deletions modules/mpi/ospray/MPIOffloadDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,29 @@ void createMPI_ListenForClient(

MPIOffloadDevice::~MPIOffloadDevice()
{
if (dynamic_cast<MPIFabric *>(fabric.get()) && world.rank == 0) {
postStatusMsg(OSP_LOG_INFO) << "shutting down mpi device";

sendWork([](networking::WriteStream &writer) { writer << work::FINALIZE; },
true);
fabric = nullptr;
maml::shutdown();

MPI_Finalize();

RKCOMMON_IF_TRACING_ENABLED({
char hostname[512] = {0};
gethostname(hostname, 511);
const std::string masterTraceFile =
std::string(hostname) + "_master.json";
rkcommon::tracing::saveLog(
masterTraceFile.c_str(), masterTraceFile.c_str());
});
try {
if (dynamic_cast<MPIFabric *>(fabric.get()) && world.rank == 0) {
postStatusMsg(OSP_LOG_INFO) << "shutting down mpi device";

sendWork(
[](networking::WriteStream &writer) { writer << work::FINALIZE; },
true);
fabric = nullptr;
maml::shutdown();

MPI_Finalize();

RKCOMMON_IF_TRACING_ENABLED({
char hostname[512] = {0};
gethostname(hostname, 511);
const std::string masterTraceFile =
std::string(hostname) + "_master.json";
rkcommon::tracing::saveLog(
masterTraceFile.c_str(), masterTraceFile.c_str());
});
}
} catch (const std::exception &e) {
handleError(OSP_UNKNOWN_ERROR, e.what());
}
}

Expand Down
2 changes: 1 addition & 1 deletion ospray/common/Managed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ManagedObject::~ManagedObject()
{
std::for_each(params_begin(), params_end(), [&](std::shared_ptr<Param> &p) {
auto &param = *p;
if (param.data.is<OSP_PTR>()) {
if (param.data.valid() && param.data.is<OSP_PTR>()) {
auto *obj = param.data.get<OSP_PTR>();
if (obj != nullptr)
obj->refDec();
Expand Down

0 comments on commit 935eecd

Please sign in to comment.