Skip to content

Commit c91c2b9

Browse files
authored
Merge pull request #1505 from kmuseth/nanovdb_fix
cleanup
2 parents 3c56b32 + 597b2d1 commit c91c2b9

File tree

4 files changed

+26
-102
lines changed

4 files changed

+26
-102
lines changed

nanovdb/nanovdb/examples/benchmark/Benchmark.cc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -609,26 +609,6 @@ TEST_F(Benchmark, DenseGrid_CPU)
609609

610610
#if defined(NANOVDB_USE_CUDA)
611611

612-
// Convenience function for checking CUDA runtime API results
613-
// can be wrapped around any runtime API call. No-op in release builds.
614-
#define cudaCheck(ans) \
615-
{ \
616-
gpuAssert((ans), __FILE__, __LINE__); \
617-
}
618-
619-
static inline bool gpuAssert(cudaError_t code, const char* file, int line, bool abort = true)
620-
{
621-
#if defined(DEBUG) || defined(_DEBUG)
622-
if (code != cudaSuccess) {
623-
fprintf(stderr, "CUDA Runtime Error: %s %s %d\n", cudaGetErrorString(code), file, line);
624-
if (abort)
625-
exit(code);
626-
return false;
627-
}
628-
#endif
629-
return true;
630-
}
631-
632612
extern "C" void launch_kernels(const nanovdb::GridHandle<nanovdb::CudaDeviceBuffer>&,
633613
nanovdb::ImageHandle<nanovdb::CudaDeviceBuffer>&,
634614
const nanovdb::Camera<float>*,

nanovdb/nanovdb/examples/benchmark/Benchmark_dense.cc

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,6 @@
1717

1818
#include <iomanip>// for std::setfill and std::setw
1919

20-
21-
// Convenience function for checking CUDA runtime API results
22-
// can be wrapped around any runtime API call. No-op in release builds.
23-
#define cudaCheck(ans) \
24-
{ \
25-
gpuAssert((ans), __FILE__, __LINE__); \
26-
}
27-
28-
static inline bool gpuAssert(cudaError_t code, const char* file, int line, bool abort = true)
29-
{
30-
#if defined(DEBUG) || defined(_DEBUG)
31-
if (code != cudaSuccess) {
32-
fprintf(stderr, "CUDA Runtime Error: %s %s %d\n", cudaGetErrorString(code), file, line);
33-
if (abort)
34-
exit(code);
35-
return false;
36-
}
37-
#endif
38-
return true;
39-
}
40-
4120
extern "C" float launch_kernels(const nanovdb::DenseGridHandle<nanovdb::CudaDeviceBuffer>&,
4221
nanovdb::ImageHandle<nanovdb::CudaDeviceBuffer>&,
4322
const nanovdb::Camera<float>*,
@@ -124,4 +103,4 @@ int main(int argc, char** argv)
124103
maxAngle, imgHandle.image()->size(), elapsedTime, elapsedTime/maxAngle, 1000.0f*maxAngle/elapsedTime);
125104

126105
return 0;
127-
}
106+
}

nanovdb/nanovdb/examples/benchmark/Benchmark_nano.cc

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,6 @@
1616

1717
#include <iomanip>// for std::setfill and std::setw
1818

19-
20-
// Convenience function for checking CUDA runtime API results
21-
// can be wrapped around any runtime API call. No-op in release builds.
22-
#define cudaCheck(ans) \
23-
{ \
24-
gpuAssert((ans), __FILE__, __LINE__); \
25-
}
26-
27-
static inline bool gpuAssert(cudaError_t code, const char* file, int line, bool abort = true)
28-
{
29-
#if defined(DEBUG) || defined(_DEBUG)
30-
if (code != cudaSuccess) {
31-
fprintf(stderr, "CUDA Runtime Error: %s %s %d\n", cudaGetErrorString(code), file, line);
32-
if (abort)
33-
exit(code);
34-
return false;
35-
}
36-
#endif
37-
return true;
38-
}
39-
4019
extern "C" float launch_kernels(const nanovdb::GridHandle<nanovdb::CudaDeviceBuffer>&,
4120
nanovdb::ImageHandle<nanovdb::CudaDeviceBuffer>&,
4221
const nanovdb::Camera<float>*,
@@ -131,4 +110,4 @@ int main(int argc, char** argv)
131110
maxAngle, imgHandle.image()->size(), elapsedTime, elapsedTime/maxAngle, 1000.0f*maxAngle/elapsedTime);
132111

