Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From tbb::atomic to std::atomic #1908

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion extras/usd/examples/usdObj/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/variant.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 extras/usd/examples/usdSchemaExamples/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,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/base/plug/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_vector.h>
#include <tbb/enumerable_thread_specific.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/base/tf/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@
#include <boost/variant.hpp>
#include <boost/variant/get.hpp>
#include <boost/variant/variant.hpp>
#include <tbb/atomic.h>
#include <tbb/enumerable_thread_specific.h>
#include <tbb/spin_mutex.h>
#include <tbb/spin_rw_mutex.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/base/trace/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_vector.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/base/vt/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/enable_if.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_unordered_map.h>
#include <tbb/enumerable_thread_specific.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/base/work/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/enable_if.hpp>
#include <tbb/atomic.h>
#include <tbb/blocked_range.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_vector.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/imaging/garch/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
#include <boost/utility/enable_if.hpp>
#include <boost/vmd/is_empty.hpp>
#include <boost/vmd/is_tuple.hpp>
#include <tbb/atomic.h>
#include <tbb/enumerable_thread_specific.h>
#include <tbb/spin_rw_mutex.h>
#ifdef PXR_PYTHON_SUPPORT_ENABLED
Expand Down
1 change: 0 additions & 1 deletion pxr/imaging/glf/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.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/imaging/hd/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
#include <boost/unordered_map.hpp>
#include <boost/utility/enable_if.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/imaging/hdMtlx/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
#include <boost/utility/enable_if.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/imaging/hdSt/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@
#include <opensubdiv/osd/cpuVertexBuffer.h>
#include <opensubdiv/osd/mesh.h>
#include <opensubdiv/version.h>
#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/imaging/hdx/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
#include <boost/unordered_map.hpp>
#include <boost/utility/enable_if.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/imaging/hgiMetal/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
#include <boost/unordered_map.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/weak_ptr.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/spin_mutex.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/imaging/plugin/hdEmbree/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
#include <embree3/rtcore.h>
#include <embree3/rtcore_geometry.h>
#include <embree3/rtcore_ray.h>
#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/imaging/plugin/hdStorm/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
#include <boost/unordered_map.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/weak_ptr.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/spin_mutex.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/imaging/plugin/hioOiio/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.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/usd/ar/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/enable_if.hpp>
#include <tbb/atomic.h>
#include <tbb/concurrent_hash_map.h>
#include <tbb/enumerable_thread_specific.h>
#include <tbb/spin_rw_mutex.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usd/ndr/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <tbb/atomic.h>
#include <tbb/blocked_range.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/enumerable_thread_specific.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usd/pcp/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include "pxr/base/tf/envSetting.h"
#include "pxr/base/tf/registryManager.h"

#include <tbb/atomic.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_vector.h>
#include <tbb/spin_rw_mutex.h>
Expand Down
4 changes: 2 additions & 2 deletions pxr/usd/pcp/mapExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ PcpMapExpression::_Node::New( _Op op_,
// Check for existing instance to re-use
_NodeMap::accessor accessor;
if (_nodeRegistry->map.insert(accessor, key) ||
accessor->second->_refCount.fetch_and_increment() == 0) {
accessor->second->_refCount.fetch_add(1) == 0) {
// Either there was no node in the table, or there was but it had
// begun dying (another client dropped its refcount to 0). We have
// to create a new node in the table. When the client that is
Expand Down Expand Up @@ -387,7 +387,7 @@ intrusive_ptr_add_ref(PcpMapExpression::_Node* p)
void
intrusive_ptr_release(PcpMapExpression::_Node* p)
{
if (p->_refCount.fetch_and_decrement() == 1)
if (p->_refCount.fetch_sub(1) == 1)
delete p;
}

Expand Down
3 changes: 1 addition & 2 deletions pxr/usd/pcp/mapExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include <boost/intrusive_ptr.hpp>

#include <tbb/atomic.h>
#include <tbb/spin_mutex.h>

#include <atomic>
Expand Down Expand Up @@ -265,7 +264,7 @@ class PcpMapExpression
struct _NodeMap;
static TfStaticData<_NodeMap> _nodeRegistry;

mutable tbb::atomic<int> _refCount;
mutable std::atomic<int> _refCount;
mutable Value _cachedValue;
mutable std::set<_Node*> _dependentExpressions;
Value _valueForVariable;
Expand Down
1 change: 0 additions & 1 deletion pxr/usd/pcp/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@
#include <boost/unordered_map.hpp>
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <tbb/atomic.h>
#include <tbb/blocked_range.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_hash_map.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usd/plugin/usdAbc/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/variant.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/usd/plugin/usdDraco/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
#include <draco/compression/encode.h>
#include <draco/mesh/mesh.h>
#include <draco/mesh/mesh_misc_functions.h>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_unordered_set.h>
Expand Down
10 changes: 5 additions & 5 deletions pxr/usd/sdf/changeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "pxr/base/tf/instantiateSingleton.h"
#include "pxr/base/tf/stackTrace.h"

#include <tbb/atomic.h>
#include <atomic>

using std::string;
using std::vector;
Expand Down Expand Up @@ -149,9 +149,9 @@ Sdf_ChangeManager::_ProcessRemoveIfInert(_Data *data)
TF_VERIFY(data->outermostBlock);
}

static tbb::atomic<size_t> &
static std::atomic<size_t> &
_InitChangeSerialNumber() {
static tbb::atomic<size_t> value;
static std::atomic<size_t> value;
value = 1;
return value;
}
Expand Down Expand Up @@ -190,8 +190,8 @@ Sdf_ChangeManager::_SendNotices(_Data *data)
}

