diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91d6d9419f..a024fe3849 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -123,14 +123,14 @@ jobs: - name: test run: ./ci/test.sh - testabi7noblosc: + testabi7lite: runs-on: ubuntu-16.04 container: image: aswf/ci-openvdb:2020 steps: - uses: actions/checkout@v1 - name: build - run: ./ci/build.sh clang++ Release 7 OFF None -DOPENVDB_CXX_STRICT=ON + run: ./ci/build.sh clang++ Release 7 OFF None -DOPENVDB_CXX_STRICT=ON -DUSE_ZLIB=OFF - name: test run: ./ci/test.sh diff --git a/CHANGES b/CHANGES index 8b96a159b8..9f0ea728e5 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,9 @@ OpenVDB Version History Version 7.1.1 - In Development + Improvements: + - util::CpuTimer now uses C++11 chrono instead of TBB. + Houdini: - Fixed a bug in the OpenVDB Points Convert SOP where the auto voxel transform was ignoring the contents of packed geometry. @@ -11,6 +14,10 @@ Version 7.1.1 - In Development - Fixed a bug where a Houdini SOP's verb would not be correctly associated with the corresponding node if the node's internal name was changed. + Bug fixes: + - Fixed a bug which could cause recursive compile time instantiations of + TypeList objects, manifesting in longer compile times. + Build: - Removed the Makefiles. - Re-organised the repository layout such that each independent library @@ -21,6 +28,11 @@ Version 7.1.1 - In Development - Fixed various compiler warnings for GCC 9.1. - Moved to CMake doxygen commands and removed the doxygen-config files for doxygen documentation. + - Added USE_ZLIB compiler flag that enables zlib compression and defaults + to on. + - Added the OPENVDB_STATICLIB define to all static builds to fix builds on + Windows which use the multithread/DLL-specific version of the CRT. + [Reported by Tobias Rittig] Version 7.1.0 - August 13, 2020 diff --git a/CMakeLists.txt b/CMakeLists.txt index c6e324dec3..72b70b6601 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,9 @@ option(USE_BLOSC [=[ Use blosc while building openvdb components. If OPENVDB_BUILD_CORE is OFF, CMake attempts to query the located openvdb build configuration to decide on blosc support. You may set this to on to force blosc to be used if you know it to be required.]=] ON) +option(USE_ZLIB [=[ +Use zlib while building openvdb components. If OPENVDB_BUILD_CORE is OFF, CMake attempts to query the located +openvdb build configuration to decide on zlib support. ZLib can only be disabled if Blosc is also disabled. ]=] ON) option(USE_LOG4CPLUS [=[ Use log4cplus while building openvdb components. If OPENVDB_BUILD_CORE is OFF, CMake attempts to query the located openvdb build configuration to decide on log4cplus support. You may set this to on to force log4cplus @@ -151,6 +154,10 @@ elseif(NOT ${OPENVDB_SIMD} IN_LIST _OPENVDB_SIMD_OPTIONS) set(OPENVDB_SIMD None CACHE STRING FORCE) endif() +if(USE_BLOSC AND NOT USE_ZLIB) + message(WARNING "ZLib can only be disabled if Blosc is also disabled. Enabling ZLib.") +endif() + # Top-level location for all openvdb headers set(OPENVDB_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/openvdb") diff --git a/cmake/FindOpenVDB.cmake b/cmake/FindOpenVDB.cmake index 9b1658306d..219b90a597 100644 --- a/cmake/FindOpenVDB.cmake +++ b/cmake/FindOpenVDB.cmake @@ -55,6 +55,8 @@ This will define the following variables: True if the system has the named OpenVDB component. ``OpenVDB_USES_BLOSC`` True if the OpenVDB Library has been built with blosc support +``OpenVDB_USES_ZLIB`` + True if the OpenVDB Library has been built with zlib support ``OpenVDB_USES_LOG4CPLUS`` True if the OpenVDB Library has been built with log4cplus support ``OpenVDB_USES_EXR`` @@ -516,6 +518,7 @@ endif() # the configuration options from the main CMakeLists.txt to allow users # to manually identify the requirements of OpenVDB builds if they know them. set(OpenVDB_USES_BLOSC ${USE_BLOSC}) +set(OpenVDB_USES_ZLIB ${USE_ZLIB}) set(OpenVDB_USES_LOG4CPLUS ${USE_LOG4CPLUS}) set(OpenVDB_USES_EXR ${USE_EXR}) set(OpenVDB_DEFINITIONS) @@ -525,7 +528,11 @@ if(WIN32) list(APPEND OpenVDB_DEFINITIONS NOMINMAX) endif() -if(NOT OPENVDB_USE_STATIC_LIBS) +if(OPENVDB_USE_STATIC_LIBS) + if(WIN32) + list(APPEND OpenVDB_DEFINITIONS OPENVDB_STATICLIB) + endif() +else() if(WIN32) list(APPEND OpenVDB_DEFINITIONS OPENVDB_DLL) endif() @@ -561,6 +568,11 @@ if(NOT OPENVDB_USE_STATIC_LIBS) set(OpenVDB_USES_BLOSC ON) endif() + string(FIND ${PREREQUISITE} "zlib" _HAS_DEP) + if(NOT ${_HAS_DEP} EQUAL -1) + set(OpenVDB_USES_ZLIB ON) + endif() + string(FIND ${PREREQUISITE} "log4cplus" _HAS_DEP) if(NOT ${_HAS_DEP} EQUAL -1) set(OpenVDB_USES_LOG4CPLUS ON) @@ -579,6 +591,10 @@ if(OpenVDB_USES_BLOSC) find_package(Blosc REQUIRED) endif() +if(OpenVDB_USES_ZLIB) + find_package(ZLIB REQUIRED) +endif() + if(OpenVDB_USES_LOG4CPLUS) find_package(Log4cplus REQUIRED) endif() @@ -648,8 +664,9 @@ if(NOT OPENVDB_USE_STATIC_LIBS) if(OpenVDB_USES_BLOSC) list(APPEND _OPENVDB_HIDDEN_DEPENDENCIES Blosc::blosc) endif() - - list(APPEND _OPENVDB_HIDDEN_DEPENDENCIES ZLIB::ZLIB) + if(OpenVDB_USES_ZLIB) + list(APPEND _OPENVDB_HIDDEN_DEPENDENCIES ZLIB::ZLIB) + endif() endif() if(openvdb_je IN_LIST OpenVDB_FIND_COMPONENTS) diff --git a/doc/build.txt b/doc/build.txt index f920a05875..3c324e4fc8 100644 --- a/doc/build.txt +++ b/doc/build.txt @@ -8,6 +8,7 @@ - @ref buildDependencies - @ref buildMixingDepInstalls - @ref buildBloscSupport + - @ref buildZLibSupport - @ref buildVCPKG - @ref buildComponents - @ref buildGuide @@ -142,16 +143,21 @@ provide direct include/lib paths to isolated software locations. @subsection buildBloscSupport Blosc Support -Blosc is one of the optional dependencies of all OpenVDB components. It is the -only dependency which is enabled by default. The documented build steps below -treat blosc as a required dependency. There are two reasons for this: +Blosc is an optional dependency of all OpenVDB components. The documented +build steps below treat blosc as a required dependency. There are two reasons +for this: - Blosc produces significantly smaller `.vdb` files - If Blosc is disabled, you will not be able to read or use any `.vdb` files that were created using blosc compression. This includes OpenVDB files from Houdini. -You can disable Blosc using `-D USE_BLOSC=OFF`. +@subsection buildZLibSupport ZLIB Support + +ZLIB is an optional dependency of all OpenVDB components. The documented build +steps below treat ZLib as a required dependency. + +You can disable ZLib using `-D USE_ZLIB=OFF` if Blosc is also disabled using `-D USE_BLOSC=OFF`. @subsection buildVCPKG Building Dependencies using VCPKG @@ -209,8 +215,9 @@ Developers may wish to build a standalone version of OpenVDB to take advantage of newer dependencies and newer library features. See [here](@ref buildBuildStandalone) for more information. -@b Note: Blosc is treated as a required dependency in these install instructions. -See the [blosc support](@ref buildBloscSupport) section for more information. +@b Note: Blosc and ZLib are treated as required dependencies in these install +instructions. See the [blosc support](@ref buildBloscSupport) and +[zlib support](@ref buildZLibSupport) sections for more information. @subsection buildBuildHouMaya Building Against Houdini/Maya @@ -253,8 +260,8 @@ LLVM | Target-independent code generation At a minimum, boost, a matching C++14 compiler and CMake will be required. See the full [dependency list](@ref dependencies) for help with downloading and -installing the above software. Note that as Blosc is provided as part of the -Houdini installation `USE_BLOSC` should be left `ON`. +installing the above software. Note that as Blosc and ZLib are provided as part +of the Houdini installation `USE_BLOSC` and `USE_ZLIB` should be left `ON`. With the necessary dependencies installed, create and enter a directory for cmake to write to. It's generally useful to create this in the location you've diff --git a/doc/changes.txt b/doc/changes.txt index 6bd5ebf86e..a85e5d6e5a 100644 --- a/doc/changes.txt +++ b/doc/changes.txt @@ -6,6 +6,10 @@ @par Version 7.1.1 - In Development +@par +Improvements: +- util::CpuTimer now uses C++11 chrono instead of TBB. + @par Houdini: - Fixed a bug in the OpenVDB Points Convert SOP where the auto voxel @@ -15,6 +19,11 @@ Houdini: - Fixed a bug where a Houdini SOP's verb would not be correctly associated with the corresponding node if the node's internal name was changed. +@par +Bug Fixes: +- Fixed a bug which could cause recursive compile time instantiations of + TypeList objects, manifesting in longer compile times. + @par Build: - Removed the Makefiles. @@ -26,6 +35,11 @@ Build: - Fixed various compiler warnings for GCC 9.1. - Moved to CMake doxygen commands and removed the doxygen-config files for doxygen documentation. +- Added USE_ZLIB compiler flag that enables zlib compression and defaults + to on. +- Added the OPENVDB_STATICLIB define to all static builds to fix builds on + Windows which use the multithread/DLL-specific version of the CRT. + [Reported by Tobias Rittig] @htmlonly @endhtmlonly diff --git a/doc/dependencies.txt b/doc/dependencies.txt index c930cdc878..8e03949fd2 100644 --- a/doc/dependencies.txt +++ b/doc/dependencies.txt @@ -37,7 +37,7 @@ Reference Platform, but for those that do, their specified versions are Component | Requirements | Optional ----------------------- | ------------------------------------------------------------------------------------ | -------- -OpenVDB Core Library | CMake, C++14 compiler, IlmBase::Half, TBB::tbb, ZLIB, Boost::system, Boost::iostream | Blosc, Log4cplus, OpenEXR::IlmImf +OpenVDB Core Library | CMake, C++14 compiler, IlmBase::Half, TBB::tbb, Boost::system, Boost::iostream | Blosc, ZLib, Log4cplus, OpenEXR::IlmImf OpenVDB Print | Core Library dependencies | - OpenVDB LOD | Core Library dependencies | - OpenVDB Render | Core Library dependencies, OpenEXR, IlmBase | - diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt index a0b9802c14..036c7c259c 100644 --- a/openvdb/openvdb/CMakeLists.txt +++ b/openvdb/openvdb/CMakeLists.txt @@ -77,8 +77,6 @@ if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_TBB_VERSION) endif() endif() -find_package(ZLIB ${MINIMUM_ZLIB_VERSION} REQUIRED) - if(USE_LOG4CPLUS) find_package(Log4cplus ${MINIMUM_LOG4CPLUS_VERSION} REQUIRED) endif() @@ -99,6 +97,10 @@ else() ) endif() +if(USE_BLOSC OR USE_ZLIB) + find_package(ZLIB ${MINIMUM_ZLIB_VERSION} REQUIRED) +endif() + if(OPENVDB_CORE_SHARED AND NOT Boost_USE_STATIC_LIBS) # @note Both of these must be set for Boost 1.70 (VFX2020) to link against # boost shared libraries (more specifically libraries built with -fPIC). @@ -166,9 +168,12 @@ if(USE_BLOSC) list(APPEND OPENVDB_CORE_DEPENDENT_LIBS Blosc::blosc) endif() +if(USE_BLOSC OR USE_ZLIB) + list(APPEND OPENVDB_CORE_DEPENDENT_LIBS ZLIB::ZLIB) +endif() + list(APPEND OPENVDB_CORE_DEPENDENT_LIBS TBB::tbb - ZLIB::ZLIB ) if(UNIX) @@ -400,6 +405,10 @@ if(USE_BLOSC) list(APPEND OPENVDB_CORE_PRIVATE_DEFINES -DOPENVDB_USE_BLOSC) endif() +if(USE_BLOSC OR USE_ZLIB) + list(APPEND OPENVDB_CORE_PRIVATE_DEFINES -DOPENVDB_USE_ZLIB) +endif() + # Public defines if(WIN32) # @note OPENVDB_OPENEXR_STATICLIB is old functionality from the makefiles @@ -429,7 +438,7 @@ if(OPENVDB_CORE_STATIC) ) target_compile_definitions(openvdb_static - PUBLIC ${OPENVDB_CORE_PUBLIC_DEFINES} + PUBLIC ${OPENVDB_CORE_PUBLIC_DEFINES} -DOPENVDB_STATICLIB PRIVATE ${OPENVDB_CORE_PRIVATE_DEFINES} ) diff --git a/openvdb/openvdb/Types.h b/openvdb/openvdb/Types.h index 654e8b68f1..13699e094a 100644 --- a/openvdb/openvdb/Types.h +++ b/openvdb/openvdb/Types.h @@ -696,17 +696,19 @@ struct TypeList static constexpr int64_t Index = internal::TSHasTypeImpl::Index; /// @brief Remove any duplicate types from this TypeList by rotating the - /// next valid type left (maintains the order of other types). + /// next valid type left (maintains the order of other types). Optionally + /// combine the result with another TypeList. /// @details Example: /// @code /// { /// using Types = openvdb::TypeList; /// } /// { - /// using UniqueTypes = Types::Unique; // + /// using UniqueTypes = Types::Unique<>; // /// } /// @endcode - using Unique = typename internal::TSMakeUniqueImpl, Ts...>::type; + template> + using Unique = typename internal::TSMakeUniqueImpl::type; /// @brief Append types, or the members of another TypeList, to this list. /// @details Example: diff --git a/openvdb/openvdb/io/Archive.cc b/openvdb/openvdb/io/Archive.cc index 01bdc6ca8f..1cf342b6ed 100644 --- a/openvdb/openvdb/io/Archive.cc +++ b/openvdb/openvdb/io/Archive.cc @@ -64,7 +64,11 @@ namespace io { #ifdef OPENVDB_USE_BLOSC const uint32_t Archive::DEFAULT_COMPRESSION_FLAGS = (COMPRESS_BLOSC | COMPRESS_ACTIVE_MASK); #else +#ifdef OPENVDB_USE_ZLIB const uint32_t Archive::DEFAULT_COMPRESSION_FLAGS = (COMPRESS_ZIP | COMPRESS_ACTIVE_MASK); +#else +const uint32_t Archive::DEFAULT_COMPRESSION_FLAGS = (COMPRESS_ACTIVE_MASK); +#endif #endif @@ -764,6 +768,18 @@ Archive::hasBloscCompression() } +//static +bool +Archive::hasZLibCompression() +{ +#ifdef OPENVDB_USE_ZLIB + return true; +#else + return false; +#endif +} + + void Archive::setGridCompression(std::ostream& os, const GridBase& grid) const { diff --git a/openvdb/openvdb/io/Archive.h b/openvdb/openvdb/io/Archive.h index b04239c0c3..ac0c300a3f 100644 --- a/openvdb/openvdb/io/Archive.h +++ b/openvdb/openvdb/io/Archive.h @@ -71,6 +71,9 @@ class OPENVDB_API Archive /// Return @c true if the OpenVDB library includes support for the Blosc compressor. static bool hasBloscCompression(); + /// Return @c true if the OpenVDB library includes support for the ZLib compressor. + static bool hasZLibCompression(); + /// Return a bit mask specifying compression options for the data stream. uint32_t compression() const { return mCompression; } /// @brief Specify whether and how the data stream should be compressed. diff --git a/openvdb/openvdb/io/Compression.cc b/openvdb/openvdb/io/Compression.cc index baa3b5491e..4d618e46ff 100644 --- a/openvdb/openvdb/io/Compression.cc +++ b/openvdb/openvdb/io/Compression.cc @@ -6,7 +6,9 @@ #include #include #include +#ifdef OPENVDB_USE_ZLIB #include +#endif #ifdef OPENVDB_USE_BLOSC #include #endif @@ -33,11 +35,20 @@ compressionToString(uint32_t flags) //////////////////////////////////////// +#ifdef OPENVDB_USE_ZLIB namespace { const int ZIP_COMPRESSION_LEVEL = Z_DEFAULT_COMPRESSION; ///< @todo use Z_BEST_SPEED? } +#endif +#ifndef OPENVDB_USE_ZLIB +size_t +zipToStreamSize(const char*, size_t) +{ + OPENVDB_THROW(IoError, "Zip encoding is not supported"); +} +#else size_t zipToStreamSize(const char* data, size_t numBytes) { @@ -55,8 +66,15 @@ zipToStreamSize(const char* data, size_t numBytes) return size_t(numBytes); } } +#endif - +#ifndef OPENVDB_USE_ZLIB +void +zipToStream(std::ostream&, const char*, size_t) +{ + OPENVDB_THROW(IoError, "Zip encoding is not supported"); +} +#else void zipToStream(std::ostream& os, const char* data, size_t numBytes) { @@ -90,8 +108,16 @@ zipToStream(std::ostream& os, const char* data, size_t numBytes) os.write(reinterpret_cast(data), numBytes); } } +#endif +#ifndef OPENVDB_USE_ZLIB +void +unzipFromStream(std::istream&, char*, size_t) +{ + OPENVDB_THROW(IoError, "Zip decoding is not supported"); +} +#else void unzipFromStream(std::istream& is, char* data, size_t numBytes) { @@ -138,6 +164,7 @@ unzipFromStream(std::istream& is, char* data, size_t numBytes) } } } +#endif namespace { diff --git a/openvdb/openvdb/tools/FastSweeping.h b/openvdb/openvdb/tools/FastSweeping.h index 7308bf642b..03fab13187 100644 --- a/openvdb/openvdb/tools/FastSweeping.h +++ b/openvdb/openvdb/tools/FastSweeping.h @@ -1220,7 +1220,6 @@ struct FastSweeping::SweepingKernel for (int sliceIdx = 0; sliceIdx < maskRange; sliceIdx++) { if (leafSliceMasks[leafOffset + sliceIdx] == uint8_t(1)) { const int64_t voxelSliceKey = leafKey+sliceIdx-maskOffset; - assert(voxelSliceKey >= 0); map[voxelSliceKey].emplace_back(leafIdx); } } diff --git a/openvdb/openvdb/unittest/CMakeLists.txt b/openvdb/openvdb/unittest/CMakeLists.txt index fcef87340d..16507af881 100644 --- a/openvdb/openvdb/unittest/CMakeLists.txt +++ b/openvdb/openvdb/unittest/CMakeLists.txt @@ -72,6 +72,7 @@ set(UNITTEST_SOURCE_FILES TestDivergence.cc TestDoubleMetadata.cc TestExceptions.cc + TestFastSweeping.cc TestFile.cc TestFindActiveValues.cc TestFloatMetadata.cc @@ -157,15 +158,22 @@ set(UNITTEST_SOURCE_FILES add_executable(vdb_test ${UNITTEST_SOURCE_FILES}) +# Blosc and ZLib are hidden dependencies for the core library +# (not exposed in headers), so we need to manually link them in +# here to provide header access for the relevant unit tests + if(USE_BLOSC OR OpenVDB_USES_BLOSC) - # Blosc is a hidden dependency for the core library (not exposed in headers) - # so we need to manually link it in here to provide header access for the - # blosc relevant unit tests find_package(Blosc ${MINIMUM_BLOSC_VERSION} REQUIRED) list(APPEND OPENVDB_TEST_DEPENDENT_LIBS Blosc::blosc) target_compile_definitions(vdb_test PRIVATE "-DOPENVDB_USE_BLOSC") endif() +if(USE_BLOSC OR OpenVDB_USES_BLOSC OR USE_ZLIB OR OpenVDB_USES_ZLIB) + find_package(ZLIB ${MINIMUM_ZLIB_VERSION} REQUIRED) + list(APPEND OPENVDB_CORE_DEPENDENT_LIBS ZLIB::ZLIB) + target_compile_definitions(vdb_test PRIVATE "-DOPENVDB_USE_ZLIB") +endif() + target_link_libraries(vdb_test ${OPENVDB_TEST_DEPENDENT_LIBS} ) diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc index f547ba52a7..21d36e9358 100644 --- a/openvdb/openvdb/unittest/TestFile.cc +++ b/openvdb/openvdb/unittest/TestFile.cc @@ -2195,9 +2195,17 @@ TestFile::testCompression() // See io/Compression.h for the flag values. #ifdef OPENVDB_USE_BLOSC - std::vector validFlags{0x0,0x1,0x2,0x3,0x4,0x6}; + #ifdef OPENVDB_USE_ZLIB + std::vector validFlags{0x0,0x1,0x2,0x3,0x4,0x6}; + #else + std::vector validFlags{0x0,0x2,0x4,0x6}; + #endif #else - std::vector validFlags{0x0,0x1,0x2,0x3}; + #ifdef OPENVDB_USE_ZLIB + std::vector validFlags{0x0,0x1,0x2,0x3}; + #else + std::vector validFlags{0x0,0x2}; + #endif #endif for (uint32_t flags : validFlags) { diff --git a/openvdb/openvdb/unittest/TestTypes.cc b/openvdb/openvdb/unittest/TestTypes.cc index 634fa1ddad..95de326f77 100644 --- a/openvdb/openvdb/unittest/TestTypes.cc +++ b/openvdb/openvdb/unittest/TestTypes.cc @@ -497,8 +497,8 @@ TestTypes::testTypeList() static_assert(!std::is_same, void>::value, ""); // Unique - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); + static_assert(std::is_same, IntTypes>::value, ""); + static_assert(std::is_same, EmptyList>::value, ""); // Front/Back static_assert(std::is_same::value, ""); @@ -536,13 +536,13 @@ TestTypes::testTypeList() // // Test some methods on lists with duplicate types - using DulplicateIntTypes = TypeList; - using DulplicateRealTypes = TypeList; - static_assert(DulplicateIntTypes::Size == 4, ""); - static_assert(DulplicateRealTypes::Size == 4, ""); - static_assert(DulplicateIntTypes::Index == 1, ""); - static_assert(std::is_same>::value, ""); - static_assert(std::is_same>::value, ""); + using DuplicateIntTypes = TypeList; + using DuplicateRealTypes = TypeList; + static_assert(DuplicateIntTypes::Size == 4, ""); + static_assert(DuplicateRealTypes::Size == 4, ""); + static_assert(DuplicateIntTypes::Index == 1, ""); + static_assert(std::is_same, TypeList>::value, ""); + static_assert(std::is_same, TypeList>::value, ""); // diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc index 77654ebadb..4e25d676a7 100644 --- a/openvdb/openvdb/unittest/TestUtil.cc +++ b/openvdb/openvdb/unittest/TestUtil.cc @@ -141,10 +141,10 @@ TestUtil::testCpuTimer() // so use this more accurate, but non-asynchronous implementation for unit testing auto sleep_for = [&](int ms) -> void { - auto start = std::chrono::high_resolution_clock::now(); + auto start = std::chrono::steady_clock::now(); while (true) { auto duration = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - start); + std::chrono::steady_clock::now() - start); if (duration.count() > ms) return; } }; diff --git a/openvdb/openvdb/util/CpuTimer.h b/openvdb/openvdb/util/CpuTimer.h index 3db8afc691..9b479c43cf 100644 --- a/openvdb/openvdb/util/CpuTimer.h +++ b/openvdb/openvdb/util/CpuTimer.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include // for std::cerr #include // for ostringstream #include // for setprecision @@ -66,19 +66,18 @@ namespace util { class CpuTimer { public: - /// @brief Initiate timer - CpuTimer(std::ostream& os = std::cerr) : mOutStream(os), mT0(tbb::tick_count::now()) {} + CpuTimer(std::ostream& os = std::cerr) : mOutStream(os), mT0(this->now()) {} /// @brief Prints message and start timer. /// /// @note Should normally be followed by a call to stop() - CpuTimer(const std::string& msg, std::ostream& os = std::cerr) : mOutStream(os), mT0() { this->start(msg); } + CpuTimer(const std::string& msg, std::ostream& os = std::cerr) : mOutStream(os) { this->start(msg); } /// @brief Start timer. /// /// @note Should normally be followed by a call to milliseconds() or stop(std::string) - inline void start() { mT0 = tbb::tick_count::now(); } + inline void start() { mT0 = this->now(); } /// @brief Print message and start timer. /// @@ -89,13 +88,21 @@ class CpuTimer this->start(); } + /// @brief Return Time difference in microseconds since construction or start was called. + /// + /// @note Combine this method with start() to get timing without any outputs. + inline int64_t microseconds() const + { + return (this->now() - mT0); + } + /// @brief Return Time difference in milliseconds since construction or start was called. /// /// @note Combine this method with start() to get timing without any outputs. inline double milliseconds() const { - tbb::tick_count::interval_t dt = tbb::tick_count::now() - mT0; - return 1000.0*dt.seconds(); + static constexpr double resolution = 1.0 / 1E3; + return static_cast(this->microseconds()) * resolution; } /// @brief Return Time difference in seconds since construction or start was called. @@ -103,8 +110,8 @@ class CpuTimer /// @note Combine this method with start() to get timing without any outputs. inline double seconds() const { - tbb::tick_count::interval_t dt = tbb::tick_count::now() - mT0; - return dt.seconds(); + static constexpr double resolution = 1.0 / 1E6; + return static_cast(this->microseconds()) * resolution; } /// @brief This method is identical to milliseconds() - deprecated @@ -162,8 +169,22 @@ class CpuTimer } private: - std::ostream& mOutStream; - tbb::tick_count mT0; + static int64_t now() + { + // steady_clock is a monotonically increasing clock designed for timing duration + // note that high_resolution_clock is aliased to either steady_clock or system_clock + // depending on the platform, so it is preferrable to use steady_clock + const auto time_since_epoch = + std::chrono::steady_clock::now().time_since_epoch(); + // cast time since epoch into microseconds (1 / 1000000 seconds) + const auto microseconds = + std::chrono::duration_cast(time_since_epoch).count(); + // cast to a a 64-bit signed integer as this will overflow in 2262! + return static_cast(microseconds); + } + + std::ostream& mOutStream; + int64_t mT0{0}; };// CpuTimer } // namespace util diff --git a/openvdb_houdini/openvdb_houdini/CMakeLists.txt b/openvdb_houdini/openvdb_houdini/CMakeLists.txt index 9c1d0bf9c5..99a158ffa4 100644 --- a/openvdb_houdini/openvdb_houdini/CMakeLists.txt +++ b/openvdb_houdini/openvdb_houdini/CMakeLists.txt @@ -336,8 +336,8 @@ foreach(DSO_NAME ${OPENVDB_DSO_NAMES}) endforeach() -# This is only required for the OpenVDB Write SOP which enables a blosc menu -# option if blosc is supported. +# This is only required for the OpenVDB Write SOP which enables a compression menu +# option if blosc and zlib are supported. if(USE_BLOSC OR OpenVDB_USES_BLOSC) if(TARGET SOP_OpenVDB_Write) @@ -345,6 +345,12 @@ if(USE_BLOSC OR OpenVDB_USES_BLOSC) endif() endif() +if(USE_BLOSC OR OpenVDB_USES_BLOSC OR USE_ZLIB OR OpenVDB_USES_ZLIB) + if(TARGET SOP_OpenVDB_Write) + target_compile_definitions(SOP_OpenVDB_Write PRIVATE "-DOPENVDB_USE_ZLIB") + endif() +endif() + ########## # Installs ########## diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Write.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Write.cc index b53352ff3f..70883497dd 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Write.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Write.cc @@ -95,6 +95,7 @@ newSopOperator(OP_OperatorTable* table) obsoleteParms.add(hutil::ParmFactory(PRM_TOGGLE, "compress_zip", "Zip Compression")); #else +#ifdef OPENVDB_USE_ZLIB parms.add(hutil::ParmFactory(PRM_TOGGLE, "compress_zip", "Zip Compression") .setDefault(true) .setTooltip( @@ -103,6 +104,12 @@ newSopOperator(OP_OperatorTable* table) obsoleteParms.add(hutil::ParmFactory(PRM_ORD, "compression", "Compression") .setChoiceListItems(PRM_CHOICELIST_SINGLE, items)); +#else + // no compression available + obsoleteParms.add(hutil::ParmFactory(PRM_TOGGLE, "compress_zip", "Zip Compression")); + obsoleteParms.add(hutil::ParmFactory(PRM_ORD, "compression", "Compression") + .setChoiceListItems(PRM_CHOICELIST_SINGLE, items)); +#endif #endif } @@ -188,11 +195,13 @@ SOP_OpenVDB_Write::resolveObsoleteParms(PRM_ParmList* obsoleteParms) setString(compression, CH_STRING_LITERAL, "compression", 0, 0.0); } #else +#ifdef OPENVDB_USE_ZLIB if (nullptr != obsoleteParms->getParmPtr("compression")) { UT_String compression; obsoleteParms->evalString(compression, "compression", 0, /*time=*/0.0); setInt("compress_zip", 0, 0.0, (compression == "zip" ? 1 : 0)); } +#endif #endif // Delegate to the base class. @@ -324,7 +333,9 @@ SOP_OpenVDB_Write::doCook(const fpreal time) UT_String compression; evalString(compression, "compression", 0, time); #else +#ifdef OPENVDB_USE_ZLIB const bool zip = evalInt("compress_zip", 0, time); +#endif #endif UT_AutoInterrupt progress(("Writing " + filename).c_str()); @@ -400,8 +411,10 @@ SOP_OpenVDB_Write::doCook(const fpreal time) } #else uint32_t compressionFlags = openvdb::io::COMPRESS_ACTIVE_MASK; +#ifdef OPENVDB_USE_ZLIB if (zip) compressionFlags |= openvdb::io::COMPRESS_ZIP; #endif +#endif // OPENVDB_USE_BLOSC file.setCompression(compressionFlags); file.write(outGrids, outMeta); diff --git a/tsc/meetings/2020-09-01.md b/tsc/meetings/2020-09-01.md new file mode 100644 index 0000000000..617b5edf00 --- /dev/null +++ b/tsc/meetings/2020-09-01.md @@ -0,0 +1,118 @@ +Minutes from 63rd OpenVDB TSC meeting, Sep 1st, 2020, (EDT) + +Attendees: *Nick* A., *Jeff* L., *Ken* M., *Dan* B. + +Additional Attendees: Johannes Meng (Intel), JT Nelson (Blender), +Andre Pradhana (DW), Ahmed Mahmoud + +Regrets: *Peter* C. + +Agenda: + +1) Confirm quorum +2) Secretary +3) Forum +4) 7.2 +5) NanoVDB +6) GCC 9.1 (PR 769) +7) CpuTimer using C++11 chrono (PR 690) +8) Introducing a "feature/abi8" branch (related to PR 788) +9) Deprecating code (PR 806, StringGrid, Tree::prune(), LeafNode::str(), etc) +10) "Locking down the grid configuration" +11) Extrapolate SOP +12) Next Meeting + + +1) Quorum was confirmed. + +2) Secretary was Dan Bailey + +3) Forum + +Ken to reply to post about large VDBs/OOC. Dan to reply to delayed-loading +post. + +There was a question about static libraries on Windows. Include paths need to +be included as a system header using MSVC. Including VDB headers is generating +warnings that are suppressed when building the core library. Nick has replied +to this qs. + +4) 7.2 + +Nick has merged the PRs that removed the Makefiles and restructured the +codebase. Planning on introducing the first PR that brings AX into the master +branch, initially the core AX library only, then the Houdini SOP subsequently. + +5) NanoVDB + +NanoVDB probably aiming for an 8.0 integration to allow a little more time for +the codebase to mature. Ken currently merging NanoVDB up to the feature branch +on a weekly cadence. + +New work includes a tool for recomputing the grid statistics, foreach, range +and invoke wrappers around TBB functionality. Current effort is in adding +DirectX support, seems this will be relatively trivial. + +Some users are asking for documentation around the memory layout. Investigation +ongoing to look at replacing Jeff's work with the C library with a more +automated approach. Jeff notes that initial compile time is a bit of a problem +when using JIT. + +Matt Pharr has incorporated NanoVDB into PBRT with pleasing results. + +6) GCC 9.1 (PR 769) + +Addressed concerns Jeff raised with bool specialization for higher-order +intepolation schemes by tackling the problem at the source. PR is now ready to +be merged. + +7) CpuTimer using C++11 chrono (PR 690) + +Dan investigated thread-safety issues with C++11 chrono. Adopted similar +solution to that favored by TBB which is to store the number of microseconds +since epoch instead of the time_point struct. This allows for starting and +stopping a CpuTimer across multiple threads. PR is now ready to be merged. + +8) Introducing a "feature/abi8" branch (related to PR 788) + +Need somewhere to put ABI=8 development in the run-up to 8.0.0. Solution +preferred by all is to use the master branch instead of introducing a new +feature branch that needs to be kept in sync. This will be gated by a standard +ABI=8 macro but with an additional EXPERIMENTAL flag to reduce chance it will +be picked up by accident, similar to the DEPRECATED flag. + +9) Deprecating code (PR 806, StringGrid, Tree::prune(), LeafNode::str(), etc) + +When should we deprecate? Is one minor version sufficient? Consensus that we +should be a bit more aggressive with deprecations, users often ignore +deprecation warnings anyway. Still nice to give users as much warning as +possible. New major version is a good time to drop API support and force +users to change their code. We should consider introducing a 7.1.1 patch +version with deprecation warnings. All to review the CSG operation PR 785. + +Can we drop support for duplicateSourceStealable()? Nick still using it +heavily. Limitations with current SOP implementation that causes issues with +time dependency. Solution is to migrate to DS, but big sweep required to do so. +Agreement that we should remove these methods anyway, Jeff/SideFX keen for +people to not use this technique now. + +10) "Locking down the grid configuration" + +Dan has implemented explicit template instantiation for the tree hierarchy. It +speeds up building unit tests by around 30%, but building the core library now +slower. It works by suppressing implicit template instantiation whenever tree +hierarchy headers are included and explicitly instantiating them once in a +source file compiled with the core library. Unfortunately had to be implemented +using C preprocessor. More discussion needed, implementation shared as draft +PR 813. + +11) Extrapolate SOP + +Andre reports an issue with an assert firing in the fast sweeping code when run +in debug mode, despite it working correctly in release mode. Assert in question +validates that array indices are non-negative. Andre to share an example with +Dan to investigate the root cause. + +12) Next Meeting + +Skipping next week. September 15th, 2020. 1pm-2pm EDT (GMT-4).