diff --git a/vtkm/Types.h b/vtkm/Types.h index 328c2db61..94ae5edc6 100644 --- a/vtkm/Types.h +++ b/vtkm/Types.h @@ -173,82 +173,21 @@ namespace internal { /// Placeholder class for when a type is not applicable. /// -struct NullType { }; +struct NullType +{ +}; //----------------------------------------------------------------------------- - -template -struct VecEquals -{ - template - VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const - { - bool equal = true; - for (vtkm::IdComponent componentIndex = 0; - equal && (componentIndex < Size); - componentIndex++) - { - equal &= a[componentIndex] == b[componentIndex]; - } - return equal; - } -}; - -template<> -struct VecEquals<1> -{ - template - VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const - { - return a[0] == b[0]; - } -}; - -template<> -struct VecEquals<2> -{ - template - VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const - { - return ((a[0] == b[0]) && (a[1] == b[1])); - } -}; - -template<> -struct VecEquals<3> -{ - template - VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const - { - return ((a[0] == b[0]) && (a[1] == b[1]) && (a[2] == b[2])); - } -}; - -template<> -struct VecEquals<4> -{ - template - VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const - { - return ((a[0] == b[0]) - && (a[1] == b[1]) - && (a[2] == b[2]) - && (a[3] == b[3])); - } -}; - -template +template struct AssignScalarToVec { template VTKM_EXEC_CONT_EXPORT void operator()(VectorType &dest, const ComponentType &src) { - for (vtkm::IdComponent componentIndex = 0; - componentIndex < Size; - componentIndex++) + for (vtkm::IdComponent i = 0; i < Size; ++i) { - dest[componentIndex] = src; + dest[i] = src; } } }; @@ -303,282 +242,7 @@ struct AssignScalarToVec<4> } }; -template -struct VecCopy -{ - template - VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src) - { - for (vtkm::IdComponent componentIndex = 0; - componentIndex < Size; - componentIndex++) - { - dest[componentIndex] = CType(src[componentIndex]); - } - } -}; - -template -struct VecCopy -{ - template - VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src) - { - dest[0] = CType(src[0]); - } -}; - -template -struct VecCopy -{ - template - VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src) - { - dest[0] = CType(src[0]); - dest[1] = CType(src[1]); - } -}; - -template -struct VecCopy -{ - template - VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src) - { - dest[0] = CType(src[0]); - dest[1] = CType(src[1]); - dest[2] = CType(src[2]); - } -}; - -template -struct VecCopy -{ - template - VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src) - { - dest[0] = CType(src[0]); - dest[1] = CType(src[1]); - dest[2] = CType(src[2]); - dest[3] = CType(src[3]); - } -}; - -template -struct VecSum -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - typename T::ComponentType sum = x[0]; - for (vtkm::IdComponent componentIndex = 1; - componentIndex < Size; - componentIndex++) - { - sum += x[componentIndex]; - } - return sum; - } -}; - -template<> -struct VecSum<0> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &) - { - return T::ComponentType(0); - } -}; - -template<> -struct VecSum<1> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - return x[0]; - } -}; - -template<> -struct VecSum<2> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - return x[0] + x[1]; - } -}; - -template<> -struct VecSum<3> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - return x[0] + x[1] + x[2]; - } -}; - -template<> -struct VecSum<4> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - return x[0] + x[1] + x[2] + x[3]; - } -}; - -template -struct VecProduct -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - typename T::ComponentType product = x[0]; - for (vtkm::IdComponent componentIndex = 1; - componentIndex < Size; - componentIndex++) - { - product *= x[componentIndex]; - } - return product; - } -}; - -template<> -struct VecProduct<0> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &) - { - return T::ComponentType(1); - } -}; - -template<> -struct VecProduct<1> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - return x[0]; - } -}; - -template<> -struct VecProduct<2> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - return x[0] * x[1]; - } -}; - -template<> -struct VecProduct<3> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - return x[0] * x[1] * x[2]; - } -}; - -template<> -struct VecProduct<4> -{ - template - VTKM_EXEC_CONT_EXPORT - typename T::ComponentType operator()(const T &x) - { - return x[0] * x[1] * x[2] * x[3]; - } -}; - -template -struct VecComponentWiseBinaryOperation -{ - template - VTKM_EXEC_CONT_EXPORT - T operator()(const T &a, const T &b, const BinaryOpType &binaryOp) const - { - T result; - for (vtkm::IdComponent componentIndex = 0; - componentIndex < Size; - componentIndex++) - { - result[componentIndex] = binaryOp(a[componentIndex], b[componentIndex]); - } - return result; - } -}; - -template<> -struct VecComponentWiseBinaryOperation<1> -{ - template - VTKM_EXEC_CONT_EXPORT - T operator()(const T &a, const T &b, const BinaryOpType &binaryOp) const - { - return T(binaryOp(a[0], b[0])); - } -}; - -template<> -struct VecComponentWiseBinaryOperation<2> -{ - template - VTKM_EXEC_CONT_EXPORT - T operator()(const T &a, const T &b, const BinaryOpType &binaryOp) const - { - return T(binaryOp(a[0], b[0]), - binaryOp(a[1], b[1])); - } -}; - -template<> -struct VecComponentWiseBinaryOperation<3> -{ - template - VTKM_EXEC_CONT_EXPORT - T operator()(const T &a, const T &b, const BinaryOpType &binaryOp) const - { - return T(binaryOp(a[0], b[0]), - binaryOp(a[1], b[1]), - binaryOp(a[2], b[2])); - } -}; - -template<> -struct VecComponentWiseBinaryOperation<4> -{ - template - VTKM_EXEC_CONT_EXPORT - T operator()(const T &a, const T &b, const BinaryOpType &binaryOp) const - { - return T(binaryOp(a[0], b[0]), - binaryOp(a[1], b[1]), - binaryOp(a[2], b[2]), - binaryOp(a[3], b[3])); - } -}; - -template +template struct VecComponentWiseUnaryOperation { template @@ -586,11 +250,9 @@ struct VecComponentWiseUnaryOperation T operator()(const T &v, const UnaryOpType &unaryOp) const { T result; - for (vtkm::IdComponent componentIndex = 0; - componentIndex < Size; - componentIndex++) + for (vtkm::IdComponent i = 0; i < Size; ++i) { - result[componentIndex] = unaryOp(v[componentIndex]); + result[i] = unaryOp(v[i]); } return result; } @@ -644,7 +306,7 @@ template struct BindLeftBinaryOp { // Warning: a reference. - const T &LeftValue; + const T& LeftValue; const BinaryOpType BinaryOp; VTKM_EXEC_CONT_EXPORT BindLeftBinaryOp(const T &leftValue, BinaryOpType binaryOp = BinaryOpType()) @@ -663,7 +325,7 @@ template struct BindRightBinaryOp { // Warning: a reference. - const T &RightValue; + const T& RightValue; const BinaryOpType BinaryOp; VTKM_EXEC_CONT_EXPORT BindRightBinaryOp(const T &rightValue, BinaryOpType binaryOp = BinaryOpType()) @@ -678,6 +340,8 @@ struct BindRightBinaryOp } }; +} // namespace internal + // Disable conversion warnings for Add, Subtract, Multiply, Divide on GCC only. // GCC creates false positive warnings for signed/unsigned char* operations. // This occurs because the values are implicitly casted up to int's for the @@ -737,164 +401,206 @@ struct Negate #pragma GCC diagnostic pop #endif // gcc || clang -} // namespace internal - //----------------------------------------------------------------------------- // Pre declaration -template class Vec; +template +class Vec; namespace detail { /// Base implementation of all Vec classes. /// -template +template class VecBase { public: typedef T ComponentType; - static const vtkm::IdComponent NUM_COMPONENTS=Size; + static const vtkm::IdComponent NUM_COMPONENTS = Size; protected: VTKM_EXEC_CONT_EXPORT - VecBase() {} + VecBase() + { + } VTKM_EXEC_CONT_EXPORT explicit VecBase(const ComponentType& value) { vtkm::internal::AssignScalarToVec()( - this->Components, value); + this->Components, value); } - template - VTKM_EXEC_CONT_EXPORT - VecBase(const VecBase &src) + template + VTKM_EXEC_CONT_EXPORT VecBase( + const VecBase& src) { - vtkm::internal::VecCopy()( - this->Components, src); + for (vtkm::IdComponent i = 0; i < Size; ++i) + { + this->Components[i] = static_cast(src[i]); + } } public: VTKM_EXEC_CONT_EXPORT - vtkm::IdComponent GetNumberOfComponents() const { return NUM_COMPONENTS; } + vtkm::IdComponent GetNumberOfComponents() const + { + return NUM_COMPONENTS; + } - template - VTKM_EXEC_CONT_EXPORT - void CopyInto(vtkm::Vec &dest) const + template + VTKM_EXEC_CONT_EXPORT void CopyInto( + vtkm::Vec& dest) const { for (vtkm::IdComponent index = 0; - (index < NUM_COMPONENTS) && (index < OtherSize); - index++) + (index < NUM_COMPONENTS) && (index < OtherSize); index++) { dest[index] = (*this)[index]; } } VTKM_EXEC_CONT_EXPORT - DerivedClass &operator=(const DerivedClass &src) + DerivedClass& operator=(const DerivedClass& src) { - vtkm::internal::VecCopy()( - this->Components, src); - return *reinterpret_cast(this); - } - - VTKM_EXEC_CONT_EXPORT - const ComponentType &operator[](vtkm::IdComponent idx) const - { - VTKM_ASSERT(idx >= 0); - VTKM_ASSERT(idx < this->NUM_COMPONENTS); - return this->Components[idx]; - } - VTKM_EXEC_CONT_EXPORT - ComponentType &operator[](vtkm::IdComponent idx) - { - VTKM_ASSERT(idx >= 0); - VTKM_ASSERT(idx < this->NUM_COMPONENTS); - return this->Components[idx]; - } - - VTKM_EXEC_CONT_EXPORT - bool operator==(const DerivedClass &other) const - { - return vtkm::internal::VecEquals()( - *reinterpret_cast(this), other); - } - - VTKM_EXEC_CONT_EXPORT - bool operator<(const DerivedClass &other) const - { - for(vtkm::IdComponent componentIndex = 0; - componentIndex < NUM_COMPONENTS; - ++componentIndex) + for (vtkm::IdComponent i = 0; i < Size; ++i) { - //ignore equals as that represents check next value - if(this->Components[componentIndex] < other[componentIndex]) + this->Components[i] = src[i]; + } + return *static_cast(this); + } + + VTKM_EXEC_CONT_EXPORT + const ComponentType& operator[](vtkm::IdComponent idx) const + { + VTKM_ASSERT(idx >= 0); + VTKM_ASSERT(idx < this->NUM_COMPONENTS); + return this->Components[idx]; + } + VTKM_EXEC_CONT_EXPORT + ComponentType& operator[](vtkm::IdComponent idx) + { + VTKM_ASSERT(idx >= 0); + VTKM_ASSERT(idx < this->NUM_COMPONENTS); + return this->Components[idx]; + } + + VTKM_EXEC_CONT_EXPORT + bool operator==(const DerivedClass& other) const + { + bool equal=true; + for(vtkm::IdComponent i=0; i < Size && equal; ++i) + { + equal = (this->Components[i] == other.Components[i]); + } + return equal; + } + + VTKM_EXEC_CONT_EXPORT + bool operator<(const DerivedClass& other) const + { + for (vtkm::IdComponent i = 0; i < NUM_COMPONENTS; ++i) + { + // ignore equals as that represents check next value + if (this->Components[i] < other[i]) { return true; } - else if(other[componentIndex] < this->Components[componentIndex]) + else if (other[i] < this->Components[i]) { return false; } - } //if all same we are not less + } // if all same we are not less return false; } VTKM_EXEC_CONT_EXPORT - bool operator!=(const DerivedClass &other) const + bool operator!=(const DerivedClass& other) const { return !(this->operator==(other)); } VTKM_EXEC_CONT_EXPORT - ComponentType Dot(const DerivedClass &other) const + ComponentType Dot(const DerivedClass& other) const { - ComponentType result = this->Components[0]*other[0]; - for (vtkm::IdComponent componentIndex = 1; - componentIndex < Size; - componentIndex++) + ComponentType result = this->Components[0] * other[0]; + for (vtkm::IdComponent i = 1; i < Size; ++i) { - result += this->Components[componentIndex]*other[componentIndex]; + result += this->Components[i] * other[i]; + } + return result; + } + +// Disable conversion warnings for Add, Subtract, Multiply, Divide on GCC only. +// GCC creates false positive warnings for signed/unsigned char* operations. +// This occurs because the values are implicitly casted up to int's for the +// operation, and than casted back down to char's when return. +// This causes a false positive warning, even when the values is within +// the value types range +#if (defined(VTKM_GCC) || defined(VTKM_CLANG)) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif // gcc || clang + + VTKM_EXEC_CONT_EXPORT + DerivedClass operator+(const DerivedClass& other) const + { + DerivedClass result; + for (vtkm::IdComponent i = 0; i < Size; ++i) + { + result[i] = this->Components[i] + other[i]; } return result; } VTKM_EXEC_CONT_EXPORT - DerivedClass operator+(const DerivedClass &other) const + DerivedClass operator-(const DerivedClass& other) const { - return vtkm::internal::VecComponentWiseBinaryOperation()( - *reinterpret_cast(this), - other, - vtkm::internal::Add()); + DerivedClass result; + for (vtkm::IdComponent i = 0; i < Size; ++i) + { + result[i] = this->Components[i] - other[i]; + } + return result; } VTKM_EXEC_CONT_EXPORT - DerivedClass operator-(const DerivedClass &other) const + DerivedClass operator*(const DerivedClass& other) const { - return vtkm::internal::VecComponentWiseBinaryOperation()( - *reinterpret_cast(this), - other, - vtkm::internal::Subtract()); + DerivedClass result; + for (vtkm::IdComponent i = 0; i < Size; ++i) + { + result[i] = this->Components[i] * other[i]; + } + return result; } VTKM_EXEC_CONT_EXPORT - DerivedClass operator*(const DerivedClass &other) const + DerivedClass operator/(const DerivedClass& other) const { - return vtkm::internal::VecComponentWiseBinaryOperation()( - *reinterpret_cast(this), - other, - vtkm::internal::Multiply()); + DerivedClass result; + for (vtkm::IdComponent i = 0; i < Size; ++i) + { + result[i] = this->Components[i] / other[i]; + } + return result; } +#if (defined(VTKM_GCC) || defined(VTKM_CLANG)) +#pragma GCC diagnostic pop +#endif // gcc || clang + VTKM_EXEC_CONT_EXPORT - DerivedClass operator/(const DerivedClass &other) const + ComponentType* GetPointer() { - return vtkm::internal::VecComponentWiseBinaryOperation()( - *reinterpret_cast(this), - other, - vtkm::internal::Divide()); + return this->Components; + } + + VTKM_EXEC_CONT_EXPORT + const ComponentType* GetPointer() const + { + return this->Components; } protected: @@ -927,7 +633,7 @@ class Vec : public detail::VecBase > public: #ifdef VTKM_DOXYGEN_ONLY typedef T ComponentType; - static const vtkm::IdComponent NUM_COMPONENTS=Size; + static const vtkm::IdComponent NUM_COMPONENTS = Size; #endif VTKM_EXEC_CONT_EXPORT Vec() {} @@ -1079,6 +785,20 @@ public: } }; +/// Provides the appropriate type when not sure if using a Vec or a scalar in a +/// templated class or function. The \c Type in the struct is the same as the +/// \c ComponentType when \c NumComponents is 1 and a \c Vec otherwise. +/// +template +struct VecOrScalar +{ + typedef vtkm::Vec Type; +}; +template +struct VecOrScalar +{ + typedef ComponentType Type; +}; /// Initializes and returns a Vec of length 2. /// @@ -1116,10 +836,10 @@ template VTKM_EXEC_CONT_EXPORT T dot(const vtkm::Vec &a, const vtkm::Vec &b) { - T result = T(a[0]*b[0]); - for (vtkm::IdComponent componentIndex = 1; componentIndex < Size; componentIndex++) + T result = T(a[0] * b[0]); + for (vtkm::IdComponent i = 1; i < Size; ++i) { - result = T(result + a[componentIndex]*b[componentIndex]); + result = T(result + a[i] * b[i]); } return result; } @@ -1138,23 +858,95 @@ T dot(const vtkm::Vec &a, const vtkm::Vec &b) return T((a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2])); } -template -VTKM_EXEC_CONT_EXPORT -T dot(const vtkm::Vec &a, const vtkm::Vec &b) +template +VTKM_EXEC_CONT_EXPORT T +dot(const vtkm::Vec& a, const vtkm::Vec& b) { - return T((a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]) + (a[3]*b[3])); + return T((a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3])); } -//Integer types of a width less than an integer get implicitly casted to -//an integer when doing a multiplication. -#define VTK_M_INTEGER_PROMOTION_SCALAR_DOT(type) \ - VTKM_EXEC_CONT_EXPORT type dot(type a, type b) { return static_cast(a * b); } +template +VTKM_EXEC_CONT_EXPORT T +ReduceSum(const vtkm::Vec& a) +{ + T result = a[0]; + for (vtkm::IdComponent i = 1; i < Size; ++i) + { + result += a[i]; + } + return result; +} + +template +VTKM_EXEC_CONT_EXPORT T +ReduceSum(const vtkm::Vec& a) +{ + return a[0] + a[1]; +} + +template +VTKM_EXEC_CONT_EXPORT T +ReduceSum(const vtkm::Vec& a) +{ + return a[0] + a[1] + a[2]; +} + +template +VTKM_EXEC_CONT_EXPORT T +ReduceSum(const vtkm::Vec& a) +{ + return a[0] + a[1] + a[2] + a[3]; +} + +template +VTKM_EXEC_CONT_EXPORT T +ReduceProduct(const vtkm::Vec& a) +{ + T result = a[0]; + for (vtkm::IdComponent i = 1; i < Size; ++i) + { + result *= a[i]; + } + return result; +} + +template +VTKM_EXEC_CONT_EXPORT T +ReduceProduct(const vtkm::Vec& a) +{ + return a[0] * a[1]; +} + +template +VTKM_EXEC_CONT_EXPORT T +ReduceProduct(const vtkm::Vec& a) +{ + return a[0] * a[1] * a[2]; +} + +template +VTKM_EXEC_CONT_EXPORT T +ReduceProduct(const vtkm::Vec& a) +{ + return a[0] * a[1] * a[2] * a[3]; +} + +// Integer types of a width less than an integer get implicitly casted to +// an integer when doing a multiplication. +#define VTK_M_INTEGER_PROMOTION_SCALAR_DOT(type) \ + VTKM_EXEC_CONT_EXPORT type dot(type a, type b) \ + { \ + return static_cast(a * b); \ + } VTK_M_INTEGER_PROMOTION_SCALAR_DOT(vtkm::Int8) VTK_M_INTEGER_PROMOTION_SCALAR_DOT(vtkm::UInt8) VTK_M_INTEGER_PROMOTION_SCALAR_DOT(vtkm::Int16) VTK_M_INTEGER_PROMOTION_SCALAR_DOT(vtkm::UInt16) -#define VTK_M_SCALAR_DOT(type) \ - VTKM_EXEC_CONT_EXPORT type dot(type a, type b) { return a * b; } +#define VTK_M_SCALAR_DOT(type) \ + VTKM_EXEC_CONT_EXPORT type dot(type a, type b) \ + { \ + return a * b; \ + } VTK_M_SCALAR_DOT(vtkm::Int32) VTK_M_SCALAR_DOT(vtkm::UInt32) VTK_M_SCALAR_DOT(vtkm::Int64) @@ -1172,7 +964,7 @@ vtkm::Vec operator*(T scalar, const vtkm::Vec &vec) { return vtkm::internal::VecComponentWiseUnaryOperation()( vec, - vtkm::internal::BindLeftBinaryOp(scalar)); + vtkm::internal::BindLeftBinaryOp(scalar)); } template @@ -1181,7 +973,7 @@ vtkm::Vec operator*(const vtkm::Vec &vec, T scalar) { return vtkm::internal::VecComponentWiseUnaryOperation()( vec, - vtkm::internal::BindRightBinaryOp(scalar)); + vtkm::internal::BindRightBinaryOp(scalar)); } template @@ -1193,7 +985,7 @@ operator*(vtkm::Float64 scalar, const vtkm::Vec &vec) vtkm::internal::VecComponentWiseUnaryOperation()( vec, vtkm::internal::BindLeftBinaryOp< - vtkm::Float64,vtkm::internal::Multiply,T>(scalar))); + vtkm::Float64,vtkm::Multiply,T>(scalar))); } template @@ -1205,7 +997,7 @@ operator*(const vtkm::Vec &vec, vtkm::Float64 scalar) vtkm::internal::VecComponentWiseUnaryOperation()( vec, vtkm::internal::BindRightBinaryOp< - vtkm::Float64,vtkm::internal::Multiply,T>(scalar))); + vtkm::Float64,vtkm::Multiply,T>(scalar))); } template @@ -1216,7 +1008,7 @@ operator*(vtkm::Float64 scalar, const vtkm::Vec &vec) return vtkm::internal::VecComponentWiseUnaryOperation()( vec, vtkm::internal::BindLeftBinaryOp< - vtkm::Float64,vtkm::internal::Multiply>(scalar)); + vtkm::Float64,vtkm::Multiply>(scalar)); } template @@ -1227,7 +1019,7 @@ operator*(const vtkm::Vec &vec, vtkm::Float64 scalar) return vtkm::internal::VecComponentWiseUnaryOperation()( vec, vtkm::internal::BindRightBinaryOp< - vtkm::Float64,vtkm::internal::Multiply>(scalar)); + vtkm::Float64,vtkm::Multiply>(scalar)); } template @@ -1236,7 +1028,7 @@ vtkm::Vec operator/(const vtkm::Vec &vec, T scalar) { return vtkm::internal::VecComponentWiseUnaryOperation()( vec, - vtkm::internal::BindRightBinaryOp(scalar)); + vtkm::internal::BindRightBinaryOp(scalar)); } template @@ -1248,7 +1040,7 @@ operator/(const vtkm::Vec &vec, vtkm::Float64 scalar) vtkm::internal::VecComponentWiseUnaryOperation()( vec, vtkm::internal::BindRightBinaryOp< - vtkm::Float64,vtkm::internal::Divide,T>(scalar))); + vtkm::Float64,vtkm::Divide,T>(scalar))); } template @@ -1259,7 +1051,7 @@ operator/(const vtkm::Vec &vec, vtkm::Float64 scalar) return vtkm::internal::VecComponentWiseUnaryOperation()( vec, vtkm::internal::BindRightBinaryOp< - vtkm::Float64,vtkm::internal::Divide>(scalar)); + vtkm::Float64,vtkm::Divide>(scalar)); } // The enable_if for this operator is effectively disabling the negate // operator for Vec of unsigned integers. Another approach would be @@ -1275,7 +1067,7 @@ typename std::enable_if< operator-(const vtkm::Vec &x) { return vtkm::internal::VecComponentWiseUnaryOperation()( - x, vtkm::internal::Negate()); + x, vtkm::Negate()); } /// Helper function for printing out vectors during testing. diff --git a/vtkm/benchmarking/BenchmarkDeviceAdapter.cxx b/vtkm/benchmarking/BenchmarkDeviceAdapter.cxx index ab5b49de0..1978261f9 100644 --- a/vtkm/benchmarking/BenchmarkDeviceAdapter.cxx +++ b/vtkm/benchmarking/BenchmarkDeviceAdapter.cxx @@ -278,7 +278,7 @@ private: vtkm::Float64 operator()(){ Timer timer; Algorithm::ReduceByKey(KeyHandle, ValueHandle, KeysOut, ValuesOut, - vtkm::internal::Add()); + vtkm::Add()); return timer.GetElapsedTime(); } diff --git a/vtkm/cont/CellSetExplicit.h b/vtkm/cont/CellSetExplicit.h index 9341f3cec..dc7114a04 100644 --- a/vtkm/cont/CellSetExplicit.h +++ b/vtkm/cont/CellSetExplicit.h @@ -425,7 +425,7 @@ public: Algorithm::ReduceByKey(pointIndices, numArray, uniquePoints, numIndices, - vtkm::internal::Add()); + vtkm::Add()); // Set the CellToPoint information vtkm::cont::ArrayHandleConstant shapeArray(CELL_SHAPE_VERTEX, numberOfPoints); diff --git a/vtkm/cont/internal/DeviceAdapterAlgorithmGeneral.h b/vtkm/cont/internal/DeviceAdapterAlgorithmGeneral.h index 493f0c05a..88119ed63 100644 --- a/vtkm/cont/internal/DeviceAdapterAlgorithmGeneral.h +++ b/vtkm/cont/internal/DeviceAdapterAlgorithmGeneral.h @@ -256,7 +256,7 @@ public: VTKM_CONT_EXPORT static T Reduce( const vtkm::cont::ArrayHandle &input, T initialValue) { - return DerivedAlgorithm::Reduce(input, initialValue, vtkm::internal::Add()); + return DerivedAlgorithm::Reduce(input, initialValue,vtkm::Add()); } template @@ -444,7 +444,7 @@ public: { return DerivedAlgorithm::ScanInclusive(input, output, - vtkm::internal::Add()); + vtkm::Add()); } template diff --git a/vtkm/cont/serial/internal/DeviceAdapterAlgorithmSerial.h b/vtkm/cont/serial/internal/DeviceAdapterAlgorithmSerial.h index 07f62f018..c21da89eb 100644 --- a/vtkm/cont/serial/internal/DeviceAdapterAlgorithmSerial.h +++ b/vtkm/cont/serial/internal/DeviceAdapterAlgorithmSerial.h @@ -53,7 +53,7 @@ public: VTKM_CONT_EXPORT static T Reduce( const vtkm::cont::ArrayHandle &input, T initialValue) { - return Reduce(input, initialValue, vtkm::internal::Add()); + return Reduce(input, initialValue,vtkm::Add()); } template diff --git a/vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h b/vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h index a056e1c8a..0f0f9413e 100644 --- a/vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h +++ b/vtkm/cont/tbb/internal/DeviceAdapterAlgorithmTBB.h @@ -94,7 +94,7 @@ public: return tbb::ScanInclusivePortals( input.PrepareForInput(vtkm::cont::DeviceAdapterTagTBB()), output.PrepareForOutput(input.GetNumberOfValues(), - vtkm::cont::DeviceAdapterTagTBB()), vtkm::internal::Add()); + vtkm::cont::DeviceAdapterTagTBB()),vtkm::Add()); } template @@ -118,7 +118,7 @@ public: input.PrepareForInput(vtkm::cont::DeviceAdapterTagTBB()), output.PrepareForOutput(input.GetNumberOfValues(), vtkm::cont::DeviceAdapterTagTBB()), - vtkm::internal::Add(), vtkm::TypeTraits::ZeroInitialization()); + vtkm::Add(), vtkm::TypeTraits::ZeroInitialization()); } template diff --git a/vtkm/cont/testing/TestingDeviceAdapter.h b/vtkm/cont/testing/TestingDeviceAdapter.h index f2cb487dc..5607be07d 100644 --- a/vtkm/cont/testing/TestingDeviceAdapter.h +++ b/vtkm/cont/testing/TestingDeviceAdapter.h @@ -1199,7 +1199,7 @@ private: values, keysOut, valuesOut, - vtkm::internal::Add() ); + vtkm::Add() ); VTKM_TEST_ASSERT(keysOut.GetNumberOfValues() == expectedLength, "Got wrong number of output keys"); @@ -1240,7 +1240,7 @@ private: values, keysOut, valuesOut, - vtkm::internal::Multiply() ); + vtkm::Multiply() ); VTKM_TEST_ASSERT(keysOut.GetNumberOfValues() == expectedLength, "Got wrong number of output keys"); @@ -1303,7 +1303,7 @@ private: valuesZip, keysOut, valuesOutZip, - vtkm::internal::Add() ); + vtkm::Add() ); VTKM_TEST_ASSERT(keysOut.GetNumberOfValues() == expectedLength, "Got wrong number of output keys"); @@ -1372,7 +1372,7 @@ private: ARRAY_SIZE); vtkm::Float64 product = Algorithm::ScanInclusive(array, array, - vtkm::internal::Multiply()); + vtkm::Multiply()); VTKM_TEST_ASSERT(product == 0.0f, "ScanInclusive product result not 0.0"); for (vtkm::Id i = 0; i < mid; ++i) @@ -1514,7 +1514,7 @@ private: vtkm::Float64 initialValue = 2.00; vtkm::Float64 product = Algorithm::ScanExclusive(array, array, - vtkm::internal::Multiply(), initialValue); + vtkm::Multiply(), initialValue); VTKM_TEST_ASSERT(product == 0.0f, "ScanExclusive product result not 0.0"); VTKM_TEST_ASSERT(array.GetPortalConstControl().Get(0) == initialValue, diff --git a/vtkm/internal/ConnectivityStructuredInternals.h b/vtkm/internal/ConnectivityStructuredInternals.h index 2615c1c16..fe03914e2 100644 --- a/vtkm/internal/ConnectivityStructuredInternals.h +++ b/vtkm/internal/ConnectivityStructuredInternals.h @@ -179,7 +179,7 @@ public: VTKM_EXEC_CONT_EXPORT vtkm::Id GetNumberOfPoints() const { - return vtkm::internal::VecProduct<2>()(this->GetPointDimensions()); + return vtkm::ReduceProduct(this->GetPointDimensions()); } //returns an id2 to signal what kind of scheduling to use @@ -198,7 +198,7 @@ public: VTKM_EXEC_CONT_EXPORT vtkm::Id GetNumberOfCells() const { - return vtkm::internal::VecProduct<2>()(this->GetCellDimensions()); + return vtkm::ReduceProduct(this->GetCellDimensions()); } VTKM_EXEC_CONT_EXPORT vtkm::IdComponent GetNumberOfPointsInCell() const {return NUM_POINTS_IN_CELL;} @@ -354,7 +354,7 @@ public: VTKM_EXEC_CONT_EXPORT vtkm::Id GetNumberOfPoints() const { - return vtkm::internal::VecProduct<3>()(this->PointDimensions); + return vtkm::ReduceProduct(this->PointDimensions); } //returns an id3 to signal what kind of scheduling to use @@ -373,7 +373,7 @@ public: VTKM_EXEC_CONT_EXPORT vtkm::Id GetNumberOfCells() const { - return vtkm::internal::VecProduct<3>()(this->GetCellDimensions()); + return vtkm::ReduceProduct(this->GetCellDimensions()); } VTKM_EXEC_CONT_EXPORT vtkm::IdComponent GetNumberOfPointsInCell() const {return NUM_POINTS_IN_CELL;} diff --git a/vtkm/worklet/AverageByKey.h b/vtkm/worklet/AverageByKey.h index c7efb3816..3c218fcf6 100644 --- a/vtkm/worklet/AverageByKey.h +++ b/vtkm/worklet/AverageByKey.h @@ -93,7 +93,7 @@ void AverageByKey(const vtkm::cont::ArrayHandle &keyArray Algorithm::ReduceByKey( keyArraySorted, inputZipHandle, outputKeyArray, outputZipHandle, - vtkm::internal::Add() ); + vtkm::Add() ); // get average DispatcherMapField().Invoke(sumArray, diff --git a/vtkm/worklet/ExternalFaces.h b/vtkm/worklet/ExternalFaces.h index 5834671e6..55cc9025f 100644 --- a/vtkm/worklet/ExternalFaces.h +++ b/vtkm/worklet/ExternalFaces.h @@ -372,7 +372,7 @@ public: ones, uniqueFaceVertices, uniqueFaceCounts, - vtkm::internal::Add()); + vtkm::Add()); #ifdef __VTKM_EXTERNAL_FACES_BENCHMARK std::cout << "ReduceByKey_Adapter," << timer.GetElapsedTime() << "\n"; #endif diff --git a/vtkm/worklet/KernelSplatter.h b/vtkm/worklet/KernelSplatter.h index e83c0c7d6..abf3dfffe 100644 --- a/vtkm/worklet/KernelSplatter.h +++ b/vtkm/worklet/KernelSplatter.h @@ -561,7 +561,7 @@ struct KernelSplatterFilterUniformGrid splatValues, uniqueVoxelIds, voxelSplatSums, - vtkm::internal::Add()); + vtkm::Add()); END_TIMER_BLOCK(ReduceByKey) debug::OutputArrayDebug(neighborVoxelIds, "neighborVoxelIds");