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
12 changes: 7 additions & 5 deletions .github/workflows/nanovdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,22 @@ jobs:
run: |
echo "/usr/local/cuda-12/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/usr/local/cuda-12/lib64:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: nanobind
run: ./ci/install_nanobind.sh 2.5.0
- name: build
# NOTE: CMAKE_POSITION_INDEPENDENT_CODE set to fix default behaviour change in clang 14
# https://github.com/AcademySoftwareFoundation/aswf-docker/issues/228
run: >
./ci/build.sh -v
--build-type=${{ matrix.config.build }}
--components=core,nano,nanotest,nanoexam,nanobench,nanotool
--components=core,nano,nanotest,nanoexam,nanobench,nanotool,nanopython,nanopytest
--cargs=\'
-DUSE_EXPLICIT_INSTANTIATION=OFF
-DNANOVDB_USE_CUDA=ON
-DCMAKE_CUDA_ARCHITECTURES="80"
-DNANOVDB_USE_OPENVDB=ON
-DCMAKE_INSTALL_PREFIX=`pwd`
-DUSE_BLOSC=OFF
-DUSE_BLOSC=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
\'
- name: test
Expand Down Expand Up @@ -122,7 +124,7 @@ jobs:
run: >
./ci/build.sh -v
--config=Release
--components=core,nano,nanotest,nanoexam,nanobench,nanotool
--components=core,nano,nanotest,nanoexam,nanobench,nanotool,nanopython,nanopytest
--cargs=\'
-A x64 -G \"Visual Studio 17 2022\" -DOPENVDB_CORE_STATIC=OFF
-DMSVC_COMPRESS_PDB=ON
Expand All @@ -136,7 +138,7 @@ jobs:
\'
- name: test
shell: bash
run: cd build && ctest -V -E ".*cuda.*|.*mgpu.*"
run: cd build && ctest -V -C Release -E ".*cuda.*|.*mgpu.*"

macos-nanovdb:
if: |
Expand All @@ -162,7 +164,7 @@ jobs:
run: >
./ci/build.sh -v
--build-type=${{ matrix.config.build }}
--components=core,nano,nanotest,nanoexam,nanobench,nanotool
--components=core,nano,nanotest,nanoexam,nanobench,nanotool,nanopython,nanopytest
--cargs=\'-DUSE_EXPLICIT_INSTANTIATION=OFF -DNANOVDB_USE_CUDA=OFF -DNANOVDB_USE_OPENVDB=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install \'
- name: test
run: cd build && ctest -V -E ".*cuda.*|.*mgpu.*"
Expand Down
2 changes: 2 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ COMPONENTS['nanotest']='NANOVDB_BUILD_UNITTESTS'
COMPONENTS['nanoexam']='NANOVDB_BUILD_EXAMPLES'
COMPONENTS['nanobench']='NANOVDB_BUILD_BENCHMARK'
COMPONENTS['nanotool']='NANOVDB_BUILD_TOOLS'
COMPONENTS['nanopython']='NANOVDB_BUILD_PYTHON_MODULE'
COMPONENTS['nanopytest']='NANOVDB_BUILD_PYTHON_UNITTESTS'

################################################

Expand Down
1 change: 1 addition & 0 deletions nanovdb/nanovdb/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ if(NANOVDB_BUILD_PYTHON_UNITTESTS)
set(PYTHONPATH "$ENV{PYTHONPATH};${NANOVDB_PYTHON_WORKING_DIR}")
string(REPLACE "\\;" ";" PYTHONPATH "${PYTHONPATH}")
string(REPLACE ";" "\\;" PYTHONPATH "${PYTHONPATH}")
set_tests_properties(pytest_nanovdb PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHONPATH}")
else()
set_tests_properties(pytest_nanovdb PROPERTIES ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${NANOVDB_PYTHON_WORKING_DIR}")
endif()
Expand Down
16 changes: 16 additions & 0 deletions nanovdb/nanovdb/python/NanoVDBModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,26 @@ bool isCudaAvailable()
#endif
}