133112
return 0;
134-
}
113+
}

nanovdb/nanovdb/util/CudaDeviceBuffer.h

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@
2020

2121
#include <cuda_runtime_api.h> // for cudaMalloc/cudaMallocManaged/cudaFree
2222

23+
#if defined(DEBUG) || defined(_DEBUG)
24+
static inline void gpuAssert(cudaError_t code, const char* file, int line, bool abort = true)
25+
{
26+
if (code != cudaSuccess) {
27+
fprintf(stderr, "CUDA Runtime Error: %s %s %d\n", cudaGetErrorString(code), file, line);
28+
if (abort) exit(code);
29+
}
30+
}
31+
static inline void ptrAssert(void* ptr, const char* msg, const char* file, int line, bool abort = true)
32+
{
33+
if (ptr == nullptr) {
34+
fprintf(stderr, "NULL pointer error: %s %s %d\n", msg, file, line);
35+
if (abort) exit(1);
36+
}
37+
if (uint64_t(ptr) % NANOVDB_DATA_ALIGNMENT) {
38+
fprintf(stderr, "Pointer misalignment error: %s %s %d\n", msg, file, line);
39+
if (abort) exit(1);
40+
}
41+
}
42+
#else
43+
static inline void gpuAssert(cudaError_t, const char*, int, bool = true){}
44+
static inline void ptrAssert(void*, const char*, const char*, int, bool = true){}
45+
#endif
46+
2347
// Convenience function for checking CUDA runtime API results
2448
// can be wrapped around any runtime API call. No-op in release builds.
2549
#define cudaCheck(ans) \
@@ -46,44 +70,6 @@ class CudaDeviceBuffer
4670
uint64_t mSize; // total number of bytes for the NanoVDB grid.
4771
uint8_t *mCpuData, *mGpuData; // raw buffer for the NanoVDB grid.
4872

49-
#if defined(DEBUG) || defined(_DEBUG)
50-
static inline bool gpuAssert(cudaError_t code, const char* file, int line, bool abort = true)
51-
{
52-
if (code != cudaSuccess) {
53-
fprintf(stderr, "CUDA Runtime Error: %s %s %d\n", cudaGetErrorString(code), file, line);
54-
if (abort)
55-
exit(code);
56-
return false;
57-
}
58-
return true;
59-
}
60-
#else
61-
static inline bool gpuAssert(cudaError_t, const char*, int, bool = true)
62-
{
63-
return true;
64-
}
65-
#endif
66-
67-
#if defined(DEBUG) || defined(_DEBUG)
68-
static inline void ptrAssert(void* ptr, const char* msg, const char* file, int line, bool abort = true)
69-
{
70-
if (ptr == nullptr) {
71-
fprintf(stderr, "NULL pointer error: %s %s %d\n", msg, file, line);
72-
if (abort)
73-
exit(1);
74-
}
75-
if (uint64_t(ptr) % NANOVDB_DATA_ALIGNMENT) {
76-
fprintf(stderr, "Alignment pointer error: %s %s %d\n", msg, file, line);
77-
if (abort)
78-
exit(1);
79-
}
80-
}
81-
#else
82-
static inline void ptrAssert(void*, const char*, const char*, int, bool = true)
83-
{
84-
}
85-
#endif
86-
8773
public:
8874
CudaDeviceBuffer(uint64_t size = 0)
8975
: mSize(0)

0 commit comments

Comments
 (0)