Skip to content

Commit

Permalink
Replace all tbb:: calls with mt:: so there can be implementation alte…
Browse files Browse the repository at this point in the history
…rnatives
  • Loading branch information
Luke Titley committed Oct 13, 2023
1 parent 6772563 commit 6ea5e8a
Show file tree
Hide file tree
Showing 74 changed files with 702 additions and 702 deletions.
8 changes: 4 additions & 4 deletions openvdb/openvdb/io/Queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct Queue::Impl
{
using NotifierMap = std::map<Queue::Id, Queue::Notifier>;
/// @todo Provide more information than just "succeeded" or "failed"?
using StatusMap = tbb::concurrent_hash_map<Queue::Id, Queue::Status>;
using StatusMap = mt::concurrent_hash_map<Queue::Id, Queue::Status>;

Impl()
: mTimeout(Queue::DEFAULT_TIMEOUT)
Expand Down Expand Up @@ -128,7 +128,7 @@ struct Queue::Impl
// If the client registered any callbacks, call them now.
bool didNotify = false;
{
// tbb::concurrent_hash_map does not support concurrent iteration
// mt::concurrent_hash_map does not support concurrent iteration
// (i.e., iteration concurrent with insertion or deletion),
// so we use a mutex-protected STL map instead. But if a callback
// invokes a notifier method such as removeNotifier() on this queue,
Expand Down Expand Up @@ -178,7 +178,7 @@ struct Queue::Impl
this->setStatus(task.id(), Queue::PENDING);

// get the global task arena
tbb::task_arena arena(tbb::task_arena::attach{});
mt::task_arena arena(mt::task_arena::attach{});
arena.enqueue([task = std::move(task)] { task.execute(); });
++mNumTasks;
}
Expand Down Expand Up @@ -226,7 +226,7 @@ void Queue::setCapacity(Index32 n) { mImpl->mCapacity = std::max<Index32>(1, n);
/// @todo void Queue::setCapacity(Index64 bytes);

/// @todo Provide a way to limit the number of tasks in flight
/// (e.g., by enqueueing tbb::tasks that pop Tasks off a concurrent_queue)?
/// (e.g., by enqueueing mt::tasks that pop Tasks off a concurrent_queue)?

/// @todo Remove any tasks from the queue that are not currently executing.
//void clear() const;
Expand Down
2 changes: 1 addition & 1 deletion openvdb/openvdb/io/Queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Archive;
/// {
/// // Use a concurrent container, because queue callback functions
/// // must be thread-safe.
/// using FilenameMap = tbb::concurrent_hash_map<Queue::Id, std::string>;
/// using FilenameMap = mt::concurrent_hash_map<Queue::Id, std::string>;
/// FilenameMap filenames;
///
/// // Callback function that prints the status of a completed task.
Expand Down
66 changes: 33 additions & 33 deletions openvdb/openvdb/math/ConjGradient.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace pcg {

using SizeType = Index32;

using SizeRange = tbb::blocked_range<SizeType>;
using SizeRange = mt::blocked_range<SizeType>;

template<typename ValueType> class Vector;

Expand Down Expand Up @@ -212,10 +212,10 @@ class Vector
//@}

private:
// Functor for use with tbb::parallel_for()
// Functor for use with mt::parallel_for()
template<typename Scalar> struct ScaleOp;
struct DeterministicDotProductOp;
// Functors for use with tbb::parallel_reduce()
// Functors for use with mt::parallel_reduce()
template<typename OtherValueType> struct EqOp;
struct InfNormOp;
struct IsFiniteOp;
Expand Down Expand Up @@ -440,12 +440,12 @@ class SparseStencilMatrix
}; // class RowEditor

private:
// Functors for use with tbb::parallel_for()
// Functors for use with mt::parallel_for()
struct MatrixCopyOp;
template<typename VecValueType> struct VecMultOp;
template<typename Scalar> struct RowScaleOp;

// Functors for use with tbb::parallel_reduce()
// Functors for use with mt::parallel_reduce()
struct IsFiniteOp;
template<typename OtherValueType> struct EqOp;

Expand Down Expand Up @@ -485,7 +485,7 @@ class Preconditioner

namespace internal {

// Functor for use with tbb::parallel_for() to copy data from one array to another
// Functor for use with mt::parallel_for() to copy data from one array to another
template<typename T>
struct CopyOp
{
Expand All @@ -500,7 +500,7 @@ struct CopyOp
};


// Functor for use with tbb::parallel_for() to fill an array with a constant value
// Functor for use with mt::parallel_for() to fill an array with a constant value
template<typename T>
struct FillOp
{
Expand All @@ -515,7 +515,7 @@ struct FillOp
};


// Functor for use with tbb::parallel_for() that computes a * x + y
// Functor for use with mt::parallel_for() that computes a * x + y
template<typename T>
struct LinearOp
{
Expand Down Expand Up @@ -558,7 +558,7 @@ template<typename T>
inline
Vector<T>::Vector(const Vector& other): mData(new T[other.mSize]), mSize(other.mSize)
{
tbb::parallel_for(SizeRange(0, mSize),
mt::parallel_for(SizeRange(0, mSize),
internal::CopyOp<T>(/*from=*/other.mData, /*to=*/mData));
}

Expand All @@ -576,7 +576,7 @@ Vector<T>& Vector<T>::operator=(const Vector<T>& other)
}

// Deep copy the data
tbb::parallel_for(SizeRange(0, mSize),
mt::parallel_for(SizeRange(0, mSize),
internal::CopyOp<T>(/*from=*/other.mData, /*to=*/mData));

return *this;
Expand All @@ -599,7 +599,7 @@ template<typename T>
inline void
Vector<T>::fill(const ValueType& value)
{
tbb::parallel_for(SizeRange(0, mSize), internal::FillOp<T>(mData, value));
mt::parallel_for(SizeRange(0, mSize), internal::FillOp<T>(mData, value));
}


Expand All @@ -623,7 +623,7 @@ template<typename Scalar>
inline void
Vector<T>::scale(const Scalar& s)
{
tbb::parallel_for(SizeRange(0, mSize), ScaleOp<Scalar>(mData, s));
mt::parallel_for(SizeRange(0, mSize), ScaleOp<Scalar>(mData, s));
}


Expand Down Expand Up @@ -689,7 +689,7 @@ Vector<T>::dot(const Vector<T>& other) const
const SizeType binCount = 100;
T partialSums[100];

tbb::parallel_for(SizeRange(0, binCount),
mt::parallel_for(SizeRange(0, binCount),
DeterministicDotProductOp(aData, bData, binCount, arraySize, partialSums));

for (SizeType n = 0; n < binCount; ++n) {
Expand Down Expand Up @@ -723,7 +723,7 @@ inline T
Vector<T>::infNorm() const
{
// Parallelize over the elements of this vector.
T result = tbb::parallel_reduce(SizeRange(0, this->size()), /*seed=*/zeroVal<T>(),
T result = mt::parallel_reduce(SizeRange(0, this->size()), /*seed=*/zeroVal<T>(),
InfNormOp(this->data()), /*join=*/[](T max1, T max2) { return Max(max1, max2); });
return result;
}
Expand Down Expand Up @@ -753,7 +753,7 @@ inline bool
Vector<T>::isFinite() const
{
// Parallelize over the elements of this vector.
bool finite = tbb::parallel_reduce(SizeRange(0, this->size()), /*seed=*/true,
bool finite = mt::parallel_reduce(SizeRange(0, this->size()), /*seed=*/true,
IsFiniteOp(this->data()),
/*join=*/[](bool finite1, bool finite2) { return (finite1 && finite2); });
return finite;
Expand Down Expand Up @@ -788,7 +788,7 @@ inline bool
Vector<T>::eq(const Vector<OtherValueType>& other, ValueType eps) const
{
if (this->size() != other.size()) return false;
bool equal = tbb::parallel_reduce(SizeRange(0, this->size()), /*seed=*/true,
bool equal = mt::parallel_reduce(SizeRange(0, this->size()), /*seed=*/true,
EqOp<OtherValueType>(this->data(), other.data(), eps),
/*join=*/[](bool eq1, bool eq2) { return (eq1 && eq2); });
return equal;
Expand Down Expand Up @@ -823,7 +823,7 @@ SparseStencilMatrix<ValueType, STENCIL_SIZE>::SparseStencilMatrix(SizeType numRo
, mRowSizeArray(new SizeType[mNumRows])
{
// Initialize the matrix to a null state by setting the size of each row to zero.
tbb::parallel_for(SizeRange(0, mNumRows),
mt::parallel_for(SizeRange(0, mNumRows),
internal::FillOp<SizeType>(mRowSizeArray.get(), /*value=*/0));
}

Expand Down Expand Up @@ -861,10 +861,10 @@ SparseStencilMatrix<ValueType, STENCIL_SIZE>::SparseStencilMatrix(const SparseSt
SizeType size = mNumRows * STENCIL_SIZE;

// Copy the value and column index arrays from the other matrix to this matrix.
tbb::parallel_for(SizeRange(0, size), MatrixCopyOp(/*from=*/other, /*to=*/*this));
mt::parallel_for(SizeRange(0, size), MatrixCopyOp(/*from=*/other, /*to=*/*this));

// Copy the row size array from the other matrix to this matrix.
tbb::parallel_for(SizeRange(0, mNumRows),
mt::parallel_for(SizeRange(0, mNumRows),
internal::CopyOp<SizeType>(/*from=*/other.mRowSizeArray.get(), /*to=*/mRowSizeArray.get()));
}

Expand Down Expand Up @@ -921,7 +921,7 @@ inline void
SparseStencilMatrix<ValueType, STENCIL_SIZE>::scale(const Scalar& s)
{
// Parallelize over the rows in the matrix.
tbb::parallel_for(SizeRange(0, mNumRows), RowScaleOp<Scalar>(*this, s));
mt::parallel_for(SizeRange(0, mNumRows), RowScaleOp<Scalar>(*this, s));
}


Expand Down Expand Up @@ -972,7 +972,7 @@ SparseStencilMatrix<ValueType, STENCIL_SIZE>::vectorMultiply(
const VecValueType* inVec, VecValueType* resultVec) const
{
// Parallelize over the rows in the matrix.
tbb::parallel_for(SizeRange(0, mNumRows),
mt::parallel_for(SizeRange(0, mNumRows),
VecMultOp<VecValueType>(*this, inVec, resultVec));
}

Expand Down Expand Up @@ -1008,7 +1008,7 @@ SparseStencilMatrix<ValueType, STENCIL_SIZE>::eq(
const SparseStencilMatrix<OtherValueType, STENCIL_SIZE>& other, ValueType eps) const
{
if (this->numRows() != other.numRows()) return false;
bool equal = tbb::parallel_reduce(SizeRange(0, this->numRows()), /*seed=*/true,
bool equal = mt::parallel_reduce(SizeRange(0, this->numRows()), /*seed=*/true,
EqOp<OtherValueType>(*this, other, eps),
/*join=*/[](bool eq1, bool eq2) { return (eq1 && eq2); });
return equal;
Expand Down Expand Up @@ -1042,7 +1042,7 @@ inline bool
SparseStencilMatrix<ValueType, STENCIL_SIZE>::isFinite() const
{
// Parallelize over the rows of this matrix.
bool finite = tbb::parallel_reduce(SizeRange(0, this->numRows()), /*seed=*/true,
bool finite = mt::parallel_reduce(SizeRange(0, this->numRows()), /*seed=*/true,
IsFiniteOp(*this), /*join=*/[](bool finite1, bool finite2) { return (finite1&&finite2); });
return finite;
}
Expand Down Expand Up @@ -1288,7 +1288,7 @@ class JacobiPreconditioner: public Preconditioner<typename MatrixType::ValueType
JacobiPreconditioner(const MatrixType& A): BaseType(A), mDiag(A.numRows())
{
// Initialize vector mDiag with the values from the matrix diagonal.
tbb::parallel_for(SizeRange(0, A.numRows()), InitOp(A, mDiag.data()));
mt::parallel_for(SizeRange(0, A.numRows()), InitOp(A, mDiag.data()));
}

~JacobiPreconditioner() override = default;
Expand All @@ -1300,14 +1300,14 @@ class JacobiPreconditioner: public Preconditioner<typename MatrixType::ValueType
assert(r.size() == z.size());
assert(r.size() == size);

tbb::parallel_for(SizeRange(0, size), ApplyOp(mDiag.data(), r.data(), z.data()));
mt::parallel_for(SizeRange(0, size), ApplyOp(mDiag.data(), r.data(), z.data()));
}

/// Return @c true if all values along the diagonal are finite.
bool isFinite() const { return mDiag.isFinite(); }

private:
// Functor for use with tbb::parallel_for()
// Functor for use with mt::parallel_for()
struct InitOp
{
InitOp(const MatrixType& m, ValueType* v): mat(&m), vec(v) {}
Expand All @@ -1321,7 +1321,7 @@ class JacobiPreconditioner: public Preconditioner<typename MatrixType::ValueType
const MatrixType* mat; ValueType* vec;
};

// Functor for use with tbb::parallel_reduce()
// Functor for use with mt::parallel_reduce()
struct ApplyOp
{
ApplyOp(const ValueType* x_, const ValueType* y_, ValueType* out_):
Expand Down Expand Up @@ -1364,7 +1364,7 @@ class IncompleteCholeskyPreconditioner: public Preconditioner<typename MatrixTyp
const SizeType numRows = mLowerTriangular.numRows();

// Copy the upper triangular part to the lower triangular part.
tbb::parallel_for(SizeRange(0, numRows), CopyToLowerOp(matrix, mLowerTriangular));
mt::parallel_for(SizeRange(0, numRows), CopyToLowerOp(matrix, mLowerTriangular));

// Build the Incomplete Cholesky Matrix
//
Expand Down Expand Up @@ -1443,7 +1443,7 @@ class IncompleteCholeskyPreconditioner: public Preconditioner<typename MatrixTyp
}

// Build the transpose of the IC matrix: mUpperTriangular
tbb::parallel_for(SizeRange(0, numRows),
mt::parallel_for(SizeRange(0, numRows),
TransposeOp(matrix, mLowerTriangular, mUpperTriangular));
}

Expand Down Expand Up @@ -1503,7 +1503,7 @@ class IncompleteCholeskyPreconditioner: public Preconditioner<typename MatrixTyp
const TriangularMatrix& upperMatrix() const { return mUpperTriangular; }

private:
// Functor for use with tbb::parallel_for()
// Functor for use with mt::parallel_for()
struct CopyToLowerOp
{
CopyToLowerOp(const MatrixType& m, TriangularMatrix& l): mat(&m), lower(&l) {}
Expand All @@ -1521,7 +1521,7 @@ class IncompleteCholeskyPreconditioner: public Preconditioner<typename MatrixTyp
const MatrixType* mat; TriangularMatrix* lower;
};

// Functor for use with tbb::parallel_for()
// Functor for use with mt::parallel_for()
struct TransposeOp
{
TransposeOp(const MatrixType& m, const TriangularMatrix& l, TriangularMatrix& u):
Expand Down Expand Up @@ -1559,7 +1559,7 @@ template<typename T>
inline void
axpy(const T& a, const T* xVec, const T* yVec, T* resultVec, SizeType size)
{
tbb::parallel_for(SizeRange(0, size), LinearOp<T>(a, xVec, yVec, resultVec));
mt::parallel_for(SizeRange(0, size), LinearOp<T>(a, xVec, yVec, resultVec));
}

/// Compute @e ax + @e y.
Expand All @@ -1582,7 +1582,7 @@ computeResidual(const MatrixOperator& A, const VecValueType* x,
// Compute r = A * x.
A.vectorMultiply(x, r);
// Compute r = b - r.
tbb::parallel_for(SizeRange(0, A.numRows()), LinearOp<VecValueType>(-1.0, r, b, r));
mt::parallel_for(SizeRange(0, A.numRows()), LinearOp<VecValueType>(-1.0, r, b, r));
}

/// Compute @e r = @e b &minus; @e Ax.
Expand Down
4 changes: 2 additions & 2 deletions openvdb/openvdb/math/Coord.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "Math.h"
#include "Vec3.h"

#include <openvdb/mt/blocked_range.h> // for tbb::split
#include <openvdb/mt/blocked_range.h> // for mt::split

namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
Expand Down Expand Up @@ -304,7 +304,7 @@ class CoordBBox
}
/// @brief Splitting constructor for use in TBB ranges
/// @note The other bounding box is assumed to be divisible.
CoordBBox(CoordBBox& other, const tbb::split&): mMin(other.mMin), mMax(other.mMax)
CoordBBox(CoordBBox& other, const mt::split&): mMin(other.mMin), mMax(other.mMax)
{
assert(this->is_divisible());
const size_t n = this->maxExtent();
Expand Down

0 comments on commit 6ea5e8a

Please sign in to comment.