bool isGpuAvailable()
{
#ifdef NANOVDB_USE_CUDA
int deviceCount = 0;
cudaError_t err = cudaGetDeviceCount(&deviceCount);
if (err != cudaSuccess) {
cudaGetLastError();
return false;
}
return deviceCount > 0;
#else
return false;
#endif
}

NB_MODULE(nanovdb, m)
{
m.doc() = "Python module for NanoVDB";
m.def("isCudaAvailable", &isCudaAvailable, "Returns whether or not the module was compiled with CUDA support");
m.def("isGpuAvailable", &isGpuAvailable, "Returns whether a CUDA-capable GPU is available at runtime");

nb::enum_<GridType>(m, "GridType")
.value("Unknown", GridType::Unknown)
Expand Down
2 changes: 1 addition & 1 deletion nanovdb/nanovdb/python/PyIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void defineFileGridMetaData(nb::module_& m)
.def_prop_ro("tileCount",
[](io::FileMetaData& metaData) { return std::make_tuple(metaData.tileCount[0], metaData.tileCount[1], metaData.tileCount[2]); })
.def_ro("codec", &io::FileMetaData::codec)
.def_ro("padding", &io::FileMetaData::padding)
.def_ro("blindDataCount", &io::FileMetaData::blindDataCount)
.def_ro("version", &io::FileMetaData::version);

nb::bind_vector<std::vector<io::FileMetaData>>(m, "FileMetaDataVector");
Expand Down
6 changes: 3 additions & 3 deletions nanovdb/nanovdb/python/PyNanoToOpenVDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ template<typename BufferT> void defineNanoToOpenVDB(nb::module_& m)
#ifdef NANOVDB_USE_OPENVDB
// Wrap nanoToOpenVDB into a lambda to workaround an MSVC compiler bug
m.def(
"nanoToOpenVDB", [](GridHandle<BufferT>& handle, int verbose, uint32_t n){
return tools::nanoToOpenVDB<BufferT>(handle, verbose, n);
}, "handle"_a, "verbose"_a = 0, "n"_a = 0);
"nanoToOpenVDB", [](GridHandle<BufferT>& handle, uint32_t n){
return tools::nanoToOpenVDB<BufferT>(handle, n);
}, "handle"_a, "n"_a = 0);
#endif
}

Expand Down
57 changes: 49 additions & 8 deletions nanovdb/nanovdb/python/test/TestNanoVDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
# Copyright Contributors to the OpenVDB Project
# SPDX-License-Identifier: Apache-2.0

import os

# If on Windows, add required dll directories from our binary build tree
if 'add_dll_directory' in dir(os):
config = os.path.basename(os.getcwd())
os.add_dll_directory(os.getcwd() + '\\..\\..\\..\\..\\openvdb\\openvdb\\' + config)
for p in os.environ.get('PATH', '').split(os.pathsep):
if os.path.isdir(p):
try:
os.add_dll_directory(p)
except OSError:
pass

import nanovdb
import unittest
import tempfile
Expand Down Expand Up @@ -326,8 +339,12 @@ def test_list_to_vector(self):
self.assertEqual(handle.gridCount(), 1)
self.assertIsNotNone(handle.doubleGrid())
handles = [handle, handle]
dstFile = tempfile.NamedTemporaryFile()
nanovdb.io.writeGrids(dstFile.name, handles)
dstFile = tempfile.NamedTemporaryFile(delete=False)
dstFile.close()
try:
nanovdb.io.writeGrids(dstFile.name, handles)
finally:
os.unlink(dstFile.name)


class TestReadWriteGrids(unittest.TestCase):
Expand All @@ -336,10 +353,16 @@ def setUp(self):
sphereHandle = nanovdb.tools.createLevelSetSphere(
nanovdb.GridType.Float, name=self.gridName
)
self.srcFile = tempfile.NamedTemporaryFile()
self.srcFile = tempfile.NamedTemporaryFile(delete=False)
self.srcFile.close()
nanovdb.io.writeGrid(self.srcFile.name, sphereHandle)
nanovdb.io.writeGrid(self.srcFile.name, sphereHandle)
self.dstFile = tempfile.NamedTemporaryFile()
self.dstFile = tempfile.NamedTemporaryFile(delete=False)
self.dstFile.close()

