mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-19 02:25:42 +00:00
Merge branch 'astyle_applied'
This commit is contained in:
commit
f2552645e0
@ -45,7 +45,7 @@ if (NOT VTKm_SOURCE_DIR)
|
|||||||
message(SEND_ERROR "VTKm_SOURCE_DIR not defined.")
|
message(SEND_ERROR "VTKm_SOURCE_DIR not defined.")
|
||||||
endif (NOT VTKm_SOURCE_DIR)
|
endif (NOT VTKm_SOURCE_DIR)
|
||||||
|
|
||||||
set(copyright_file ${VTKm_SOURCE_DIR}/CMake/VTKMCopyrightStatement.txt)
|
set(copyright_file ${VTKm_SOURCE_DIR}/CMake/VTKmCopyrightStatement.txt)
|
||||||
|
|
||||||
if (NOT EXISTS ${copyright_file})
|
if (NOT EXISTS ${copyright_file})
|
||||||
message(SEND_ERROR "Cannot find VTKMCopyrightStatement.txt.")
|
message(SEND_ERROR "Cannot find VTKMCopyrightStatement.txt.")
|
@ -57,7 +57,8 @@ template<typename T> struct TypeTraits;
|
|||||||
/// override behavior of called functions.
|
/// override behavior of called functions.
|
||||||
///
|
///
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class TypeTraits {
|
class TypeTraits
|
||||||
|
{
|
||||||
typedef int tag_type; // Shut up, test compile.
|
typedef int tag_type; // Shut up, test compile.
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -82,16 +83,16 @@ struct TypeTraits<const T> : TypeTraits<T>
|
|||||||
{ };
|
{ };
|
||||||
|
|
||||||
#define VTKM_BASIC_REAL_TYPE(T) \
|
#define VTKM_BASIC_REAL_TYPE(T) \
|
||||||
template<> struct TypeTraits<T> { \
|
template<> struct TypeTraits<T> { \
|
||||||
typedef TypeTraitsRealTag NumericTag; \
|
typedef TypeTraitsRealTag NumericTag; \
|
||||||
typedef TypeTraitsScalarTag DimensionalityTag; \
|
typedef TypeTraitsScalarTag DimensionalityTag; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VTKM_BASIC_INTEGER_TYPE(T) \
|
#define VTKM_BASIC_INTEGER_TYPE(T) \
|
||||||
template<> struct TypeTraits<T> { \
|
template<> struct TypeTraits<T> { \
|
||||||
typedef TypeTraitsIntegerTag NumericTag; \
|
typedef TypeTraitsIntegerTag NumericTag; \
|
||||||
typedef TypeTraitsScalarTag DimensionalityTag; \
|
typedef TypeTraitsScalarTag DimensionalityTag; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Traits for basic C++ types.
|
/// Traits for basic C++ types.
|
||||||
///
|
///
|
||||||
@ -118,10 +119,10 @@ VTKM_BASIC_INTEGER_TYPE(unsigned long long);
|
|||||||
#undef VTKM_BASIC_INTEGER_TYPE
|
#undef VTKM_BASIC_INTEGER_TYPE
|
||||||
|
|
||||||
#define VTKM_VECTOR_TYPE(T, NTag) \
|
#define VTKM_VECTOR_TYPE(T, NTag) \
|
||||||
template<> struct TypeTraits<T> { \
|
template<> struct TypeTraits<T> { \
|
||||||
typedef NTag NumericTag; \
|
typedef NTag NumericTag; \
|
||||||
typedef TypeTraitsVectorTag DimensionalityTag; \
|
typedef TypeTraitsVectorTag DimensionalityTag; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Traits for vector types.
|
/// Traits for vector types.
|
||||||
///
|
///
|
||||||
@ -135,7 +136,8 @@ VTKM_VECTOR_TYPE(vtkm::Vector4, TypeTraitsRealTag);
|
|||||||
|
|
||||||
/// Traits for tuples.
|
/// Traits for tuples.
|
||||||
///
|
///
|
||||||
template<typename T, int Size> struct TypeTraits<vtkm::Tuple<T, Size> > {
|
template<typename T, int Size> struct TypeTraits<vtkm::Tuple<T, Size> >
|
||||||
|
{
|
||||||
typedef typename TypeTraits<T>::NumericTag NumericTag;
|
typedef typename TypeTraits<T>::NumericTag NumericTag;
|
||||||
typedef TypeTraitsVectorTag DimensionalityTag;
|
typedef TypeTraitsVectorTag DimensionalityTag;
|
||||||
};
|
};
|
||||||
|
172
vtkm/Types.h
172
vtkm/Types.h
@ -79,8 +79,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm {
|
||||||
{
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// Typedefs for basic types.
|
// Typedefs for basic types.
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
@ -179,7 +178,8 @@ struct assign_scalar_to_vector<2>
|
|||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
void operator()(VectorType &dest, const ComponentType &src)
|
void operator()(VectorType &dest, const ComponentType &src)
|
||||||
{
|
{
|
||||||
dest[0] = src; dest[1] = src;
|
dest[0] = src;
|
||||||
|
dest[1] = src;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -190,7 +190,9 @@ struct assign_scalar_to_vector<3>
|
|||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
void operator()(VectorType &dest, const ComponentType &src)
|
void operator()(VectorType &dest, const ComponentType &src)
|
||||||
{
|
{
|
||||||
dest[0] = src; dest[1] = src; dest[2] = src;
|
dest[0] = src;
|
||||||
|
dest[1] = src;
|
||||||
|
dest[2] = src;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -221,7 +223,8 @@ struct copy_vector<2>
|
|||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
|
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
|
||||||
{
|
{
|
||||||
dest[0] = src[0]; dest[1] = src[1];
|
dest[0] = src[0];
|
||||||
|
dest[1] = src[1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -231,7 +234,9 @@ struct copy_vector<3>
|
|||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
|
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
|
||||||
{
|
{
|
||||||
dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2];
|
dest[0] = src[0];
|
||||||
|
dest[1] = src[1];
|
||||||
|
dest[2] = src[2];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -270,49 +275,52 @@ typedef float Scalar __attribute__ ((aligned(VTKM_SIZE_SCALAR)));
|
|||||||
|
|
||||||
/// Tuple corresponds to a Size-tuple of type T
|
/// Tuple corresponds to a Size-tuple of type T
|
||||||
template<typename T, int Size>
|
template<typename T, int Size>
|
||||||
class Tuple {
|
class Tuple
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
typedef T ComponentType;
|
typedef T ComponentType;
|
||||||
static const int NUM_COMPONENTS=Size;
|
static const int NUM_COMPONENTS=Size;
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT Tuple(){}
|
VTKM_EXEC_CONT_EXPORT Tuple() {}
|
||||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
||||||
|
{
|
||||||
|
for(int i=0; i < NUM_COMPONENTS; ++i)
|
||||||
{
|
{
|
||||||
for(int i=0; i < NUM_COMPONENTS;++i)
|
|
||||||
{
|
|
||||||
this->Components[i]=value;
|
this->Components[i]=value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values)
|
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values)
|
||||||
|
{
|
||||||
|
for(int i=0; i < NUM_COMPONENTS; ++i)
|
||||||
{
|
{
|
||||||
for(int i=0; i < NUM_COMPONENTS;++i)
|
|
||||||
{
|
|
||||||
this->Components[i]=values[i];
|
this->Components[i]=values[i];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
Tuple(const Tuple<ComponentType, Size> &src)
|
Tuple(const Tuple<ComponentType, Size> &src)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUM_COMPONENTS; i++)
|
for (int i = 0; i < NUM_COMPONENTS; i++)
|
||||||
{
|
{
|
||||||
this->Components[i] = src[i];
|
this->Components[i] = src[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
Tuple<ComponentType, Size> &operator=(const Tuple<ComponentType, Size> &src)
|
Tuple<ComponentType, Size> &operator=(const Tuple<ComponentType, Size> &src)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUM_COMPONENTS; i++)
|
for (int i = 0; i < NUM_COMPONENTS; i++)
|
||||||
{
|
{
|
||||||
this->Components[i] = src[i];
|
this->Components[i] = src[i];
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
|
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
|
||||||
|
{
|
||||||
return this->Components[idx];
|
return this->Components[idx];
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
|
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
|
||||||
|
{
|
||||||
return this->Components[idx];
|
return this->Components[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,9 +329,9 @@ public:
|
|||||||
{
|
{
|
||||||
bool same = true;
|
bool same = true;
|
||||||
for (int componentIndex=0; componentIndex<NUM_COMPONENTS; componentIndex++)
|
for (int componentIndex=0; componentIndex<NUM_COMPONENTS; componentIndex++)
|
||||||
{
|
{
|
||||||
same &= (this->Components[componentIndex] == other[componentIndex]);
|
same &= (this->Components[componentIndex] == other[componentIndex]);
|
||||||
}
|
}
|
||||||
return same;
|
return same;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,14 +339,14 @@ public:
|
|||||||
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||||
{
|
{
|
||||||
for(vtkm::Id i=0; i < NUM_COMPONENTS; ++i)
|
for(vtkm::Id i=0; i < NUM_COMPONENTS; ++i)
|
||||||
{
|
{
|
||||||
//ignore equals as that represents check next value
|
//ignore equals as that represents check next value
|
||||||
if(this->Components[i] < other[i])
|
if(this->Components[i] < other[i])
|
||||||
return true;
|
{ return true; }
|
||||||
else if(other[i] < this->Components[i])
|
else if(other[i] < this->Components[i])
|
||||||
return false;
|
{ return false; }
|
||||||
} //if all same we are not less
|
} //if all same we are not less
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
@ -355,12 +363,13 @@ protected:
|
|||||||
// Specializations for common tuple sizes (with special names).
|
// Specializations for common tuple sizes (with special names).
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Tuple<T,2>{
|
class Tuple<T,2>
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
typedef T ComponentType;
|
typedef T ComponentType;
|
||||||
static const int NUM_COMPONENTS = 2;
|
static const int NUM_COMPONENTS = 2;
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT Tuple(){}
|
VTKM_EXEC_CONT_EXPORT Tuple() {}
|
||||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
||||||
{
|
{
|
||||||
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
||||||
@ -369,7 +378,8 @@ public:
|
|||||||
{
|
{
|
||||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT Tuple(ComponentType x, ComponentType y) {
|
VTKM_EXEC_CONT_EXPORT Tuple(ComponentType x, ComponentType y)
|
||||||
|
{
|
||||||
this->Components[0] = x;
|
this->Components[0] = x;
|
||||||
this->Components[1] = y;
|
this->Components[1] = y;
|
||||||
}
|
}
|
||||||
@ -387,10 +397,12 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
|
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
|
||||||
|
{
|
||||||
return this->Components[idx];
|
return this->Components[idx];
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
|
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
|
||||||
|
{
|
||||||
return this->Components[idx];
|
return this->Components[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,9 +420,9 @@ public:
|
|||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||||
{
|
{
|
||||||
return( (this->Components[0] < other[0]) ||
|
return( (this->Components[0] < other[0]) ||
|
||||||
(!(other[0] < this->Components[0]) && (this->Components[1] < other[1]))
|
(!(other[0] < this->Components[0]) && (this->Components[1] < other[1]))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -426,12 +438,13 @@ typedef vtkm::Tuple<vtkm::Scalar,2>
|
|||||||
typedef vtkm::Tuple<vtkm::Id,2> Id2 __attribute__ ((aligned(VTKM_SIZE_ID)));
|
typedef vtkm::Tuple<vtkm::Id,2> Id2 __attribute__ ((aligned(VTKM_SIZE_ID)));
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Tuple<T,3>{
|
class Tuple<T,3>
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
typedef T ComponentType;
|
typedef T ComponentType;
|
||||||
static const int NUM_COMPONENTS = 3;
|
static const int NUM_COMPONENTS = 3;
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT Tuple(){}
|
VTKM_EXEC_CONT_EXPORT Tuple() {}
|
||||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
||||||
{
|
{
|
||||||
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
||||||
@ -441,7 +454,8 @@ public:
|
|||||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
Tuple(ComponentType x, ComponentType y, ComponentType z) {
|
Tuple(ComponentType x, ComponentType y, ComponentType z)
|
||||||
|
{
|
||||||
this->Components[0] = x;
|
this->Components[0] = x;
|
||||||
this->Components[1] = y;
|
this->Components[1] = y;
|
||||||
this->Components[2] = z;
|
this->Components[2] = z;
|
||||||
@ -460,10 +474,12 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
|
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
|
||||||
|
{
|
||||||
return this->Components[idx];
|
return this->Components[idx];
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
|
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
|
||||||
|
{
|
||||||
return this->Components[idx];
|
return this->Components[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,12 +497,12 @@ public:
|
|||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||||
{
|
{
|
||||||
return((this->Components[0] < other[0]) ||
|
return((this->Components[0] < other[0]) ||
|
||||||
( !(other[0] < this->Components[0]) &&
|
( !(other[0] < this->Components[0]) &&
|
||||||
(this->Components[1] < other[1])) ||
|
(this->Components[1] < other[1])) ||
|
||||||
( !(other[0] < this->Components[0]) &&
|
( !(other[0] < this->Components[0]) &&
|
||||||
!(other[1] < this->Components[1]) &&
|
!(other[1] < this->Components[1]) &&
|
||||||
(this->Components[2] < other[2]) ) );
|
(this->Components[2] < other[2]) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -498,12 +514,13 @@ typedef vtkm::Tuple<vtkm::Scalar,3>
|
|||||||
Vector3 __attribute__ ((aligned(VTKM_SIZE_SCALAR)));
|
Vector3 __attribute__ ((aligned(VTKM_SIZE_SCALAR)));
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Tuple<T,4>{
|
class Tuple<T,4>
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
typedef T ComponentType;
|
typedef T ComponentType;
|
||||||
static const int NUM_COMPONENTS = 4;
|
static const int NUM_COMPONENTS = 4;
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT Tuple(){}
|
VTKM_EXEC_CONT_EXPORT Tuple() {}
|
||||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
||||||
{
|
{
|
||||||
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
||||||
@ -513,7 +530,8 @@ public:
|
|||||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
Tuple(ComponentType x, ComponentType y, ComponentType z, ComponentType w) {
|
Tuple(ComponentType x, ComponentType y, ComponentType z, ComponentType w)
|
||||||
|
{
|
||||||
this->Components[0] = x;
|
this->Components[0] = x;
|
||||||
this->Components[1] = y;
|
this->Components[1] = y;
|
||||||
this->Components[2] = z;
|
this->Components[2] = z;
|
||||||
@ -533,10 +551,12 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
|
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
|
||||||
|
{
|
||||||
return this->Components[idx];
|
return this->Components[idx];
|
||||||
}
|
}
|
||||||
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
|
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
|
||||||
|
{
|
||||||
return this->Components[idx];
|
return this->Components[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,16 +574,16 @@ public:
|
|||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||||
{
|
{
|
||||||
return((this->Components[0] < other[0]) ||
|
return((this->Components[0] < other[0]) ||
|
||||||
( !(other[0] < this->Components[0]) &&
|
( !(other[0] < this->Components[0]) &&
|
||||||
this->Components[1] < other[1]) ||
|
this->Components[1] < other[1]) ||
|
||||||
( !(other[0] < this->Components[0]) &&
|
( !(other[0] < this->Components[0]) &&
|
||||||
!(other[1] < this->Components[1]) &&
|
!(other[1] < this->Components[1]) &&
|
||||||
(this->Components[2] < other[2]) ) ||
|
(this->Components[2] < other[2]) ) ||
|
||||||
( !(other[0] < this->Components[0]) &&
|
( !(other[0] < this->Components[0]) &&
|
||||||
!(other[1] < this->Components[1]) &&
|
!(other[1] < this->Components[1]) &&
|
||||||
!(other[2] < this->Components[2]) &&
|
!(other[2] < this->Components[2]) &&
|
||||||
(this->Components[3] < other[3])) );
|
(this->Components[3] < other[3])) );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -611,13 +631,13 @@ VTKM_EXEC_CONT_EXPORT vtkm::Id3 make_Id3(vtkm::Id x, vtkm::Id y, vtkm::Id z)
|
|||||||
|
|
||||||
template<typename T, int Size>
|
template<typename T, int Size>
|
||||||
VTKM_EXEC_CONT_EXPORT T dot(const vtkm::Tuple<T,Size> &a,
|
VTKM_EXEC_CONT_EXPORT T dot(const vtkm::Tuple<T,Size> &a,
|
||||||
const vtkm::Tuple<T,Size> &b)
|
const vtkm::Tuple<T,Size> &b)
|
||||||
{
|
{
|
||||||
T result = a[0]*b[0];
|
T result = a[0]*b[0];
|
||||||
for (int componentIndex = 1; componentIndex < Size; componentIndex++)
|
for (int componentIndex = 1; componentIndex < Size; componentIndex++)
|
||||||
{
|
{
|
||||||
result += a[componentIndex]*b[componentIndex];
|
result += a[componentIndex]*b[componentIndex];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,9 +659,9 @@ VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator+(const vtkm::Tuple<T,Size> &a
|
|||||||
{
|
{
|
||||||
vtkm::Tuple<T,Size> result;
|
vtkm::Tuple<T,Size> result;
|
||||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||||
{
|
{
|
||||||
result[componentIndex] = a[componentIndex] + b[componentIndex];
|
result[componentIndex] = a[componentIndex] + b[componentIndex];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
template<typename T, int Size>
|
template<typename T, int Size>
|
||||||
@ -650,9 +670,9 @@ VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator-(const vtkm::Tuple<T,Size> &a
|
|||||||
{
|
{
|
||||||
vtkm::Tuple<T,Size> result;
|
vtkm::Tuple<T,Size> result;
|
||||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||||
{
|
{
|
||||||
result[componentIndex] = a[componentIndex] - b[componentIndex];
|
result[componentIndex] = a[componentIndex] - b[componentIndex];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
template<typename T, int Size>
|
template<typename T, int Size>
|
||||||
@ -661,9 +681,9 @@ VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator*(const vtkm::Tuple<T,Size> &a
|
|||||||
{
|
{
|
||||||
vtkm::Tuple<T,Size> result;
|
vtkm::Tuple<T,Size> result;
|
||||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||||
{
|
{
|
||||||
result[componentIndex] = a[componentIndex] * b[componentIndex];
|
result[componentIndex] = a[componentIndex] * b[componentIndex];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
template<typename T, int Size>
|
template<typename T, int Size>
|
||||||
@ -672,9 +692,9 @@ VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator/(const vtkm::Tuple<T,Size> &a
|
|||||||
{
|
{
|
||||||
vtkm::Tuple<T,Size> result;
|
vtkm::Tuple<T,Size> result;
|
||||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||||
{
|
{
|
||||||
result[componentIndex] = a[componentIndex] / b[componentIndex];
|
result[componentIndex] = a[componentIndex] / b[componentIndex];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,9 +704,9 @@ VTKM_EXEC_CONT_EXPORT vtkm::Tuple<Ta,Size> operator*(const vtkm::Tuple<Ta,Size>
|
|||||||
{
|
{
|
||||||
vtkm::Tuple<Ta,Size> result;
|
vtkm::Tuple<Ta,Size> result;
|
||||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||||
{
|
{
|
||||||
result[componentIndex] = a[componentIndex] * b;
|
result[componentIndex] = a[componentIndex] * b;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
template<typename Ta, typename Tb, int Size>
|
template<typename Ta, typename Tb, int Size>
|
||||||
@ -695,9 +715,9 @@ VTKM_EXEC_CONT_EXPORT vtkm::Tuple<Tb,Size> operator*(const Ta &a,
|
|||||||
{
|
{
|
||||||
vtkm::Tuple<Tb,Size> result;
|
vtkm::Tuple<Tb,Size> result;
|
||||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||||
{
|
{
|
||||||
result[componentIndex] = a * b[componentIndex];
|
result[componentIndex] = a * b[componentIndex];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,14 @@ struct VectorTraitsTagSingleComponent { };
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template<int numComponents>
|
template<int numComponents>
|
||||||
struct VectorTraitsMultipleComponentChooser {
|
struct VectorTraitsMultipleComponentChooser
|
||||||
|
{
|
||||||
typedef VectorTraitsTagMultipleComponents Type;
|
typedef VectorTraitsTagMultipleComponents Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct VectorTraitsMultipleComponentChooser<1> {
|
struct VectorTraitsMultipleComponentChooser<1>
|
||||||
|
{
|
||||||
typedef VectorTraitsTagSingleComponent Type;
|
typedef VectorTraitsTagSingleComponent Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,53 +73,53 @@ public:
|
|||||||
void ReleaseResources()
|
void ReleaseResources()
|
||||||
{
|
{
|
||||||
if (this->NumberOfValues > 0)
|
if (this->NumberOfValues > 0)
|
||||||
{
|
{
|
||||||
VTKM_ASSERT_CONT(this->Array != NULL);
|
VTKM_ASSERT_CONT(this->Array != NULL);
|
||||||
AllocatorType allocator;
|
AllocatorType allocator;
|
||||||
allocator.deallocate(this->Array, this->AllocatedSize);
|
allocator.deallocate(this->Array, this->AllocatedSize);
|
||||||
this->Array = NULL;
|
this->Array = NULL;
|
||||||
this->NumberOfValues = 0;
|
this->NumberOfValues = 0;
|
||||||
this->AllocatedSize = 0;
|
this->AllocatedSize = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VTKM_ASSERT_CONT(this->Array == NULL);
|
VTKM_ASSERT_CONT(this->Array == NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Allocate(vtkm::Id numberOfValues)
|
void Allocate(vtkm::Id numberOfValues)
|
||||||
{
|
{
|
||||||
if (numberOfValues <= this->AllocatedSize)
|
if (numberOfValues <= this->AllocatedSize)
|
||||||
{
|
{
|
||||||
this->NumberOfValues = numberOfValues;
|
this->NumberOfValues = numberOfValues;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->ReleaseResources();
|
this->ReleaseResources();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (numberOfValues > 0)
|
if (numberOfValues > 0)
|
||||||
{
|
{
|
||||||
AllocatorType allocator;
|
AllocatorType allocator;
|
||||||
this->Array = allocator.allocate(numberOfValues);
|
this->Array = allocator.allocate(numberOfValues);
|
||||||
this->AllocatedSize = numberOfValues;
|
this->AllocatedSize = numberOfValues;
|
||||||
this->NumberOfValues = numberOfValues;
|
this->NumberOfValues = numberOfValues;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ReleaseResources should have already set AllocatedSize to 0.
|
// ReleaseResources should have already set AllocatedSize to 0.
|
||||||
VTKM_ASSERT_CONT(this->AllocatedSize == 0);
|
VTKM_ASSERT_CONT(this->AllocatedSize == 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (std::bad_alloc err)
|
catch (std::bad_alloc err)
|
||||||
{
|
{
|
||||||
// Make sureour state is OK.
|
// Make sureour state is OK.
|
||||||
this->Array = NULL;
|
this->Array = NULL;
|
||||||
this->NumberOfValues = 0;
|
this->NumberOfValues = 0;
|
||||||
this->AllocatedSize = 0;
|
this->AllocatedSize = 0;
|
||||||
throw vtkm::cont::ErrorControlOutOfMemory(
|
throw vtkm::cont::ErrorControlOutOfMemory(
|
||||||
"Could not allocate basic control array.");
|
"Could not allocate basic control array.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Id GetNumberOfValues() const
|
vtkm::Id GetNumberOfValues() const
|
||||||
@ -130,10 +130,10 @@ public:
|
|||||||
void Shrink(vtkm::Id numberOfValues)
|
void Shrink(vtkm::Id numberOfValues)
|
||||||
{
|
{
|
||||||
if (numberOfValues > this->GetNumberOfValues())
|
if (numberOfValues > this->GetNumberOfValues())
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
"Shrink method cannot be used to grow array.");
|
"Shrink method cannot be used to grow array.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this->NumberOfValues = numberOfValues;
|
this->NumberOfValues = numberOfValues;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@ namespace cont {
|
|||||||
/// and environment do not share memory. This is wasteful and should be fixed.
|
/// and environment do not share memory. This is wasteful and should be fixed.
|
||||||
///
|
///
|
||||||
template<class ArrayPortalType>
|
template<class ArrayPortalType>
|
||||||
struct ArrayContainerControlTagImplicit {
|
struct ArrayContainerControlTagImplicit
|
||||||
|
{
|
||||||
typedef ArrayPortalType PortalType;
|
typedef ArrayPortalType PortalType;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,16 +62,19 @@ public:
|
|||||||
|
|
||||||
// This is meant to be invalid. Because implicit arrays are read only, you
|
// This is meant to be invalid. Because implicit arrays are read only, you
|
||||||
// should only be able to use the const version.
|
// should only be able to use the const version.
|
||||||
struct PortalType {
|
struct PortalType
|
||||||
|
{
|
||||||
typedef void *ValueType;
|
typedef void *ValueType;
|
||||||
typedef void *IteratorType;
|
typedef void *IteratorType;
|
||||||
};
|
};
|
||||||
|
|
||||||
// All these methods do nothing but raise errors.
|
// All these methods do nothing but raise errors.
|
||||||
PortalType GetPortal() {
|
PortalType GetPortal()
|
||||||
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
|
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
|
||||||
}
|
}
|
||||||
PortalConstType GetPortalConst() const {
|
PortalConstType GetPortalConst() const
|
||||||
|
{
|
||||||
// This does not work because the ArrayHandle holds the constant
|
// This does not work because the ArrayHandle holds the constant
|
||||||
// ArrayPortal, not the container.
|
// ArrayPortal, not the container.
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
@ -78,7 +82,8 @@ public:
|
|||||||
"Perhaps you did not set the ArrayPortal when "
|
"Perhaps you did not set the ArrayPortal when "
|
||||||
"constructing the ArrayHandle.");
|
"constructing the ArrayHandle.");
|
||||||
}
|
}
|
||||||
vtkm::Id GetNumberOfValues() const {
|
vtkm::Id GetNumberOfValues() const
|
||||||
|
{
|
||||||
// This does not work because the ArrayHandle holds the constant
|
// This does not work because the ArrayHandle holds the constant
|
||||||
// ArrayPortal, not the container.
|
// ArrayPortal, not the container.
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
@ -86,13 +91,16 @@ public:
|
|||||||
"Perhaps you did not set the ArrayPortal when "
|
"Perhaps you did not set the ArrayPortal when "
|
||||||
"constructing the ArrayHandle.");
|
"constructing the ArrayHandle.");
|
||||||
}
|
}
|
||||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||||
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
|
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
|
||||||
}
|
}
|
||||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||||
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
|
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
|
||||||
}
|
}
|
||||||
void ReleaseResources() {
|
void ReleaseResources()
|
||||||
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
|
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -117,17 +125,20 @@ public:
|
|||||||
|
|
||||||
ArrayTransfer() : PortalValid(false) { }
|
ArrayTransfer() : PortalValid(false) { }
|
||||||
|
|
||||||
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const {
|
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const
|
||||||
|
{
|
||||||
VTKM_ASSERT_CONT(this->PortalValid);
|
VTKM_ASSERT_CONT(this->PortalValid);
|
||||||
return this->Portal.GetNumberOfValues();
|
return this->Portal.GetNumberOfValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT void LoadDataForInput(PortalConstControl portal) {
|
VTKM_CONT_EXPORT void LoadDataForInput(PortalConstControl portal)
|
||||||
|
{
|
||||||
this->Portal = portal;
|
this->Portal = portal;
|
||||||
this->PortalValid = true;
|
this->PortalValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT void LoadDataForInput(const ContainerType &controlArray) {
|
VTKM_CONT_EXPORT void LoadDataForInput(const ContainerType &controlArray)
|
||||||
|
{
|
||||||
this->LoadDataForInput(controlArray.GetPortalConst());
|
this->LoadDataForInput(controlArray.GetPortalConst());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ public:
|
|||||||
typedef typename ArrayContainerControlType::PortalConstType
|
typedef typename ArrayContainerControlType::PortalConstType
|
||||||
PortalConstControl;
|
PortalConstControl;
|
||||||
template <typename DeviceAdapterTag>
|
template <typename DeviceAdapterTag>
|
||||||
struct ExecutionTypes {
|
struct ExecutionTypes
|
||||||
|
{
|
||||||
typedef typename ExecutionManagerType
|
typedef typename ExecutionManagerType
|
||||||
::template ExecutionTypes<DeviceAdapterTag>::Portal Portal;
|
::template ExecutionTypes<DeviceAdapterTag>::Portal Portal;
|
||||||
typedef typename ExecutionManagerType
|
typedef typename ExecutionManagerType
|
||||||
@ -115,22 +116,22 @@ public:
|
|||||||
{
|
{
|
||||||
this->SyncControlArray();
|
this->SyncControlArray();
|
||||||
if (this->Internals->UserPortalValid)
|
if (this->Internals->UserPortalValid)
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
"ArrayHandle has a read-only control portal.");
|
"ArrayHandle has a read-only control portal.");
|
||||||
}
|
}
|
||||||
else if (this->Internals->ControlArrayValid)
|
else if (this->Internals->ControlArrayValid)
|
||||||
{
|
{
|
||||||
// If the user writes into the iterator we return, then the execution
|
// If the user writes into the iterator we return, then the execution
|
||||||
// array will become invalid. Play it safe and release the execution
|
// array will become invalid. Play it safe and release the execution
|
||||||
// resources. (Use the const version to preserve the execution array.)
|
// resources. (Use the const version to preserve the execution array.)
|
||||||
this->ReleaseResourcesExecution();
|
this->ReleaseResourcesExecution();
|
||||||
return this->Internals->ControlArray.GetPortal();
|
return this->Internals->ControlArray.GetPortal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue("ArrayHandle contains no data.");
|
throw vtkm::cont::ErrorControlBadValue("ArrayHandle contains no data.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the array portal of the control array.
|
/// Get the array portal of the control array.
|
||||||
@ -139,17 +140,17 @@ public:
|
|||||||
{
|
{
|
||||||
this->SyncControlArray();
|
this->SyncControlArray();
|
||||||
if (this->Internals->UserPortalValid)
|
if (this->Internals->UserPortalValid)
|
||||||
{
|
{
|
||||||
return this->Internals->UserPortal;
|
return this->Internals->UserPortal;
|
||||||
}
|
}
|
||||||
else if (this->Internals->ControlArrayValid)
|
else if (this->Internals->ControlArrayValid)
|
||||||
{
|
{
|
||||||
return this->Internals->ControlArray.GetPortalConst();
|
return this->Internals->ControlArray.GetPortalConst();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue("ArrayHandle contains no data.");
|
throw vtkm::cont::ErrorControlBadValue("ArrayHandle contains no data.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the number of entries in the array.
|
/// Returns the number of entries in the array.
|
||||||
@ -157,22 +158,22 @@ public:
|
|||||||
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const
|
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const
|
||||||
{
|
{
|
||||||
if (this->Internals->UserPortalValid)
|
if (this->Internals->UserPortalValid)
|
||||||
{
|
{
|
||||||
return this->Internals->UserPortal.GetNumberOfValues();
|
return this->Internals->UserPortal.GetNumberOfValues();
|
||||||
}
|
}
|
||||||
else if (this->Internals->ControlArrayValid)
|
else if (this->Internals->ControlArrayValid)
|
||||||
{
|
{
|
||||||
return this->Internals->ControlArray.GetNumberOfValues();
|
return this->Internals->ControlArray.GetNumberOfValues();
|
||||||
}
|
}
|
||||||
else if (this->Internals->ExecutionArrayValid)
|
else if (this->Internals->ExecutionArrayValid)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
this->Internals->ExecutionArray->GetNumberOfValues();
|
this->Internals->ExecutionArray->GetNumberOfValues();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Reduces the size of the array without changing its values.
|
/// \brief Reduces the size of the array without changing its values.
|
||||||
@ -188,30 +189,30 @@ public:
|
|||||||
vtkm::Id originalNumberOfValues = this->GetNumberOfValues();
|
vtkm::Id originalNumberOfValues = this->GetNumberOfValues();
|
||||||
|
|
||||||
if (numberOfValues < originalNumberOfValues)
|
if (numberOfValues < originalNumberOfValues)
|
||||||
{
|
{
|
||||||
if (this->Internals->UserPortalValid)
|
if (this->Internals->UserPortalValid)
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
"ArrayHandle has a read-only control portal.");
|
"ArrayHandle has a read-only control portal.");
|
||||||
}
|
}
|
||||||
if (this->Internals->ControlArrayValid)
|
if (this->Internals->ControlArrayValid)
|
||||||
{
|
{
|
||||||
this->Internals->ControlArray.Shrink(numberOfValues);
|
this->Internals->ControlArray.Shrink(numberOfValues);
|
||||||
}
|
}
|
||||||
if (this->Internals->ExecutionArrayValid)
|
if (this->Internals->ExecutionArrayValid)
|
||||||
{
|
{
|
||||||
this->Internals->ExecutionArray->Shrink(numberOfValues);
|
this->Internals->ExecutionArray->Shrink(numberOfValues);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (numberOfValues == originalNumberOfValues)
|
else if (numberOfValues == originalNumberOfValues)
|
||||||
{
|
{
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
else // numberOfValues > originalNumberOfValues
|
else // numberOfValues > originalNumberOfValues
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
"ArrayHandle::Shrink cannot be used to grow array.");
|
"ArrayHandle::Shrink cannot be used to grow array.");
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_ASSERT_CONT(this->GetNumberOfValues() == numberOfValues);
|
VTKM_ASSERT_CONT(this->GetNumberOfValues() == numberOfValues);
|
||||||
}
|
}
|
||||||
@ -222,10 +223,10 @@ public:
|
|||||||
VTKM_CONT_EXPORT void ReleaseResourcesExecution()
|
VTKM_CONT_EXPORT void ReleaseResourcesExecution()
|
||||||
{
|
{
|
||||||
if (this->Internals->ExecutionArrayValid)
|
if (this->Internals->ExecutionArrayValid)
|
||||||
{
|
{
|
||||||
this->Internals->ExecutionArray->ReleaseResources();
|
this->Internals->ExecutionArray->ReleaseResources();
|
||||||
this->Internals->ExecutionArrayValid = false;
|
this->Internals->ExecutionArrayValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Releases all resources in both the control and execution environments.
|
/// Releases all resources in both the control and execution environments.
|
||||||
@ -238,10 +239,10 @@ public:
|
|||||||
this->Internals->UserPortalValid = false;
|
this->Internals->UserPortalValid = false;
|
||||||
|
|
||||||
if (this->Internals->ControlArrayValid)
|
if (this->Internals->ControlArrayValid)
|
||||||
{
|
{
|
||||||
this->Internals->ControlArray.ReleaseResources();
|
this->Internals->ControlArray.ReleaseResources();
|
||||||
this->Internals->ControlArrayValid = false;
|
this->Internals->ControlArrayValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepares this array to be used as an input to an operation in the
|
/// Prepares this array to be used as an input to an operation in the
|
||||||
@ -258,31 +259,31 @@ public:
|
|||||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
||||||
|
|
||||||
if (this->Internals->ExecutionArrayValid)
|
if (this->Internals->ExecutionArrayValid)
|
||||||
{
|
{
|
||||||
// Nothing to do, data already loaded.
|
// Nothing to do, data already loaded.
|
||||||
}
|
}
|
||||||
else if (this->Internals->UserPortalValid)
|
else if (this->Internals->UserPortalValid)
|
||||||
{
|
{
|
||||||
VTKM_ASSERT_CONT(!this->Internals->ControlArrayValid);
|
VTKM_ASSERT_CONT(!this->Internals->ControlArrayValid);
|
||||||
this->PrepareForDevice(DeviceAdapterTag());
|
this->PrepareForDevice(DeviceAdapterTag());
|
||||||
this->Internals->ExecutionArray->LoadDataForInput(
|
this->Internals->ExecutionArray->LoadDataForInput(
|
||||||
this->Internals->UserPortal);
|
this->Internals->UserPortal);
|
||||||
this->Internals->ExecutionArrayValid = true;
|
this->Internals->ExecutionArrayValid = true;
|
||||||
}
|
}
|
||||||
else if (this->Internals->ControlArrayValid)
|
else if (this->Internals->ControlArrayValid)
|
||||||
{
|
{
|
||||||
this->PrepareForDevice(DeviceAdapterTag());
|
this->PrepareForDevice(DeviceAdapterTag());
|
||||||
this->Internals->ExecutionArray->LoadDataForInput(
|
this->Internals->ExecutionArray->LoadDataForInput(
|
||||||
this->Internals->ControlArray);
|
this->Internals->ControlArray);
|
||||||
this->Internals->ExecutionArrayValid = true;
|
this->Internals->ExecutionArrayValid = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
"ArrayHandle has no data when PrepareForInput called.");
|
"ArrayHandle has no data when PrepareForInput called.");
|
||||||
}
|
}
|
||||||
return this->Internals->ExecutionArray->GetPortalConstExecution(
|
return this->Internals->ExecutionArray->GetPortalConstExecution(
|
||||||
DeviceAdapterTag());
|
DeviceAdapterTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepares (allocates) this array to be used as an output from an operation
|
/// Prepares (allocates) this array to be used as an output from an operation
|
||||||
@ -307,7 +308,7 @@ public:
|
|||||||
|
|
||||||
this->PrepareForDevice(DeviceAdapterTag());
|
this->PrepareForDevice(DeviceAdapterTag());
|
||||||
this->Internals->ExecutionArray->AllocateArrayForOutput(
|
this->Internals->ExecutionArray->AllocateArrayForOutput(
|
||||||
this->Internals->ControlArray, numberOfValues);
|
this->Internals->ControlArray, numberOfValues);
|
||||||
|
|
||||||
// We are assuming that the calling code will fill the array using the
|
// We are assuming that the calling code will fill the array using the
|
||||||
// iterators we are returning, so go ahead and mark the execution array as
|
// iterators we are returning, so go ahead and mark the execution array as
|
||||||
@ -337,32 +338,32 @@ public:
|
|||||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
||||||
|
|
||||||
if (this->Internals->UserPortalValid)
|
if (this->Internals->UserPortalValid)
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
"In place execution cannot be used with an ArrayHandle that has "
|
"In place execution cannot be used with an ArrayHandle that has "
|
||||||
"user arrays because this might write data back into user space "
|
"user arrays because this might write data back into user space "
|
||||||
"unexpectedly. Copy the data to a new array first.");
|
"unexpectedly. Copy the data to a new array first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This code is similar to PrepareForInput except that we have to give a
|
// This code is similar to PrepareForInput except that we have to give a
|
||||||
// writable portal instead of the const portal to the execution array
|
// writable portal instead of the const portal to the execution array
|
||||||
// manager so that the data can (potentially) be written to.
|
// manager so that the data can (potentially) be written to.
|
||||||
if (this->Internals->ExecutionArrayValid)
|
if (this->Internals->ExecutionArrayValid)
|
||||||
{
|
{
|
||||||
// Nothing to do, data already loaded.
|
// Nothing to do, data already loaded.
|
||||||
}
|
}
|
||||||
else if (this->Internals->ControlArrayValid)
|
else if (this->Internals->ControlArrayValid)
|
||||||
{
|
{
|
||||||
this->PrepareForDevice(DeviceAdapterTag());
|
this->PrepareForDevice(DeviceAdapterTag());
|
||||||
this->Internals->ExecutionArray->LoadDataForInPlace(
|
this->Internals->ExecutionArray->LoadDataForInPlace(
|
||||||
this->Internals->ControlArray);
|
this->Internals->ControlArray);
|
||||||
this->Internals->ExecutionArrayValid = true;
|
this->Internals->ExecutionArrayValid = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlBadValue(
|
throw vtkm::cont::ErrorControlBadValue(
|
||||||
"ArrayHandle has no data when PrepareForInput called.");
|
"ArrayHandle has no data when PrepareForInput called.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalidate any control arrays since their data will become invalid when
|
// Invalidate any control arrays since their data will become invalid when
|
||||||
// the execution data is overwritten. Don't actually release the control
|
// the execution data is overwritten. Don't actually release the control
|
||||||
@ -386,8 +387,9 @@ public:
|
|||||||
this->Internals->ExecutionArrayValid = false;
|
this->Internals->ExecutionArrayValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private:
|
// private:
|
||||||
struct InternalStruct {
|
struct InternalStruct
|
||||||
|
{
|
||||||
PortalConstControl UserPortal;
|
PortalConstControl UserPortal;
|
||||||
bool UserPortalValid;
|
bool UserPortalValid;
|
||||||
|
|
||||||
@ -400,7 +402,7 @@ public:
|
|||||||
bool ExecutionArrayValid;
|
bool ExecutionArrayValid;
|
||||||
};
|
};
|
||||||
|
|
||||||
ArrayHandle(boost::shared_ptr<InternalStruct> i)
|
ArrayHandle(boost::shared_ptr<InternalStruct> i)
|
||||||
: Internals(i)
|
: Internals(i)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -414,14 +416,14 @@ public:
|
|||||||
void PrepareForDevice(DeviceAdapterTag) const
|
void PrepareForDevice(DeviceAdapterTag) const
|
||||||
{
|
{
|
||||||
if (this->Internals->ExecutionArray != NULL)
|
if (this->Internals->ExecutionArray != NULL)
|
||||||
{
|
{
|
||||||
if (this->Internals->ExecutionArray->IsDeviceAdapter(DeviceAdapterTag()))
|
if (this->Internals->ExecutionArray->IsDeviceAdapter(DeviceAdapterTag()))
|
||||||
{
|
{
|
||||||
// Already have manager for correct device adapter. Nothing to do.
|
// Already have manager for correct device adapter. Nothing to do.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Have the wrong manager. Delete the old one and create a new one
|
// Have the wrong manager. Delete the old one and create a new one
|
||||||
// of the right type. (BTW, it would be possible for the array handle
|
// of the right type. (BTW, it would be possible for the array handle
|
||||||
// to hold references to execution arrays on multiple devices. However,
|
// to hold references to execution arrays on multiple devices. However,
|
||||||
@ -458,23 +460,23 @@ public:
|
|||||||
VTKM_CONT_EXPORT void SyncControlArray() const
|
VTKM_CONT_EXPORT void SyncControlArray() const
|
||||||
{
|
{
|
||||||
if ( !this->Internals->UserPortalValid
|
if ( !this->Internals->UserPortalValid
|
||||||
&& !this->Internals->ControlArrayValid)
|
&& !this->Internals->ControlArrayValid)
|
||||||
{
|
{
|
||||||
// Need to change some state that does not change the logical state from
|
// Need to change some state that does not change the logical state from
|
||||||
// an external point of view.
|
// an external point of view.
|
||||||
InternalStruct *internals
|
InternalStruct *internals
|
||||||
= const_cast<InternalStruct*>(this->Internals.get());
|
= const_cast<InternalStruct*>(this->Internals.get());
|
||||||
internals->ExecutionArray->RetrieveOutputData(internals->ControlArray);
|
internals->ExecutionArray->RetrieveOutputData(internals->ControlArray);
|
||||||
internals->ControlArrayValid = true;
|
internals->ControlArrayValid = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// It should never be the case that both the user and control array are
|
// It should never be the case that both the user and control array are
|
||||||
// valid.
|
// valid.
|
||||||
VTKM_ASSERT_CONT(!this->Internals->UserPortalValid
|
VTKM_ASSERT_CONT(!this->Internals->UserPortalValid
|
||||||
|| !this->Internals->ControlArrayValid);
|
|| !this->Internals->ControlArrayValid);
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<InternalStruct> Internals;
|
boost::shared_ptr<InternalStruct> Internals;
|
||||||
|
@ -38,14 +38,14 @@ public:
|
|||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
ArrayPortalCounting() :
|
ArrayPortalCounting() :
|
||||||
StartingValue(),
|
StartingValue(),
|
||||||
NumberOfValues(0)
|
NumberOfValues(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
ArrayPortalCounting(ValueType startingValue, vtkm::Id numValues) :
|
ArrayPortalCounting(ValueType startingValue, vtkm::Id numValues) :
|
||||||
StartingValue(startingValue),
|
StartingValue(startingValue),
|
||||||
NumberOfValues(numValues)
|
NumberOfValues(numValues)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename OtherValueType>
|
template<typename OtherValueType>
|
||||||
@ -58,7 +58,7 @@ public:
|
|||||||
template<typename OtherValueType>
|
template<typename OtherValueType>
|
||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
ArrayPortalCounting<ValueType> &operator=(
|
ArrayPortalCounting<ValueType> &operator=(
|
||||||
const ArrayPortalCounting<OtherValueType> &src)
|
const ArrayPortalCounting<OtherValueType> &src)
|
||||||
{
|
{
|
||||||
this->StartingValue = src.StartingValue;
|
this->StartingValue = src.StartingValue;
|
||||||
this->NumberOfValues = src.NumberOfValues;
|
this->NumberOfValues = src.NumberOfValues;
|
||||||
|
@ -44,18 +44,18 @@ namespace vtkm {
|
|||||||
namespace cont {
|
namespace cont {
|
||||||
|
|
||||||
VTKM_CONT_EXPORT void Assert(bool condition,
|
VTKM_CONT_EXPORT void Assert(bool condition,
|
||||||
const std::string &file,
|
const std::string &file,
|
||||||
vtkm::Id line,
|
vtkm::Id line,
|
||||||
const std::string &message)
|
const std::string &message)
|
||||||
{
|
{
|
||||||
if (condition)
|
if (condition)
|
||||||
{
|
{
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlAssert(file, line, message);
|
throw vtkm::cont::ErrorControlAssert(file, line, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,8 @@ protected:
|
|||||||
Error() { }
|
Error() { }
|
||||||
Error(const std::string message) : Message(message) { }
|
Error(const std::string message) : Message(message) { }
|
||||||
|
|
||||||
void SetMessage(const std::string &message) {
|
void SetMessage(const std::string &message)
|
||||||
|
{
|
||||||
this->Message = message;
|
this->Message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename DeviceAdapter>
|
template <typename DeviceAdapter>
|
||||||
struct ExecutionTypes {
|
struct ExecutionTypes
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
typedef vtkm::cont::internal::ArrayTransfer<T,Container,DeviceAdapter>
|
typedef vtkm::cont::internal::ArrayTransfer<T,Container,DeviceAdapter>
|
||||||
ArrayTransferType;
|
ArrayTransferType;
|
||||||
@ -158,17 +159,17 @@ public:
|
|||||||
bool IsDeviceAdapter(DeviceAdapter) const
|
bool IsDeviceAdapter(DeviceAdapter) const
|
||||||
{
|
{
|
||||||
return this->IsDeviceAdapterImpl(
|
return this->IsDeviceAdapterImpl(
|
||||||
vtkm::cont::internal::DeviceAdapterTraits<DeviceAdapter>::GetId());
|
vtkm::cont::internal::DeviceAdapterTraits<DeviceAdapter>::GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void GetPortalExecutionImpl(void *portalExecution) = 0;
|
virtual void GetPortalExecutionImpl(void *portalExecution) = 0;
|
||||||
|
|
||||||
virtual void GetPortalConstExecutionImpl(
|
virtual void GetPortalConstExecutionImpl(
|
||||||
void *portalConstExecution) const = 0;
|
void *portalConstExecution) const = 0;
|
||||||
|
|
||||||
virtual bool IsDeviceAdapterImpl(
|
virtual bool IsDeviceAdapterImpl(
|
||||||
const vtkm::cont::internal::DeviceAdapterId &id) const = 0;
|
const vtkm::cont::internal::DeviceAdapterId &id) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename DeviceAdapter>
|
template<typename DeviceAdapter>
|
||||||
@ -176,9 +177,9 @@ private:
|
|||||||
void VerifyDeviceAdapter(DeviceAdapter device) const
|
void VerifyDeviceAdapter(DeviceAdapter device) const
|
||||||
{
|
{
|
||||||
if (!this->IsDeviceAdapter(device))
|
if (!this->IsDeviceAdapter(device))
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorControlInternal("Device Adapter Mismatch");
|
throw vtkm::cont::ErrorControlInternal("Device Adapter Mismatch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -193,7 +194,7 @@ template<typename T,
|
|||||||
typename Container,
|
typename Container,
|
||||||
typename DeviceAdapter>
|
typename DeviceAdapter>
|
||||||
class ArrayHandleExecutionManager
|
class ArrayHandleExecutionManager
|
||||||
: public ArrayHandleExecutionManagerBase<T, Container>
|
: public ArrayHandleExecutionManagerBase<T, Container>
|
||||||
{
|
{
|
||||||
typedef ArrayHandleExecutionManagerBase<T, Container> Superclass;
|
typedef ArrayHandleExecutionManagerBase<T, Container> Superclass;
|
||||||
typedef vtkm::cont::internal::ArrayTransfer<T,Container,DeviceAdapter>
|
typedef vtkm::cont::internal::ArrayTransfer<T,Container,DeviceAdapter>
|
||||||
|
@ -56,7 +56,8 @@ public:
|
|||||||
|
|
||||||
/// Returns the size of the saved portal.
|
/// Returns the size of the saved portal.
|
||||||
///
|
///
|
||||||
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const {
|
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const
|
||||||
|
{
|
||||||
VTKM_ASSERT_CONT(this->ConstPortalValid);
|
VTKM_ASSERT_CONT(this->ConstPortalValid);
|
||||||
return this->ConstPortal.GetNumberOfValues();
|
return this->ConstPortal.GetNumberOfValues();
|
||||||
}
|
}
|
||||||
@ -106,7 +107,7 @@ public:
|
|||||||
{
|
{
|
||||||
VTKM_ASSERT_CONT(this->ConstPortalValid);
|
VTKM_ASSERT_CONT(this->ConstPortalValid);
|
||||||
VTKM_ASSERT_CONT(controlArray.GetPortalConst().GetIteratorBegin() ==
|
VTKM_ASSERT_CONT(controlArray.GetPortalConst().GetIteratorBegin() ==
|
||||||
this->ConstPortal.GetIteratorBegin());
|
this->ConstPortal.GetIteratorBegin());
|
||||||
controlArray.Shrink(this->ConstPortal.GetNumberOfValues());
|
controlArray.Shrink(this->ConstPortal.GetNumberOfValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +131,9 @@ public:
|
|||||||
this->ConstPortal.Shrink(numberOfValues);
|
this->ConstPortal.Shrink(numberOfValues);
|
||||||
|
|
||||||
if (this->PortalValid)
|
if (this->PortalValid)
|
||||||
{
|
{
|
||||||
this->Portal.Shrink(numberOfValues);
|
this->Portal.Shrink(numberOfValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the portal previously saved from an \c ArrayContainerControl.
|
/// Returns the portal previously saved from an \c ArrayContainerControl.
|
||||||
|
@ -61,17 +61,20 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
vtkm::Id GetNumberOfValues() const {
|
vtkm::Id GetNumberOfValues() const
|
||||||
|
{
|
||||||
return std::distance(this->BeginIterator, this->EndIterator);
|
return std::distance(this->BeginIterator, this->EndIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
ValueType Get(vtkm::Id index) const {
|
ValueType Get(vtkm::Id index) const
|
||||||
|
{
|
||||||
return *this->IteratorAt(index);
|
return *this->IteratorAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
void Set(vtkm::Id index, ValueType value) const {
|
void Set(vtkm::Id index, ValueType value) const
|
||||||
|
{
|
||||||
*this->IteratorAt(index) = value;
|
*this->IteratorAt(index) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +89,8 @@ private:
|
|||||||
IteratorType EndIterator;
|
IteratorType EndIterator;
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
IteratorType IteratorAt(vtkm::Id index) const {
|
IteratorType IteratorAt(vtkm::Id index) const
|
||||||
|
{
|
||||||
VTKM_ASSERT_CONT(index >= 0);
|
VTKM_ASSERT_CONT(index >= 0);
|
||||||
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());
|
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
VTKM_CONT_EXPORT ArrayPortalShrink(const DelegatePortalType &delegatePortal,
|
VTKM_CONT_EXPORT ArrayPortalShrink(const DelegatePortalType &delegatePortal,
|
||||||
vtkm::Id numberOfValues)
|
vtkm::Id numberOfValues)
|
||||||
: DelegatePortal(delegatePortal), NumberOfValues(numberOfValues)
|
: DelegatePortal(delegatePortal), NumberOfValues(numberOfValues)
|
||||||
{
|
{
|
||||||
VTKM_ASSERT_CONT(numberOfValues <= delegatePortal.GetNumberOfValues());
|
VTKM_ASSERT_CONT(numberOfValues <= delegatePortal.GetNumberOfValues());
|
||||||
@ -69,26 +69,30 @@ public:
|
|||||||
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
|
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
ValueType Get(vtkm::Id index) const {
|
ValueType Get(vtkm::Id index) const
|
||||||
|
{
|
||||||
VTKM_ASSERT_CONT(index >= 0);
|
VTKM_ASSERT_CONT(index >= 0);
|
||||||
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());
|
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());
|
||||||
return this->DelegatePortal.Get(index);
|
return this->DelegatePortal.Get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
void Set(vtkm::Id index, ValueType value) const {
|
void Set(vtkm::Id index, ValueType value) const
|
||||||
|
{
|
||||||
VTKM_ASSERT_CONT(index >= 0);
|
VTKM_ASSERT_CONT(index >= 0);
|
||||||
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());
|
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());
|
||||||
this->DelegatePortal.Set(index, value);
|
this->DelegatePortal.Set(index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
IteratorType GetIteratorBegin() const {
|
IteratorType GetIteratorBegin() const
|
||||||
|
{
|
||||||
return this->DelegatePortal.GetIteratorBegin();
|
return this->DelegatePortal.GetIteratorBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
IteratorType GetIteratorEnd() const {
|
IteratorType GetIteratorEnd() const
|
||||||
|
{
|
||||||
IteratorType iterator = this->DelegatePortal.GetIteratorBegin();
|
IteratorType iterator = this->DelegatePortal.GetIteratorBegin();
|
||||||
std::advance(iterator, this->GetNumberOfValues());
|
std::advance(iterator, this->GetNumberOfValues());
|
||||||
return iterator;
|
return iterator;
|
||||||
@ -98,7 +102,8 @@ public:
|
|||||||
/// (exposed) array.
|
/// (exposed) array.
|
||||||
///
|
///
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
void Shrink(vtkm::Id numberOfValues) {
|
void Shrink(vtkm::Id numberOfValues)
|
||||||
|
{
|
||||||
VTKM_ASSERT_CONT(numberOfValues < this->GetNumberOfValues());
|
VTKM_ASSERT_CONT(numberOfValues < this->GetNumberOfValues());
|
||||||
this->NumberOfValues = numberOfValues;
|
this->NumberOfValues = numberOfValues;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ struct DeviceAdapterAlgorithm
|
|||||||
///
|
///
|
||||||
template<class Functor>
|
template<class Functor>
|
||||||
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
||||||
vtkm::Id numInstances);
|
vtkm::Id numInstances);
|
||||||
|
|
||||||
/// \brief Schedule many instances of a function to run on concurrent threads.
|
/// \brief Schedule many instances of a function to run on concurrent threads.
|
||||||
///
|
///
|
||||||
@ -178,7 +178,7 @@ struct DeviceAdapterAlgorithm
|
|||||||
///
|
///
|
||||||
template<class Functor, class IndiceType>
|
template<class Functor, class IndiceType>
|
||||||
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
||||||
vtkm::Id3 rangeMax);
|
vtkm::Id3 rangeMax);
|
||||||
|
|
||||||
/// \brief Unstable ascending sort of input array.
|
/// \brief Unstable ascending sort of input array.
|
||||||
///
|
///
|
||||||
@ -355,7 +355,8 @@ public:
|
|||||||
|
|
||||||
return elapsedTime;
|
return elapsedTime;
|
||||||
}
|
}
|
||||||
struct TimeStamp {
|
struct TimeStamp
|
||||||
|
{
|
||||||
vtkm::internal::Int64Type Seconds;
|
vtkm::internal::Int64Type Seconds;
|
||||||
vtkm::internal::Int64Type Microseconds;
|
vtkm::internal::Int64Type Microseconds;
|
||||||
};
|
};
|
||||||
|
@ -29,8 +29,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
/// Predicate that takes a single argument \c x, and returns
|
/// Predicate that takes a single argument \c x, and returns
|
||||||
/// True if it isn't the identity of the Type \p T.
|
/// True if it isn't the identity of the Type \p T.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -132,7 +131,8 @@ private:
|
|||||||
// Copy
|
// Copy
|
||||||
private:
|
private:
|
||||||
template<class InputPortalType, class OutputPortalType>
|
template<class InputPortalType, class OutputPortalType>
|
||||||
struct CopyKernel {
|
struct CopyKernel
|
||||||
|
{
|
||||||
InputPortalType InputPortal;
|
InputPortalType InputPortal;
|
||||||
OutputPortalType OutputPortal;
|
OutputPortalType OutputPortal;
|
||||||
vtkm::Id InputOffset;
|
vtkm::Id InputOffset;
|
||||||
@ -150,10 +150,11 @@ private:
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
this->OutputPortal.Set(
|
this->OutputPortal.Set(
|
||||||
index + this->OutputOffset,
|
index + this->OutputOffset,
|
||||||
this->InputPortal.Get(index + this->InputOffset));
|
this->InputPortal.Get(index + this->InputOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
@ -164,7 +165,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
template<typename T, class CIn, class COut>
|
template<typename T, class CIn, class COut>
|
||||||
VTKM_CONT_EXPORT static void Copy(const vtkm::cont::ArrayHandle<T, CIn> &input,
|
VTKM_CONT_EXPORT static void Copy(const vtkm::cont::ArrayHandle<T, CIn> &input,
|
||||||
vtkm::cont::ArrayHandle<T, COut> &output)
|
vtkm::cont::ArrayHandle<T, COut> &output)
|
||||||
{
|
{
|
||||||
vtkm::Id arraySize = input.GetNumberOfValues();
|
vtkm::Id arraySize = input.GetNumberOfValues();
|
||||||
|
|
||||||
@ -181,7 +182,8 @@ public:
|
|||||||
// Lower Bounds
|
// Lower Bounds
|
||||||
private:
|
private:
|
||||||
template<class InputPortalType,class ValuesPortalType,class OutputPortalType>
|
template<class InputPortalType,class ValuesPortalType,class OutputPortalType>
|
||||||
struct LowerBoundsKernel {
|
struct LowerBoundsKernel
|
||||||
|
{
|
||||||
InputPortalType InputPortal;
|
InputPortalType InputPortal;
|
||||||
ValuesPortalType ValuesPortal;
|
ValuesPortalType ValuesPortal;
|
||||||
OutputPortalType OutputPortal;
|
OutputPortalType OutputPortal;
|
||||||
@ -195,7 +197,8 @@ private:
|
|||||||
OutputPortal(outputPortal) { }
|
OutputPortal(outputPortal) { }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
// This method assumes that (1) InputPortalType can return working
|
// This method assumes that (1) InputPortalType can return working
|
||||||
// iterators in the execution environment and that (2) methods not
|
// iterators in the execution environment and that (2) methods not
|
||||||
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
|
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
|
||||||
@ -220,7 +223,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class InputPortalType,class ValuesPortalType,class OutputPortalType,class Compare>
|
template<class InputPortalType,class ValuesPortalType,class OutputPortalType,class Compare>
|
||||||
struct LowerBoundsComparisonKernel {
|
struct LowerBoundsComparisonKernel
|
||||||
|
{
|
||||||
InputPortalType InputPortal;
|
InputPortalType InputPortal;
|
||||||
ValuesPortalType ValuesPortal;
|
ValuesPortalType ValuesPortal;
|
||||||
OutputPortalType OutputPortal;
|
OutputPortalType OutputPortal;
|
||||||
@ -228,16 +232,17 @@ private:
|
|||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
LowerBoundsComparisonKernel(InputPortalType inputPortal,
|
LowerBoundsComparisonKernel(InputPortalType inputPortal,
|
||||||
ValuesPortalType valuesPortal,
|
ValuesPortalType valuesPortal,
|
||||||
OutputPortalType outputPortal,
|
OutputPortalType outputPortal,
|
||||||
Compare comp)
|
Compare comp)
|
||||||
: InputPortal(inputPortal),
|
: InputPortal(inputPortal),
|
||||||
ValuesPortal(valuesPortal),
|
ValuesPortal(valuesPortal),
|
||||||
OutputPortal(outputPortal),
|
OutputPortal(outputPortal),
|
||||||
CompareFunctor(comp) { }
|
CompareFunctor(comp) { }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
// This method assumes that (1) InputPortalType can return working
|
// This method assumes that (1) InputPortalType can return working
|
||||||
// iterators in the execution environment and that (2) methods not
|
// iterators in the execution environment and that (2) methods not
|
||||||
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
|
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
|
||||||
@ -356,9 +361,9 @@ public:
|
|||||||
|
|
||||||
vtkm::Id numValues = inclusiveScan.GetNumberOfValues();
|
vtkm::Id numValues = inclusiveScan.GetNumberOfValues();
|
||||||
if (numValues < 1)
|
if (numValues < 1)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef typename TempArrayType::template ExecutionTypes<DeviceAdapterTag>
|
typedef typename TempArrayType::template ExecutionTypes<DeviceAdapterTag>
|
||||||
::PortalConst SrcPortalType;
|
::PortalConst SrcPortalType;
|
||||||
@ -411,11 +416,11 @@ private:
|
|||||||
vtkm::Id rightIndex = leftIndex + this->Distance;
|
vtkm::Id rightIndex = leftIndex + this->Distance;
|
||||||
|
|
||||||
if (rightIndex < this->Portal.GetNumberOfValues())
|
if (rightIndex < this->Portal.GetNumberOfValues())
|
||||||
{
|
{
|
||||||
ValueType leftValue = this->Portal.Get(leftIndex);
|
ValueType leftValue = this->Portal.Get(leftIndex);
|
||||||
ValueType rightValue = this->Portal.Get(rightIndex);
|
ValueType rightValue = this->Portal.Get(rightIndex);
|
||||||
this->Portal.Set(rightIndex, leftValue+rightValue);
|
this->Portal.Set(rightIndex, leftValue+rightValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -433,25 +438,25 @@ public:
|
|||||||
|
|
||||||
vtkm::Id numValues = output.GetNumberOfValues();
|
vtkm::Id numValues = output.GetNumberOfValues();
|
||||||
if (numValues < 1)
|
if (numValues < 1)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PortalType portal = output.PrepareForInPlace(DeviceAdapterTag());
|
PortalType portal = output.PrepareForInPlace(DeviceAdapterTag());
|
||||||
|
|
||||||
vtkm::Id stride;
|
vtkm::Id stride;
|
||||||
for (stride = 2; stride-1 < numValues; stride *= 2)
|
for (stride = 2; stride-1 < numValues; stride *= 2)
|
||||||
{
|
{
|
||||||
ScanKernel<PortalType> kernel(portal, stride, stride/2 - 1);
|
ScanKernel<PortalType> kernel(portal, stride, stride/2 - 1);
|
||||||
DerivedAlgorithm::Schedule(kernel, numValues/stride);
|
DerivedAlgorithm::Schedule(kernel, numValues/stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do reverse operation on odd indices. Start at stride we were just at.
|
// Do reverse operation on odd indices. Start at stride we were just at.
|
||||||
for (stride /= 2; stride > 1; stride /= 2)
|
for (stride /= 2; stride > 1; stride /= 2)
|
||||||
{
|
{
|
||||||
ScanKernel<PortalType> kernel(portal, stride, stride - 1);
|
ScanKernel<PortalType> kernel(portal, stride, stride - 1);
|
||||||
DerivedAlgorithm::Schedule(kernel, numValues/stride);
|
DerivedAlgorithm::Schedule(kernel, numValues/stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetExecutionValue(output, numValues-1);
|
return GetExecutionValue(output, numValues-1);
|
||||||
}
|
}
|
||||||
@ -473,7 +478,8 @@ private:
|
|||||||
: Portal(portal), Compare(compare), GroupSize(groupSize) { }
|
: Portal(portal), Compare(compare), GroupSize(groupSize) { }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
typedef typename PortalType::ValueType ValueType;
|
typedef typename PortalType::ValueType ValueType;
|
||||||
|
|
||||||
vtkm::Id groupIndex = index%this->GroupSize;
|
vtkm::Id groupIndex = index%this->GroupSize;
|
||||||
@ -484,15 +490,15 @@ private:
|
|||||||
vtkm::Id highIndex = lowIndex + this->GroupSize;
|
vtkm::Id highIndex = lowIndex + this->GroupSize;
|
||||||
|
|
||||||
if (highIndex < this->Portal.GetNumberOfValues())
|
if (highIndex < this->Portal.GetNumberOfValues())
|
||||||
{
|
{
|
||||||
ValueType lowValue = this->Portal.Get(lowIndex);
|
ValueType lowValue = this->Portal.Get(lowIndex);
|
||||||
ValueType highValue = this->Portal.Get(highIndex);
|
ValueType highValue = this->Portal.Get(highIndex);
|
||||||
if (this->Compare(highValue, lowValue))
|
if (this->Compare(highValue, lowValue))
|
||||||
{
|
{
|
||||||
this->Portal.Set(highIndex, lowValue);
|
this->Portal.Set(highIndex, lowValue);
|
||||||
this->Portal.Set(lowIndex, highValue);
|
this->Portal.Set(lowIndex, highValue);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -510,7 +516,8 @@ private:
|
|||||||
: Portal(portal), Compare(compare), GroupSize(groupSize) { }
|
: Portal(portal), Compare(compare), GroupSize(groupSize) { }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
typedef typename PortalType::ValueType ValueType;
|
typedef typename PortalType::ValueType ValueType;
|
||||||
|
|
||||||
vtkm::Id groupIndex = index%this->GroupSize;
|
vtkm::Id groupIndex = index%this->GroupSize;
|
||||||
@ -521,15 +528,15 @@ private:
|
|||||||
vtkm::Id highIndex = blockIndex*blockSize + (blockSize - groupIndex - 1);
|
vtkm::Id highIndex = blockIndex*blockSize + (blockSize - groupIndex - 1);
|
||||||
|
|
||||||
if (highIndex < this->Portal.GetNumberOfValues())
|
if (highIndex < this->Portal.GetNumberOfValues())
|
||||||
{
|
{
|
||||||
ValueType lowValue = this->Portal.Get(lowIndex);
|
ValueType lowValue = this->Portal.Get(lowIndex);
|
||||||
ValueType highValue = this->Portal.Get(highIndex);
|
ValueType highValue = this->Portal.Get(highIndex);
|
||||||
if (this->Compare(highValue, lowValue))
|
if (this->Compare(highValue, lowValue))
|
||||||
{
|
{
|
||||||
this->Portal.Set(highIndex, lowValue);
|
this->Portal.Set(highIndex, lowValue);
|
||||||
this->Portal.Set(lowIndex, highValue);
|
this->Portal.Set(lowIndex, highValue);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -569,15 +576,15 @@ public:
|
|||||||
for (vtkm::Id crossoverSize = 1;
|
for (vtkm::Id crossoverSize = 1;
|
||||||
crossoverSize < numValues;
|
crossoverSize < numValues;
|
||||||
crossoverSize *= 2)
|
crossoverSize *= 2)
|
||||||
{
|
{
|
||||||
DerivedAlgorithm::Schedule(CrossoverKernel(portal,compare,crossoverSize),
|
DerivedAlgorithm::Schedule(CrossoverKernel(portal,compare,crossoverSize),
|
||||||
numThreads);
|
numThreads);
|
||||||
for (vtkm::Id mergeSize = crossoverSize/2; mergeSize > 0; mergeSize /= 2)
|
for (vtkm::Id mergeSize = crossoverSize/2; mergeSize > 0; mergeSize /= 2)
|
||||||
{
|
{
|
||||||
DerivedAlgorithm::Schedule(MergeKernel(portal,compare,mergeSize),
|
DerivedAlgorithm::Schedule(MergeKernel(portal,compare,mergeSize),
|
||||||
numThreads);
|
numThreads);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, class Container>
|
template<typename T, class Container>
|
||||||
@ -642,14 +649,14 @@ private:
|
|||||||
typedef typename StencilPortalType::ValueType StencilValueType;
|
typedef typename StencilPortalType::ValueType StencilValueType;
|
||||||
StencilValueType stencilValue = this->StencilPortal.Get(index);
|
StencilValueType stencilValue = this->StencilPortal.Get(index);
|
||||||
if (not_default_constructor<StencilValueType>()(stencilValue))
|
if (not_default_constructor<StencilValueType>()(stencilValue))
|
||||||
{
|
{
|
||||||
vtkm::Id outputIndex = this->IndexPortal.Get(index);
|
vtkm::Id outputIndex = this->IndexPortal.Get(index);
|
||||||
|
|
||||||
typedef typename OutputPortalType::ValueType OutputValueType;
|
typedef typename OutputPortalType::ValueType OutputValueType;
|
||||||
OutputValueType value = this->InputPortal.Get(index);
|
OutputValueType value = this->InputPortal.Get(index);
|
||||||
|
|
||||||
this->OutputPortal.Set(outputIndex, value);
|
this->OutputPortal.Set(outputIndex, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
@ -729,7 +736,8 @@ public:
|
|||||||
// Unique
|
// Unique
|
||||||
private:
|
private:
|
||||||
template<class InputPortalType, class StencilPortalType>
|
template<class InputPortalType, class StencilPortalType>
|
||||||
struct ClassifyUniqueKernel {
|
struct ClassifyUniqueKernel
|
||||||
|
{
|
||||||
InputPortalType InputPortal;
|
InputPortalType InputPortal;
|
||||||
StencilPortalType StencilPortal;
|
StencilPortalType StencilPortal;
|
||||||
|
|
||||||
@ -739,19 +747,20 @@ private:
|
|||||||
: InputPortal(inputPortal), StencilPortal(stencilPortal) { }
|
: InputPortal(inputPortal), StencilPortal(stencilPortal) { }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
typedef typename StencilPortalType::ValueType ValueType;
|
typedef typename StencilPortalType::ValueType ValueType;
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
// Always copy first value.
|
// Always copy first value.
|
||||||
this->StencilPortal.Set(index, ValueType(1));
|
this->StencilPortal.Set(index, ValueType(1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ValueType flag = ValueType(this->InputPortal.Get(index-1)
|
ValueType flag = ValueType(this->InputPortal.Get(index-1)
|
||||||
!= this->InputPortal.Get(index));
|
!= this->InputPortal.Get(index));
|
||||||
this->StencilPortal.Set(index, flag);
|
this->StencilPortal.Set(index, flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
@ -760,35 +769,37 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class InputPortalType, class StencilPortalType, class Compare>
|
template<class InputPortalType, class StencilPortalType, class Compare>
|
||||||
struct ClassifyUniqueComparisonKernel {
|
struct ClassifyUniqueComparisonKernel
|
||||||
|
{
|
||||||
InputPortalType InputPortal;
|
InputPortalType InputPortal;
|
||||||
StencilPortalType StencilPortal;
|
StencilPortalType StencilPortal;
|
||||||
Compare CompareFunctor;
|
Compare CompareFunctor;
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
ClassifyUniqueComparisonKernel(InputPortalType inputPortal,
|
ClassifyUniqueComparisonKernel(InputPortalType inputPortal,
|
||||||
StencilPortalType stencilPortal,
|
StencilPortalType stencilPortal,
|
||||||
Compare comp):
|
Compare comp):
|
||||||
InputPortal(inputPortal),
|
InputPortal(inputPortal),
|
||||||
StencilPortal(stencilPortal),
|
StencilPortal(stencilPortal),
|
||||||
CompareFunctor(comp) { }
|
CompareFunctor(comp) { }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
typedef typename StencilPortalType::ValueType ValueType;
|
typedef typename StencilPortalType::ValueType ValueType;
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
// Always copy first value.
|
// Always copy first value.
|
||||||
this->StencilPortal.Set(index, ValueType(1));
|
this->StencilPortal.Set(index, ValueType(1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//comparison predicate returns true when they match
|
//comparison predicate returns true when they match
|
||||||
const bool same = !(this->CompareFunctor(this->InputPortal.Get(index-1),
|
const bool same = !(this->CompareFunctor(this->InputPortal.Get(index-1),
|
||||||
this->InputPortal.Get(index)));
|
this->InputPortal.Get(index)));
|
||||||
ValueType flag = ValueType(same);
|
ValueType flag = ValueType(same);
|
||||||
this->StencilPortal.Set(index, flag);
|
this->StencilPortal.Set(index, flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
@ -850,7 +861,8 @@ public:
|
|||||||
// Upper bounds
|
// Upper bounds
|
||||||
private:
|
private:
|
||||||
template<class InputPortalType,class ValuesPortalType,class OutputPortalType>
|
template<class InputPortalType,class ValuesPortalType,class OutputPortalType>
|
||||||
struct UpperBoundsKernel {
|
struct UpperBoundsKernel
|
||||||
|
{
|
||||||
InputPortalType InputPortal;
|
InputPortalType InputPortal;
|
||||||
ValuesPortalType ValuesPortal;
|
ValuesPortalType ValuesPortal;
|
||||||
OutputPortalType OutputPortal;
|
OutputPortalType OutputPortal;
|
||||||
@ -864,7 +876,8 @@ private:
|
|||||||
OutputPortal(outputPortal) { }
|
OutputPortal(outputPortal) { }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
// This method assumes that (1) InputPortalType can return working
|
// This method assumes that (1) InputPortalType can return working
|
||||||
// iterators in the execution environment and that (2) methods not
|
// iterators in the execution environment and that (2) methods not
|
||||||
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
|
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
|
||||||
@ -890,7 +903,8 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
template<class InputPortalType,class ValuesPortalType,class OutputPortalType,class Compare>
|
template<class InputPortalType,class ValuesPortalType,class OutputPortalType,class Compare>
|
||||||
struct UpperBoundsKernelComparisonKernel {
|
struct UpperBoundsKernelComparisonKernel
|
||||||
|
{
|
||||||
InputPortalType InputPortal;
|
InputPortalType InputPortal;
|
||||||
ValuesPortalType ValuesPortal;
|
ValuesPortalType ValuesPortal;
|
||||||
OutputPortalType OutputPortal;
|
OutputPortalType OutputPortal;
|
||||||
@ -898,16 +912,17 @@ private:
|
|||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
UpperBoundsKernelComparisonKernel(InputPortalType inputPortal,
|
UpperBoundsKernelComparisonKernel(InputPortalType inputPortal,
|
||||||
ValuesPortalType valuesPortal,
|
ValuesPortalType valuesPortal,
|
||||||
OutputPortalType outputPortal,
|
OutputPortalType outputPortal,
|
||||||
Compare comp)
|
Compare comp)
|
||||||
: InputPortal(inputPortal),
|
: InputPortal(inputPortal),
|
||||||
ValuesPortal(valuesPortal),
|
ValuesPortal(valuesPortal),
|
||||||
OutputPortal(outputPortal),
|
OutputPortal(outputPortal),
|
||||||
CompareFunctor(comp) { }
|
CompareFunctor(comp) { }
|
||||||
|
|
||||||
VTKM_EXEC_EXPORT
|
VTKM_EXEC_EXPORT
|
||||||
void operator()(vtkm::Id index) const {
|
void operator()(vtkm::Id index) const
|
||||||
|
{
|
||||||
// This method assumes that (1) InputPortalType can return working
|
// This method assumes that (1) InputPortalType can return working
|
||||||
// iterators in the execution environment and that (2) methods not
|
// iterators in the execution environment and that (2) methods not
|
||||||
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
|
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
|
||||||
|
@ -125,7 +125,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
template<class Functor>
|
template<class Functor>
|
||||||
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
||||||
vtkm::Id numInstances)
|
vtkm::Id numInstances)
|
||||||
{
|
{
|
||||||
const vtkm::Id MESSAGE_SIZE = 1024;
|
const vtkm::Id MESSAGE_SIZE = 1024;
|
||||||
char errorString[MESSAGE_SIZE];
|
char errorString[MESSAGE_SIZE];
|
||||||
@ -143,9 +143,9 @@ public:
|
|||||||
kernel);
|
kernel);
|
||||||
|
|
||||||
if (errorMessage.IsErrorRaised())
|
if (errorMessage.IsErrorRaised())
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorExecution(errorString);
|
throw vtkm::cont::ErrorExecution(errorString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class FunctorType>
|
template<class FunctorType>
|
||||||
@ -168,7 +168,7 @@ public:
|
|||||||
|
|
||||||
template<typename T, class Container, class Compare>
|
template<typename T, class Container, class Compare>
|
||||||
VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle<T,Container>& values,
|
VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle<T,Container>& values,
|
||||||
Compare comp)
|
Compare comp)
|
||||||
{
|
{
|
||||||
typedef typename vtkm::cont::ArrayHandle<T,Container>
|
typedef typename vtkm::cont::ArrayHandle<T,Container>
|
||||||
::template ExecutionTypes<Device>::Portal PortalType;
|
::template ExecutionTypes<Device>::Portal PortalType;
|
||||||
|
@ -32,7 +32,8 @@ namespace internal {
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class ArrayPortalType>
|
template<class ArrayPortalType>
|
||||||
struct IteratorFromArrayPortalValue {
|
struct IteratorFromArrayPortalValue
|
||||||
|
{
|
||||||
typedef typename ArrayPortalType::ValueType ValueType;
|
typedef typename ArrayPortalType::ValueType ValueType;
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
@ -52,20 +53,22 @@ struct IteratorFromArrayPortalValue {
|
|||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
IteratorFromArrayPortalValue<ArrayPortalType> &operator=(
|
IteratorFromArrayPortalValue<ArrayPortalType> &operator=(
|
||||||
const IteratorFromArrayPortalValue<ArrayPortalType> &rhs)
|
const IteratorFromArrayPortalValue<ArrayPortalType> &rhs)
|
||||||
{
|
{
|
||||||
this->Portal.Set(this->Index, rhs.Portal.Get(rhs.Index));
|
this->Portal.Set(this->Index, rhs.Portal.Get(rhs.Index));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
ValueType operator=(ValueType value) {
|
ValueType operator=(ValueType value)
|
||||||
|
{
|
||||||
this->Portal.Set(this->Index, value);
|
this->Portal.Set(this->Index, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
operator ValueType(void) const {
|
operator ValueType(void) const
|
||||||
|
{
|
||||||
return this->Portal.Get(this->Index);
|
return this->Portal.Get(this->Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +99,8 @@ public:
|
|||||||
detail::IteratorFromArrayPortalValue<ArrayPortalType>
|
detail::IteratorFromArrayPortalValue<ArrayPortalType>
|
||||||
operator[](int idx) const
|
operator[](int idx) const
|
||||||
{
|
{
|
||||||
return detail::IteratorFromArrayPortalValue<ArrayPortalType>(this->Portal,
|
return detail::IteratorFromArrayPortalValue<ArrayPortalType>(this->Portal,
|
||||||
idx);
|
idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -108,13 +111,15 @@ private:
|
|||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
detail::IteratorFromArrayPortalValue<ArrayPortalType> dereference() const {
|
detail::IteratorFromArrayPortalValue<ArrayPortalType> dereference() const
|
||||||
|
{
|
||||||
return detail::IteratorFromArrayPortalValue<ArrayPortalType>(this->Portal,
|
return detail::IteratorFromArrayPortalValue<ArrayPortalType>(this->Portal,
|
||||||
this->Index);
|
this->Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
bool equal(const IteratorFromArrayPortal<ArrayPortalType> &other) const {
|
bool equal(const IteratorFromArrayPortal<ArrayPortalType> &other) const
|
||||||
|
{
|
||||||
// Technically, we should probably check that the portals are the same,
|
// Technically, we should probably check that the portals are the same,
|
||||||
// but the portal interface does not specify an equal operator. It is
|
// but the portal interface does not specify an equal operator. It is
|
||||||
// by its nature undefined what happens when comparing iterators from
|
// by its nature undefined what happens when comparing iterators from
|
||||||
@ -123,21 +128,24 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
void increment() {
|
void increment()
|
||||||
|
{
|
||||||
this->Index++;
|
this->Index++;
|
||||||
VTKM_ASSERT_CONT(this->Index >= 0);
|
VTKM_ASSERT_CONT(this->Index >= 0);
|
||||||
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
|
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
void decrement() {
|
void decrement()
|
||||||
|
{
|
||||||
this->Index--;
|
this->Index--;
|
||||||
VTKM_ASSERT_CONT(this->Index >= 0);
|
VTKM_ASSERT_CONT(this->Index >= 0);
|
||||||
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
|
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
void advance(vtkm::Id delta) {
|
void advance(vtkm::Id delta)
|
||||||
|
{
|
||||||
this->Index += delta;
|
this->Index += delta;
|
||||||
VTKM_ASSERT_CONT(this->Index >= 0);
|
VTKM_ASSERT_CONT(this->Index >= 0);
|
||||||
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
|
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
|
||||||
@ -145,7 +153,8 @@ private:
|
|||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
vtkm::Id
|
vtkm::Id
|
||||||
distance_to(const IteratorFromArrayPortal<ArrayPortalType> &other) const {
|
distance_to(const IteratorFromArrayPortal<ArrayPortalType> &other) const
|
||||||
|
{
|
||||||
// Technically, we should probably check that the portals are the same,
|
// Technically, we should probably check that the portals are the same,
|
||||||
// but the portal interface does not specify an equal operator. It is
|
// but the portal interface does not specify an equal operator. It is
|
||||||
// by its nature undefined what happens when comparing iterators from
|
// by its nature undefined what happens when comparing iterators from
|
||||||
@ -156,28 +165,28 @@ private:
|
|||||||
|
|
||||||
template<class ArrayPortalType>
|
template<class ArrayPortalType>
|
||||||
IteratorFromArrayPortal<ArrayPortalType> make_IteratorBegin(
|
IteratorFromArrayPortal<ArrayPortalType> make_IteratorBegin(
|
||||||
const ArrayPortalType &portal)
|
const ArrayPortalType &portal)
|
||||||
{
|
{
|
||||||
return IteratorFromArrayPortal<ArrayPortalType>(portal, 0);
|
return IteratorFromArrayPortal<ArrayPortalType>(portal, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ArrayPortalType>
|
template<class ArrayPortalType>
|
||||||
IteratorFromArrayPortal<ArrayPortalType> make_IteratorEnd(
|
IteratorFromArrayPortal<ArrayPortalType> make_IteratorEnd(
|
||||||
const ArrayPortalType &portal)
|
const ArrayPortalType &portal)
|
||||||
{
|
{
|
||||||
return IteratorFromArrayPortal<ArrayPortalType>(portal,
|
return IteratorFromArrayPortal<ArrayPortalType>(portal,
|
||||||
portal.GetNumberOfValues());
|
portal.GetNumberOfValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//implementat a custom swap function, since the std::swap won't work
|
//implementat a custom swap function, since the std::swap won't work
|
||||||
//since we return RValues instead of Lvalues
|
//since we return RValues instead of Lvalues
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void swap( vtkm::cont::internal::detail::IteratorFromArrayPortalValue<T> a,
|
void swap( vtkm::cont::internal::detail::IteratorFromArrayPortalValue<T> a,
|
||||||
vtkm::cont::internal::detail::IteratorFromArrayPortalValue<T> b)
|
vtkm::cont::internal::detail::IteratorFromArrayPortalValue<T> b)
|
||||||
{
|
{
|
||||||
a.Swap(b);
|
a.Swap(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,9 @@ struct TemplatedTests
|
|||||||
bool CheckArray(IteratorType begin, IteratorType end, ValueType value)
|
bool CheckArray(IteratorType begin, IteratorType end, ValueType value)
|
||||||
{
|
{
|
||||||
for (IteratorType iter = begin; iter != end; iter++)
|
for (IteratorType iter = begin; iter != end; iter++)
|
||||||
{
|
{
|
||||||
if (!test_equal(*iter, value)) return false;
|
if (!test_equal(*iter, value)) { return false; }
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ struct TemplatedTests
|
|||||||
executionArray.CopyInto(copyBack.begin());
|
executionArray.CopyInto(copyBack.begin());
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(CheckArray(copyBack.begin(), copyBack.end(), INPUT_VALUE),
|
VTKM_TEST_ASSERT(CheckArray(copyBack.begin(), copyBack.end(), INPUT_VALUE),
|
||||||
"Did not get correct array back.");
|
"Did not get correct array back.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void InPlaceData()
|
void InPlaceData()
|
||||||
@ -117,7 +117,7 @@ struct TemplatedTests
|
|||||||
executionArray.CopyInto(copyBack.begin());
|
executionArray.CopyInto(copyBack.begin());
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(CheckArray(copyBack.begin(), copyBack.end(), INPUT_VALUE),
|
VTKM_TEST_ASSERT(CheckArray(copyBack.begin(), copyBack.end(), INPUT_VALUE),
|
||||||
"Did not get correct array back.");
|
"Did not get correct array back.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputData()
|
void OutputData()
|
||||||
@ -137,15 +137,16 @@ struct TemplatedTests
|
|||||||
executionArray.CopyInto(copyBack.begin());
|
executionArray.CopyInto(copyBack.begin());
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(CheckArray(copyBack.begin(), copyBack.end(), OUTPUT_VALUE),
|
VTKM_TEST_ASSERT(CheckArray(copyBack.begin(), copyBack.end(), OUTPUT_VALUE),
|
||||||
"Did not get correct array back.");
|
"Did not get correct array back.");
|
||||||
|
|
||||||
executionArray.RetrieveOutputData(controlArray);
|
executionArray.RetrieveOutputData(controlArray);
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(CheckContainer(controlArray, OUTPUT_VALUE),
|
VTKM_TEST_ASSERT(CheckContainer(controlArray, OUTPUT_VALUE),
|
||||||
"Did not get the right value in the control container.");
|
"Did not get the right value in the control container.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()() {
|
void operator()()
|
||||||
|
{
|
||||||
|
|
||||||
InputData();
|
InputData();
|
||||||
InPlaceData();
|
InPlaceData();
|
||||||
|
@ -33,30 +33,33 @@ struct TemplatedTests
|
|||||||
typedef T ValueType;
|
typedef T ValueType;
|
||||||
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
|
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
|
||||||
|
|
||||||
ValueType ExpectedValue(vtkm::Id index, ComponentType value) {
|
ValueType ExpectedValue(vtkm::Id index, ComponentType value)
|
||||||
|
{
|
||||||
return ValueType(index + value);
|
return ValueType(index + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class IteratorType>
|
template<class IteratorType>
|
||||||
void FillIterator(IteratorType begin, IteratorType end, ComponentType value) {
|
void FillIterator(IteratorType begin, IteratorType end, ComponentType value)
|
||||||
|
{
|
||||||
vtkm::Id index = 0;
|
vtkm::Id index = 0;
|
||||||
for (IteratorType iter = begin; iter != end; iter++)
|
for (IteratorType iter = begin; iter != end; iter++)
|
||||||
{
|
{
|
||||||
*iter = ExpectedValue(index, value);
|
*iter = ExpectedValue(index, value);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class IteratorType>
|
template<class IteratorType>
|
||||||
bool CheckIterator(IteratorType begin,
|
bool CheckIterator(IteratorType begin,
|
||||||
IteratorType end,
|
IteratorType end,
|
||||||
ComponentType value) {
|
ComponentType value)
|
||||||
|
{
|
||||||
vtkm::Id index = 0;
|
vtkm::Id index = 0;
|
||||||
for (IteratorType iter = begin; iter != end; iter++)
|
for (IteratorType iter = begin; iter != end; iter++)
|
||||||
{
|
{
|
||||||
if (*iter != ExpectedValue(index, value)) return false;
|
if (*iter != ExpectedValue(index, value)) { return false; }
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,47 +71,47 @@ struct TemplatedTests
|
|||||||
FillIterator(array, array+ARRAY_SIZE, ORIGINAL_VALUE);
|
FillIterator(array, array+ARRAY_SIZE, ORIGINAL_VALUE);
|
||||||
|
|
||||||
::vtkm::cont::internal::ArrayPortalFromIterators<ValueType *>
|
::vtkm::cont::internal::ArrayPortalFromIterators<ValueType *>
|
||||||
portal(array, array+ARRAY_SIZE);
|
portal(array, array+ARRAY_SIZE);
|
||||||
::vtkm::cont::internal::ArrayPortalFromIterators<const ValueType *>
|
::vtkm::cont::internal::ArrayPortalFromIterators<const ValueType *>
|
||||||
const_portal(array, array+ARRAY_SIZE);
|
const_portal(array, array+ARRAY_SIZE);
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(portal.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(portal.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Portal array size wrong.");
|
"Portal array size wrong.");
|
||||||
VTKM_TEST_ASSERT(const_portal.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(const_portal.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Const portal array size wrong.");
|
"Const portal array size wrong.");
|
||||||
|
|
||||||
std::cout << " Check inital value." << std::endl;
|
std::cout << " Check inital value." << std::endl;
|
||||||
VTKM_TEST_ASSERT(CheckIterator(portal.GetIteratorBegin(),
|
VTKM_TEST_ASSERT(CheckIterator(portal.GetIteratorBegin(),
|
||||||
portal.GetIteratorEnd(),
|
portal.GetIteratorEnd(),
|
||||||
ORIGINAL_VALUE),
|
ORIGINAL_VALUE),
|
||||||
"Portal iterator has bad value.");
|
"Portal iterator has bad value.");
|
||||||
VTKM_TEST_ASSERT(CheckIterator(const_portal.GetIteratorBegin(),
|
VTKM_TEST_ASSERT(CheckIterator(const_portal.GetIteratorBegin(),
|
||||||
const_portal.GetIteratorEnd(),
|
const_portal.GetIteratorEnd(),
|
||||||
ORIGINAL_VALUE),
|
ORIGINAL_VALUE),
|
||||||
"Const portal iterator has bad value.");
|
"Const portal iterator has bad value.");
|
||||||
|
|
||||||
static const ComponentType SET_VALUE = 562;
|
static const ComponentType SET_VALUE = 562;
|
||||||
|
|
||||||
std::cout << " Check get/set methods." << std::endl;
|
std::cout << " Check get/set methods." << std::endl;
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(portal.Get(index)
|
VTKM_TEST_ASSERT(portal.Get(index)
|
||||||
== ExpectedValue(index, ORIGINAL_VALUE),
|
== ExpectedValue(index, ORIGINAL_VALUE),
|
||||||
"Bad portal value.");
|
"Bad portal value.");
|
||||||
VTKM_TEST_ASSERT(const_portal.Get(index)
|
VTKM_TEST_ASSERT(const_portal.Get(index)
|
||||||
== ExpectedValue(index, ORIGINAL_VALUE),
|
== ExpectedValue(index, ORIGINAL_VALUE),
|
||||||
"Bad const portal value.");
|
"Bad const portal value.");
|
||||||
|
|
||||||
portal.Set(index, ExpectedValue(index, SET_VALUE));
|
portal.Set(index, ExpectedValue(index, SET_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << " Make sure set has correct value." << std::endl;
|
std::cout << " Make sure set has correct value." << std::endl;
|
||||||
VTKM_TEST_ASSERT(CheckIterator(portal.GetIteratorBegin(),
|
VTKM_TEST_ASSERT(CheckIterator(portal.GetIteratorBegin(),
|
||||||
portal.GetIteratorEnd(),
|
portal.GetIteratorEnd(),
|
||||||
SET_VALUE),
|
SET_VALUE),
|
||||||
"Portal iterator has bad value.");
|
"Portal iterator has bad value.");
|
||||||
VTKM_TEST_ASSERT(CheckIterator(array, array+ARRAY_SIZE, SET_VALUE),
|
VTKM_TEST_ASSERT(CheckIterator(array, array+ARRAY_SIZE, SET_VALUE),
|
||||||
"Array has bad value.");
|
"Array has bad value.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,30 +35,33 @@ struct TemplatedTests
|
|||||||
typedef T ValueType;
|
typedef T ValueType;
|
||||||
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
|
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
|
||||||
|
|
||||||
ValueType ExpectedValue(vtkm::Id index, ComponentType value) {
|
ValueType ExpectedValue(vtkm::Id index, ComponentType value)
|
||||||
|
{
|
||||||
return ValueType(index + value);
|
return ValueType(index + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class IteratorType>
|
template<class IteratorType>
|
||||||
void FillIterator(IteratorType begin, IteratorType end, ComponentType value) {
|
void FillIterator(IteratorType begin, IteratorType end, ComponentType value)
|
||||||
|
{
|
||||||
vtkm::Id index = 0;
|
vtkm::Id index = 0;
|
||||||
for (IteratorType iter = begin; iter != end; iter++)
|
for (IteratorType iter = begin; iter != end; iter++)
|
||||||
{
|
{
|
||||||
*iter = ExpectedValue(index, value);
|
*iter = ExpectedValue(index, value);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class IteratorType>
|
template<class IteratorType>
|
||||||
bool CheckIterator(IteratorType begin,
|
bool CheckIterator(IteratorType begin,
|
||||||
IteratorType end,
|
IteratorType end,
|
||||||
ComponentType value) {
|
ComponentType value)
|
||||||
|
{
|
||||||
vtkm::Id index = 0;
|
vtkm::Id index = 0;
|
||||||
for (IteratorType iter = begin; iter != end; iter++)
|
for (IteratorType iter = begin; iter != end; iter++)
|
||||||
{
|
{
|
||||||
if (ValueType(*iter) != ExpectedValue(index, value)) return false;
|
if (ValueType(*iter) != ExpectedValue(index, value)) { return false; }
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,29 +75,29 @@ struct TemplatedTests
|
|||||||
IteratorType begin = vtkm::cont::internal::make_IteratorBegin(portal);
|
IteratorType begin = vtkm::cont::internal::make_IteratorBegin(portal);
|
||||||
IteratorType end = vtkm::cont::internal::make_IteratorEnd(portal);
|
IteratorType end = vtkm::cont::internal::make_IteratorEnd(portal);
|
||||||
VTKM_TEST_ASSERT(std::distance(begin, end) == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(std::distance(begin, end) == ARRAY_SIZE,
|
||||||
"Distance between begin and end incorrect.");
|
"Distance between begin and end incorrect.");
|
||||||
|
|
||||||
std::cout << " Check forward iteration." << std::endl;
|
std::cout << " Check forward iteration." << std::endl;
|
||||||
VTKM_TEST_ASSERT(CheckIterator(begin, end, ORIGINAL_VALUE()),
|
VTKM_TEST_ASSERT(CheckIterator(begin, end, ORIGINAL_VALUE()),
|
||||||
"Forward iteration wrong");
|
"Forward iteration wrong");
|
||||||
|
|
||||||
std::cout << " Check backward iteration." << std::endl;
|
std::cout << " Check backward iteration." << std::endl;
|
||||||
IteratorType middle = end;
|
IteratorType middle = end;
|
||||||
for (vtkm::Id index = portal.GetNumberOfValues()-1; index >= 0; index--)
|
for (vtkm::Id index = portal.GetNumberOfValues()-1; index >= 0; index--)
|
||||||
{
|
{
|
||||||
middle--;
|
middle--;
|
||||||
ValueType value = *middle;
|
ValueType value = *middle;
|
||||||
VTKM_TEST_ASSERT(value == ExpectedValue(index, ORIGINAL_VALUE()),
|
VTKM_TEST_ASSERT(value == ExpectedValue(index, ORIGINAL_VALUE()),
|
||||||
"Backward iteration wrong");
|
"Backward iteration wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << " Check advance" << std::endl;
|
std::cout << " Check advance" << std::endl;
|
||||||
middle = begin + ARRAY_SIZE/2;
|
middle = begin + ARRAY_SIZE/2;
|
||||||
VTKM_TEST_ASSERT(std::distance(begin, middle) == ARRAY_SIZE/2,
|
VTKM_TEST_ASSERT(std::distance(begin, middle) == ARRAY_SIZE/2,
|
||||||
"Bad distance to middle.");
|
"Bad distance to middle.");
|
||||||
VTKM_TEST_ASSERT(
|
VTKM_TEST_ASSERT(
|
||||||
ValueType(*middle) == ExpectedValue(ARRAY_SIZE/2, ORIGINAL_VALUE()),
|
ValueType(*middle) == ExpectedValue(ARRAY_SIZE/2, ORIGINAL_VALUE()),
|
||||||
"Bad value at middle.");
|
"Bad value at middle.");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ArrayPortalType>
|
template<class ArrayPortalType>
|
||||||
@ -112,9 +115,9 @@ struct TemplatedTests
|
|||||||
|
|
||||||
std::cout << " Check values in portal." << std::endl;
|
std::cout << " Check values in portal." << std::endl;
|
||||||
VTKM_TEST_ASSERT(CheckIterator(portal.GetIteratorBegin(),
|
VTKM_TEST_ASSERT(CheckIterator(portal.GetIteratorBegin(),
|
||||||
portal.GetIteratorEnd(),
|
portal.GetIteratorEnd(),
|
||||||
WRITE_VALUE),
|
WRITE_VALUE),
|
||||||
"Did not get correct values when writing to iterator.");
|
"Did not get correct values when writing to iterator.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()()
|
void operator()()
|
||||||
|
@ -35,27 +35,27 @@ public:
|
|||||||
static VTKM_CONT_EXPORT int Run(Func function)
|
static VTKM_CONT_EXPORT int Run(Func function)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
function();
|
function();
|
||||||
}
|
}
|
||||||
catch (vtkm::testing::Testing::TestFailure error)
|
catch (vtkm::testing::Testing::TestFailure error)
|
||||||
{
|
{
|
||||||
std::cout << "***** Test failed @ "
|
std::cout << "***** Test failed @ "
|
||||||
<< error.GetFile() << ":" << error.GetLine() << std::endl
|
<< error.GetFile() << ":" << error.GetLine() << std::endl
|
||||||
<< error.GetMessage() << std::endl;
|
<< error.GetMessage() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::Error error)
|
catch (vtkm::cont::Error error)
|
||||||
{
|
{
|
||||||
std::cout << "***** Uncaught VTKm exception thrown." << std::endl
|
std::cout << "***** Uncaught VTKm exception thrown." << std::endl
|
||||||
<< error.GetMessage() << std::endl;
|
<< error.GetMessage() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cout << "***** Unidentified exception thrown." << std::endl;
|
std::cout << "***** Unidentified exception thrown." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -42,63 +42,62 @@ namespace vtkm {
|
|||||||
namespace cont {
|
namespace cont {
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
|
struct SortLess
|
||||||
{
|
{
|
||||||
struct SortLess
|
template<typename T>
|
||||||
|
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a,const T& b) const
|
||||||
{
|
{
|
||||||
template<typename T>
|
typedef typename vtkm::TypeTraits<T>::DimensionalityTag Dimensionality;
|
||||||
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a,const T& b) const
|
return this->compare(a,b,Dimensionality());
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
||||||
|
vtkm::TypeTraitsScalarTag) const
|
||||||
|
{
|
||||||
|
return a < b;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
||||||
|
vtkm::TypeTraitsVectorTag) const
|
||||||
|
{
|
||||||
|
enum {SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
|
||||||
|
bool valid = true;
|
||||||
|
for(unsigned int i=0; i < SIZE && valid; ++i)
|
||||||
{
|
{
|
||||||
typedef typename vtkm::TypeTraits<T>::DimensionalityTag Dimensionality;
|
valid = a[i] < b[i];
|
||||||
return this->compare(a,b,Dimensionality());
|
|
||||||
}
|
}
|
||||||
template<typename T>
|
return valid;
|
||||||
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
}
|
||||||
vtkm::TypeTraitsScalarTag) const
|
};
|
||||||
{
|
|
||||||
return a < b;
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
|
||||||
vtkm::TypeTraitsVectorTag) const
|
|
||||||
{
|
|
||||||
enum{SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
|
|
||||||
bool valid = true;
|
|
||||||
for(unsigned int i=0; i < SIZE && valid; ++i)
|
|
||||||
{
|
|
||||||
valid = a[i] < b[i];
|
|
||||||
}
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SortGreater
|
struct SortGreater
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a,const T& b) const
|
||||||
{
|
{
|
||||||
template<typename T>
|
typedef typename vtkm::TypeTraits<T>::DimensionalityTag Dimensionality;
|
||||||
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a,const T& b) const
|
return this->compare(a,b,Dimensionality());
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
||||||
|
vtkm::TypeTraitsScalarTag) const
|
||||||
|
{
|
||||||
|
return a > b;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
||||||
|
vtkm::TypeTraitsVectorTag) const
|
||||||
|
{
|
||||||
|
enum {SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
|
||||||
|
bool valid = true;
|
||||||
|
for(unsigned int i=0; i < SIZE && valid; ++i)
|
||||||
{
|
{
|
||||||
typedef typename vtkm::TypeTraits<T>::DimensionalityTag Dimensionality;
|
valid = a[i] > b[i];
|
||||||
return this->compare(a,b,Dimensionality());
|
|
||||||
}
|
}
|
||||||
template<typename T>
|
return valid;
|
||||||
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
}
|
||||||
vtkm::TypeTraitsScalarTag) const
|
};
|
||||||
{
|
|
||||||
return a > b;
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
|
||||||
vtkm::TypeTraitsVectorTag) const
|
|
||||||
{
|
|
||||||
enum{SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
|
|
||||||
bool valid = true;
|
|
||||||
for(unsigned int i=0; i < SIZE && valid; ++i)
|
|
||||||
{
|
|
||||||
valid = a[i] > b[i];
|
|
||||||
}
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ERROR_MESSAGE "Got an error."
|
#define ERROR_MESSAGE "Got an error."
|
||||||
@ -213,9 +212,9 @@ public:
|
|||||||
VTKM_EXEC_EXPORT void operator()(vtkm::Id index) const
|
VTKM_EXEC_EXPORT void operator()(vtkm::Id index) const
|
||||||
{
|
{
|
||||||
if (index == ARRAY_SIZE/2)
|
if (index == ARRAY_SIZE/2)
|
||||||
{
|
{
|
||||||
this->ErrorMessage.RaiseError(ERROR_MESSAGE);
|
this->ErrorMessage.RaiseError(ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT void SetErrorMessageBuffer(
|
VTKM_CONT_EXPORT void SetErrorMessageBuffer(
|
||||||
@ -282,21 +281,21 @@ public:
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
VTKM_EXEC_EXPORT T operator()(T a, T b) const
|
VTKM_EXEC_EXPORT T operator()(T a, T b) const
|
||||||
{
|
{
|
||||||
return a * b;
|
return a * b;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NGNoOp //: public vtkm::exec::WorkletMapField
|
struct NGNoOp //: public vtkm::exec::WorkletMapField
|
||||||
{
|
{
|
||||||
// typedef void ControlSignature(Field(In), Field(Out));
|
// typedef void ControlSignature(Field(In), Field(Out));
|
||||||
// typedef _2 ExecutionSignature(_1);
|
// typedef _2 ExecutionSignature(_1);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
VTKM_EXEC_EXPORT T operator()(T a) const
|
VTKM_EXEC_EXPORT T operator()(T a) const
|
||||||
{
|
{
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FuseAll
|
struct FuseAll
|
||||||
@ -318,8 +317,8 @@ private:
|
|||||||
MakeArrayHandle(const T *array, vtkm::Id length)
|
MakeArrayHandle(const T *array, vtkm::Id length)
|
||||||
{
|
{
|
||||||
return vtkm::cont::make_ArrayHandle(array,
|
return vtkm::cont::make_ArrayHandle(array,
|
||||||
length,
|
length,
|
||||||
ArrayContainerControlTagBasic());
|
ArrayContainerControlTagBasic());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -328,7 +327,7 @@ private:
|
|||||||
MakeArrayHandle(const std::vector<T>& array)
|
MakeArrayHandle(const std::vector<T>& array)
|
||||||
{
|
{
|
||||||
return vtkm::cont::make_ArrayHandle(array,
|
return vtkm::cont::make_ArrayHandle(array,
|
||||||
ArrayContainerControlTagBasic());
|
ArrayContainerControlTagBasic());
|
||||||
}
|
}
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void TestDeviceAdapterTag()
|
static VTKM_CONT_EXPORT void TestDeviceAdapterTag()
|
||||||
@ -341,9 +340,9 @@ private:
|
|||||||
vtkm::cont::DeviceAdapterTagError> ErrorTraits;
|
vtkm::cont::DeviceAdapterTagError> ErrorTraits;
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(Traits::GetId() == Traits::GetId(),
|
VTKM_TEST_ASSERT(Traits::GetId() == Traits::GetId(),
|
||||||
"Device adapter Id does not equal itself.");
|
"Device adapter Id does not equal itself.");
|
||||||
VTKM_TEST_ASSERT(Traits::GetId() != ErrorTraits::GetId(),
|
VTKM_TEST_ASSERT(Traits::GetId() != ErrorTraits::GetId(),
|
||||||
"Device adapter Id not distinguishable from others.");
|
"Device adapter Id not distinguishable from others.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: this test does not actually test to make sure the data is available
|
// Note: this test does not actually test to make sure the data is available
|
||||||
@ -362,9 +361,9 @@ private:
|
|||||||
// Create original input array.
|
// Create original input array.
|
||||||
vtkm::Scalar inputArray[ARRAY_SIZE*2];
|
vtkm::Scalar inputArray[ARRAY_SIZE*2];
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE*2; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE*2; index++)
|
||||||
{
|
{
|
||||||
inputArray[index] = index;
|
inputArray[index] = index;
|
||||||
}
|
}
|
||||||
::vtkm::cont::internal::ArrayPortalFromIterators<vtkm::Scalar *>
|
::vtkm::cont::internal::ArrayPortalFromIterators<vtkm::Scalar *>
|
||||||
inputPortal(inputArray, inputArray+ARRAY_SIZE*2);
|
inputPortal(inputArray, inputArray+ARRAY_SIZE*2);
|
||||||
ArrayManagerExecution inputManager;
|
ArrayManagerExecution inputManager;
|
||||||
@ -380,10 +379,10 @@ private:
|
|||||||
|
|
||||||
// Check array.
|
// Check array.
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(outputArray[index] == index,
|
VTKM_TEST_ASSERT(outputArray[index] == index,
|
||||||
"Did not get correct values from array.");
|
"Did not get correct values from array.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void TestOutOfMemory()
|
static VTKM_CONT_EXPORT void TestOutOfMemory()
|
||||||
@ -395,7 +394,7 @@ private:
|
|||||||
std::cout << "-------------------------------------------" << std::endl;
|
std::cout << "-------------------------------------------" << std::endl;
|
||||||
std::cout << "Testing Out of Memory" << std::endl;
|
std::cout << "Testing Out of Memory" << std::endl;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::cout << "Do array allocation that should fail." << std::endl;
|
std::cout << "Do array allocation that should fail." << std::endl;
|
||||||
vtkm::cont::internal::ArrayManagerExecution<
|
vtkm::cont::internal::ArrayManagerExecution<
|
||||||
vtkm::Vector4,ArrayContainerControlTagBasic,DeviceAdapterTag>
|
vtkm::Vector4,ArrayContainerControlTagBasic,DeviceAdapterTag>
|
||||||
@ -406,41 +405,41 @@ private:
|
|||||||
bigManager.AllocateArrayForOutput(supportArray, bigSize);
|
bigManager.AllocateArrayForOutput(supportArray, bigSize);
|
||||||
// It does not seem reasonable to get here. The previous call should fail.
|
// It does not seem reasonable to get here. The previous call should fail.
|
||||||
VTKM_TEST_FAIL("A ridiculously sized allocation succeeded. Either there "
|
VTKM_TEST_FAIL("A ridiculously sized allocation succeeded. Either there "
|
||||||
"was a failure that was not reported but should have been "
|
"was a failure that was not reported but should have been "
|
||||||
"or the width of vtkm::Id is not large enough to express all "
|
"or the width of vtkm::Id is not large enough to express all "
|
||||||
"array sizes.");
|
"array sizes.");
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::ErrorControlOutOfMemory error)
|
catch (vtkm::cont::ErrorControlOutOfMemory error)
|
||||||
{
|
{
|
||||||
std::cout << "Got the expected error: " << error.GetMessage() << std::endl;
|
std::cout << "Got the expected error: " << error.GetMessage() << std::endl;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::cout << "--------- Skiping out of memory test" << std::endl;
|
std::cout << "--------- Skiping out of memory test" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// VTKM_CONT_EXPORT static void TestTimer()
|
// VTKM_CONT_EXPORT static void TestTimer()
|
||||||
// {
|
// {
|
||||||
// std::cout << "-------------------------------------------" << std::endl;
|
// std::cout << "-------------------------------------------" << std::endl;
|
||||||
// std::cout << "Testing Timer" << std::endl;
|
// std::cout << "Testing Timer" << std::endl;
|
||||||
|
|
||||||
// vtkm::cont::Timer<DeviceAdapterTag> timer;
|
// vtkm::cont::Timer<DeviceAdapterTag> timer;
|
||||||
|
|
||||||
// #ifndef _WIN32
|
// #ifndef _WIN32
|
||||||
// sleep(1);
|
// sleep(1);
|
||||||
// #else
|
// #else
|
||||||
// Sleep(1000);
|
// Sleep(1000);
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// vtkm::Scalar elapsedTime = timer.GetElapsedTime();
|
// vtkm::Scalar elapsedTime = timer.GetElapsedTime();
|
||||||
|
|
||||||
// std::cout << "Elapsed time: " << elapsedTime << std::endl;
|
// std::cout << "Elapsed time: " << elapsedTime << std::endl;
|
||||||
|
|
||||||
// VTKM_TEST_ASSERT(elapsedTime > 0.999,
|
// VTKM_TEST_ASSERT(elapsedTime > 0.999,
|
||||||
// "Timer did not capture full second wait.");
|
// "Timer did not capture full second wait.");
|
||||||
// VTKM_TEST_ASSERT(elapsedTime < 2.0,
|
// VTKM_TEST_ASSERT(elapsedTime < 2.0,
|
||||||
// "Timer counted too far or system really busy.");
|
// "Timer counted too far or system really busy.");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void TestAlgorithmSchedule()
|
static VTKM_CONT_EXPORT void TestAlgorithmSchedule()
|
||||||
{
|
{
|
||||||
@ -448,25 +447,25 @@ private:
|
|||||||
std::cout << "Testing single value Scheduling with vtkm::Id" << std::endl;
|
std::cout << "Testing single value Scheduling with vtkm::Id" << std::endl;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::cout << "Allocating execution array" << std::endl;
|
std::cout << "Allocating execution array" << std::endl;
|
||||||
IdContainer container;
|
IdContainer container;
|
||||||
IdArrayManagerExecution manager;
|
IdArrayManagerExecution manager;
|
||||||
manager.AllocateArrayForOutput(container, 1);
|
manager.AllocateArrayForOutput(container, 1);
|
||||||
|
|
||||||
std::cout << "Running clear." << std::endl;
|
std::cout << "Running clear." << std::endl;
|
||||||
Algorithm::Schedule(ClearArrayKernel(manager.GetPortal()), 1);
|
Algorithm::Schedule(ClearArrayKernel(manager.GetPortal()), 1);
|
||||||
|
|
||||||
std::cout << "Running add." << std::endl;
|
std::cout << "Running add." << std::endl;
|
||||||
Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), 1);
|
Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), 1);
|
||||||
|
|
||||||
std::cout << "Checking results." << std::endl;
|
std::cout << "Checking results." << std::endl;
|
||||||
manager.RetrieveOutputData(container);
|
manager.RetrieveOutputData(container);
|
||||||
|
|
||||||
for (vtkm::Id index = 0; index < 1; index++)
|
for (vtkm::Id index = 0; index < 1; index++)
|
||||||
{
|
{
|
||||||
vtkm::Scalar value = container.GetPortalConst().Get(index);
|
vtkm::Scalar value = container.GetPortalConst().Get(index);
|
||||||
VTKM_TEST_ASSERT(value == index + OFFSET,
|
VTKM_TEST_ASSERT(value == index + OFFSET,
|
||||||
"Got bad value for single value scheduled kernel.");
|
"Got bad value for single value scheduled kernel.");
|
||||||
}
|
}
|
||||||
} //release memory
|
} //release memory
|
||||||
|
|
||||||
@ -474,25 +473,25 @@ private:
|
|||||||
std::cout << "Testing Schedule with vtkm::Id" << std::endl;
|
std::cout << "Testing Schedule with vtkm::Id" << std::endl;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::cout << "Allocating execution array" << std::endl;
|
std::cout << "Allocating execution array" << std::endl;
|
||||||
IdContainer container;
|
IdContainer container;
|
||||||
IdArrayManagerExecution manager;
|
IdArrayManagerExecution manager;
|
||||||
manager.AllocateArrayForOutput(container, ARRAY_SIZE);
|
manager.AllocateArrayForOutput(container, ARRAY_SIZE);
|
||||||
|
|
||||||
std::cout << "Running clear." << std::endl;
|
std::cout << "Running clear." << std::endl;
|
||||||
Algorithm::Schedule(ClearArrayKernel(manager.GetPortal()), ARRAY_SIZE);
|
Algorithm::Schedule(ClearArrayKernel(manager.GetPortal()), ARRAY_SIZE);
|
||||||
|
|
||||||
std::cout << "Running add." << std::endl;
|
std::cout << "Running add." << std::endl;
|
||||||
Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), ARRAY_SIZE);
|
Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), ARRAY_SIZE);
|
||||||
|
|
||||||
std::cout << "Checking results." << std::endl;
|
std::cout << "Checking results." << std::endl;
|
||||||
manager.RetrieveOutputData(container);
|
manager.RetrieveOutputData(container);
|
||||||
|
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
vtkm::Id value = container.GetPortalConst().Get(index);
|
vtkm::Id value = container.GetPortalConst().Get(index);
|
||||||
VTKM_TEST_ASSERT(value == index + OFFSET,
|
VTKM_TEST_ASSERT(value == index + OFFSET,
|
||||||
"Got bad value for scheduled kernels.");
|
"Got bad value for scheduled kernels.");
|
||||||
}
|
}
|
||||||
} //release memory
|
} //release memory
|
||||||
|
|
||||||
@ -501,29 +500,29 @@ private:
|
|||||||
std::cout << "Testing Schedule with vtkm::Id3" << std::endl;
|
std::cout << "Testing Schedule with vtkm::Id3" << std::endl;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::cout << "Allocating execution array" << std::endl;
|
std::cout << "Allocating execution array" << std::endl;
|
||||||
IdContainer container;
|
IdContainer container;
|
||||||
IdArrayManagerExecution manager;
|
IdArrayManagerExecution manager;
|
||||||
vtkm::Id DIM_SIZE = std::pow(ARRAY_SIZE, 1/3.0f);
|
vtkm::Id DIM_SIZE = std::pow(ARRAY_SIZE, 1/3.0f);
|
||||||
manager.AllocateArrayForOutput(container,
|
manager.AllocateArrayForOutput(container,
|
||||||
DIM_SIZE * DIM_SIZE * DIM_SIZE);
|
DIM_SIZE * DIM_SIZE * DIM_SIZE);
|
||||||
vtkm::Id3 maxRange(DIM_SIZE);
|
vtkm::Id3 maxRange(DIM_SIZE);
|
||||||
|
|
||||||
std::cout << "Running clear." << std::endl;
|
std::cout << "Running clear." << std::endl;
|
||||||
Algorithm::Schedule(ClearArrayKernel(manager.GetPortal()), maxRange);
|
Algorithm::Schedule(ClearArrayKernel(manager.GetPortal()), maxRange);
|
||||||
|
|
||||||
std::cout << "Running add." << std::endl;
|
std::cout << "Running add." << std::endl;
|
||||||
Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), maxRange);
|
Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), maxRange);
|
||||||
|
|
||||||
std::cout << "Checking results." << std::endl;
|
std::cout << "Checking results." << std::endl;
|
||||||
manager.RetrieveOutputData(container);
|
manager.RetrieveOutputData(container);
|
||||||
|
|
||||||
const vtkm::Id maxId = DIM_SIZE * DIM_SIZE * DIM_SIZE;
|
const vtkm::Id maxId = DIM_SIZE * DIM_SIZE * DIM_SIZE;
|
||||||
for (vtkm::Id index = 0; index < maxId; index++)
|
for (vtkm::Id index = 0; index < maxId; index++)
|
||||||
{
|
{
|
||||||
vtkm::Id value = container.GetPortalConst().Get(index);
|
vtkm::Id value = container.GetPortalConst().Get(index);
|
||||||
VTKM_TEST_ASSERT(value == index + OFFSET,
|
VTKM_TEST_ASSERT(value == index + OFFSET,
|
||||||
"Got bad value for scheduled vtkm::Id3 kernels.");
|
"Got bad value for scheduled vtkm::Id3 kernels.");
|
||||||
}
|
}
|
||||||
} //release memory
|
} //release memory
|
||||||
}
|
}
|
||||||
@ -642,14 +641,14 @@ private:
|
|||||||
|
|
||||||
Algorithm::StreamCompact(array, result);
|
Algorithm::StreamCompact(array, result);
|
||||||
VTKM_TEST_ASSERT(result.GetNumberOfValues() == array.GetNumberOfValues()/2,
|
VTKM_TEST_ASSERT(result.GetNumberOfValues() == array.GetNumberOfValues()/2,
|
||||||
"result of compacation has an incorrect size");
|
"result of compacation has an incorrect size");
|
||||||
|
|
||||||
for (vtkm::Id index = 0; index < result.GetNumberOfValues(); index++)
|
for (vtkm::Id index = 0; index < result.GetNumberOfValues(); index++)
|
||||||
{
|
{
|
||||||
const vtkm::Id value = result.GetPortalConstControl().Get(index);
|
const vtkm::Id value = result.GetPortalConstControl().Get(index);
|
||||||
VTKM_TEST_ASSERT(value == (index*2)+1,
|
VTKM_TEST_ASSERT(value == (index*2)+1,
|
||||||
"Incorrect value in compaction results.");
|
"Incorrect value in compaction results.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void TestStreamCompactWithStencil()
|
static VTKM_CONT_EXPORT void TestStreamCompactWithStencil()
|
||||||
@ -673,14 +672,14 @@ private:
|
|||||||
|
|
||||||
Algorithm::StreamCompact(array,stencil,result);
|
Algorithm::StreamCompact(array,stencil,result);
|
||||||
VTKM_TEST_ASSERT(result.GetNumberOfValues() == array.GetNumberOfValues()/2,
|
VTKM_TEST_ASSERT(result.GetNumberOfValues() == array.GetNumberOfValues()/2,
|
||||||
"result of compacation has an incorrect size");
|
"result of compacation has an incorrect size");
|
||||||
|
|
||||||
for (vtkm::Id index = 0; index < result.GetNumberOfValues(); index++)
|
for (vtkm::Id index = 0; index < result.GetNumberOfValues(); index++)
|
||||||
{
|
{
|
||||||
const vtkm::Id value = result.GetPortalConstControl().Get(index);
|
const vtkm::Id value = result.GetPortalConstControl().Get(index);
|
||||||
VTKM_TEST_ASSERT(value == (OFFSET + (index*2)+1),
|
VTKM_TEST_ASSERT(value == (OFFSET + (index*2)+1),
|
||||||
"Incorrect value in compaction result.");
|
"Incorrect value in compaction result.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void TestOrderedUniqueValues()
|
static VTKM_CONT_EXPORT void TestOrderedUniqueValues()
|
||||||
@ -689,9 +688,9 @@ private:
|
|||||||
std::cout << "Testing Sort, Unique, LowerBounds and UpperBounds" << std::endl;
|
std::cout << "Testing Sort, Unique, LowerBounds and UpperBounds" << std::endl;
|
||||||
vtkm::Id testData[ARRAY_SIZE];
|
vtkm::Id testData[ARRAY_SIZE];
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
testData[i]= OFFSET+(i % 50);
|
testData[i]= OFFSET+(i % 50);
|
||||||
}
|
}
|
||||||
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
||||||
|
|
||||||
IdArrayHandle handle;
|
IdArrayHandle handle;
|
||||||
@ -714,12 +713,12 @@ private:
|
|||||||
"Unique did not resize array (or size did not copy to control).");
|
"Unique did not resize array (or size did not copy to control).");
|
||||||
|
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
vtkm::Id value = handle.GetPortalConstControl().Get(i);
|
vtkm::Id value = handle.GetPortalConstControl().Get(i);
|
||||||
vtkm::Id value1 = handle1.GetPortalConstControl().Get(i);
|
vtkm::Id value1 = handle1.GetPortalConstControl().Get(i);
|
||||||
VTKM_TEST_ASSERT(value == i % 50, "Got bad value (LowerBounds)");
|
VTKM_TEST_ASSERT(value == i % 50, "Got bad value (LowerBounds)");
|
||||||
VTKM_TEST_ASSERT(value1 >= i % 50, "Got bad value (UpperBounds)");
|
VTKM_TEST_ASSERT(value1 >= i % 50, "Got bad value (UpperBounds)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Testing Sort, Unique, LowerBounds and UpperBounds with random values"
|
std::cout << "Testing Sort, Unique, LowerBounds and UpperBounds with random values"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -737,22 +736,22 @@ private:
|
|||||||
input = MakeArrayHandle(randomData, RANDOMDATA_SIZE);
|
input = MakeArrayHandle(randomData, RANDOMDATA_SIZE);
|
||||||
Algorithm::Copy(input,handle);
|
Algorithm::Copy(input,handle);
|
||||||
VTKM_TEST_ASSERT(handle.GetNumberOfValues() == RANDOMDATA_SIZE,
|
VTKM_TEST_ASSERT(handle.GetNumberOfValues() == RANDOMDATA_SIZE,
|
||||||
"Handle incorrect size after setting new control data");
|
"Handle incorrect size after setting new control data");
|
||||||
|
|
||||||
Algorithm::Copy(input,handle1);
|
Algorithm::Copy(input,handle1);
|
||||||
VTKM_TEST_ASSERT(handle.GetNumberOfValues() == RANDOMDATA_SIZE,
|
VTKM_TEST_ASSERT(handle.GetNumberOfValues() == RANDOMDATA_SIZE,
|
||||||
"Handle incorrect size after setting new control data");
|
"Handle incorrect size after setting new control data");
|
||||||
|
|
||||||
Algorithm::Copy(handle,temp);
|
Algorithm::Copy(handle,temp);
|
||||||
VTKM_TEST_ASSERT(temp.GetNumberOfValues() == RANDOMDATA_SIZE,
|
VTKM_TEST_ASSERT(temp.GetNumberOfValues() == RANDOMDATA_SIZE,
|
||||||
"Copy failed");
|
"Copy failed");
|
||||||
Algorithm::Sort(temp);
|
Algorithm::Sort(temp);
|
||||||
Algorithm::Unique(temp);
|
Algorithm::Unique(temp);
|
||||||
Algorithm::LowerBounds(temp,handle);
|
Algorithm::LowerBounds(temp,handle);
|
||||||
Algorithm::UpperBounds(temp,handle1);
|
Algorithm::UpperBounds(temp,handle1);
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(handle.GetNumberOfValues() == RANDOMDATA_SIZE,
|
VTKM_TEST_ASSERT(handle.GetNumberOfValues() == RANDOMDATA_SIZE,
|
||||||
"LowerBounds returned incorrect size");
|
"LowerBounds returned incorrect size");
|
||||||
|
|
||||||
std::copy(handle.GetPortalConstControl().GetIteratorBegin(),
|
std::copy(handle.GetPortalConstControl().GetIteratorBegin(),
|
||||||
handle.GetPortalConstControl().GetIteratorEnd(),
|
handle.GetPortalConstControl().GetIteratorEnd(),
|
||||||
@ -765,7 +764,7 @@ private:
|
|||||||
VTKM_TEST_ASSERT(randomData[5] == 3, "Got bad value - LowerBounds");
|
VTKM_TEST_ASSERT(randomData[5] == 3, "Got bad value - LowerBounds");
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(handle1.GetNumberOfValues() == RANDOMDATA_SIZE,
|
VTKM_TEST_ASSERT(handle1.GetNumberOfValues() == RANDOMDATA_SIZE,
|
||||||
"UppererBounds returned incorrect size");
|
"UppererBounds returned incorrect size");
|
||||||
|
|
||||||
std::copy(handle1.GetPortalConstControl().GetIteratorBegin(),
|
std::copy(handle1.GetPortalConstControl().GetIteratorBegin(),
|
||||||
handle1.GetPortalConstControl().GetIteratorEnd(),
|
handle1.GetPortalConstControl().GetIteratorEnd(),
|
||||||
@ -784,9 +783,9 @@ private:
|
|||||||
std::cout << "Sort with comparison object" << std::endl;
|
std::cout << "Sort with comparison object" << std::endl;
|
||||||
vtkm::Id testData[ARRAY_SIZE];
|
vtkm::Id testData[ARRAY_SIZE];
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
testData[i]= OFFSET+((ARRAY_SIZE-i) % 50);
|
testData[i]= OFFSET+((ARRAY_SIZE-i) % 50);
|
||||||
}
|
}
|
||||||
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
||||||
|
|
||||||
IdArrayHandle sorted;
|
IdArrayHandle sorted;
|
||||||
@ -799,34 +798,34 @@ private:
|
|||||||
Algorithm::Sort(sorted);
|
Algorithm::Sort(sorted);
|
||||||
|
|
||||||
for (vtkm::Id i = 0; i < ARRAY_SIZE-1; ++i)
|
for (vtkm::Id i = 0; i < ARRAY_SIZE-1; ++i)
|
||||||
{
|
{
|
||||||
vtkm::Id sorted1 = sorted.GetPortalConstControl().Get(i);
|
vtkm::Id sorted1 = sorted.GetPortalConstControl().Get(i);
|
||||||
vtkm::Id sorted2 = sorted.GetPortalConstControl().Get(i+1);
|
vtkm::Id sorted2 = sorted.GetPortalConstControl().Get(i+1);
|
||||||
// std::cout << sorted1 << " <= " << sorted2 << std::endl;
|
// std::cout << sorted1 << " <= " << sorted2 << std::endl;
|
||||||
VTKM_TEST_ASSERT(sorted1 <= sorted2, "Values not properly sorted.");
|
VTKM_TEST_ASSERT(sorted1 <= sorted2, "Values not properly sorted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Validate the sort, and SortGreater are inverse
|
//Validate the sort, and SortGreater are inverse
|
||||||
Algorithm::Sort(comp_sorted,SortGreater());
|
Algorithm::Sort(comp_sorted,SortGreater());
|
||||||
|
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
vtkm::Id sorted1 = sorted.GetPortalConstControl().Get(i);
|
vtkm::Id sorted1 = sorted.GetPortalConstControl().Get(i);
|
||||||
vtkm::Id sorted2 = comp_sorted.GetPortalConstControl().Get(ARRAY_SIZE - (i + 1));
|
vtkm::Id sorted2 = comp_sorted.GetPortalConstControl().Get(ARRAY_SIZE - (i + 1));
|
||||||
// std::cout << sorted1 << "==" << sorted2 << std::endl;
|
// std::cout << sorted1 << "==" << sorted2 << std::endl;
|
||||||
VTKM_TEST_ASSERT(sorted1 == sorted2,
|
VTKM_TEST_ASSERT(sorted1 == sorted2,
|
||||||
"Got bad sort values when using SortGreater");
|
"Got bad sort values when using SortGreater");
|
||||||
}
|
}
|
||||||
|
|
||||||
Algorithm::Sort(comp_sorted,SortLess());
|
Algorithm::Sort(comp_sorted,SortLess());
|
||||||
|
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
vtkm::Id sorted1 = sorted.GetPortalConstControl().Get(i);
|
vtkm::Id sorted1 = sorted.GetPortalConstControl().Get(i);
|
||||||
vtkm::Id sorted2 = comp_sorted.GetPortalConstControl().Get(i);
|
vtkm::Id sorted2 = comp_sorted.GetPortalConstControl().Get(i);
|
||||||
VTKM_TEST_ASSERT(sorted1 == sorted2,
|
VTKM_TEST_ASSERT(sorted1 == sorted2,
|
||||||
"Got bad sort values when using SortLesser");
|
"Got bad sort values when using SortLesser");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static VTKM_CONT_EXPORT void TestSortByKey()
|
// static VTKM_CONT_EXPORT void TestSortByKey()
|
||||||
@ -906,9 +905,9 @@ private:
|
|||||||
std::cout << "Testing LowerBounds with comparison object" << std::endl;
|
std::cout << "Testing LowerBounds with comparison object" << std::endl;
|
||||||
vtkm::Id testData[ARRAY_SIZE];
|
vtkm::Id testData[ARRAY_SIZE];
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
testData[i]= OFFSET+(i % 50);
|
testData[i]= OFFSET+(i % 50);
|
||||||
}
|
}
|
||||||
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
||||||
|
|
||||||
IdArrayHandle temp;
|
IdArrayHandle temp;
|
||||||
@ -929,10 +928,10 @@ private:
|
|||||||
"Unique did not resize array (or size did not copy to control).");
|
"Unique did not resize array (or size did not copy to control).");
|
||||||
|
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
vtkm::Id value = handle.GetPortalConstControl().Get(i);
|
vtkm::Id value = handle.GetPortalConstControl().Get(i);
|
||||||
VTKM_TEST_ASSERT(value == i % 50, "Got bad LowerBounds value with SortLess");
|
VTKM_TEST_ASSERT(value == i % 50, "Got bad LowerBounds value with SortLess");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -942,9 +941,9 @@ private:
|
|||||||
std::cout << "Testing UpperBounds with comparison object" << std::endl;
|
std::cout << "Testing UpperBounds with comparison object" << std::endl;
|
||||||
vtkm::Id testData[ARRAY_SIZE];
|
vtkm::Id testData[ARRAY_SIZE];
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
testData[i]= OFFSET+(i % 50);
|
testData[i]= OFFSET+(i % 50);
|
||||||
}
|
}
|
||||||
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
||||||
|
|
||||||
IdArrayHandle temp;
|
IdArrayHandle temp;
|
||||||
@ -965,10 +964,10 @@ private:
|
|||||||
"Unique did not resize array (or size did not copy to control).");
|
"Unique did not resize array (or size did not copy to control).");
|
||||||
|
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
vtkm::Id value = handle.GetPortalConstControl().Get(i);
|
vtkm::Id value = handle.GetPortalConstControl().Get(i);
|
||||||
VTKM_TEST_ASSERT(value == (i % 50)+1, "Got bad UpperBounds value with SortLess");
|
VTKM_TEST_ASSERT(value == (i % 50)+1, "Got bad UpperBounds value with SortLess");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void TestUniqueWithComparisonObject()
|
static VTKM_CONT_EXPORT void TestUniqueWithComparisonObject()
|
||||||
@ -977,9 +976,9 @@ private:
|
|||||||
std::cout << "Testing Unique with comparison object" << std::endl;
|
std::cout << "Testing Unique with comparison object" << std::endl;
|
||||||
vtkm::Id testData[ARRAY_SIZE];
|
vtkm::Id testData[ARRAY_SIZE];
|
||||||
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
for(vtkm::Id i=0; i < ARRAY_SIZE; ++i)
|
||||||
{
|
{
|
||||||
testData[i]= OFFSET+(i % 50);
|
testData[i]= OFFSET+(i % 50);
|
||||||
}
|
}
|
||||||
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
IdArrayHandle input = MakeArrayHandle(testData, ARRAY_SIZE);
|
||||||
|
|
||||||
IdArrayHandle temp;
|
IdArrayHandle temp;
|
||||||
@ -1008,28 +1007,28 @@ private:
|
|||||||
//construct the index array
|
//construct the index array
|
||||||
IdArrayHandle array;
|
IdArrayHandle array;
|
||||||
Algorithm::Schedule(
|
Algorithm::Schedule(
|
||||||
ClearArrayKernel(array.PrepareForOutput(ARRAY_SIZE,
|
ClearArrayKernel(array.PrepareForOutput(ARRAY_SIZE,
|
||||||
DeviceAdapterTag())),
|
DeviceAdapterTag())),
|
||||||
ARRAY_SIZE);
|
ARRAY_SIZE);
|
||||||
|
|
||||||
//we know have an array whose sum is equal to OFFSET * ARRAY_SIZE,
|
//we know have an array whose sum is equal to OFFSET * ARRAY_SIZE,
|
||||||
//let's validate that
|
//let's validate that
|
||||||
vtkm::Id sum = Algorithm::ScanInclusive(array, array);
|
vtkm::Id sum = Algorithm::ScanInclusive(array, array);
|
||||||
VTKM_TEST_ASSERT(sum == OFFSET * ARRAY_SIZE,
|
VTKM_TEST_ASSERT(sum == OFFSET * ARRAY_SIZE,
|
||||||
"Got bad sum from Inclusive Scan");
|
"Got bad sum from Inclusive Scan");
|
||||||
|
|
||||||
//each value should be equal to the Triangle Number of that index
|
//each value should be equal to the Triangle Number of that index
|
||||||
//ie 1, 3, 6, 10, 15, 21 ...
|
//ie 1, 3, 6, 10, 15, 21 ...
|
||||||
vtkm::Id partialSum = 0;
|
vtkm::Id partialSum = 0;
|
||||||
vtkm::Id triangleNumber = 0;
|
vtkm::Id triangleNumber = 0;
|
||||||
for(unsigned int i=0, pos=1; i < ARRAY_SIZE; ++i, ++pos)
|
for(unsigned int i=0, pos=1; i < ARRAY_SIZE; ++i, ++pos)
|
||||||
{
|
{
|
||||||
const vtkm::Id value = array.GetPortalConstControl().Get(i);
|
const vtkm::Id value = array.GetPortalConstControl().Get(i);
|
||||||
partialSum += value;
|
partialSum += value;
|
||||||
triangleNumber = ((pos*(pos+1))/2);
|
triangleNumber = ((pos*(pos+1))/2);
|
||||||
VTKM_TEST_ASSERT(partialSum == triangleNumber * OFFSET,
|
VTKM_TEST_ASSERT(partialSum == triangleNumber * OFFSET,
|
||||||
"Incorrect partial sum");
|
"Incorrect partial sum");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void TestScanExclusive()
|
static VTKM_CONT_EXPORT void TestScanExclusive()
|
||||||
@ -1040,29 +1039,29 @@ private:
|
|||||||
//construct the index array
|
//construct the index array
|
||||||
IdArrayHandle array;
|
IdArrayHandle array;
|
||||||
Algorithm::Schedule(
|
Algorithm::Schedule(
|
||||||
ClearArrayKernel(array.PrepareForOutput(ARRAY_SIZE,
|
ClearArrayKernel(array.PrepareForOutput(ARRAY_SIZE,
|
||||||
DeviceAdapterTag())),
|
DeviceAdapterTag())),
|
||||||
ARRAY_SIZE);
|
ARRAY_SIZE);
|
||||||
|
|
||||||
// we know have an array whose sum = (OFFSET * ARRAY_SIZE),
|
// we know have an array whose sum = (OFFSET * ARRAY_SIZE),
|
||||||
// let's validate that
|
// let's validate that
|
||||||
vtkm::Id sum = Algorithm::ScanExclusive(array, array);
|
vtkm::Id sum = Algorithm::ScanExclusive(array, array);
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(sum == (OFFSET * ARRAY_SIZE),
|
VTKM_TEST_ASSERT(sum == (OFFSET * ARRAY_SIZE),
|
||||||
"Got bad sum from Exclusive Scan");
|
"Got bad sum from Exclusive Scan");
|
||||||
|
|
||||||
//each value should be equal to the Triangle Number of that index
|
//each value should be equal to the Triangle Number of that index
|
||||||
//ie 0, 1, 3, 6, 10, 15, 21 ...
|
//ie 0, 1, 3, 6, 10, 15, 21 ...
|
||||||
vtkm::Id partialSum = 0;
|
vtkm::Id partialSum = 0;
|
||||||
vtkm::Id triangleNumber = 0;
|
vtkm::Id triangleNumber = 0;
|
||||||
for(unsigned int i=0, pos=0; i < ARRAY_SIZE; ++i, ++pos)
|
for(unsigned int i=0, pos=0; i < ARRAY_SIZE; ++i, ++pos)
|
||||||
{
|
{
|
||||||
const vtkm::Id value = array.GetPortalConstControl().Get(i);
|
const vtkm::Id value = array.GetPortalConstControl().Get(i);
|
||||||
partialSum += value;
|
partialSum += value;
|
||||||
triangleNumber = ((pos*(pos+1))/2);
|
triangleNumber = ((pos*(pos+1))/2);
|
||||||
VTKM_TEST_ASSERT(partialSum == triangleNumber * OFFSET,
|
VTKM_TEST_ASSERT(partialSum == triangleNumber * OFFSET,
|
||||||
"Incorrect partial sum");
|
"Incorrect partial sum");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void TestErrorExecution()
|
static VTKM_CONT_EXPORT void TestErrorExecution()
|
||||||
@ -1073,30 +1072,30 @@ private:
|
|||||||
std::cout << "Generating one error." << std::endl;
|
std::cout << "Generating one error." << std::endl;
|
||||||
std::string message;
|
std::string message;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Algorithm::Schedule(OneErrorKernel(), ARRAY_SIZE);
|
Algorithm::Schedule(OneErrorKernel(), ARRAY_SIZE);
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::ErrorExecution error)
|
catch (vtkm::cont::ErrorExecution error)
|
||||||
{
|
{
|
||||||
std::cout << "Got expected error: " << error.GetMessage() << std::endl;
|
std::cout << "Got expected error: " << error.GetMessage() << std::endl;
|
||||||
message = error.GetMessage();
|
message = error.GetMessage();
|
||||||
}
|
}
|
||||||
VTKM_TEST_ASSERT(message == ERROR_MESSAGE,
|
VTKM_TEST_ASSERT(message == ERROR_MESSAGE,
|
||||||
"Did not get expected error message.");
|
"Did not get expected error message.");
|
||||||
|
|
||||||
std::cout << "Generating lots of errors." << std::endl;
|
std::cout << "Generating lots of errors." << std::endl;
|
||||||
message = "";
|
message = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Algorithm::Schedule(AllErrorKernel(), ARRAY_SIZE);
|
Algorithm::Schedule(AllErrorKernel(), ARRAY_SIZE);
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::ErrorExecution error)
|
catch (vtkm::cont::ErrorExecution error)
|
||||||
{
|
{
|
||||||
std::cout << "Got expected error: " << error.GetMessage() << std::endl;
|
std::cout << "Got expected error: " << error.GetMessage() << std::endl;
|
||||||
message = error.GetMessage();
|
message = error.GetMessage();
|
||||||
}
|
}
|
||||||
VTKM_TEST_ASSERT(message == ERROR_MESSAGE,
|
VTKM_TEST_ASSERT(message == ERROR_MESSAGE,
|
||||||
"Did not get expected error message.");
|
"Did not get expected error message.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename GridType>
|
// template<typename GridType>
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
#include <vtkm/cont/testing/Testing.h>
|
#include <vtkm/cont/testing/Testing.h>
|
||||||
#include <vtkm/VectorTraits.h>
|
#include <vtkm/VectorTraits.h>
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
|
|
||||||
const vtkm::Id ARRAY_SIZE = 10;
|
const vtkm::Id ARRAY_SIZE = 10;
|
||||||
|
|
||||||
@ -44,9 +43,9 @@ struct TemplatedTests
|
|||||||
for (IteratorType iter = array.GetPortal().GetIteratorBegin();
|
for (IteratorType iter = array.GetPortal().GetIteratorBegin();
|
||||||
iter != array.GetPortal().GetIteratorEnd();
|
iter != array.GetPortal().GetIteratorEnd();
|
||||||
iter ++)
|
iter ++)
|
||||||
{
|
{
|
||||||
*iter = value;
|
*iter = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckContainer(ArrayContainerType &array, ValueType value)
|
bool CheckContainer(ArrayContainerType &array, ValueType value)
|
||||||
@ -54,13 +53,14 @@ struct TemplatedTests
|
|||||||
for (IteratorType iter = array.GetPortal().GetIteratorBegin();
|
for (IteratorType iter = array.GetPortal().GetIteratorBegin();
|
||||||
iter != array.GetPortal().GetIteratorEnd();
|
iter != array.GetPortal().GetIteratorEnd();
|
||||||
iter ++)
|
iter ++)
|
||||||
{
|
{
|
||||||
if (!test_equal(*iter, value)) return false;
|
if (!test_equal(*iter, value)) { return false; }
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename vtkm::VectorTraits<ValueType>::ComponentType STOLEN_ARRAY_VALUE() {
|
typename vtkm::VectorTraits<ValueType>::ComponentType STOLEN_ARRAY_VALUE()
|
||||||
|
{
|
||||||
return 4529;
|
return 4529;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,11 +78,11 @@ struct TemplatedTests
|
|||||||
SetContainer(stealMyArray, stolenArrayValue);
|
SetContainer(stealMyArray, stolenArrayValue);
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(stealMyArray.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(stealMyArray.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Array not properly allocated.");
|
"Array not properly allocated.");
|
||||||
// This call steals the array and prevents deallocation.
|
// This call steals the array and prevents deallocation.
|
||||||
stolenArray = stealMyArray.StealArray();
|
stolenArray = stealMyArray.StealArray();
|
||||||
VTKM_TEST_ASSERT(stealMyArray.GetNumberOfValues() == 0,
|
VTKM_TEST_ASSERT(stealMyArray.GetNumberOfValues() == 0,
|
||||||
"StealArray did not let go of array.");
|
"StealArray did not let go of array.");
|
||||||
|
|
||||||
return stolenArray;
|
return stolenArray;
|
||||||
}
|
}
|
||||||
@ -91,10 +91,10 @@ struct TemplatedTests
|
|||||||
ValueType stolenArrayValue = ValueType(STOLEN_ARRAY_VALUE());
|
ValueType stolenArrayValue = ValueType(STOLEN_ARRAY_VALUE());
|
||||||
|
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(stolenArray[index], stolenArrayValue),
|
VTKM_TEST_ASSERT(test_equal(stolenArray[index], stolenArrayValue),
|
||||||
"Stolen array did not retain values.");
|
"Stolen array did not retain values.");
|
||||||
}
|
}
|
||||||
delete[] stolenArray;
|
delete[] stolenArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,36 +102,36 @@ struct TemplatedTests
|
|||||||
{
|
{
|
||||||
ArrayContainerType arrayContainer;
|
ArrayContainerType arrayContainer;
|
||||||
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == 0,
|
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == 0,
|
||||||
"New array container not zero sized.");
|
"New array container not zero sized.");
|
||||||
|
|
||||||
arrayContainer.Allocate(ARRAY_SIZE);
|
arrayContainer.Allocate(ARRAY_SIZE);
|
||||||
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Array not properly allocated.");
|
"Array not properly allocated.");
|
||||||
|
|
||||||
const ValueType BASIC_ALLOC_VALUE = ValueType(548);
|
const ValueType BASIC_ALLOC_VALUE = ValueType(548);
|
||||||
SetContainer(arrayContainer, BASIC_ALLOC_VALUE);
|
SetContainer(arrayContainer, BASIC_ALLOC_VALUE);
|
||||||
VTKM_TEST_ASSERT(CheckContainer(arrayContainer, BASIC_ALLOC_VALUE),
|
VTKM_TEST_ASSERT(CheckContainer(arrayContainer, BASIC_ALLOC_VALUE),
|
||||||
"Array not holding value.");
|
"Array not holding value.");
|
||||||
|
|
||||||
arrayContainer.Allocate(ARRAY_SIZE * 2);
|
arrayContainer.Allocate(ARRAY_SIZE * 2);
|
||||||
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE * 2,
|
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE * 2,
|
||||||
"Array not reallocated correctly.");
|
"Array not reallocated correctly.");
|
||||||
|
|
||||||
arrayContainer.Shrink(ARRAY_SIZE);
|
arrayContainer.Shrink(ARRAY_SIZE);
|
||||||
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Array Shrnk failed to resize.");
|
"Array Shrnk failed to resize.");
|
||||||
|
|
||||||
arrayContainer.ReleaseResources();
|
arrayContainer.ReleaseResources();
|
||||||
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == 0,
|
VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == 0,
|
||||||
"Array not released correctly.");
|
"Array not released correctly.");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
arrayContainer.Shrink(ARRAY_SIZE);
|
arrayContainer.Shrink(ARRAY_SIZE);
|
||||||
VTKM_TEST_ASSERT(true==false,
|
VTKM_TEST_ASSERT(true==false,
|
||||||
"Array shrink do a larger size was possible. This can't be allowed.");
|
"Array shrink do a larger size was possible. This can't be allowed.");
|
||||||
}
|
}
|
||||||
catch(vtkm::cont::ErrorControlBadValue){}
|
catch(vtkm::cont::ErrorControlBadValue) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()()
|
void operator()()
|
||||||
|
@ -28,8 +28,7 @@
|
|||||||
|
|
||||||
#include <vtkm/VectorTraits.h>
|
#include <vtkm/VectorTraits.h>
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct TestImplicitContainer
|
struct TestImplicitContainer
|
||||||
@ -52,16 +51,18 @@ struct TestImplicitContainer
|
|||||||
VTKM_EXEC_CONT_EXPORT
|
VTKM_EXEC_CONT_EXPORT
|
||||||
ValueType Get(vtkm::Id vtkmNotUsed(index)) const
|
ValueType Get(vtkm::Id vtkmNotUsed(index)) const
|
||||||
{
|
{
|
||||||
return Temp;
|
return Temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
IteratorType GetIteratorBegin() const {
|
IteratorType GetIteratorBegin() const
|
||||||
|
{
|
||||||
return IteratorType(*this);
|
return IteratorType(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
IteratorType GetIteratorEnd() const {
|
IteratorType GetIteratorEnd() const
|
||||||
|
{
|
||||||
return IteratorType(*this, this->GetNumberOfValues());
|
return IteratorType(*this, this->GetNumberOfValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,45 +87,49 @@ struct TemplatedTests
|
|||||||
{
|
{
|
||||||
ArrayContainerType arrayContainer;
|
ArrayContainerType arrayContainer;
|
||||||
|
|
||||||
try{ arrayContainer.GetNumberOfValues();
|
try
|
||||||
|
{
|
||||||
|
arrayContainer.GetNumberOfValues();
|
||||||
VTKM_TEST_ASSERT(false == true,
|
VTKM_TEST_ASSERT(false == true,
|
||||||
"Implicit Container GetNumberOfValues method didn't throw error.");
|
"Implicit Container GetNumberOfValues method didn't throw error.");
|
||||||
}
|
}
|
||||||
catch(vtkm::cont::ErrorControlBadValue e){}
|
catch(vtkm::cont::ErrorControlBadValue e) {}
|
||||||
|
|
||||||
try{ arrayContainer.Allocate(ARRAY_SIZE);
|
|
||||||
VTKM_TEST_ASSERT(false == true,
|
|
||||||
"Implicit Container Allocate method didn't throw error.");
|
|
||||||
}
|
|
||||||
catch(vtkm::cont::ErrorControlBadValue e){}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
arrayContainer.Allocate(ARRAY_SIZE);
|
||||||
|
VTKM_TEST_ASSERT(false == true,
|
||||||
|
"Implicit Container Allocate method didn't throw error.");
|
||||||
|
}
|
||||||
|
catch(vtkm::cont::ErrorControlBadValue e) {}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
arrayContainer.Shrink(ARRAY_SIZE);
|
arrayContainer.Shrink(ARRAY_SIZE);
|
||||||
VTKM_TEST_ASSERT(true==false,
|
VTKM_TEST_ASSERT(true==false,
|
||||||
"Array shrink do a larger size was possible. This can't be allowed.");
|
"Array shrink do a larger size was possible. This can't be allowed.");
|
||||||
}
|
}
|
||||||
catch(vtkm::cont::ErrorControlBadValue){}
|
catch(vtkm::cont::ErrorControlBadValue) {}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
arrayContainer.ReleaseResources();
|
arrayContainer.ReleaseResources();
|
||||||
VTKM_TEST_ASSERT(true==false,
|
VTKM_TEST_ASSERT(true==false,
|
||||||
"Can't Release an implicit array");
|
"Can't Release an implicit array");
|
||||||
}
|
}
|
||||||
catch(vtkm::cont::ErrorControlBadValue){}
|
catch(vtkm::cont::ErrorControlBadValue) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicAccess()
|
void BasicAccess()
|
||||||
{
|
{
|
||||||
TestImplicitContainer<T> portal;
|
TestImplicitContainer<T> portal;
|
||||||
vtkm::cont::ArrayHandle<T,ContainerTagType> implictHandle(portal);
|
vtkm::cont::ArrayHandle<T,ContainerTagType> implictHandle(portal);
|
||||||
VTKM_TEST_ASSERT(implictHandle.GetNumberOfValues() == 1,
|
VTKM_TEST_ASSERT(implictHandle.GetNumberOfValues() == 1,
|
||||||
"handle should have size 1");
|
"handle should have size 1");
|
||||||
VTKM_TEST_ASSERT(implictHandle.GetPortalConstControl().Get(0) == T(1),
|
VTKM_TEST_ASSERT(implictHandle.GetPortalConstControl().Get(0) == T(1),
|
||||||
"portals first values should be 1");
|
"portals first values should be 1");
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()()
|
void operator()()
|
||||||
{
|
{
|
||||||
|
@ -29,8 +29,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const vtkm::Id ARRAY_SIZE = 10;
|
const vtkm::Id ARRAY_SIZE = 10;
|
||||||
|
|
||||||
vtkm::Scalar TestValue(vtkm::Id index)
|
vtkm::Scalar TestValue(vtkm::Id index)
|
||||||
@ -43,10 +42,10 @@ bool CheckValues(IteratorType begin, IteratorType end)
|
|||||||
{
|
{
|
||||||
vtkm::Id index = 0;
|
vtkm::Id index = 0;
|
||||||
for (IteratorType iter = begin; iter != end; iter++)
|
for (IteratorType iter = begin; iter != end; iter++)
|
||||||
{
|
{
|
||||||
if (!test_equal(*iter, TestValue(index))) return false;
|
if (!test_equal(*iter, TestValue(index))) { return false; }
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,9 +61,9 @@ void TestArrayHandle()
|
|||||||
std::cout << "Create array handle." << std::endl;
|
std::cout << "Create array handle." << std::endl;
|
||||||
vtkm::Scalar array[ARRAY_SIZE];
|
vtkm::Scalar array[ARRAY_SIZE];
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
array[index] = TestValue(index);
|
array[index] = TestValue(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Scalar>::PortalControl arrayPortal(
|
vtkm::cont::ArrayHandle<vtkm::Scalar>::PortalControl arrayPortal(
|
||||||
&array[0], &array[ARRAY_SIZE]);
|
&array[0], &array[ARRAY_SIZE]);
|
||||||
@ -73,11 +72,11 @@ void TestArrayHandle()
|
|||||||
arrayHandle(arrayPortal);
|
arrayHandle(arrayPortal);
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"ArrayHandle has wrong number of entries.");
|
"ArrayHandle has wrong number of entries.");
|
||||||
|
|
||||||
std::cout << "Check basic array." << std::endl;
|
std::cout << "Check basic array." << std::endl;
|
||||||
VTKM_TEST_ASSERT(CheckValues(arrayHandle),
|
VTKM_TEST_ASSERT(CheckValues(arrayHandle),
|
||||||
"Array values not set correctly.");
|
"Array values not set correctly.");
|
||||||
|
|
||||||
std::cout << "Check out execution array behavior." << std::endl;
|
std::cout << "Check out execution array behavior." << std::endl;
|
||||||
{
|
{
|
||||||
@ -86,73 +85,73 @@ void TestArrayHandle()
|
|||||||
executionPortal;
|
executionPortal;
|
||||||
executionPortal =
|
executionPortal =
|
||||||
arrayHandle.PrepareForInput(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
arrayHandle.PrepareForInput(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||||
VTKM_TEST_ASSERT(CheckValues(executionPortal.GetIteratorBegin(),
|
VTKM_TEST_ASSERT(CheckValues(executionPortal.GetIteratorBegin(),
|
||||||
executionPortal.GetIteratorEnd()),
|
executionPortal.GetIteratorEnd()),
|
||||||
"Array not copied to execution correctly.");
|
"Array not copied to execution correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
bool gotException = false;
|
bool gotException = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
arrayHandle.PrepareForInPlace(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
arrayHandle.PrepareForInPlace(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::Error &error)
|
catch (vtkm::cont::Error &error)
|
||||||
{
|
{
|
||||||
std::cout << "Got expected error: " << error.GetMessage() << std::endl;
|
std::cout << "Got expected error: " << error.GetMessage() << std::endl;
|
||||||
gotException = true;
|
gotException = true;
|
||||||
}
|
}
|
||||||
VTKM_TEST_ASSERT(gotException,
|
VTKM_TEST_ASSERT(gotException,
|
||||||
"PrepareForInPlace did not fail for const array.");
|
"PrepareForInPlace did not fail for const array.");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
vtkm::cont::ArrayHandle<vtkm::Scalar>::
|
vtkm::cont::ArrayHandle<vtkm::Scalar>::
|
||||||
ExecutionTypes<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Portal executionPortal;
|
ExecutionTypes<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Portal executionPortal;
|
||||||
executionPortal =
|
executionPortal =
|
||||||
arrayHandle.PrepareForOutput(ARRAY_SIZE*2,
|
arrayHandle.PrepareForOutput(ARRAY_SIZE*2,
|
||||||
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||||
vtkm::Id index = 0;
|
vtkm::Id index = 0;
|
||||||
for (vtkm::Scalar *iter = executionPortal.GetIteratorBegin();
|
for (vtkm::Scalar *iter = executionPortal.GetIteratorBegin();
|
||||||
iter != executionPortal.GetIteratorEnd();
|
iter != executionPortal.GetIteratorEnd();
|
||||||
iter++)
|
iter++)
|
||||||
{
|
{
|
||||||
*iter = TestValue(index);
|
*iter = TestValue(index);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE*2,
|
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE*2,
|
||||||
"Array not allocated correctly.");
|
"Array not allocated correctly.");
|
||||||
VTKM_TEST_ASSERT(CheckValues(arrayHandle),
|
VTKM_TEST_ASSERT(CheckValues(arrayHandle),
|
||||||
"Array values not retrieved from execution.");
|
"Array values not retrieved from execution.");
|
||||||
|
|
||||||
std::cout << "Try shrinking the array." << std::endl;
|
std::cout << "Try shrinking the array." << std::endl;
|
||||||
arrayHandle.Shrink(ARRAY_SIZE);
|
arrayHandle.Shrink(ARRAY_SIZE);
|
||||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Array size did not shrink correctly.");
|
"Array size did not shrink correctly.");
|
||||||
VTKM_TEST_ASSERT(CheckValues(arrayHandle),
|
VTKM_TEST_ASSERT(CheckValues(arrayHandle),
|
||||||
"Array values not retrieved from execution.");
|
"Array values not retrieved from execution.");
|
||||||
|
|
||||||
std::cout << "Try in place operation." << std::endl;
|
std::cout << "Try in place operation." << std::endl;
|
||||||
{
|
{
|
||||||
vtkm::cont::ArrayHandle<vtkm::Scalar>::
|
vtkm::cont::ArrayHandle<vtkm::Scalar>::
|
||||||
ExecutionTypes<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Portal executionPortal;
|
ExecutionTypes<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Portal executionPortal;
|
||||||
executionPortal =
|
executionPortal =
|
||||||
arrayHandle.PrepareForInPlace(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
arrayHandle.PrepareForInPlace(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||||
for (vtkm::Scalar *iter = executionPortal.GetIteratorBegin();
|
for (vtkm::Scalar *iter = executionPortal.GetIteratorBegin();
|
||||||
iter != executionPortal.GetIteratorEnd();
|
iter != executionPortal.GetIteratorEnd();
|
||||||
iter++)
|
iter++)
|
||||||
{
|
{
|
||||||
*iter += 1;
|
*iter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vtkm::cont::ArrayHandle<vtkm::Scalar>::PortalConstControl controlPortal =
|
vtkm::cont::ArrayHandle<vtkm::Scalar>::PortalConstControl controlPortal =
|
||||||
arrayHandle.GetPortalConstControl();
|
arrayHandle.GetPortalConstControl();
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(controlPortal.Get(index), TestValue(index) + 1),
|
VTKM_TEST_ASSERT(test_equal(controlPortal.Get(index), TestValue(index) + 1),
|
||||||
"Did not get result from in place operation.");
|
"Did not get result from in place operation.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,19 +36,19 @@ struct CountByTwo
|
|||||||
explicit CountByTwo(T t): Value(t) {}
|
explicit CountByTwo(T t): Value(t) {}
|
||||||
|
|
||||||
bool operator==(const T& other) const
|
bool operator==(const T& other) const
|
||||||
{ return Value == other; }
|
{ return Value == other; }
|
||||||
|
|
||||||
bool operator==(const CountByTwo<T>& other) const
|
bool operator==(const CountByTwo<T>& other) const
|
||||||
{ return Value == other.Value; }
|
{ return Value == other.Value; }
|
||||||
|
|
||||||
CountByTwo<T> operator+(vtkm::Id count) const
|
CountByTwo<T> operator+(vtkm::Id count) const
|
||||||
{ return CountByTwo<T>(Value+(count*2)); }
|
{ return CountByTwo<T>(Value+(count*2)); }
|
||||||
|
|
||||||
CountByTwo<T>& operator++()
|
CountByTwo<T>& operator++()
|
||||||
{ ++Value; ++Value; return *this; }
|
{ ++Value; ++Value; return *this; }
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream& os, const CountByTwo<T>& obj)
|
friend std::ostream& operator<< (std::ostream& os, const CountByTwo<T>& obj)
|
||||||
{ os << obj.Value; return os; }
|
{ os << obj.Value; return os; }
|
||||||
T Value;
|
T Value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,40 +60,40 @@ struct TemplatedTests
|
|||||||
typedef vtkm::cont::ArrayHandleCounting<ValueType> ArrayHandleType;
|
typedef vtkm::cont::ArrayHandleCounting<ValueType> ArrayHandleType;
|
||||||
|
|
||||||
typedef vtkm::cont::ArrayHandle<ValueType,
|
typedef vtkm::cont::ArrayHandle<ValueType,
|
||||||
typename vtkm::cont::internal::ArrayHandleCountingTraits<ValueType>::Tag>
|
typename vtkm::cont::internal::ArrayHandleCountingTraits<ValueType>::Tag>
|
||||||
ArrayHandleType2;
|
ArrayHandleType2;
|
||||||
|
|
||||||
typedef typename ArrayHandleType::PortalConstControl PortalType;
|
typedef typename ArrayHandleType::PortalConstControl PortalType;
|
||||||
|
|
||||||
void operator()( const ValueType startingValue )
|
void operator()( const ValueType startingValue )
|
||||||
{
|
{
|
||||||
ArrayHandleType arrayConst(startingValue, ARRAY_SIZE);
|
ArrayHandleType arrayConst(startingValue, ARRAY_SIZE);
|
||||||
|
|
||||||
ArrayHandleType arrayMake = vtkm::cont::make_ArrayHandleCounting(startingValue,ARRAY_SIZE);
|
ArrayHandleType arrayMake = vtkm::cont::make_ArrayHandleCounting(startingValue,ARRAY_SIZE);
|
||||||
|
|
||||||
ArrayHandleType2 arrayHandle =
|
ArrayHandleType2 arrayHandle =
|
||||||
ArrayHandleType2(PortalType(startingValue, ARRAY_SIZE));
|
ArrayHandleType2(PortalType(startingValue, ARRAY_SIZE));
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(arrayConst.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(arrayConst.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Counting array using constructor has wrong size.");
|
"Counting array using constructor has wrong size.");
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(arrayMake.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(arrayMake.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Counting array using make has wrong size.");
|
"Counting array using make has wrong size.");
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
||||||
"Counting array using raw array handle + tag has wrong size.");
|
"Counting array using raw array handle + tag has wrong size.");
|
||||||
|
|
||||||
ValueType properValue = startingValue;
|
ValueType properValue = startingValue;
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(arrayConst.GetPortalConstControl().Get(index) == properValue,
|
VTKM_TEST_ASSERT(arrayConst.GetPortalConstControl().Get(index) == properValue,
|
||||||
"Counting array using constructor has unexpected value.");
|
"Counting array using constructor has unexpected value.");
|
||||||
VTKM_TEST_ASSERT(arrayMake.GetPortalConstControl().Get(index) == properValue,
|
VTKM_TEST_ASSERT(arrayMake.GetPortalConstControl().Get(index) == properValue,
|
||||||
"Counting array using make has unexpected value.");
|
"Counting array using make has unexpected value.");
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(arrayHandle.GetPortalConstControl().Get(index) == properValue,
|
VTKM_TEST_ASSERT(arrayHandle.GetPortalConstControl().Get(index) == properValue,
|
||||||
"Counting array using raw array handle + tag has unexpected value.");
|
"Counting array using raw array handle + tag has unexpected value.");
|
||||||
++properValue;
|
++properValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -54,18 +54,18 @@ int UnitTestContTesting(int, char *[])
|
|||||||
{
|
{
|
||||||
std::cout << "-------\nThis call should fail." << std::endl;
|
std::cout << "-------\nThis call should fail." << std::endl;
|
||||||
if (vtkm::cont::testing::Testing::Run(TestFail) == 0)
|
if (vtkm::cont::testing::Testing::Run(TestFail) == 0)
|
||||||
{
|
{
|
||||||
std::cout << "Did not get expected fail!" << std::endl;
|
std::cout << "Did not get expected fail!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::cout << "-------\nThis call should fail." << std::endl;
|
std::cout << "-------\nThis call should fail." << std::endl;
|
||||||
if (vtkm::cont::testing::Testing::Run(BadTestAssert) == 0)
|
if (vtkm::cont::testing::Testing::Run(BadTestAssert) == 0)
|
||||||
{
|
{
|
||||||
std::cout << "Did not get expected fail!" << std::endl;
|
std::cout << "Did not get expected fail!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//VTKM_ASSERT_CONT only is a valid call when you are building with debug
|
//VTKM_ASSERT_CONT only is a valid call when you are building with debug
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
int expectedResult=0;
|
int expectedResult=0;
|
||||||
#else
|
#else
|
||||||
@ -74,10 +74,10 @@ int UnitTestContTesting(int, char *[])
|
|||||||
|
|
||||||
std::cout << "-------\nThis call should fail on debug builds." << std::endl;
|
std::cout << "-------\nThis call should fail on debug builds." << std::endl;
|
||||||
if (vtkm::cont::testing::Testing::Run(BadAssert) == expectedResult)
|
if (vtkm::cont::testing::Testing::Run(BadAssert) == expectedResult)
|
||||||
{
|
{
|
||||||
std::cout << "Did not get expected fail!" << std::endl;
|
std::cout << "Did not get expected fail!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "-------\nThis call should pass." << std::endl;
|
std::cout << "-------\nThis call should pass." << std::endl;
|
||||||
// This is what your main function typically looks like.
|
// This is what your main function typically looks like.
|
||||||
|
@ -57,14 +57,14 @@ public:
|
|||||||
|
|
||||||
template<class Functor>
|
template<class Functor>
|
||||||
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
||||||
vtkm::Id numInstances)
|
vtkm::Id numInstances)
|
||||||
{
|
{
|
||||||
Algorithm::Schedule(functor, numInstances);
|
Algorithm::Schedule(functor, numInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Functor>
|
template<class Functor>
|
||||||
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
VTKM_CONT_EXPORT static void Schedule(Functor functor,
|
||||||
vtkm::Id3 rangeMax)
|
vtkm::Id3 rangeMax)
|
||||||
{
|
{
|
||||||
Algorithm::Schedule(functor, rangeMax);
|
Algorithm::Schedule(functor, rangeMax);
|
||||||
}
|
}
|
||||||
|
@ -60,10 +60,10 @@ public:
|
|||||||
|
|
||||||
// Safely copy message into array.
|
// Safely copy message into array.
|
||||||
for (vtkm::Id index = 0; index < this->MessageBufferSize; index++)
|
for (vtkm::Id index = 0; index < this->MessageBufferSize; index++)
|
||||||
{
|
{
|
||||||
this->MessageBuffer[index] = message[index];
|
this->MessageBuffer[index] = message[index];
|
||||||
if (message[index] == '\0') { break; }
|
if (message[index] == '\0') { break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure message is null terminated.
|
// Make sure message is null terminated.
|
||||||
this->MessageBuffer[this->MessageBufferSize-1] = '\0';
|
this->MessageBuffer[this->MessageBufferSize-1] = '\0';
|
||||||
@ -72,14 +72,14 @@ public:
|
|||||||
VTKM_EXEC_CONT_EXPORT bool IsErrorRaised() const
|
VTKM_EXEC_CONT_EXPORT bool IsErrorRaised() const
|
||||||
{
|
{
|
||||||
if (this->MessageBufferSize > 0)
|
if (this->MessageBufferSize > 0)
|
||||||
{
|
{
|
||||||
return (this->MessageBuffer[0] != '\0');
|
return (this->MessageBuffer[0] != '\0');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If there is no buffer set, then always report an error.
|
// If there is no buffer set, then always report an error.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -40,13 +40,13 @@ namespace {
|
|||||||
void TestTypeSizes()
|
void TestTypeSizes()
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(VTKM_SIZE_ID == EXPECTED_SIZE,
|
VTKM_TEST_ASSERT(VTKM_SIZE_ID == EXPECTED_SIZE,
|
||||||
"VTKM_SIZE_ID an unexpected size.");
|
"VTKM_SIZE_ID an unexpected size.");
|
||||||
VTKM_TEST_ASSERT(sizeof(vtkm::Id) == EXPECTED_SIZE,
|
VTKM_TEST_ASSERT(sizeof(vtkm::Id) == EXPECTED_SIZE,
|
||||||
"vtkm::Id an unexpected size.");
|
"vtkm::Id an unexpected size.");
|
||||||
VTKM_TEST_ASSERT(VTKM_SIZE_SCALAR == EXPECTED_SIZE,
|
VTKM_TEST_ASSERT(VTKM_SIZE_SCALAR == EXPECTED_SIZE,
|
||||||
"VTKM_SIZE_SCALAR an unexpected size.");
|
"VTKM_SIZE_SCALAR an unexpected size.");
|
||||||
VTKM_TEST_ASSERT(sizeof(vtkm::Scalar) == EXPECTED_SIZE,
|
VTKM_TEST_ASSERT(sizeof(vtkm::Scalar) == EXPECTED_SIZE,
|
||||||
"vtkm::Scalar an unexpected size.");
|
"vtkm::Scalar an unexpected size.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,13 @@ namespace {
|
|||||||
void TestTypeSizes()
|
void TestTypeSizes()
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(VTKM_SIZE_ID == EXPECTED_SIZE,
|
VTKM_TEST_ASSERT(VTKM_SIZE_ID == EXPECTED_SIZE,
|
||||||
"VTKM_SIZE_ID an unexpected size.");
|
"VTKM_SIZE_ID an unexpected size.");
|
||||||
VTKM_TEST_ASSERT(sizeof(vtkm::Id) == EXPECTED_SIZE,
|
VTKM_TEST_ASSERT(sizeof(vtkm::Id) == EXPECTED_SIZE,
|
||||||
"vtkm::Id an unexpected size.");
|
"vtkm::Id an unexpected size.");
|
||||||
VTKM_TEST_ASSERT(VTKM_SIZE_SCALAR == EXPECTED_SIZE,
|
VTKM_TEST_ASSERT(VTKM_SIZE_SCALAR == EXPECTED_SIZE,
|
||||||
"VTKM_SIZE_SCALAR an unexpected size.");
|
"VTKM_SIZE_SCALAR an unexpected size.");
|
||||||
VTKM_TEST_ASSERT(sizeof(vtkm::Scalar) == EXPECTED_SIZE,
|
VTKM_TEST_ASSERT(sizeof(vtkm::Scalar) == EXPECTED_SIZE,
|
||||||
"vtkm::Scalar an unexpected size.");
|
"vtkm::Scalar an unexpected size.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -214,11 +214,11 @@
|
|||||||
#ifndef OPTIONPARSER_H_
|
#ifndef OPTIONPARSER_H_
|
||||||
#define OPTIONPARSER_H_
|
#define OPTIONPARSER_H_
|
||||||
|
|
||||||
namespace vtkm { namespace testing {
|
namespace vtkm {
|
||||||
|
namespace testing {
|
||||||
|
|
||||||
/** @brief The namespace of The Lean Mean C++ Option Parser. */
|
/** @brief The namespace of The Lean Mean C++ Option Parser. */
|
||||||
namespace option
|
namespace option {
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
@ -604,7 +604,7 @@ public:
|
|||||||
{
|
{
|
||||||
Option* p = this;
|
Option* p = this;
|
||||||
while (!p->isFirst())
|
while (!p->isFirst())
|
||||||
p = p->prev_;
|
{ p = p->prev_; }
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,7 +748,7 @@ public:
|
|||||||
* @ref desc, @ref name, @ref arg and @ref namelen.
|
* @ref desc, @ref name, @ref arg and @ref namelen.
|
||||||
*/
|
*/
|
||||||
Option() :
|
Option() :
|
||||||
desc(0), name(0), arg(0), namelen(0)
|
desc(0), name(0), arg(0), namelen(0)
|
||||||
{
|
{
|
||||||
prev_ = tag(this);
|
prev_ = tag(this);
|
||||||
next_ = tag(this);
|
next_ = tag(this);
|
||||||
@ -805,12 +805,12 @@ private:
|
|||||||
next_ = tag(this);
|
next_ = tag(this);
|
||||||
namelen = 0;
|
namelen = 0;
|
||||||
if (name == 0)
|
if (name == 0)
|
||||||
return;
|
{ return; }
|
||||||
namelen = 1;
|
namelen = 1;
|
||||||
if (name[0] != '-')
|
if (name[0] != '-')
|
||||||
return;
|
{ return; }
|
||||||
while (name[namelen] != 0 && name[namelen] != '=')
|
while (name[namelen] != 0 && name[namelen] != '=')
|
||||||
++namelen;
|
{ ++namelen; }
|
||||||
}
|
}
|
||||||
|
|
||||||
static Option* tag(Option* ptr)
|
static Option* tag(Option* ptr)
|
||||||
@ -895,9 +895,9 @@ struct Arg
|
|||||||
static ArgStatus Optional(const Option& option, bool)
|
static ArgStatus Optional(const Option& option, bool)
|
||||||
{
|
{
|
||||||
if (option.arg && option.name[option.namelen] != 0)
|
if (option.arg && option.name[option.namelen] != 0)
|
||||||
return ARG_OK;
|
{ return ARG_OK; }
|
||||||
else
|
else
|
||||||
return ARG_IGNORE;
|
{ return ARG_IGNORE; }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -940,7 +940,7 @@ struct Stats
|
|||||||
* @brief Creates a Stats object with counts set to 1 (for the sentinel element).
|
* @brief Creates a Stats object with counts set to 1 (for the sentinel element).
|
||||||
*/
|
*/
|
||||||
Stats() :
|
Stats() :
|
||||||
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -955,7 +955,7 @@ struct Stats
|
|||||||
*/
|
*/
|
||||||
Stats(bool gnu, const Descriptor usage[], int argc, const char** argv, int min_abbr_len = 0, //
|
Stats(bool gnu, const Descriptor usage[], int argc, const char** argv, int min_abbr_len = 0, //
|
||||||
bool single_minus_longopt = false) :
|
bool single_minus_longopt = false) :
|
||||||
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
||||||
{
|
{
|
||||||
add(gnu, usage, argc, argv, min_abbr_len, single_minus_longopt);
|
add(gnu, usage, argc, argv, min_abbr_len, single_minus_longopt);
|
||||||
}
|
}
|
||||||
@ -963,7 +963,7 @@ struct Stats
|
|||||||
//! @brief Stats(...) with non-const argv.
|
//! @brief Stats(...) with non-const argv.
|
||||||
Stats(bool gnu, const Descriptor usage[], int argc, char** argv, int min_abbr_len = 0, //
|
Stats(bool gnu, const Descriptor usage[], int argc, char** argv, int min_abbr_len = 0, //
|
||||||
bool single_minus_longopt = false) :
|
bool single_minus_longopt = false) :
|
||||||
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
||||||
{
|
{
|
||||||
add(gnu, usage, argc, (const char**) argv, min_abbr_len, single_minus_longopt);
|
add(gnu, usage, argc, (const char**) argv, min_abbr_len, single_minus_longopt);
|
||||||
}
|
}
|
||||||
@ -971,7 +971,7 @@ struct Stats
|
|||||||
//! @brief POSIX Stats(...) (gnu==false).
|
//! @brief POSIX Stats(...) (gnu==false).
|
||||||
Stats(const Descriptor usage[], int argc, const char** argv, int min_abbr_len = 0, //
|
Stats(const Descriptor usage[], int argc, const char** argv, int min_abbr_len = 0, //
|
||||||
bool single_minus_longopt = false) :
|
bool single_minus_longopt = false) :
|
||||||
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
||||||
{
|
{
|
||||||
add(false, usage, argc, argv, min_abbr_len, single_minus_longopt);
|
add(false, usage, argc, argv, min_abbr_len, single_minus_longopt);
|
||||||
}
|
}
|
||||||
@ -979,7 +979,7 @@ struct Stats
|
|||||||
//! @brief POSIX Stats(...) (gnu==false) with non-const argv.
|
//! @brief POSIX Stats(...) (gnu==false) with non-const argv.
|
||||||
Stats(const Descriptor usage[], int argc, char** argv, int min_abbr_len = 0, //
|
Stats(const Descriptor usage[], int argc, char** argv, int min_abbr_len = 0, //
|
||||||
bool single_minus_longopt = false) :
|
bool single_minus_longopt = false) :
|
||||||
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
buffer_max(1), options_max(1) // 1 more than necessary as sentinel
|
||||||
{
|
{
|
||||||
add(false, usage, argc, (const char**) argv, min_abbr_len, single_minus_longopt);
|
add(false, usage, argc, (const char**) argv, min_abbr_len, single_minus_longopt);
|
||||||
}
|
}
|
||||||
@ -1052,7 +1052,7 @@ public:
|
|||||||
* @brief Creates a new Parser.
|
* @brief Creates a new Parser.
|
||||||
*/
|
*/
|
||||||
Parser() :
|
Parser() :
|
||||||
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1062,7 +1062,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
Parser(bool gnu, const Descriptor usage[], int argc, const char** argv, Option options[], Option buffer[],
|
Parser(bool gnu, const Descriptor usage[], int argc, const char** argv, Option options[], Option buffer[],
|
||||||
int min_abbr_len = 0, bool single_minus_longopt = false, int bufmax = -1) :
|
int min_abbr_len = 0, bool single_minus_longopt = false, int bufmax = -1) :
|
||||||
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
||||||
{
|
{
|
||||||
parse(gnu, usage, argc, argv, options, buffer, min_abbr_len, single_minus_longopt, bufmax);
|
parse(gnu, usage, argc, argv, options, buffer, min_abbr_len, single_minus_longopt, bufmax);
|
||||||
}
|
}
|
||||||
@ -1070,7 +1070,7 @@ public:
|
|||||||
//! @brief Parser(...) with non-const argv.
|
//! @brief Parser(...) with non-const argv.
|
||||||
Parser(bool gnu, const Descriptor usage[], int argc, char** argv, Option options[], Option buffer[],
|
Parser(bool gnu, const Descriptor usage[], int argc, char** argv, Option options[], Option buffer[],
|
||||||
int min_abbr_len = 0, bool single_minus_longopt = false, int bufmax = -1) :
|
int min_abbr_len = 0, bool single_minus_longopt = false, int bufmax = -1) :
|
||||||
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
||||||
{
|
{
|
||||||
parse(gnu, usage, argc, (const char**) argv, options, buffer, min_abbr_len, single_minus_longopt, bufmax);
|
parse(gnu, usage, argc, (const char**) argv, options, buffer, min_abbr_len, single_minus_longopt, bufmax);
|
||||||
}
|
}
|
||||||
@ -1078,7 +1078,7 @@ public:
|
|||||||
//! @brief POSIX Parser(...) (gnu==false).
|
//! @brief POSIX Parser(...) (gnu==false).
|
||||||
Parser(const Descriptor usage[], int argc, const char** argv, Option options[], Option buffer[], int min_abbr_len = 0,
|
Parser(const Descriptor usage[], int argc, const char** argv, Option options[], Option buffer[], int min_abbr_len = 0,
|
||||||
bool single_minus_longopt = false, int bufmax = -1) :
|
bool single_minus_longopt = false, int bufmax = -1) :
|
||||||
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
||||||
{
|
{
|
||||||
parse(false, usage, argc, argv, options, buffer, min_abbr_len, single_minus_longopt, bufmax);
|
parse(false, usage, argc, argv, options, buffer, min_abbr_len, single_minus_longopt, bufmax);
|
||||||
}
|
}
|
||||||
@ -1086,7 +1086,7 @@ public:
|
|||||||
//! @brief POSIX Parser(...) (gnu==false) with non-const argv.
|
//! @brief POSIX Parser(...) (gnu==false) with non-const argv.
|
||||||
Parser(const Descriptor usage[], int argc, char** argv, Option options[], Option buffer[], int min_abbr_len = 0,
|
Parser(const Descriptor usage[], int argc, char** argv, Option options[], Option buffer[], int min_abbr_len = 0,
|
||||||
bool single_minus_longopt = false, int bufmax = -1) :
|
bool single_minus_longopt = false, int bufmax = -1) :
|
||||||
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
op_count(0), nonop_count(0), nonop_args(0), err(false)
|
||||||
{
|
{
|
||||||
parse(false, usage, argc, (const char**) argv, options, buffer, min_abbr_len, single_minus_longopt, bufmax);
|
parse(false, usage, argc, (const char**) argv, options, buffer, min_abbr_len, single_minus_longopt, bufmax);
|
||||||
}
|
}
|
||||||
@ -1279,7 +1279,7 @@ private:
|
|||||||
{
|
{
|
||||||
while (*st1 != 0)
|
while (*st1 != 0)
|
||||||
if (*st1++ != *st2++)
|
if (*st1++ != *st2++)
|
||||||
return false;
|
{ return false; }
|
||||||
return (*st2 == 0 || *st2 == '=');
|
return (*st2 == 0 || *st2 == '=');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1328,7 +1328,7 @@ private:
|
|||||||
static bool instr(char ch, const char* st)
|
static bool instr(char ch, const char* st)
|
||||||
{
|
{
|
||||||
while (*st != 0 && *st != ch)
|
while (*st != 0 && *st != ch)
|
||||||
++st;
|
{ ++st; }
|
||||||
return *st == ch;
|
return *st == ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1398,14 +1398,14 @@ public:
|
|||||||
* parsed Option.
|
* parsed Option.
|
||||||
*/
|
*/
|
||||||
CountOptionsAction(unsigned* buffer_max_) :
|
CountOptionsAction(unsigned* buffer_max_) :
|
||||||
buffer_max(buffer_max_)
|
buffer_max(buffer_max_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool perform(Option&)
|
bool perform(Option&)
|
||||||
{
|
{
|
||||||
if (*buffer_max == 0x7fffffff)
|
if (*buffer_max == 0x7fffffff)
|
||||||
return false; // overflow protection: don't accept number of options that doesn't fit signed int
|
{ return false; } // overflow protection: don't accept number of options that doesn't fit signed int
|
||||||
++*buffer_max;
|
++*buffer_max;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1431,12 +1431,12 @@ public:
|
|||||||
* @param bufmax_ number of slots in @c buffer_. @c -1 means "large enough".
|
* @param bufmax_ number of slots in @c buffer_. @c -1 means "large enough".
|
||||||
*/
|
*/
|
||||||
StoreOptionAction(Parser& parser_, Option options_[], Option buffer_[], int bufmax_) :
|
StoreOptionAction(Parser& parser_, Option options_[], Option buffer_[], int bufmax_) :
|
||||||
parser(parser_), options(options_), buffer(buffer_), bufmax(bufmax_)
|
parser(parser_), options(options_), buffer(buffer_), bufmax(bufmax_)
|
||||||
{
|
{
|
||||||
// find first empty slot in buffer (if any)
|
// find first empty slot in buffer (if any)
|
||||||
int bufidx = 0;
|
int bufidx = 0;
|
||||||
while ((bufmax < 0 || bufidx < bufmax) && buffer[bufidx])
|
while ((bufmax < 0 || bufidx < bufmax) && buffer[bufidx])
|
||||||
++bufidx;
|
{ ++bufidx; }
|
||||||
|
|
||||||
// set parser's optionCount
|
// set parser's optionCount
|
||||||
parser.op_count = bufidx;
|
parser.op_count = bufidx;
|
||||||
@ -1447,14 +1447,14 @@ public:
|
|||||||
if (bufmax < 0 || parser.op_count < bufmax)
|
if (bufmax < 0 || parser.op_count < bufmax)
|
||||||
{
|
{
|
||||||
if (parser.op_count == 0x7fffffff)
|
if (parser.op_count == 0x7fffffff)
|
||||||
return false; // overflow protection: don't accept number of options that doesn't fit signed int
|
{ return false; } // overflow protection: don't accept number of options that doesn't fit signed int
|
||||||
|
|
||||||
buffer[parser.op_count] = option;
|
buffer[parser.op_count] = option;
|
||||||
int idx = buffer[parser.op_count].desc->index;
|
int idx = buffer[parser.op_count].desc->index;
|
||||||
if (options[idx])
|
if (options[idx])
|
||||||
options[idx].append(buffer[parser.op_count]);
|
{ options[idx].append(buffer[parser.op_count]); }
|
||||||
else
|
else
|
||||||
options[idx] = buffer[parser.op_count];
|
{ options[idx] = buffer[parser.op_count]; }
|
||||||
++parser.op_count;
|
++parser.op_count;
|
||||||
}
|
}
|
||||||
return true; // NOTE: an option that is discarded because of a full buffer is not fatal
|
return true; // NOTE: an option that is discarded because of a full buffer is not fatal
|
||||||
@ -1490,7 +1490,7 @@ inline void Stats::add(bool gnu, const Descriptor usage[], int argc, const char*
|
|||||||
while (usage[i].shortopt != 0)
|
while (usage[i].shortopt != 0)
|
||||||
{
|
{
|
||||||
if (usage[i].index + 1 >= options_max)
|
if (usage[i].index + 1 >= options_max)
|
||||||
options_max = (usage[i].index + 1) + 1; // 1 more than necessary as sentinel
|
{ options_max = (usage[i].index + 1) + 1; } // 1 more than necessary as sentinel
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -1504,7 +1504,7 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
|
|||||||
{
|
{
|
||||||
// protect against NULL pointer
|
// protect against NULL pointer
|
||||||
if (args == 0)
|
if (args == 0)
|
||||||
numargs = 0;
|
{ numargs = 0; }
|
||||||
|
|
||||||
int nonops = 0;
|
int nonops = 0;
|
||||||
|
|
||||||
@ -1521,11 +1521,11 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
|
|||||||
++nonops;
|
++nonops;
|
||||||
++args;
|
++args;
|
||||||
if (numargs > 0)
|
if (numargs > 0)
|
||||||
--numargs;
|
{ --numargs; }
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
{ break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- terminates the option list. The -- itself is skipped.
|
// -- terminates the option list. The -- itself is skipped.
|
||||||
@ -1534,7 +1534,7 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
|
|||||||
shift(args, nonops);
|
shift(args, nonops);
|
||||||
++args;
|
++args;
|
||||||
if (numargs > 0)
|
if (numargs > 0)
|
||||||
--numargs;
|
{ --numargs; }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1565,55 +1565,56 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
|
|||||||
{
|
{
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while (usage[idx].longopt != 0 && !streq(usage[idx].longopt, longopt_name))
|
while (usage[idx].longopt != 0 && !streq(usage[idx].longopt, longopt_name))
|
||||||
++idx;
|
{ ++idx; }
|
||||||
|
|
||||||
if (usage[idx].longopt == 0 && min_abbr_len > 0) // if we should try to match abbreviated long options
|
if (usage[idx].longopt == 0 && min_abbr_len > 0) // if we should try to match abbreviated long options
|
||||||
{
|
{
|
||||||
int i1 = 0;
|
int i1 = 0;
|
||||||
while (usage[i1].longopt != 0 && !streqabbr(usage[i1].longopt, longopt_name, min_abbr_len))
|
while (usage[i1].longopt != 0 && !streqabbr(usage[i1].longopt, longopt_name, min_abbr_len))
|
||||||
++i1;
|
{ ++i1; }
|
||||||
if (usage[i1].longopt != 0)
|
if (usage[i1].longopt != 0)
|
||||||
{ // now test if the match is unambiguous by checking for another match
|
{
|
||||||
|
// now test if the match is unambiguous by checking for another match
|
||||||
int i2 = i1 + 1;
|
int i2 = i1 + 1;
|
||||||
while (usage[i2].longopt != 0 && !streqabbr(usage[i2].longopt, longopt_name, min_abbr_len))
|
while (usage[i2].longopt != 0 && !streqabbr(usage[i2].longopt, longopt_name, min_abbr_len))
|
||||||
++i2;
|
{ ++i2; }
|
||||||
|
|
||||||
if (usage[i2].longopt == 0) // if there was no second match it's unambiguous, so accept i1 as idx
|
if (usage[i2].longopt == 0) // if there was no second match it's unambiguous, so accept i1 as idx
|
||||||
idx = i1;
|
{ idx = i1; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we found something, disable handle_short_options (only relevant if single_minus_longopt)
|
// if we found something, disable handle_short_options (only relevant if single_minus_longopt)
|
||||||
if (usage[idx].longopt != 0)
|
if (usage[idx].longopt != 0)
|
||||||
handle_short_options = false;
|
{ handle_short_options = false; }
|
||||||
|
|
||||||
try_single_minus_longopt = false; // prevent looking for longopt in the middle of shortopt group
|
try_single_minus_longopt = false; // prevent looking for longopt in the middle of shortopt group
|
||||||
|
|
||||||
optarg = longopt_name;
|
optarg = longopt_name;
|
||||||
while (*optarg != 0 && *optarg != '=')
|
while (*optarg != 0 && *optarg != '=')
|
||||||
++optarg;
|
{ ++optarg; }
|
||||||
if (*optarg == '=') // attached argument
|
if (*optarg == '=') // attached argument
|
||||||
++optarg;
|
{ ++optarg; }
|
||||||
else
|
else
|
||||||
// possibly detached argument
|
// possibly detached argument
|
||||||
optarg = (have_more_args ? args[1] : 0);
|
{ optarg = (have_more_args ? args[1] : 0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************ short option ***********************************/
|
/************************ short option ***********************************/
|
||||||
if (handle_short_options)
|
if (handle_short_options)
|
||||||
{
|
{
|
||||||
if (*++param == 0) // point at the 1st/next option character
|
if (*++param == 0) // point at the 1st/next option character
|
||||||
break; // end of short option group
|
{ break; } // end of short option group
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while (usage[idx].shortopt != 0 && !instr(*param, usage[idx].shortopt))
|
while (usage[idx].shortopt != 0 && !instr(*param, usage[idx].shortopt))
|
||||||
++idx;
|
{ ++idx; }
|
||||||
|
|
||||||
if (param[1] == 0) // if the potential argument is separate
|
if (param[1] == 0) // if the potential argument is separate
|
||||||
optarg = (have_more_args ? args[1] : 0);
|
{ optarg = (have_more_args ? args[1] : 0); }
|
||||||
else
|
else
|
||||||
// if the potential argument is attached
|
// if the potential argument is attached
|
||||||
optarg = param + 1;
|
{ optarg = param + 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
const Descriptor* descriptor = &usage[idx];
|
const Descriptor* descriptor = &usage[idx];
|
||||||
@ -1623,7 +1624,7 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
|
|||||||
// look for dummy entry (shortopt == "" and longopt == "") to use as Descriptor for unknown options
|
// look for dummy entry (shortopt == "" and longopt == "") to use as Descriptor for unknown options
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while (usage[idx].shortopt != 0 && (usage[idx].shortopt[0] != 0 || usage[idx].longopt[0] != 0))
|
while (usage[idx].shortopt != 0 && (usage[idx].shortopt[0] != 0 || usage[idx].longopt[0] != 0))
|
||||||
++idx;
|
{ ++idx; }
|
||||||
descriptor = (usage[idx].shortopt == 0 ? 0 : &usage[idx]);
|
descriptor = (usage[idx].shortopt == 0 ? 0 : &usage[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1640,7 +1641,7 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
|
|||||||
{
|
{
|
||||||
shift(args, nonops);
|
shift(args, nonops);
|
||||||
if (numargs > 0)
|
if (numargs > 0)
|
||||||
--numargs;
|
{ --numargs; }
|
||||||
++args;
|
++args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1655,26 +1656,28 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!action.perform(option))
|
if (!action.perform(option))
|
||||||
return false;
|
{ return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (handle_short_options);
|
}
|
||||||
|
while (handle_short_options);
|
||||||
|
|
||||||
shift(args, nonops);
|
shift(args, nonops);
|
||||||
++args;
|
++args;
|
||||||
if (numargs > 0)
|
if (numargs > 0)
|
||||||
--numargs;
|
{ --numargs; }
|
||||||
|
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
if (numargs > 0 && *args == 0) // It's a bug in the caller if numargs is greater than the actual number
|
if (numargs > 0 && *args == 0) // It's a bug in the caller if numargs is greater than the actual number
|
||||||
numargs = 0; // of arguments, but as a service to the user we fix this if we spot it.
|
{ numargs = 0; } // of arguments, but as a service to the user we fix this if we spot it.
|
||||||
|
|
||||||
if (numargs < 0) // if we don't know the number of remaining non-option arguments
|
if (numargs < 0) // if we don't know the number of remaining non-option arguments
|
||||||
{ // we need to count them
|
{
|
||||||
|
// we need to count them
|
||||||
numargs = 0;
|
numargs = 0;
|
||||||
while (args[numargs] != 0)
|
while (args[numargs] != 0)
|
||||||
++numargs;
|
{ ++numargs; }
|
||||||
}
|
}
|
||||||
|
|
||||||
return action.finished(numargs + nonops, args - nonops);
|
return action.finished(numargs + nonops, args - nonops);
|
||||||
@ -1716,7 +1719,7 @@ struct PrintUsageImplementation
|
|||||||
}
|
}
|
||||||
|
|
||||||
FunctionWriter(Function* w) :
|
FunctionWriter(Function* w) :
|
||||||
write(w)
|
write(w)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1737,7 +1740,7 @@ struct PrintUsageImplementation
|
|||||||
}
|
}
|
||||||
|
|
||||||
OStreamWriter(OStream& o) :
|
OStreamWriter(OStream& o) :
|
||||||
ostream(o)
|
ostream(o)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1758,7 +1761,7 @@ struct PrintUsageImplementation
|
|||||||
}
|
}
|
||||||
|
|
||||||
TemporaryWriter(const Temporary& u) :
|
TemporaryWriter(const Temporary& u) :
|
||||||
userstream(u)
|
userstream(u)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1781,7 +1784,7 @@ struct PrintUsageImplementation
|
|||||||
}
|
}
|
||||||
|
|
||||||
SyscallWriter(Syscall* w, int f) :
|
SyscallWriter(Syscall* w, int f) :
|
||||||
write(w), fd(f)
|
write(w), fd(f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1802,7 +1805,7 @@ struct PrintUsageImplementation
|
|||||||
}
|
}
|
||||||
|
|
||||||
StreamWriter(Function* w, Stream* s) :
|
StreamWriter(Function* w, Stream* s) :
|
||||||
fwrite(w), stream(s)
|
fwrite(w), stream(s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1840,7 +1843,7 @@ struct PrintUsageImplementation
|
|||||||
{
|
{
|
||||||
char space = ' ';
|
char space = ' ';
|
||||||
for (int i = 0; i < indent; ++i)
|
for (int i = 0; i < indent; ++i)
|
||||||
write(&space, 1);
|
{ write(&space, 1); }
|
||||||
x = want_x;
|
x = want_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1866,12 +1869,12 @@ struct PrintUsageImplementation
|
|||||||
static bool isWideChar(unsigned ch)
|
static bool isWideChar(unsigned ch)
|
||||||
{
|
{
|
||||||
if (ch == 0x303F)
|
if (ch == 0x303F)
|
||||||
return false;
|
{ return false; }
|
||||||
|
|
||||||
return ((0x1100 <= ch && ch <= 0x115F) || (0x2329 <= ch && ch <= 0x232A) || (0x2E80 <= ch && ch <= 0xA4C6)
|
return ((0x1100 <= ch && ch <= 0x115F) || (0x2329 <= ch && ch <= 0x232A) || (0x2E80 <= ch && ch <= 0xA4C6)
|
||||||
|| (0xA960 <= ch && ch <= 0xA97C) || (0xAC00 <= ch && ch <= 0xD7FB) || (0xF900 <= ch && ch <= 0xFAFF)
|
|| (0xA960 <= ch && ch <= 0xA97C) || (0xAC00 <= ch && ch <= 0xD7FB) || (0xF900 <= ch && ch <= 0xFAFF)
|
||||||
|| (0xFE10 <= ch && ch <= 0xFE6B) || (0xFF01 <= ch && ch <= 0xFF60) || (0xFFE0 <= ch && ch <= 0xFFE6)
|
|| (0xFE10 <= ch && ch <= 0xFE6B) || (0xFF01 <= ch && ch <= 0xFF60) || (0xFFE0 <= ch && ch <= 0xFFE6)
|
||||||
|| (0x1B000 <= ch));
|
|| (0x1B000 <= ch));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1948,7 +1951,7 @@ struct PrintUsageImplementation
|
|||||||
}
|
}
|
||||||
// ch is the decoded unicode code point
|
// ch is the decoded unicode code point
|
||||||
if (ch >= 0x1100 && isWideChar(ch)) // the test for 0x1100 is here to avoid the function call in the Latin case
|
if (ch >= 0x1100 && isWideChar(ch)) // the test for 0x1100 is here to avoid the function call in the Latin case
|
||||||
++screenlen;
|
{ ++screenlen; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1956,8 +1959,8 @@ struct PrintUsageImplementation
|
|||||||
public:
|
public:
|
||||||
//! @brief Creates an iterator for @c usage.
|
//! @brief Creates an iterator for @c usage.
|
||||||
LinePartIterator(const Descriptor usage[]) :
|
LinePartIterator(const Descriptor usage[]) :
|
||||||
tablestart(usage), rowdesc(0), rowstart(0), ptr(0), col(-1), len(0), max_line_in_block(0), line_in_block(0),
|
tablestart(usage), rowdesc(0), rowstart(0), ptr(0), col(-1), len(0), max_line_in_block(0), line_in_block(0),
|
||||||
target_line_in_block(0), hit_target_line(true)
|
target_line_in_block(0), hit_target_line(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1973,12 +1976,12 @@ struct PrintUsageImplementation
|
|||||||
if (rowdesc != 0)
|
if (rowdesc != 0)
|
||||||
{
|
{
|
||||||
while (tablestart->help != 0 && tablestart->shortopt != 0)
|
while (tablestart->help != 0 && tablestart->shortopt != 0)
|
||||||
++tablestart;
|
{ ++tablestart; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the next table after the break (if any)
|
// Find the next table after the break (if any)
|
||||||
while (tablestart->help == 0 && tablestart->shortopt != 0)
|
while (tablestart->help == 0 && tablestart->shortopt != 0)
|
||||||
++tablestart;
|
{ ++tablestart; }
|
||||||
|
|
||||||
restartTable();
|
restartTable();
|
||||||
return rowstart != 0;
|
return rowstart != 0;
|
||||||
@ -2008,12 +2011,12 @@ struct PrintUsageImplementation
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (*ptr != 0 && *ptr != '\n')
|
while (*ptr != 0 && *ptr != '\n')
|
||||||
++ptr;
|
{ ++ptr; }
|
||||||
|
|
||||||
if (*ptr == 0)
|
if (*ptr == 0)
|
||||||
{
|
{
|
||||||
if ((rowdesc + 1)->help == 0) // table break
|
if ((rowdesc + 1)->help == 0) // table break
|
||||||
return false;
|
{ return false; }
|
||||||
|
|
||||||
++rowdesc;
|
++rowdesc;
|
||||||
rowstart = rowdesc->help;
|
rowstart = rowdesc->help;
|
||||||
@ -2052,7 +2055,7 @@ struct PrintUsageImplementation
|
|||||||
bool next()
|
bool next()
|
||||||
{
|
{
|
||||||
if (ptr == 0)
|
if (ptr == 0)
|
||||||
return false;
|
{ return false; }
|
||||||
|
|
||||||
if (col == -1)
|
if (col == -1)
|
||||||
{
|
{
|
||||||
@ -2072,7 +2075,8 @@ struct PrintUsageImplementation
|
|||||||
break;
|
break;
|
||||||
case '\t':
|
case '\t':
|
||||||
if (!hit_target_line) // if previous column did not have the targetline
|
if (!hit_target_line) // if previous column did not have the targetline
|
||||||
{ // then "insert" a 0-length part
|
{
|
||||||
|
// then "insert" a 0-length part
|
||||||
update_length();
|
update_length();
|
||||||
hit_target_line = true;
|
hit_target_line = true;
|
||||||
return true;
|
return true;
|
||||||
@ -2086,7 +2090,8 @@ struct PrintUsageImplementation
|
|||||||
case 0:
|
case 0:
|
||||||
case '\n':
|
case '\n':
|
||||||
if (!hit_target_line) // if previous column did not have the targetline
|
if (!hit_target_line) // if previous column did not have the targetline
|
||||||
{ // then "insert" a 0-length part
|
{
|
||||||
|
// then "insert" a 0-length part
|
||||||
update_length();
|
update_length();
|
||||||
hit_target_line = true;
|
hit_target_line = true;
|
||||||
return true;
|
return true;
|
||||||
@ -2249,7 +2254,7 @@ struct PrintUsageImplementation
|
|||||||
void output(IStringWriter& write, const char* data, int len)
|
void output(IStringWriter& write, const char* data, int len)
|
||||||
{
|
{
|
||||||
if (buf_full())
|
if (buf_full())
|
||||||
write_one_line(write);
|
{ write_one_line(write); }
|
||||||
|
|
||||||
buf_store(data, len);
|
buf_store(data, len);
|
||||||
}
|
}
|
||||||
@ -2284,12 +2289,12 @@ struct PrintUsageImplementation
|
|||||||
void flush(IStringWriter& write)
|
void flush(IStringWriter& write)
|
||||||
{
|
{
|
||||||
if (buf_empty())
|
if (buf_empty())
|
||||||
return;
|
{ return; }
|
||||||
int _ = 0;
|
int _ = 0;
|
||||||
indent(write, _, x);
|
indent(write, _, x);
|
||||||
wrote_something = false;
|
wrote_something = false;
|
||||||
while (!buf_empty())
|
while (!buf_empty())
|
||||||
write_one_line(write);
|
{ write_one_line(write); }
|
||||||
write("\n", 1);
|
write("\n", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2337,7 +2342,7 @@ struct PrintUsageImplementation
|
|||||||
unsigned mask = (unsigned) -1 >> __builtin_clz(ch ^ 0xff);
|
unsigned mask = (unsigned) -1 >> __builtin_clz(ch ^ 0xff);
|
||||||
ch = ch & mask; // mask out length bits, we don't verify their correctness
|
ch = ch & mask; // mask out length bits, we don't verify their correctness
|
||||||
while ((maxi + charbytes < len) && //
|
while ((maxi + charbytes < len) && //
|
||||||
(((unsigned char) data[maxi + charbytes] ^ 0x80) <= 0x3F)) // while next byte is continuation byte
|
(((unsigned char) data[maxi + charbytes] ^ 0x80) <= 0x3F)) // while next byte is continuation byte
|
||||||
{
|
{
|
||||||
ch = (ch << 6) ^ (unsigned char) data[maxi + charbytes] ^ 0x80; // add continuation to char code
|
ch = (ch << 6) ^ (unsigned char) data[maxi + charbytes] ^ 0x80; // add continuation to char code
|
||||||
++charbytes;
|
++charbytes;
|
||||||
@ -2346,7 +2351,7 @@ struct PrintUsageImplementation
|
|||||||
if (ch >= 0x1100 && isWideChar(ch)) // the test for 0x1100 is here to avoid the function call in the Latin case
|
if (ch >= 0x1100 && isWideChar(ch)) // the test for 0x1100 is here to avoid the function call in the Latin case
|
||||||
{
|
{
|
||||||
if (utf8width + 2 > width)
|
if (utf8width + 2 > width)
|
||||||
break;
|
{ break; }
|
||||||
++utf8width;
|
++utf8width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2367,7 +2372,7 @@ struct PrintUsageImplementation
|
|||||||
int i;
|
int i;
|
||||||
for (i = maxi; i >= 0; --i)
|
for (i = maxi; i >= 0; --i)
|
||||||
if (data[i] == ' ')
|
if (data[i] == ' ')
|
||||||
break;
|
{ break; }
|
||||||
|
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
{
|
{
|
||||||
@ -2376,7 +2381,8 @@ struct PrintUsageImplementation
|
|||||||
len -= i + 1;
|
len -= i + 1;
|
||||||
}
|
}
|
||||||
else // did not find a space to split at => split before data[maxi]
|
else // did not find a space to split at => split before data[maxi]
|
||||||
{ // data[maxi] is always the beginning of a character, never a continuation byte
|
{
|
||||||
|
// data[maxi] is always the beginning of a character, never a continuation byte
|
||||||
output(write, data, maxi);
|
output(write, data, maxi);
|
||||||
data += maxi;
|
data += maxi;
|
||||||
len -= maxi;
|
len -= maxi;
|
||||||
@ -2385,7 +2391,7 @@ struct PrintUsageImplementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!wrote_something) // if we didn't already write something to make space in the buffer
|
if (!wrote_something) // if we didn't already write something to make space in the buffer
|
||||||
write_one_line(write); // write at most one line of actual output
|
{ write_one_line(write); } // write at most one line of actual output
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2395,10 +2401,10 @@ struct PrintUsageImplementation
|
|||||||
* @c x1 gives the indentation LineWrapper uses if it needs to indent.
|
* @c x1 gives the indentation LineWrapper uses if it needs to indent.
|
||||||
*/
|
*/
|
||||||
LineWrapper(int x1, int x2) :
|
LineWrapper(int x1, int x2) :
|
||||||
x(x1), width(x2 - x1), head(0), tail(bufmask)
|
x(x1), width(x2 - x1), head(0), tail(bufmask)
|
||||||
{
|
{
|
||||||
if (width < 2) // because of wide characters we need at least width 2 or the code breaks
|
if (width < 2) // because of wide characters we need at least width 2 or the code breaks
|
||||||
width = 2;
|
{ width = 2; }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2411,15 +2417,15 @@ struct PrintUsageImplementation
|
|||||||
int last_column_min_percent = 50, int last_column_own_line_max_percent = 75)
|
int last_column_min_percent = 50, int last_column_own_line_max_percent = 75)
|
||||||
{
|
{
|
||||||
if (width < 1) // protect against nonsense values
|
if (width < 1) // protect against nonsense values
|
||||||
width = 80;
|
{ width = 80; }
|
||||||
|
|
||||||
if (width > 10000) // protect against overflow in the following computation
|
if (width > 10000) // protect against overflow in the following computation
|
||||||
width = 10000;
|
{ width = 10000; }
|
||||||
|
|
||||||
int last_column_min_width = ((width * last_column_min_percent) + 50) / 100;
|
int last_column_min_width = ((width * last_column_min_percent) + 50) / 100;
|
||||||
int last_column_own_line_max_width = ((width * last_column_own_line_max_percent) + 50) / 100;
|
int last_column_own_line_max_width = ((width * last_column_own_line_max_percent) + 50) / 100;
|
||||||
if (last_column_own_line_max_width == 0)
|
if (last_column_own_line_max_width == 0)
|
||||||
last_column_own_line_max_width = 1;
|
{ last_column_own_line_max_width = 1; }
|
||||||
|
|
||||||
LinePartIterator part(usage);
|
LinePartIterator part(usage);
|
||||||
while (part.nextTable())
|
while (part.nextTable())
|
||||||
@ -2436,7 +2442,7 @@ struct PrintUsageImplementation
|
|||||||
{
|
{
|
||||||
lastcolumn = 0;
|
lastcolumn = 0;
|
||||||
for (int i = 0; i < maxcolumns; ++i)
|
for (int i = 0; i < maxcolumns; ++i)
|
||||||
col_width[i] = 0;
|
{ col_width[i] = 0; }
|
||||||
|
|
||||||
part.restartTable();
|
part.restartTable();
|
||||||
while (part.nextRow())
|
while (part.nextRow())
|
||||||
@ -2452,7 +2458,7 @@ struct PrintUsageImplementation
|
|||||||
// or explanatory paragraphs that do not participate in the table layout.
|
// or explanatory paragraphs that do not participate in the table layout.
|
||||||
if (part.column() > 0 || part.line() > 0 || part.data()[part.length()] == '\t'
|
if (part.column() > 0 || part.line() > 0 || part.data()[part.length()] == '\t'
|
||||||
|| part.data()[part.length()] == '\v')
|
|| part.data()[part.length()] == '\v')
|
||||||
upmax(col_width[part.column()], part.screenLength());
|
{ upmax(col_width[part.column()], part.screenLength()); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2476,14 +2482,15 @@ struct PrintUsageImplementation
|
|||||||
upmax(overlong_column_threshold, col_width[i]);
|
upmax(overlong_column_threshold, col_width[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (leftwidth > width);
|
}
|
||||||
|
while (leftwidth > width);
|
||||||
|
|
||||||
/**************** Determine tab stops and last column handling **********************/
|
/**************** Determine tab stops and last column handling **********************/
|
||||||
|
|
||||||
int tabstop[maxcolumns];
|
int tabstop[maxcolumns];
|
||||||
tabstop[0] = 0;
|
tabstop[0] = 0;
|
||||||
for (int i = 1; i < maxcolumns; ++i)
|
for (int i = 1; i < maxcolumns; ++i)
|
||||||
tabstop[i] = tabstop[i - 1] + col_width[i - 1];
|
{ tabstop[i] = tabstop[i - 1] + col_width[i - 1]; }
|
||||||
|
|
||||||
int rightwidth = width - tabstop[lastcolumn];
|
int rightwidth = width - tabstop[lastcolumn];
|
||||||
bool print_last_column_on_own_line = false;
|
bool print_last_column_on_own_line = false;
|
||||||
@ -2502,7 +2509,7 @@ struct PrintUsageImplementation
|
|||||||
// a bullshit value >100 for last_column_min_percent) => the above if condition
|
// a bullshit value >100 for last_column_min_percent) => the above if condition
|
||||||
// is false => print_last_column_on_own_line==false
|
// is false => print_last_column_on_own_line==false
|
||||||
if (lastcolumn == 0)
|
if (lastcolumn == 0)
|
||||||
print_last_column_on_own_line = false;
|
{ print_last_column_on_own_line = false; }
|
||||||
|
|
||||||
LineWrapper lastColumnLineWrapper(width - rightwidth, width);
|
LineWrapper lastColumnLineWrapper(width - rightwidth, width);
|
||||||
LineWrapper interjectionLineWrapper(0, width);
|
LineWrapper interjectionLineWrapper(0, width);
|
||||||
@ -2517,12 +2524,12 @@ struct PrintUsageImplementation
|
|||||||
while (part.next())
|
while (part.next())
|
||||||
{
|
{
|
||||||
if (part.column() > lastcolumn)
|
if (part.column() > lastcolumn)
|
||||||
continue; // drop excess columns (can happen if lastcolumn == maxcolumns-1)
|
{ continue; } // drop excess columns (can happen if lastcolumn == maxcolumns-1)
|
||||||
|
|
||||||
if (part.column() == 0)
|
if (part.column() == 0)
|
||||||
{
|
{
|
||||||
if (x >= 0)
|
if (x >= 0)
|
||||||
write("\n", 1);
|
{ write("\n", 1); }
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2536,7 +2543,7 @@ struct PrintUsageImplementation
|
|||||||
x += part.screenLength();
|
x += part.screenLength();
|
||||||
}
|
}
|
||||||
else // either part.column() == lastcolumn or we are in the special case of
|
else // either part.column() == lastcolumn or we are in the special case of
|
||||||
// an interjection that doesn't contain \v or \t
|
// an interjection that doesn't contain \v or \t
|
||||||
{
|
{
|
||||||
// NOTE: This code block is not necessarily executed for
|
// NOTE: This code block is not necessarily executed for
|
||||||
// each line, because some rows may have fewer columns.
|
// each line, because some rows may have fewer columns.
|
||||||
@ -2544,7 +2551,7 @@ struct PrintUsageImplementation
|
|||||||
LineWrapper& lineWrapper = (part.column() == 0) ? interjectionLineWrapper : lastColumnLineWrapper;
|
LineWrapper& lineWrapper = (part.column() == 0) ? interjectionLineWrapper : lastColumnLineWrapper;
|
||||||
|
|
||||||
if (!print_last_column_on_own_line)
|
if (!print_last_column_on_own_line)
|
||||||
lineWrapper.process(write, part.data(), part.length());
|
{ lineWrapper.process(write, part.data(), part.length()); }
|
||||||
}
|
}
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
@ -2804,7 +2811,7 @@ void printUsage(Syscall* prn, int fd, const Descriptor descriptors[], int width
|
|||||||
|
|
||||||
template<typename Function, typename Stream>
|
template<typename Function, typename Stream>
|
||||||
void printUsage(Function* prn, Stream* stream, const Descriptor descriptors[], int width = 80, int last_column_min_percent =
|
void printUsage(Function* prn, Stream* stream, const Descriptor descriptors[], int width = 80, int last_column_min_percent =
|
||||||
50,
|
50,
|
||||||
int last_column_own_line_max_percent = 75)
|
int last_column_own_line_max_percent = 75)
|
||||||
{
|
{
|
||||||
PrintUsageImplementation::StreamWriter<Function, Stream> write(prn, stream);
|
PrintUsageImplementation::StreamWriter<Function, Stream> write(prn, stream);
|
||||||
@ -2814,7 +2821,8 @@ void printUsage(Function* prn, Stream* stream, const Descriptor descriptors[], i
|
|||||||
}
|
}
|
||||||
// namespace option
|
// namespace option
|
||||||
|
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
// namespace vtkm::testing
|
// namespace vtkm::testing
|
||||||
|
|
||||||
#endif /* OPTIONPARSER_H_ */
|
#endif /* OPTIONPARSER_H_ */
|
||||||
|
@ -68,14 +68,14 @@ public:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VTKM_CONT_EXPORT TestFailure(const std::string &file,
|
VTKM_CONT_EXPORT TestFailure(const std::string &file,
|
||||||
vtkm::Id line,
|
vtkm::Id line,
|
||||||
const std::string &message)
|
const std::string &message)
|
||||||
: File(file), Line(line), Message(message) { }
|
: File(file), Line(line), Message(message) { }
|
||||||
|
|
||||||
VTKM_CONT_EXPORT TestFailure(const std::string &file,
|
VTKM_CONT_EXPORT TestFailure(const std::string &file,
|
||||||
vtkm::Id line,
|
vtkm::Id line,
|
||||||
const std::string &message,
|
const std::string &message,
|
||||||
const std::string &condition)
|
const std::string &condition)
|
||||||
: File(file), Line(line)
|
: File(file), Line(line)
|
||||||
{
|
{
|
||||||
this->Message.append(message);
|
this->Message.append(message);
|
||||||
@ -86,7 +86,8 @@ public:
|
|||||||
|
|
||||||
VTKM_CONT_EXPORT const std::string &GetFile() const { return this->File; }
|
VTKM_CONT_EXPORT const std::string &GetFile() const { return this->File; }
|
||||||
VTKM_CONT_EXPORT vtkm::Id GetLine() const { return this->Line; }
|
VTKM_CONT_EXPORT vtkm::Id GetLine() const { return this->Line; }
|
||||||
VTKM_CONT_EXPORT const std::string &GetMessage() const {
|
VTKM_CONT_EXPORT const std::string &GetMessage() const
|
||||||
|
{
|
||||||
return this->Message;
|
return this->Message;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
@ -96,19 +97,19 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static VTKM_CONT_EXPORT void Assert(bool condition,
|
static VTKM_CONT_EXPORT void Assert(bool condition,
|
||||||
const std::string &file,
|
const std::string &file,
|
||||||
vtkm::Id line,
|
vtkm::Id line,
|
||||||
const std::string &message,
|
const std::string &message,
|
||||||
const std::string &conditionString)
|
const std::string &conditionString)
|
||||||
{
|
{
|
||||||
if (condition)
|
if (condition)
|
||||||
{
|
{
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw TestFailure(file, line, message, conditionString);
|
throw TestFailure(file, line, message, conditionString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef VTKM_TESTING_IN_CONT
|
#ifndef VTKM_TESTING_IN_CONT
|
||||||
@ -143,89 +144,104 @@ public:
|
|||||||
static VTKM_CONT_EXPORT int Run(Func function)
|
static VTKM_CONT_EXPORT int Run(Func function)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
function();
|
function();
|
||||||
}
|
}
|
||||||
catch (TestFailure error)
|
catch (TestFailure error)
|
||||||
{
|
{
|
||||||
std::cout << "***** Test failed @ "
|
std::cout << "***** Test failed @ "
|
||||||
<< error.GetFile() << ":" << error.GetLine() << std::endl
|
<< error.GetFile() << ":" << error.GetLine() << std::endl
|
||||||
<< error.GetMessage() << std::endl;
|
<< error.GetMessage() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cout << "***** Unidentified exception thrown." << std::endl;
|
std::cout << "***** Unidentified exception thrown." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Check functors to be used with the TryAllTypes method.
|
/// Check functors to be used with the TryAllTypes method.
|
||||||
///
|
///
|
||||||
struct TypeCheckAlwaysTrue {
|
struct TypeCheckAlwaysTrue
|
||||||
|
{
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void operator()(T t, Functor function) const { function(t); }
|
void operator()(T t, Functor function) const { function(t); }
|
||||||
};
|
};
|
||||||
struct TypeCheckInteger {
|
struct TypeCheckInteger
|
||||||
|
{
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void operator()(T t, Functor function) const {
|
void operator()(T t, Functor function) const
|
||||||
|
{
|
||||||
this->DoInteger(typename vtkm::TypeTraits<T>::NumericTag(), t, function);
|
this->DoInteger(typename vtkm::TypeTraits<T>::NumericTag(), t, function);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
template <class Tag, typename T, class Functor>
|
template <class Tag, typename T, class Functor>
|
||||||
void DoInteger(Tag, T, const Functor&) const { }
|
void DoInteger(Tag, T, const Functor&) const { }
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void DoInteger(vtkm::TypeTraitsIntegerTag, T t, Functor function) const {
|
void DoInteger(vtkm::TypeTraitsIntegerTag, T t, Functor function) const
|
||||||
|
{
|
||||||
function(t);
|
function(t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct TypeCheckReal {
|
struct TypeCheckReal
|
||||||
|
{
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void operator()(T t, Functor function) const {
|
void operator()(T t, Functor function) const
|
||||||
|
{
|
||||||
this->DoReal(typename vtkm::TypeTraits<T>::NumericTag(), t, function);
|
this->DoReal(typename vtkm::TypeTraits<T>::NumericTag(), t, function);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
template <class Tag, typename T, class Functor>
|
template <class Tag, typename T, class Functor>
|
||||||
void DoReal(Tag, T, const Functor&) const { }
|
void DoReal(Tag, T, const Functor&) const { }
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void DoReal(vtkm::TypeTraitsRealTag, T t, Functor function) const {
|
void DoReal(vtkm::TypeTraitsRealTag, T t, Functor function) const
|
||||||
|
{
|
||||||
function(t);
|
function(t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct TypeCheckScalar {
|
struct TypeCheckScalar
|
||||||
|
{
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void operator()(T t, Functor func) const {
|
void operator()(T t, Functor func) const
|
||||||
|
{
|
||||||
this->DoScalar(typename vtkm::TypeTraits<T>::DimensionalityTag(), t, func);
|
this->DoScalar(typename vtkm::TypeTraits<T>::DimensionalityTag(), t, func);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
template <class Tag, typename T, class Functor>
|
template <class Tag, typename T, class Functor>
|
||||||
void DoScalar(Tag, const T &, const Functor &) const { }
|
void DoScalar(Tag, const T &, const Functor &) const { }
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void DoScalar(vtkm::TypeTraitsScalarTag, T t, Functor function) const {
|
void DoScalar(vtkm::TypeTraitsScalarTag, T t, Functor function) const
|
||||||
|
{
|
||||||
function(t);
|
function(t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct TypeCheckVector {
|
struct TypeCheckVector
|
||||||
|
{
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void operator()(T t, Functor func) const {
|
void operator()(T t, Functor func) const
|
||||||
|
{
|
||||||
this->DoVector(typename vtkm::TypeTraits<T>::DimensionalityTag(), t, func);
|
this->DoVector(typename vtkm::TypeTraits<T>::DimensionalityTag(), t, func);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
template <class Tag, typename T, class Functor>
|
template <class Tag, typename T, class Functor>
|
||||||
void DoVector(Tag, const T &, const Functor &) const { }
|
void DoVector(Tag, const T &, const Functor &) const { }
|
||||||
template <typename T, class Functor>
|
template <typename T, class Functor>
|
||||||
void DoVector(vtkm::TypeTraitsVectorTag, T t, Functor function) const {
|
void DoVector(vtkm::TypeTraitsVectorTag, T t, Functor function) const
|
||||||
|
{
|
||||||
function(t);
|
function(t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class FunctionType>
|
template<class FunctionType>
|
||||||
struct InternalPrintOnInvoke {
|
struct InternalPrintOnInvoke
|
||||||
|
{
|
||||||
InternalPrintOnInvoke(FunctionType function, std::string toprint)
|
InternalPrintOnInvoke(FunctionType function, std::string toprint)
|
||||||
: Function(function), ToPrint(toprint) { }
|
: Function(function), ToPrint(toprint) { }
|
||||||
template <typename T> void operator()(T t) {
|
template <typename T> void operator()(T t)
|
||||||
|
{
|
||||||
std::cout << this->ToPrint << std::endl;
|
std::cout << this->ToPrint << std::endl;
|
||||||
this->Function(t);
|
this->Function(t);
|
||||||
}
|
}
|
||||||
@ -288,27 +304,27 @@ VTKM_EXEC_CONT_EXPORT bool test_equal(VectorType vector1,
|
|||||||
{
|
{
|
||||||
typedef typename vtkm::VectorTraits<VectorType> Traits;
|
typedef typename vtkm::VectorTraits<VectorType> Traits;
|
||||||
for (int component = 0; component < Traits::NUM_COMPONENTS; component++)
|
for (int component = 0; component < Traits::NUM_COMPONENTS; component++)
|
||||||
{
|
{
|
||||||
vtkm::Scalar value1 = Traits::GetComponent(vector1, component);
|
vtkm::Scalar value1 = Traits::GetComponent(vector1, component);
|
||||||
vtkm::Scalar value2 = Traits::GetComponent(vector2, component);
|
vtkm::Scalar value2 = Traits::GetComponent(vector2, component);
|
||||||
if ((fabs(value1) < 2*tolerance) && (fabs(value2) < 2*tolerance))
|
if ((fabs(value1) < 2*tolerance) && (fabs(value2) < 2*tolerance))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
vtkm::Scalar ratio = value1/value2;
|
vtkm::Scalar ratio = value1/value2;
|
||||||
if ((ratio > vtkm::Scalar(1.0) - tolerance)
|
if ((ratio > vtkm::Scalar(1.0) - tolerance)
|
||||||
&& (ratio < vtkm::Scalar(1.0) + tolerance))
|
&& (ratio < vtkm::Scalar(1.0) + tolerance))
|
||||||
{
|
{
|
||||||
// This component is OK. The condition is checked in this way to
|
// This component is OK. The condition is checked in this way to
|
||||||
// correctly handle non-finites that fail all comparisons. Thus, if a
|
// correctly handle non-finites that fail all comparisons. Thus, if a
|
||||||
// non-finite is encountered, this condition will fail and false will be
|
// non-finite is encountered, this condition will fail and false will be
|
||||||
// returned.
|
// returned.
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,9 +336,9 @@ std::ostream &operator<<(std::ostream &stream, const vtkm::Tuple<T,Size> &tuple)
|
|||||||
{
|
{
|
||||||
stream << "[";
|
stream << "[";
|
||||||
for (int component = 0; component < Size-1; component++)
|
for (int component = 0; component < Size-1; component++)
|
||||||
{
|
{
|
||||||
stream << tuple[component] << ",";
|
stream << tuple[component] << ",";
|
||||||
}
|
}
|
||||||
return stream << tuple[Size-1] << "]";
|
return stream << tuple[Size-1] << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ void GoodAssert()
|
|||||||
void TestTestEqual()
|
void TestTestEqual()
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(test_equal(vtkm::Scalar(2.0), vtkm::Scalar(1.9999999)),
|
VTKM_TEST_ASSERT(test_equal(vtkm::Scalar(2.0), vtkm::Scalar(1.9999999)),
|
||||||
"These should be close enough.");
|
"These should be close enough.");
|
||||||
VTKM_TEST_ASSERT(!test_equal(vtkm::Scalar(2.0), vtkm::Scalar(1.999)),
|
VTKM_TEST_ASSERT(!test_equal(vtkm::Scalar(2.0), vtkm::Scalar(1.999)),
|
||||||
"These should not be close enough.");
|
"These should not be close enough.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// All tests that should not raise a failure.
|
// All tests that should not raise a failure.
|
||||||
@ -61,16 +61,16 @@ int UnitTestTesting(int, char *[])
|
|||||||
{
|
{
|
||||||
std::cout << "This call should fail." << std::endl;
|
std::cout << "This call should fail." << std::endl;
|
||||||
if (vtkm::testing::Testing::Run(Fail) == 0)
|
if (vtkm::testing::Testing::Run(Fail) == 0)
|
||||||
{
|
{
|
||||||
std::cout << "Did not get expected fail!" << std::endl;
|
std::cout << "Did not get expected fail!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::cout << "This call should fail." << std::endl;
|
std::cout << "This call should fail." << std::endl;
|
||||||
if (vtkm::testing::Testing::Run(BadAssert) == 0)
|
if (vtkm::testing::Testing::Run(BadAssert) == 0)
|
||||||
{
|
{
|
||||||
std::cout << "Did not get expected fail!" << std::endl;
|
std::cout << "Did not get expected fail!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "This call should pass." << std::endl;
|
std::cout << "This call should pass." << std::endl;
|
||||||
// This is what your main function typically looks like.
|
// This is what your main function typically looks like.
|
||||||
|
@ -28,7 +28,8 @@ namespace {
|
|||||||
|
|
||||||
struct TypeTraitTest
|
struct TypeTraitTest
|
||||||
{
|
{
|
||||||
template <typename T> void operator()(T t) {
|
template <typename T> void operator()(T t)
|
||||||
|
{
|
||||||
// If you get compiler errors here, it could be a TypeTraits instance
|
// If you get compiler errors here, it could be a TypeTraits instance
|
||||||
// has missing or malformed tags.
|
// has missing or malformed tags.
|
||||||
this->TestDimensionality(t, typename vtkm::TypeTraits<T>::DimensionalityTag());
|
this->TestDimensionality(t, typename vtkm::TypeTraits<T>::DimensionalityTag());
|
||||||
@ -37,32 +38,36 @@ struct TypeTraitTest
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void TestDimensionality(T, vtkm::TypeTraitsScalarTag) {
|
void TestDimensionality(T, vtkm::TypeTraitsScalarTag)
|
||||||
|
{
|
||||||
std::cout << " scalar" << std::endl;
|
std::cout << " scalar" << std::endl;
|
||||||
VTKM_TEST_ASSERT(vtkm::VectorTraits<T>::NUM_COMPONENTS == 1,
|
VTKM_TEST_ASSERT(vtkm::VectorTraits<T>::NUM_COMPONENTS == 1,
|
||||||
"Scalar type does not have one component.");
|
"Scalar type does not have one component.");
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void TestDimensionality(T, vtkm::TypeTraitsVectorTag) {
|
void TestDimensionality(T, vtkm::TypeTraitsVectorTag)
|
||||||
|
{
|
||||||
std::cout << " vector" << std::endl;
|
std::cout << " vector" << std::endl;
|
||||||
VTKM_TEST_ASSERT(vtkm::VectorTraits<T>::NUM_COMPONENTS > 1,
|
VTKM_TEST_ASSERT(vtkm::VectorTraits<T>::NUM_COMPONENTS > 1,
|
||||||
"Vector type does not have multiple components.");
|
"Vector type does not have multiple components.");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void TestNumeric(T, vtkm::TypeTraitsIntegerTag) {
|
void TestNumeric(T, vtkm::TypeTraitsIntegerTag)
|
||||||
|
{
|
||||||
std::cout << " integer" << std::endl;
|
std::cout << " integer" << std::endl;
|
||||||
typedef typename vtkm::VectorTraits<T>::ComponentType VT;
|
typedef typename vtkm::VectorTraits<T>::ComponentType VT;
|
||||||
VT value = VT(2.001);
|
VT value = VT(2.001);
|
||||||
VTKM_TEST_ASSERT(value == 2, "Integer does not round to integer.");
|
VTKM_TEST_ASSERT(value == 2, "Integer does not round to integer.");
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void TestNumeric(T, vtkm::TypeTraitsRealTag) {
|
void TestNumeric(T, vtkm::TypeTraitsRealTag)
|
||||||
|
{
|
||||||
std::cout << " real" << std::endl;
|
std::cout << " real" << std::endl;
|
||||||
typedef typename vtkm::VectorTraits<T>::ComponentType VT;
|
typedef typename vtkm::VectorTraits<T>::ComponentType VT;
|
||||||
VT value = VT(2.001);
|
VT value = VT(2.001);
|
||||||
VTKM_TEST_ASSERT(test_equal(float(value), float(2.001)),
|
VTKM_TEST_ASSERT(test_equal(float(value), float(2.001)),
|
||||||
"Real does not hold floaing point number.");
|
"Real does not hold floaing point number.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,11 +52,11 @@ template <typename T> void TypeTest()
|
|||||||
typename T::ComponentType s(5);
|
typename T::ComponentType s(5);
|
||||||
|
|
||||||
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
||||||
{
|
{
|
||||||
a[i]=typename T::ComponentType((i+1)*2);
|
a[i]=typename T::ComponentType((i+1)*2);
|
||||||
b[i]=typename T::ComponentType(i+1);
|
b[i]=typename T::ComponentType(i+1);
|
||||||
c[i]=typename T::ComponentType((i+1)*2);
|
c[i]=typename T::ComponentType((i+1)*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//verify prefix and postfix increment and decrement
|
//verify prefix and postfix increment and decrement
|
||||||
++c[T::NUM_COMPONENTS-1];
|
++c[T::NUM_COMPONENTS-1];
|
||||||
@ -70,42 +70,42 @@ template <typename T> void TypeTest()
|
|||||||
T plus = a + b;
|
T plus = a + b;
|
||||||
T correct_plus;
|
T correct_plus;
|
||||||
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
||||||
{ correct_plus[i] = a[i] + b[i]; }
|
{ correct_plus[i] = a[i] + b[i]; }
|
||||||
VTKM_TEST_ASSERT(test_equal(plus, correct_plus),"Tuples not added correctly.");
|
VTKM_TEST_ASSERT(test_equal(plus, correct_plus),"Tuples not added correctly.");
|
||||||
|
|
||||||
T minus = a - b;
|
T minus = a - b;
|
||||||
T correct_minus;
|
T correct_minus;
|
||||||
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
||||||
{ correct_minus[i] = a[i] - b[i]; }
|
{ correct_minus[i] = a[i] - b[i]; }
|
||||||
VTKM_TEST_ASSERT(test_equal(minus, correct_minus),"Tuples not subtracted correctly.");
|
VTKM_TEST_ASSERT(test_equal(minus, correct_minus),"Tuples not subtracted correctly.");
|
||||||
|
|
||||||
|
|
||||||
T mult = a * b;
|
T mult = a * b;
|
||||||
T correct_mult;
|
T correct_mult;
|
||||||
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
||||||
{ correct_mult[i] = a[i] * b[i]; }
|
{ correct_mult[i] = a[i] * b[i]; }
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, correct_mult),"Tuples not multiplied correctly.");
|
VTKM_TEST_ASSERT(test_equal(mult, correct_mult),"Tuples not multiplied correctly.");
|
||||||
|
|
||||||
T div = a / b;
|
T div = a / b;
|
||||||
T correct_div;
|
T correct_div;
|
||||||
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
||||||
{ correct_div[i] = a[i] / b[i]; }
|
{ correct_div[i] = a[i] / b[i]; }
|
||||||
VTKM_TEST_ASSERT(test_equal(div,correct_div),"Tuples not divided correctly.");
|
VTKM_TEST_ASSERT(test_equal(div,correct_div),"Tuples not divided correctly.");
|
||||||
|
|
||||||
mult = s * a;
|
mult = s * a;
|
||||||
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
||||||
{ correct_mult[i] = s * a[i]; }
|
{ correct_mult[i] = s * a[i]; }
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, correct_mult),
|
VTKM_TEST_ASSERT(test_equal(mult, correct_mult),
|
||||||
"Scalar and Tuple did not multiply correctly.");
|
"Scalar and Tuple did not multiply correctly.");
|
||||||
|
|
||||||
mult = a * s;
|
mult = a * s;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, correct_mult),
|
VTKM_TEST_ASSERT(test_equal(mult, correct_mult),
|
||||||
"Tuple and Scalar to not multiply correctly.");
|
"Tuple and Scalar to not multiply correctly.");
|
||||||
|
|
||||||
typename T::ComponentType d = vtkm::dot(a, b);
|
typename T::ComponentType d = vtkm::dot(a, b);
|
||||||
typename T::ComponentType correct_d = 0;
|
typename T::ComponentType correct_d = 0;
|
||||||
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
for(int i=0; i < T::NUM_COMPONENTS; ++i)
|
||||||
{correct_d += a[i] * b[i]; }
|
{correct_d += a[i] * b[i]; }
|
||||||
VTKM_TEST_ASSERT(test_equal(d, correct_d), "dot(Tuple) wrong");
|
VTKM_TEST_ASSERT(test_equal(d, correct_d), "dot(Tuple) wrong");
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(!(a < b), "operator< wrong");
|
VTKM_TEST_ASSERT(!(a < b), "operator< wrong");
|
||||||
@ -137,27 +137,27 @@ template<> void TypeTest<vtkm::Vector2>()
|
|||||||
|
|
||||||
vtkm::Vector2 plus = a + b;
|
vtkm::Vector2 plus = a + b;
|
||||||
VTKM_TEST_ASSERT(test_equal(plus, vtkm::make_Vector2(3, 6)),
|
VTKM_TEST_ASSERT(test_equal(plus, vtkm::make_Vector2(3, 6)),
|
||||||
"Vectors do not add correctly.");
|
"Vectors do not add correctly.");
|
||||||
|
|
||||||
vtkm::Vector2 minus = a - b;
|
vtkm::Vector2 minus = a - b;
|
||||||
VTKM_TEST_ASSERT(test_equal(minus, vtkm::make_Vector2(1, 2)),
|
VTKM_TEST_ASSERT(test_equal(minus, vtkm::make_Vector2(1, 2)),
|
||||||
"Vectors to not subtract correctly.");
|
"Vectors to not subtract correctly.");
|
||||||
|
|
||||||
vtkm::Vector2 mult = a * b;
|
vtkm::Vector2 mult = a * b;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector2(2, 8)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector2(2, 8)),
|
||||||
"Vectors to not multiply correctly.");
|
"Vectors to not multiply correctly.");
|
||||||
|
|
||||||
vtkm::Vector2 div = a / b;
|
vtkm::Vector2 div = a / b;
|
||||||
VTKM_TEST_ASSERT(test_equal(div, vtkm::make_Vector2(2, 2)),
|
VTKM_TEST_ASSERT(test_equal(div, vtkm::make_Vector2(2, 2)),
|
||||||
"Vectors to not divide correctly.");
|
"Vectors to not divide correctly.");
|
||||||
|
|
||||||
mult = s * a;
|
mult = s * a;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector2(10, 20)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector2(10, 20)),
|
||||||
"Vector and scalar to not multiply correctly.");
|
"Vector and scalar to not multiply correctly.");
|
||||||
|
|
||||||
mult = a * s;
|
mult = a * s;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector2(10, 20)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector2(10, 20)),
|
||||||
"Vector and scalar to not multiply correctly.");
|
"Vector and scalar to not multiply correctly.");
|
||||||
|
|
||||||
vtkm::Scalar d = vtkm::dot(a, b);
|
vtkm::Scalar d = vtkm::dot(a, b);
|
||||||
VTKM_TEST_ASSERT(test_equal(d, vtkm::Scalar(10)), "dot(Vector2) wrong");
|
VTKM_TEST_ASSERT(test_equal(d, vtkm::Scalar(10)), "dot(Vector2) wrong");
|
||||||
@ -193,27 +193,27 @@ template<> void TypeTest<vtkm::Vector3>()
|
|||||||
|
|
||||||
vtkm::Vector3 plus = a + b;
|
vtkm::Vector3 plus = a + b;
|
||||||
VTKM_TEST_ASSERT(test_equal(plus, vtkm::make_Vector3(3, 6, 9)),
|
VTKM_TEST_ASSERT(test_equal(plus, vtkm::make_Vector3(3, 6, 9)),
|
||||||
"Vectors do not add correctly.");
|
"Vectors do not add correctly.");
|
||||||
|
|
||||||
vtkm::Vector3 minus = a - b;
|
vtkm::Vector3 minus = a - b;
|
||||||
VTKM_TEST_ASSERT(test_equal(minus, vtkm::make_Vector3(1, 2, 3)),
|
VTKM_TEST_ASSERT(test_equal(minus, vtkm::make_Vector3(1, 2, 3)),
|
||||||
"Vectors to not subtract correctly.");
|
"Vectors to not subtract correctly.");
|
||||||
|
|
||||||
vtkm::Vector3 mult = a * b;
|
vtkm::Vector3 mult = a * b;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector3(2, 8, 18)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector3(2, 8, 18)),
|
||||||
"Vectors to not multiply correctly.");
|
"Vectors to not multiply correctly.");
|
||||||
|
|
||||||
vtkm::Vector3 div = a / b;
|
vtkm::Vector3 div = a / b;
|
||||||
VTKM_TEST_ASSERT(test_equal(div, vtkm::make_Vector3(2, 2, 2)),
|
VTKM_TEST_ASSERT(test_equal(div, vtkm::make_Vector3(2, 2, 2)),
|
||||||
"Vectors to not divide correctly.");
|
"Vectors to not divide correctly.");
|
||||||
|
|
||||||
mult = s * a;
|
mult = s * a;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector3(10, 20, 30)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector3(10, 20, 30)),
|
||||||
"Vector and scalar to not multiply correctly.");
|
"Vector and scalar to not multiply correctly.");
|
||||||
|
|
||||||
mult = a * s;
|
mult = a * s;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector3(10, 20, 30)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector3(10, 20, 30)),
|
||||||
"Vector and scalar to not multiply correctly.");
|
"Vector and scalar to not multiply correctly.");
|
||||||
|
|
||||||
vtkm::Scalar d = vtkm::dot(a, b);
|
vtkm::Scalar d = vtkm::dot(a, b);
|
||||||
VTKM_TEST_ASSERT(test_equal(d, vtkm::Scalar(28)), "dot(Vector3) wrong");
|
VTKM_TEST_ASSERT(test_equal(d, vtkm::Scalar(28)), "dot(Vector3) wrong");
|
||||||
@ -249,27 +249,27 @@ template<> void TypeTest<vtkm::Vector4>()
|
|||||||
|
|
||||||
vtkm::Vector4 plus = a + b;
|
vtkm::Vector4 plus = a + b;
|
||||||
VTKM_TEST_ASSERT(test_equal(plus, vtkm::make_Vector4(3, 6, 9, 12)),
|
VTKM_TEST_ASSERT(test_equal(plus, vtkm::make_Vector4(3, 6, 9, 12)),
|
||||||
"Vectors do not add correctly.");
|
"Vectors do not add correctly.");
|
||||||
|
|
||||||
vtkm::Vector4 minus = a - b;
|
vtkm::Vector4 minus = a - b;
|
||||||
VTKM_TEST_ASSERT(test_equal(minus, vtkm::make_Vector4(1, 2, 3, 4)),
|
VTKM_TEST_ASSERT(test_equal(minus, vtkm::make_Vector4(1, 2, 3, 4)),
|
||||||
"Vectors to not subtract correctly.");
|
"Vectors to not subtract correctly.");
|
||||||
|
|
||||||
vtkm::Vector4 mult = a * b;
|
vtkm::Vector4 mult = a * b;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector4(2, 8, 18, 32)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector4(2, 8, 18, 32)),
|
||||||
"Vectors to not multiply correctly.");
|
"Vectors to not multiply correctly.");
|
||||||
|
|
||||||
vtkm::Vector4 div = a / b;
|
vtkm::Vector4 div = a / b;
|
||||||
VTKM_TEST_ASSERT(test_equal(div, vtkm::make_Vector4(2, 2, 2, 2)),
|
VTKM_TEST_ASSERT(test_equal(div, vtkm::make_Vector4(2, 2, 2, 2)),
|
||||||
"Vectors to not divide correctly.");
|
"Vectors to not divide correctly.");
|
||||||
|
|
||||||
mult = s * a;
|
mult = s * a;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector4(10, 20, 30, 40)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector4(10, 20, 30, 40)),
|
||||||
"Vector and scalar to not multiply correctly.");
|
"Vector and scalar to not multiply correctly.");
|
||||||
|
|
||||||
mult = a * s;
|
mult = a * s;
|
||||||
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector4(10, 20, 30, 40)),
|
VTKM_TEST_ASSERT(test_equal(mult, vtkm::make_Vector4(10, 20, 30, 40)),
|
||||||
"Vector and scalar to not multiply correctly.");
|
"Vector and scalar to not multiply correctly.");
|
||||||
|
|
||||||
vtkm::Scalar d = vtkm::dot(a, b);
|
vtkm::Scalar d = vtkm::dot(a, b);
|
||||||
VTKM_TEST_ASSERT(test_equal(d, vtkm::Scalar(60)), "dot(Vector4) wrong");
|
VTKM_TEST_ASSERT(test_equal(d, vtkm::Scalar(60)), "dot(Vector4) wrong");
|
||||||
@ -306,44 +306,44 @@ template<> void TypeTest<vtkm::Id3>()
|
|||||||
|
|
||||||
vtkm::Id3 plus = a + b;
|
vtkm::Id3 plus = a + b;
|
||||||
if ((plus[0] != 3) || (plus[1] != 6) || (plus[2] != 9))
|
if ((plus[0] != 3) || (plus[1] != 6) || (plus[2] != 9))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Vectors do not add correctly.");
|
VTKM_TEST_FAIL("Vectors do not add correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Id3 minus = a - b;
|
vtkm::Id3 minus = a - b;
|
||||||
if ((minus[0] != 1) || (minus[1] != 2) || (minus[2] != 3))
|
if ((minus[0] != 1) || (minus[1] != 2) || (minus[2] != 3))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Vectors to not subtract correctly.");
|
VTKM_TEST_FAIL("Vectors to not subtract correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Id3 mult = a * b;
|
vtkm::Id3 mult = a * b;
|
||||||
if ((mult[0] != 2) || (mult[1] != 8) || (mult[2] != 18))
|
if ((mult[0] != 2) || (mult[1] != 8) || (mult[2] != 18))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Vectors to not multiply correctly.");
|
VTKM_TEST_FAIL("Vectors to not multiply correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Id3 div = a / b;
|
vtkm::Id3 div = a / b;
|
||||||
if ((div[0] != 2) || (div[1] != 2) || (div[2] != 2))
|
if ((div[0] != 2) || (div[1] != 2) || (div[2] != 2))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Vectors to not divide correctly.");
|
VTKM_TEST_FAIL("Vectors to not divide correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
mult = s * a;
|
mult = s * a;
|
||||||
if ((mult[0] != 10) || (mult[1] != 20) || (mult[2] != 30))
|
if ((mult[0] != 10) || (mult[1] != 20) || (mult[2] != 30))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Vector and scalar to not multiply correctly.");
|
VTKM_TEST_FAIL("Vector and scalar to not multiply correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
mult = a * s;
|
mult = a * s;
|
||||||
if ((mult[0] != 10) || (mult[1] != 20) || (mult[2] != 30))
|
if ((mult[0] != 10) || (mult[1] != 20) || (mult[2] != 30))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Vector and scalar to not multiply correctly.");
|
VTKM_TEST_FAIL("Vector and scalar to not multiply correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vtkm::dot(a, b) != 28)
|
if (vtkm::dot(a, b) != 28)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("dot(Id3) wrong");
|
VTKM_TEST_FAIL("dot(Id3) wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(!(a < b), "operator< wrong");
|
VTKM_TEST_ASSERT(!(a < b), "operator< wrong");
|
||||||
VTKM_TEST_ASSERT((b < a), "operator< wrong");
|
VTKM_TEST_ASSERT((b < a), "operator< wrong");
|
||||||
@ -352,22 +352,22 @@ template<> void TypeTest<vtkm::Id3>()
|
|||||||
VTKM_TEST_ASSERT((minus < plus), "operator< wrong");
|
VTKM_TEST_ASSERT((minus < plus), "operator< wrong");
|
||||||
|
|
||||||
if (a == b)
|
if (a == b)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("operator== wrong");
|
VTKM_TEST_FAIL("operator== wrong");
|
||||||
}
|
}
|
||||||
if (!(a == a))
|
if (!(a == a))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("operator== wrong");
|
VTKM_TEST_FAIL("operator== wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(a != b))
|
if (!(a != b))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("operator!= wrong");
|
VTKM_TEST_FAIL("operator!= wrong");
|
||||||
}
|
}
|
||||||
if (a != a)
|
if (a != a)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("operator!= wrong");
|
VTKM_TEST_FAIL("operator!= wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
//test against a tuple that shares some values
|
//test against a tuple that shares some values
|
||||||
const vtkm::Id3 c = vtkm::make_Id3(2,4,5);
|
const vtkm::Id3 c = vtkm::make_Id3(2,4,5);
|
||||||
@ -387,41 +387,41 @@ template<> void TypeTest<vtkm::Scalar>()
|
|||||||
|
|
||||||
vtkm::Scalar plus = a + b;
|
vtkm::Scalar plus = a + b;
|
||||||
if (plus != 6)
|
if (plus != 6)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Scalars do not add correctly.");
|
VTKM_TEST_FAIL("Scalars do not add correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Scalar minus = a - b;
|
vtkm::Scalar minus = a - b;
|
||||||
if (minus != 2)
|
if (minus != 2)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Scalars to not subtract correctly.");
|
VTKM_TEST_FAIL("Scalars to not subtract correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Scalar mult = a * b;
|
vtkm::Scalar mult = a * b;
|
||||||
if (mult != 8)
|
if (mult != 8)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Scalars to not multiply correctly.");
|
VTKM_TEST_FAIL("Scalars to not multiply correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Scalar div = a / b;
|
vtkm::Scalar div = a / b;
|
||||||
if (div != 2)
|
if (div != 2)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Scalars to not divide correctly.");
|
VTKM_TEST_FAIL("Scalars to not divide correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == b)
|
if (a == b)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("operator== wrong");
|
VTKM_TEST_FAIL("operator== wrong");
|
||||||
}
|
}
|
||||||
if (!(a != b))
|
if (!(a != b))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("operator!= wrong");
|
VTKM_TEST_FAIL("operator!= wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vtkm::dot(a, b) != 8)
|
if (vtkm::dot(a, b) != 8)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("dot(Scalar) wrong");
|
VTKM_TEST_FAIL("dot(Scalar) wrong");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void TypeTest<vtkm::Id>()
|
template<> void TypeTest<vtkm::Id>()
|
||||||
@ -431,46 +431,47 @@ template<> void TypeTest<vtkm::Id>()
|
|||||||
|
|
||||||
vtkm::Id plus = a + b;
|
vtkm::Id plus = a + b;
|
||||||
if (plus != 6)
|
if (plus != 6)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Scalars do not add correctly.");
|
VTKM_TEST_FAIL("Scalars do not add correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Id minus = a - b;
|
vtkm::Id minus = a - b;
|
||||||
if (minus != 2)
|
if (minus != 2)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Scalars to not subtract correctly.");
|
VTKM_TEST_FAIL("Scalars to not subtract correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Id mult = a * b;
|
vtkm::Id mult = a * b;
|
||||||
if (mult != 8)
|
if (mult != 8)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Scalars to not multiply correctly.");
|
VTKM_TEST_FAIL("Scalars to not multiply correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::Id div = a / b;
|
vtkm::Id div = a / b;
|
||||||
if (div != 2)
|
if (div != 2)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("Scalars to not divide correctly.");
|
VTKM_TEST_FAIL("Scalars to not divide correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == b)
|
if (a == b)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("operator== wrong");
|
VTKM_TEST_FAIL("operator== wrong");
|
||||||
}
|
}
|
||||||
if (!(a != b))
|
if (!(a != b))
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("operator!= wrong");
|
VTKM_TEST_FAIL("operator!= wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vtkm::dot(a, b) != 8)
|
if (vtkm::dot(a, b) != 8)
|
||||||
{
|
{
|
||||||
VTKM_TEST_FAIL("dot(Id) wrong");
|
VTKM_TEST_FAIL("dot(Id) wrong");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TypeTestFunctor
|
struct TypeTestFunctor
|
||||||
{
|
{
|
||||||
template <typename T> void operator()(const T&) const {
|
template <typename T> void operator()(const T&) const
|
||||||
|
{
|
||||||
TypeTest<T>();
|
TypeTest<T>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -28,15 +28,16 @@ static const vtkm::Id VectorInit[MAX_VECTOR_SIZE] = { 42, 54, 67, 12, 78 };
|
|||||||
|
|
||||||
struct TestVectorTypeFunctor
|
struct TestVectorTypeFunctor
|
||||||
{
|
{
|
||||||
template <typename T> void operator()(const T&) const {
|
template <typename T> void operator()(const T&) const
|
||||||
|
{
|
||||||
typedef vtkm::VectorTraits<T> Traits;
|
typedef vtkm::VectorTraits<T> Traits;
|
||||||
VTKM_TEST_ASSERT(Traits::NUM_COMPONENTS <= MAX_VECTOR_SIZE,
|
VTKM_TEST_ASSERT(Traits::NUM_COMPONENTS <= MAX_VECTOR_SIZE,
|
||||||
"Need to update test for larger vectors.");
|
"Need to update test for larger vectors.");
|
||||||
T vector;
|
T vector;
|
||||||
for (int index = 0; index < Traits::NUM_COMPONENTS; index++)
|
for (int index = 0; index < Traits::NUM_COMPONENTS; index++)
|
||||||
{
|
{
|
||||||
Traits::SetComponent(vector, index, VectorInit[index]);
|
Traits::SetComponent(vector, index, VectorInit[index]);
|
||||||
}
|
}
|
||||||
vtkm::testing::TestVectorType(vector);
|
vtkm::testing::TestVectorType(vector);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -48,7 +48,7 @@ inline void CompareDimensionalityTags(vtkm::TypeTraitsVectorTag,
|
|||||||
/// the Tuple class.
|
/// the Tuple class.
|
||||||
template <class T>
|
template <class T>
|
||||||
static void TestVectorTypeImpl(
|
static void TestVectorTypeImpl(
|
||||||
const typename boost::remove_const<T>::type &vector)
|
const typename boost::remove_const<T>::type &vector)
|
||||||
{
|
{
|
||||||
typedef typename vtkm::VectorTraits<T> Traits;
|
typedef typename vtkm::VectorTraits<T> Traits;
|
||||||
typedef typename Traits::ComponentType ComponentType;
|
typedef typename Traits::ComponentType ComponentType;
|
||||||
@ -56,48 +56,48 @@ static void TestVectorTypeImpl(
|
|||||||
typedef typename boost::remove_const<T>::type NonConstT;
|
typedef typename boost::remove_const<T>::type NonConstT;
|
||||||
|
|
||||||
{
|
{
|
||||||
NonConstT result;
|
NonConstT result;
|
||||||
const ComponentType multiplier = 4;
|
const ComponentType multiplier = 4;
|
||||||
for (int i = 0; i < NUM_COMPONENTS; i++)
|
for (int i = 0; i < NUM_COMPONENTS; i++)
|
||||||
{
|
{
|
||||||
Traits::SetComponent(result, i, multiplier*Traits::GetComponent(vector, i));
|
Traits::SetComponent(result, i, multiplier*Traits::GetComponent(vector, i));
|
||||||
}
|
}
|
||||||
VTKM_TEST_ASSERT(test_equal(Traits::ToTuple(result),
|
VTKM_TEST_ASSERT(test_equal(Traits::ToTuple(result),
|
||||||
multiplier*Traits::ToTuple(vector)),
|
multiplier*Traits::ToTuple(vector)),
|
||||||
"Got bad result for scalar multiple");
|
"Got bad result for scalar multiple");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
NonConstT result;
|
NonConstT result;
|
||||||
const ComponentType multiplier = 7;
|
const ComponentType multiplier = 7;
|
||||||
for (int i = 0; i < NUM_COMPONENTS; i++)
|
for (int i = 0; i < NUM_COMPONENTS; i++)
|
||||||
{
|
{
|
||||||
Traits::GetComponent(result, i)
|
Traits::GetComponent(result, i)
|
||||||
= multiplier * Traits::GetComponent(vector, i);
|
= multiplier * Traits::GetComponent(vector, i);
|
||||||
}
|
}
|
||||||
VTKM_TEST_ASSERT(test_equal(Traits::ToTuple(result),
|
VTKM_TEST_ASSERT(test_equal(Traits::ToTuple(result),
|
||||||
multiplier*Traits::ToTuple(vector)),
|
multiplier*Traits::ToTuple(vector)),
|
||||||
"Got bad result for scalar multiple");
|
"Got bad result for scalar multiple");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ComponentType result = 0;
|
ComponentType result = 0;
|
||||||
for (int i = 0; i < NUM_COMPONENTS; i++)
|
for (int i = 0; i < NUM_COMPONENTS; i++)
|
||||||
{
|
{
|
||||||
ComponentType component
|
ComponentType component
|
||||||
= Traits::GetComponent(vector, i);
|
= Traits::GetComponent(vector, i);
|
||||||
result += component * component;
|
result += component * component;
|
||||||
}
|
}
|
||||||
VTKM_TEST_ASSERT(
|
VTKM_TEST_ASSERT(
|
||||||
test_equal(result,
|
test_equal(result,
|
||||||
vtkm::dot(Traits::ToTuple(vector), Traits::ToTuple(vector))),
|
vtkm::dot(Traits::ToTuple(vector), Traits::ToTuple(vector))),
|
||||||
"Got bad result for dot product");
|
"Got bad result for dot product");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will fail to compile if the tags are wrong.
|
// This will fail to compile if the tags are wrong.
|
||||||
detail::CompareDimensionalityTags(
|
detail::CompareDimensionalityTags(
|
||||||
typename vtkm::TypeTraits<T>::DimensionalityTag(),
|
typename vtkm::TypeTraits<T>::DimensionalityTag(),
|
||||||
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CheckVectorComponentsTag(vtkm::VectorTraitsTagMultipleComponents)
|
inline void CheckVectorComponentsTag(vtkm::VectorTraitsTagMultipleComponents)
|
||||||
@ -117,7 +117,7 @@ inline void TestVectorComponentsTag()
|
|||||||
// This will fail to compile if the tag is wrong
|
// This will fail to compile if the tag is wrong
|
||||||
// (i.e. not vtkm::VectorTraitsTagMultipleComponents)
|
// (i.e. not vtkm::VectorTraitsTagMultipleComponents)
|
||||||
detail::CheckVectorComponentsTag(
|
detail::CheckVectorComponentsTag(
|
||||||
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@ -148,7 +148,7 @@ inline void TestScalarComponentsTag()
|
|||||||
// This will fail to compile if the tag is wrong
|
// This will fail to compile if the tag is wrong
|
||||||
// (i.e. not vtkm::VectorTraitsTagSingleComponent)
|
// (i.e. not vtkm::VectorTraitsTagSingleComponent)
|
||||||
detail::CheckScalarComponentsTag(
|
detail::CheckScalarComponentsTag(
|
||||||
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user