Skip to content

Commit 8fc5038

Browse files
committed
Fix race condition in split/mergeGridHandles
* Fix race condition in split/mergeGridHandles * Fix missing semicolon Signed-off-by: Matthew Cong <[email protected]>
1 parent c13dfc3 commit 8fc5038

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

nanovdb/nanovdb/cuda/DeviceResource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define NANOVDB_CUDA_DEVICERESOURCE_H_HAS_BEEN_INCLUDED
66

77
#include <cuda_runtime_api.h>
8+
#include <nanovdb/util/cuda/Util.h>
89

910
namespace nanovdb {
1011

nanovdb/nanovdb/cuda/GridHandle.cuh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ splitGridHandles(const GridHandle<BufferT> &handle, const BufferT* other = nullp
6161
updateGridCount<<<1, 1, 0, stream>>>(dst, 0u, 1u, d_dirty);
6262
cudaCheckError();
6363
cudaCheck(cudaMemcpyAsync(&dirty, d_dirty, sizeof(bool), cudaMemcpyDeviceToHost, stream));
64+
cudaCheck(cudaStreamSynchronize(stream));
6465
if (dirty) tools::cuda::updateChecksum(dst, CheckMode::Partial, stream);
6566
handles[n] = nanovdb::GridHandle<BufferT>(std::move(buffer));
6667
ptr = util::PtrAdd(ptr, handle.gridSize(n));
@@ -93,6 +94,7 @@ mergeGridHandles(const VectorT<GridHandle<BufferT>> &handles, const BufferT* oth
9394
updateGridCount<<<1, 1, 0, stream>>>(data, counter++, gridCount, d_dirty);
9495
cudaCheckError();
9596
cudaCheck(cudaMemcpyAsync(&dirty, d_dirty, sizeof(bool), cudaMemcpyDeviceToHost, stream));
97+
cudaCheck(cudaStreamSynchronize(stream));
9698
if (dirty) tools::cuda::updateChecksum(data, CheckMode::Partial, stream);
9799
dst = util::PtrAdd(dst, h.gridSize(n));
98100
src = util::PtrAdd(src, h.gridSize(n));

0 commit comments

Comments
 (0)