def tearDown(self):
os.unlink(self.srcFile.name)
os.unlink(self.dstFile.name)

def test_metadata(self):
metadataList = nanovdb.io.readGridMetaData(self.srcFile.name)
Expand All @@ -358,7 +381,7 @@ def test_metadata(self):
self.assertIsInstance(metadata.nodeCount, tuple)
self.assertIsInstance(metadata.tileCount, tuple)
self.assertEqual(metadata.codec, nanovdb.io.Codec.NONE)
self.assertEqual(metadata.padding, 0)
self.assertEqual(metadata.blindDataCount, 0)
self.assertEqual(metadata.version, nanovdb.Version())

def test_read_write_grid(self):
Expand Down Expand Up @@ -400,16 +423,25 @@ def test_read_write_grids(self):
@unittest.skipIf(
not nanovdb.isCudaAvailable(), "nanovdb module was compiled without CUDA support"
)
@unittest.skipIf(
not nanovdb.isGpuAvailable(), "No CUDA-capable GPU available"
)
class TestDeviceReadWriteGrids(unittest.TestCase):
def setUp(self):
self.gridName = "sphere_ls"
sphereHandle = nanovdb.tools.cuda.createLevelSetSphere(
nanovdb.GridType.Float, name=self.gridName
)
self.srcFile = tempfile.NamedTemporaryFile()
self.srcFile = tempfile.NamedTemporaryFile(delete=False)
self.srcFile.close()
nanovdb.io.deviceWriteGrid(self.srcFile.name, sphereHandle)
nanovdb.io.deviceWriteGrid(self.srcFile.name, sphereHandle)
self.dstFile = tempfile.NamedTemporaryFile()
self.dstFile = tempfile.NamedTemporaryFile(delete=False)
self.dstFile.close()

def tearDown(self):
os.unlink(self.srcFile.name)
os.unlink(self.dstFile.name)

def test_metadata(self):
metadataList = nanovdb.io.readGridMetaData(self.srcFile.name)
Expand All @@ -428,7 +460,7 @@ def test_metadata(self):
self.assertIsInstance(metadata.nodeCount, tuple)
self.assertIsInstance(metadata.tileCount, tuple)
self.assertEqual(metadata.codec, nanovdb.io.Codec.NONE)
self.assertEqual(metadata.padding, 0)
self.assertEqual(metadata.blindDataCount, 0)
self.assertEqual(metadata.version, nanovdb.Version())

def test_read_write_grid(self):
Expand Down Expand Up @@ -482,6 +514,9 @@ def test_read_write_grids(self):
@unittest.skipIf(
not nanovdb.isCudaAvailable(), "nanovdb module was compiled without CUDA support"
)
@unittest.skipIf(
not nanovdb.isGpuAvailable(), "No CUDA-capable GPU available"
)
class TestPointsToGrid(unittest.TestCase):
def test_points_to_grid(self):
try:
Expand All @@ -506,6 +541,9 @@ def test_points_to_grid(self):
@unittest.skipIf(
not nanovdb.isCudaAvailable(), "nanovdb module was compiled without CUDA support"
)
@unittest.skipIf(
not nanovdb.isGpuAvailable(), "No CUDA-capable GPU available"
)
class TestSignedFloodFill(unittest.TestCase):
def test_signed_flood_fill_float(self):
handle = nanovdb.tools.cuda.createLevelSetSphere(nanovdb.GridType.Float, 100)
Expand Down Expand Up @@ -571,6 +609,9 @@ def test_signed_flood_fill_double(self):
@unittest.skipIf(
not nanovdb.isCudaAvailable(), "nanovdb module was compiled without CUDA support"
)
@unittest.skipIf(
not nanovdb.isGpuAvailable(), "No CUDA-capable GPU available"
)
class TestSampleFromPoints(unittest.TestCase):
def test_sample_from_points_float(self):
try:
Expand Down
Loading