Skip to content

Commit

Permalink
oneTBB: tbb::atomic to std::atomic in usdImagining
Browse files Browse the repository at this point in the history
  • Loading branch information
boberfly authored and brechtvl committed Jun 1, 2023
1 parent 96f9ec8 commit 0193864
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 14 deletions.
1 change: 0 additions & 1 deletion pxr/usdImaging/plugin/usdShaders/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
#include <boost/unordered_map.hpp>
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_unordered_set.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usdImaging/usdAppUtils/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <boost/weak_ptr.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_unordered_set.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usdImaging/usdImaging/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <boost/weak_ptr.hpp>
#include <tbb/atomic.h>
#include <tbb/blocked_range.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
Expand Down
24 changes: 19 additions & 5 deletions pxr/usdImaging/usdImaging/resolvedAttributeCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,36 @@ class UsdImaging_ResolvedAttributeCache
// non-time varying data, entries may exist in the cache with invalid
// values. The version is used to determine validity.
struct _Entry {
_Entry()
_Entry() noexcept
: value(Strategy::MakeDefault())
, version(_GetInitialEntryVersion())
{ }

_Entry(const query_type & query_,
const value_type& value_,
unsigned version_)
unsigned version_) noexcept
: query(query_)
, value(value_)
, version(version_)
{ }

_Entry(const _Entry &other) noexcept
: query(other.query)
, value(other.value)
{
version.store(other.version.load());
}

_Entry(_Entry &&other) noexcept
: query(std::move(other.query))
, value(std::move(other.value))
{
version.store(other.version.load());
}

query_type query;
value_type value;
tbb::atomic<unsigned> version;
std::atomic<unsigned> version;
};

// Returns the version number for a valid cache entry
Expand Down Expand Up @@ -340,7 +354,7 @@ class UsdImaging_ResolvedAttributeCache

// A serial number indicating the valid state of entries in the cache. When
// an entry has an equal or greater value, the entry is valid.
tbb::atomic<unsigned> _cacheVersion;
std::atomic<unsigned> _cacheVersion;

// Value overrides for a set of descendents.
ValueOverridesMap _valueOverrides;
Expand All @@ -359,7 +373,7 @@ UsdImaging_ResolvedAttributeCache<Strategy,ImplData>::_SetCacheEntryForPrim(
// Note: _cacheVersion is not allowed to change during cache access.
unsigned v = entry->version;
if (v < _cacheVersion
&& entry->version.compare_and_swap(_cacheVersion, v) == v)
&& entry->version.compare_exchange_strong(v, _cacheVersion.load()))
{
entry->value = value;
entry->version = _GetValidVersion();
Expand Down
1 change: 0 additions & 1 deletion pxr/usdImaging/usdImagingGL/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <boost/weak_ptr.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_unordered_map.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usdImaging/usdProcImaging/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
#include <boost/variant.hpp>
#include <boost/vmd/is_empty.hpp>
#include <boost/vmd/is_tuple.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_hash_map.h>
#include <tbb/concurrent_queue.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usdImaging/usdRiImaging/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <boost/weak_ptr.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_unordered_map.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usdImaging/usdSkelImaging/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <boost/weak_ptr.hpp>
#include <tbb/atomic.h>
#include <tbb/blocked_range.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usdImaging/usdVolImaging/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <boost/weak_ptr.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_unordered_map.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usdImaging/usdviewq/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@
#include <boost/variant.hpp>
#include <boost/vmd/is_empty.hpp>
#include <boost/vmd/is_tuple.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_hash_map.h>
#include <tbb/concurrent_queue.h>
Expand Down

0 comments on commit 0193864

Please sign in to comment.