// Obtain a serial number for this round of change processing.
static tbb::atomic<size_t> &changeSerialNumber = _InitChangeSerialNumber();
size_t serialNumber = changeSerialNumber.fetch_and_increment();
static std::atomic<size_t> &changeSerialNumber = _InitChangeSerialNumber();
size_t serialNumber = changeSerialNumber.fetch_add(1);

// Send global notice.
SdfNotice::LayersDidChange(changes, serialNumber).Send();
Expand Down
4 changes: 2 additions & 2 deletions pxr/usd/sdf/pathNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static_assert(sizeof(Sdf_PrimPropertyPathNode) == 3 * sizeof(void *), "");
struct Sdf_PathNodePrivateAccess
{
template <class Handle>
static inline tbb::atomic<unsigned int> &
static inline std::atomic<unsigned int> &
GetRefCount(Handle h) {
Sdf_PathNode const *p =
reinterpret_cast<Sdf_PathNode const *>(h.GetPtr());
Expand Down Expand Up @@ -265,7 +265,7 @@ _FindOrCreate(Table &table,
if (iresult.second ||
(Table::NodeHandle::IsCounted &&
Access::GetRefCount(
iresult.first->second).fetch_and_increment() == 0)) {
iresult.first->second).fetch_add(1) == 0)) {
// There was either no entry, or there was one but it had begun dying
// (another client dropped its refcount to 0). We have to create a new
// entry in the table. When the client that is deleting the other node
Expand Down
6 changes: 3 additions & 3 deletions pxr/usd/sdf/pathNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <boost/noncopyable.hpp>
#include <boost/intrusive_ptr.hpp>

#include <tbb/atomic.h>
#include <atomic>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down Expand Up @@ -311,7 +311,7 @@ class Sdf_PathNode {
// Instance variables. PathNode's size is important to keep small. Please
// be mindful of that when making any changes here.
const Sdf_PathNodeConstRefPtr _parent;
mutable tbb::atomic<unsigned int> _refCount;
mutable std::atomic<unsigned int> _refCount;

const short _elementCount;
const unsigned char _nodeType;
Expand Down Expand Up @@ -751,7 +751,7 @@ inline void intrusive_ptr_add_ref(const PXR_NS::Sdf_PathNode* p) {
++p->_refCount;
}
inline void intrusive_ptr_release(const PXR_NS::Sdf_PathNode* p) {
if (p->_refCount.fetch_and_decrement() == 1)
if (p->_refCount.fetch_sub(1) == 1)
p->_Destroy();
}

Expand Down
1 change: 0 additions & 1 deletion pxr/usd/sdf/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
#include <boost/variant.hpp>
#include <boost/vmd/is_empty.hpp>
#include <boost/vmd/is_tuple.hpp>
#include <tbb/atomic.h>
#include <tbb/blocked_range.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_hash_map.h>
Expand Down
1 change: 0 additions & 1 deletion pxr/usd/usd/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/utility/in_place_factory.hpp>
#include <tbb/atomic.h>
#include <tbb/blocked_range.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_hash_map.h>
Expand Down
21 changes: 17 additions & 4 deletions pxr/usd/usdGeom/bboxCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

#include <tbb/enumerable_thread_specific.h>
#include <algorithm>
#include <atomic>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down Expand Up @@ -100,11 +101,24 @@ class UsdGeomBBoxCache::_PrototypeBBoxResolver

struct _PrototypeTask
{
_PrototypeTask() : numDependencies(0) { }
_PrototypeTask() noexcept
: numDependencies(0) { }

_PrototypeTask(const _PrototypeTask &other) noexcept
: dependentPrototypes(other.dependentPrototypes)
{
numDependencies.store(other.numDependencies.load());
}

_PrototypeTask(_PrototypeTask &&other) noexcept
: dependentPrototypes(std::move(other.dependentPrototypes))
{
numDependencies.store(other.numDependencies.load());
}

// Number of dependencies -- prototype prims that must be resolved
// before this prototype can be resolved.
tbb::atomic<size_t> numDependencies;
std::atomic<size_t> numDependencies;

// List of prototype prims that depend on this prototype.
std::vector<_PrimContext> dependentPrototypes;
Expand Down Expand Up @@ -196,7 +210,7 @@ class UsdGeomBBoxCache::_PrototypeBBoxResolver
_PrototypeTask& dependentPrototypeData =
prototypeTasks->find(dependentPrototype)->second;
if (dependentPrototypeData.numDependencies
.fetch_and_decrement() == 1){
.fetch_sub(1) == 1){
dispatcher->Run(
&_PrototypeBBoxResolver::_ExecuteTaskForPrototype,
this, dependentPrototype, prototypeTasks, xfCaches,
Expand Down Expand Up @@ -1484,4 +1498,3 @@ size_t hash_value(const UsdGeomBBoxCache::_PrimContext &key)


PXR_NAMESPACE_CLOSE_SCOPE

1 change: 0 additions & 1 deletion pxr/usd/usdGeom/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/variant.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/usd/usdHydra/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,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/usd/usdLux/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/variant.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/usd/usdMedia/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <tbb/atomic.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_queue.h>
#include <tbb/concurrent_unordered_set.h>
Expand Down
Loading