From 978a66642ad00759ae24920afe02775f20b979b6 Mon Sep 17 00:00:00 2001 From: Ingo Wald Date: Tue, 16 Jun 2026 18:25:46 -0600 Subject: [PATCH 1/2] This commit contains multiple different fixes: - owlParamsGetStream previously returned cudaTextureOBject_t rather than cudaStream_t. fixed. - tear-down of context previously set cuda error state because launch params used cudaFree instead of cudaFreeHost on host-side staging area of LP data. - added various fixes to copyright headers (2026), cuda-checks on some operations that previously didn't have them, and cleanups to how virtual/override destructors are specified. Also various cleanups and typos. --- include/owl/owl_host.h | 2 +- owl/APIContext.cpp | 9 ++++----- owl/Context.cpp | 6 ++---- owl/Context.h | 5 ++--- owl/DeviceContext.cpp | 8 +++----- owl/DeviceContext.h | 5 ++--- owl/DeviceMemory.h | 13 +++++++------ owl/LaunchParams.cpp | 16 +++++++++++----- owl/LaunchParams.h | 11 ++++++----- owl/Object.h | 8 ++++---- owl/ObjectRegistry.cpp | 8 +++++--- owl/ObjectRegistry.h | 7 +++---- owl/RegisteredObject.cpp | 5 ++--- owl/RegisteredObject.h | 7 +++---- owl/SBTObject.cpp | 8 +++++--- owl/SBTObject.h | 24 ++++++++++++------------ owl/helper/cuda.h | 5 ++--- owl/impl.cpp | 11 +++++------ 18 files changed, 79 insertions(+), 79 deletions(-) diff --git a/include/owl/owl_host.h b/include/owl/owl_host.h index 001450f..5a40e92 100644 --- a/include/owl/owl_host.h +++ b/include/owl/owl_host.h @@ -900,7 +900,7 @@ owlAsyncLaunch2DOnDevice(OWLRayGen rayGen, int dims_x, int dims_y, int deviceID, OWLParams params); -OWL_API cudaTextureObject_t//CUstream +OWL_API cudaStream_t owlParamsGetCudaStream(OWLParams params, int deviceID); /*! wait for the async launch to finish */ diff --git a/owl/APIContext.cpp b/owl/APIContext.cpp index a8b30f8..223aadc 100644 --- a/owl/APIContext.cpp +++ b/owl/APIContext.cpp @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #include "APIContext.h" #include "APIHandle.h" @@ -46,15 +45,15 @@ namespace owl { for (auto &it : activeHandles) { if (it && it->object ) { - // PRINT(it->object->toString()); it->object = {}; it->context = {}; handlesToFree.push_back(it); } } activeHandles.clear(); - for (auto handle : handlesToFree) + for (auto handle : handlesToFree) { delete handle; + } } void APIContext::track(APIHandle *object) diff --git a/owl/Context.cpp b/owl/Context.cpp index 1203bd6..23c8992 100644 --- a/owl/Context.cpp +++ b/owl/Context.cpp @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #include "Context.h" #include "Module.h" #include "Geometry.h" @@ -65,7 +64,6 @@ namespace owl { devices.clear(); } - void Context::enablePeerAccess() { LOG("enabling peer access ('.'=self, '+'=can access other device)"); diff --git a/owl/Context.h b/owl/Context.h index a1c2102..1fafd78 100644 --- a/owl/Context.h +++ b/owl/Context.h @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "DeviceContext.h" diff --git a/owl/DeviceContext.cpp b/owl/DeviceContext.cpp index 34930cb..648b245 100644 --- a/owl/DeviceContext.cpp +++ b/owl/DeviceContext.cpp @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #include "Context.h" #include "UserGeom.h" #include "InstanceGroup.h" @@ -216,7 +215,7 @@ namespace owl { destroyPipeline(); OPTIX_CHECK(optixDeviceContextDestroy(optixContext)); - cudaStreamDestroy(stream); + OWL_CUDA_CALL_NOTHROW(StreamDestroy(stream)); } @@ -244,7 +243,6 @@ namespace owl { pipeline = 0; } - void DeviceContext::configurePipelineOptions(bool debug) { // ------------------------------------------------------------------ diff --git a/owl/DeviceContext.h b/owl/DeviceContext.h index 4b8182b..a32dfee 100644 --- a/owl/DeviceContext.h +++ b/owl/DeviceContext.h @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "owl/owl.h" diff --git a/owl/DeviceMemory.h b/owl/DeviceMemory.h index 5209700..7897f56 100644 --- a/owl/DeviceMemory.h +++ b/owl/DeviceMemory.h @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "owl/helper/cuda.h" @@ -124,11 +123,13 @@ namespace owl { struct PinnedHostMem { PinnedHostMem() = default; - ~PinnedHostMem() { if (ptr) cudaFree(ptr); } + ~PinnedHostMem() { + if (ptr) OWL_CUDA_CALL_NOTHROW(FreeHost(ptr)); + } void resize(size_t N) { - if (ptr) cudaFree(ptr); + if (ptr) OWL_CUDA_CALL(Free(ptr)); ptr = 0; - if (N > 0) cudaMallocHost(&ptr,N); + if (N > 0) OWL_CUDA_CALL(MallocHost(&ptr,N)); } uint8_t *data() { return ptr; } diff --git a/owl/LaunchParams.cpp b/owl/LaunchParams.cpp index a8db7ba..65ef2d1 100644 --- a/owl/LaunchParams.cpp +++ b/owl/LaunchParams.cpp @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #include "LaunchParams.h" #include "Context.h" @@ -11,13 +10,16 @@ namespace owl { // ------------------------------------------------------------------ // LaunchParamsType // ------------------------------------------------------------------ - + LaunchParamsType::LaunchParamsType(Context *const context, size_t varStructSize, const std::vector &varDecls) : SBTObjectType(context,context->launchParamTypes,varStructSize,varDecls) {} + LaunchParamsType::~LaunchParamsType() + {} + /*! creates the device-specific data for this group */ Object::DeviceData::SP LaunchParamsType::createOn(const DeviceContext::SP &device) @@ -48,7 +50,8 @@ namespace owl { LaunchParams::DeviceData::~DeviceData() { - cudaStreamDestroy(stream); + if (stream) + OWL_CUDA_CALL_NOTHROW(StreamDestroy(stream)); } // ------------------------------------------------------------------ @@ -64,6 +67,9 @@ namespace owl { assert(type.get()); } + LaunchParams::~LaunchParams() + {} + /*! pretty-printer, for printf-debugging */ std::string LaunchParams::toString() const { diff --git a/owl/LaunchParams.h b/owl/LaunchParams.h index ce795e0..d55690b 100644 --- a/owl/LaunchParams.h +++ b/owl/LaunchParams.h @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "SBTObject.h" @@ -23,7 +22,7 @@ namespace owl { LaunchParamsType(Context *const context, size_t varStructSize, const std::vector &varDecls); - virtual ~LaunchParamsType() = default; + ~LaunchParamsType() override; Object::DeviceData::SP createOn(const DeviceContext::SP &device) override; @@ -44,7 +43,7 @@ namespace owl { /*! constructor, which allocs all the device-side data */ DeviceData(const DeviceContext::SP &device, size_t dataSize); - virtual ~DeviceData(); + ~DeviceData() override; const size_t dataSize; @@ -67,6 +66,8 @@ namespace owl { /*! create a new instenace of given launch param type */ LaunchParams(Context *const context, LaunchParamsType::SP type); + ~LaunchParams() override; + /*! create a new instenace of given launch param type */ /*! pretty-printer, for printf-debugging */ diff --git a/owl/Object.h b/owl/Object.h index 394f40e..81f3134 100644 --- a/owl/Object.h +++ b/owl/Object.h @@ -1,15 +1,15 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 +// NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "DeviceContext.h" namespace owl { - /*! convert a OWLDataType enum into a strict that represents the name of that type */ + /*! convert a OWLDataType enum into a strict that represents the + name of that type */ std::string typeToString(OWLDataType type); /*! returns number of bytes for given data type (where applicable) */ diff --git a/owl/ObjectRegistry.cpp b/owl/ObjectRegistry.cpp index 84c4a56..b72dd94 100644 --- a/owl/ObjectRegistry.cpp +++ b/owl/ObjectRegistry.cpp @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #include "ObjectRegistry.h" #include "RegisteredObject.h" #include "Context.h" @@ -14,6 +13,9 @@ namespace owl { + ObjectRegistry::~ObjectRegistry() + {} + void ObjectRegistry::forget(RegisteredObject *object) { assert(object); diff --git a/owl/ObjectRegistry.h b/owl/ObjectRegistry.h index bf298ee..de5daec 100644 --- a/owl/ObjectRegistry.h +++ b/owl/ObjectRegistry.h @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "Object.h" @@ -18,7 +17,7 @@ namespace owl { in this registry under this ID */ struct ObjectRegistry { ObjectRegistry() = default; - virtual ~ObjectRegistry() = default; + virtual ~ObjectRegistry(); // ReallocContextIDsCB reallocContextIDs, // const char *typeDescription); diff --git a/owl/RegisteredObject.cpp b/owl/RegisteredObject.cpp index f4bf8b3..cdf4b97 100644 --- a/owl/RegisteredObject.cpp +++ b/owl/RegisteredObject.cpp @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #include "RegisteredObject.h" #include "ObjectRegistry.h" diff --git a/owl/RegisteredObject.h b/owl/RegisteredObject.h index a322369..e0ea34f 100644 --- a/owl/RegisteredObject.h +++ b/owl/RegisteredObject.h @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "Object.h" @@ -20,7 +19,7 @@ namespace owl { RegisteredObject(Context *const context, ObjectRegistry ®istry); - virtual ~RegisteredObject(); + ~RegisteredObject() override; /*! the ID we're registered by - should only ever get set to any useful value in the constructor, and get set to -1 when the diff --git a/owl/SBTObject.cpp b/owl/SBTObject.cpp index 84ad83d..3045690 100644 --- a/owl/SBTObject.cpp +++ b/owl/SBTObject.cpp @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #include "SBTObject.h" namespace owl { @@ -93,6 +92,9 @@ namespace owl { variables(type->instantiateVariables()) {} + SBTObjectBase::~SBTObjectBase() + {} + /*! this function is arguably the heart of the owl variable layer: given an SBT Object's set of variables, create the SBT entry that writes the given variables' values into the specified diff --git a/owl/SBTObject.h b/owl/SBTObject.h index 668c52d..85f8ed3 100644 --- a/owl/SBTObject.h +++ b/owl/SBTObject.h @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "RegisteredObject.h" @@ -28,7 +27,7 @@ namespace owl { const std::vector &varDecls); /*! clean up; in particular, frees the vardecls */ - virtual ~SBTObjectType(); + ~SBTObjectType() override; /*! find index of variable with given name, or -1 if not exists */ int getVariableIdx(const std::string &varName); @@ -61,7 +60,7 @@ namespace owl { - /*! abstract base classs for any object that can store variables and + /*! abstract base class for any object that can store variables and write itself into a device-side shader binding table (ie, raygen programs, closest hit programs, etc. Each SBTObjectBase has a type that describes its variables, but the actual work for @@ -73,7 +72,7 @@ namespace owl { SBTObjectBase(Context *const context, ObjectRegistry ®istry, std::shared_ptr type); - virtual ~SBTObjectBase() = default; + ~SBTObjectBase() override; /*! returns whether this object has a variable of this name */ inline bool hasVariable(const std::string &name); @@ -117,17 +116,18 @@ namespace owl { : SBTObjectBase(context,registry,type), type(type) {} - virtual ~SBTObject() = default; - virtual std::string toString() const { return "SBTObject<"+type->toString()+">"; } + ~SBTObject() override + {} + + virtual std::string toString() const + { return "SBTObject<"+type->toString()+">"; } /*! our own type description, that tells us which variables (of which type, etc) we have */ std::shared_ptr const type; }; - - // ------------------------------------------------------------------ // implementation section // ------------------------------------------------------------------ @@ -138,8 +138,8 @@ namespace owl { return type->hasVariable(name); } - /*! return shared-ptr to this variable - should only be called for - variables that we actually own */ + /*! return shared-ptr to this variable - should only be called for + variables that we actually own */ inline Variable::SP SBTObjectBase::getVariable(const std::string &name) { int varID = type->getVariableIdx(name); diff --git a/owl/helper/cuda.h b/owl/helper/cuda.h index 80b3e0b..20b2e01 100644 --- a/owl/helper/cuda.h +++ b/owl/helper/cuda.h @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #pragma once #include "owl/common.h" diff --git a/owl/impl.cpp b/owl/impl.cpp index 377ea9e..7501152 100644 --- a/owl/impl.cpp +++ b/owl/impl.cpp @@ -1,8 +1,7 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +// CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 - - #include #include "APIContext.h" #include "APIHandle.h" @@ -661,6 +660,7 @@ OWL_API void owlContextDestroy(OWLContext _context) // will remain alive even if the context frees all api handles. APIContext::SP context = checkGet(_context); context->releaseAll(); + context = {}; } /*! creates a device buffer where every device has its own local @@ -879,15 +879,14 @@ owlGroupGetTraversable(OWLGroup _group, int deviceID) return group->getTraversable(group->context->getDevice(deviceID)); } -OWL_API cudaTextureObject_t -// OWL_API CUstream +OWL_API cudaStream_t owlParamsGetCudaStream(OWLLaunchParams _lp, int deviceID) { LOG_API_CALL(); assert(_lp); LaunchParams::SP lp = ((APIHandle *)_lp)->get(); assert(lp); - return (cudaTextureObject_t)lp->getCudaStream(lp->context->getDevice(deviceID)); + return (cudaStream_t)lp->getCudaStream(lp->context->getDevice(deviceID)); } OWL_API void From 04d5054877c8de19a0c681026f2cb521a3ab802c Mon Sep 17 00:00:00 2001 From: Ingo Wald Date: Tue, 16 Jun 2026 18:30:20 -0600 Subject: [PATCH 2/2] bumped version to 1.2.5 to mark bugfix in device teardown --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d6aab1..2d36d85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA +# CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 - set(OWL_VERSION_MAJOR 1) set(OWL_VERSION_MINOR 2) -set(OWL_VERSION_PATCH 4) +set(OWL_VERSION_PATCH 5) cmake_minimum_required(VERSION 3.24)