File tree Expand file tree Collapse file tree 3 files changed +33
-4
lines changed
Expand file tree Collapse file tree 3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 9292#define OPENVDB_UNLIKELY (x ) (x)
9393#endif
9494
95+ // / Macros for assume builtins. Note that we currently don't simply apply these
96+ // / in place of asserts (when asserts are disabled) - they should be only be
97+ // / applied with an assert once profiled
98+ #ifdef __has_cpp_attribute
99+ #if __has_cpp_attribute(assume) >= 202207L
100+ #define OPENVDB_ASSUME (...) [[assume(__VA_ARGS__)]]
101+ #endif
102+ #endif
103+ #ifndef OPENVDB_ASSUME
104+ #if defined(__clang__)
105+ #define OPENVDB_ASSUME (...) __builtin_assume(__VA_ARGS__);
106+ #elif defined(_MSC_VER)
107+ #define OPENVDB_ASSUME (...) __assume(__VA_ARGS__);
108+ #elif defined(__GNUC__)
109+ #if __GNUC__ >= 13
110+ #define OPENVDB_ASSUME (...) __attribute__((__assume__(__VA_ARGS__)))
111+ #endif
112+ #endif
113+ #endif
114+ #ifndef OPENVDB_ASSUME
115+ #define OPENVDB_ASSUME (...)
116+ #endif
117+
95118// / Force inline function macros. These macros do not necessary guarantee that
96119// / the decorated function will be inlined, but provide the strongest vendor
97120// / annotations to that end.
Original file line number Diff line number Diff line change @@ -242,6 +242,8 @@ class LeafNode
242242 " ValueIter::setItem cannot be called on const iterators" );
243243 }
244244 else {
245+ OPENVDB_ASSERT (pos < SIZE);
246+ OPENVDB_ASSUME (pos < SIZE);
245247 mData [pos] = value;
246248 }
247249 }
@@ -257,6 +259,8 @@ class LeafNode
257259 " ValueIter::modifyItem cannot be called on const iterators" );
258260 }
259261 else {
262+ OPENVDB_ASSERT (n < SIZE);
263+ OPENVDB_ASSUME (n < SIZE);
260264 op (mData [n]);
261265 this ->parent ().setValueOn (n);
262266 }
Original file line number Diff line number Diff line change 11OpenVDB:
22 - Improvements:
3- - Significantly improved the performance of all LeafNode ValueIterators,
4- especially when delay loading is enabled. Construction of a ValueIterator
5- on a leaf node now requests the leaf buffers ahead of iteration to avoid
6- expensive API calls.
3+ - Significantly improved the performance of all LeafNode ValueIterators,
4+ up to 5x on some platforms and up to 10x when delay loading is enabled.
5+ Construction of a ValueIterator from a leaf node now requests the leaf
6+ buffers ahead of iteration to avoid potentially expensive API calls.
7+ - Added OPENVDB_ASSUME macros to mimic builtin assume and C++23 assume
8+ attributes.
You can’t perform that action at this time.
0 commit comments