Add IdComponent and other base types with explicit widths

In preparation for supporting base types with more widths, add typedefs
for the base types with explicit widths (number of bits).

Also added a IdComponent type that should be used for indices for
components into tuples and vectors. There now should be no reason to use
"int" inside of VTK-m code (especially for indexing). This change cleans
up many of the int types that were used throughout.
This commit is contained in:
Kenneth Moreland 2014-10-07 10:59:34 -06:00
parent 750dd66687
commit cbe6284b83
20 changed files with 287 additions and 213 deletions

@ -108,6 +108,8 @@ include(CheckTypeSize)
check_type_size(float VTKm_SIZE_FLOAT BUILTIN_TYPES_ONLY)
check_type_size(double VTKm_SIZE_DOUBLE BUILTIN_TYPES_ONLY)
check_type_size(char VTKm_SIZE_CHAR BUILTIN_TYPES_ONLY)
check_type_size(short VTKm_SIZE_SHORT BUILTIN_TYPES_ONLY)
check_type_size(int VTKm_SIZE_INT BUILTIN_TYPES_ONLY)
check_type_size(long VTKm_SIZE_LONG BUILTIN_TYPES_ONLY)
check_type_size("long long" VTKm_SIZE_LONG_LONG BUILTIN_TYPES_ONLY)

@ -27,7 +27,7 @@ namespace vtkm {
/// Extent stores the values for the index ranges for a structured grid array.
/// It does this through the minimum indices and the maximum indices.
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
struct Extent
{
vtkm::Tuple<vtkm::Id,Dimensions> Min;
@ -66,7 +66,7 @@ typedef vtkm::Extent<2> Extent2;
/// Given an extent, returns the array dimensions for the points.
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Tuple<vtkm::Id,Dimensions>
ExtentPointDimensions(const vtkm::Extent<Dimensions> &extent)
@ -93,7 +93,7 @@ vtkm::Id2 ExtentPointDimensions(const vtkm::Extent2 &extent)
/// Given an extent, returns the array dimensions for the cells.
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Tuple<vtkm::Id,Dimensions>
ExtentCellDimensions(const vtkm::Extent<Dimensions> &extent)
@ -103,7 +103,7 @@ ExtentCellDimensions(const vtkm::Extent<Dimensions> &extent)
/// Given an extent, returns the number of points in the structured mesh.
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Id ExtentNumberOfPoints(const vtkm::Extent<Dimensions> &extent)
{
@ -134,7 +134,7 @@ vtkm::Id ExtentNumberOfPoints(const vtkm::Extent2 &extent)
/// Given an extent, returns the number of cells in the structured mesh.
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Id ExtentNumberOfCells(const vtkm::Extent<Dimensions> &extent)
{
@ -168,7 +168,7 @@ vtkm::Id ExtentNumberOfCells(const vtkm::Extent2 &extent)
/// then the s direction and so on. This method converts a flat index to the
/// topological coordinates (e.g. r,s,t for 3d topologies).
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Tuple<vtkm::Id,Dimensions>
ExtentPointFlatIndexToTopologyIndex(vtkm::Id index,
@ -178,7 +178,7 @@ ExtentPointFlatIndexToTopologyIndex(vtkm::Id index,
vtkm::ExtentPointDimensions(extent);
vtkm::Tuple<vtkm::Id,Dimensions> ijkIndex;
vtkm::Id indexOnDim = index;
for (int dimIndex = 0; dimIndex < Dimensions-1; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions-1; dimIndex++)
{
ijkIndex[dimIndex] = indexOnDim % dims[dimIndex] + extent.Min[dimIndex];
indexOnDim /= dims[dimIndex];
@ -216,7 +216,7 @@ vtkm::Id2 ExtentPointFlatIndexToTopologyIndex(vtkm::Id index,
/// then the s direction and so on. This method converts a flat index to the
/// topological coordinates (e.g. r,s,t for 3d topologies).
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Tuple<vtkm::Id,Dimensions>
ExtentCellFlatIndexToTopologyIndex(vtkm::Id index,
@ -226,7 +226,7 @@ ExtentCellFlatIndexToTopologyIndex(vtkm::Id index,
vtkm::ExtentCellDimensions(extent);
vtkm::Tuple<vtkm::Id,Dimensions> ijkIndex;
vtkm::Id indexOnDim = index;
for (int dimIndex = 0; dimIndex < Dimensions-1; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions-1; dimIndex++)
{
ijkIndex[dimIndex] = indexOnDim % dims[dimIndex] + extent.Min[dimIndex];
indexOnDim /= dims[dimIndex];
@ -264,7 +264,7 @@ vtkm::Id2 ExtentCellFlatIndexToTopologyIndex(vtkm::Id index,
/// then the s direction and so on. This method converts topological
/// coordinates to a flat index.
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Id
ExtentPointTopologyIndexToFlatIndex(const vtkm::Tuple<vtkm::Id,Dimensions> &ijk,
@ -273,7 +273,7 @@ ExtentPointTopologyIndexToFlatIndex(const vtkm::Tuple<vtkm::Id,Dimensions> &ijk,
const vtkm::Tuple<vtkm::Id,Dimensions> dims = ExtentPointDimensions(extent);
const vtkm::Tuple<vtkm::Id,Dimensions> deltas = ijk - extent.Min;
vtkm::Id flatIndex = deltas[Dimensions-1];
for (int dimIndex = Dimensions-2; dimIndex >= 0; dimIndex--)
for (vtkm::IdComponent dimIndex = Dimensions-2; dimIndex >= 0; dimIndex--)
{
flatIndex = flatIndex*dims[dimIndex] + deltas[dimIndex];
}
@ -285,7 +285,7 @@ ExtentPointTopologyIndexToFlatIndex(const vtkm::Tuple<vtkm::Id,Dimensions> &ijk,
/// then the s direction and so on. This method converts topological
/// coordinates to a flat index.
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Id
ExtentCellTopologyIndexToFlatIndex(const vtkm::Tuple<vtkm::Id,Dimensions> &ijk,
@ -294,7 +294,7 @@ ExtentCellTopologyIndexToFlatIndex(const vtkm::Tuple<vtkm::Id,Dimensions> &ijk,
const vtkm::Tuple<vtkm::Id,Dimensions> dims = ExtentCellDimensions(extent);
const vtkm::Tuple<vtkm::Id,Dimensions> deltas = ijk - extent.Min;
vtkm::Id flatIndex = deltas[Dimensions-1];
for (int dimIndex = Dimensions-2; dimIndex >= 0; dimIndex--)
for (vtkm::IdComponent dimIndex = Dimensions-2; dimIndex >= 0; dimIndex--)
{
flatIndex = flatIndex*dims[dimIndex] + deltas[dimIndex];
}
@ -304,7 +304,7 @@ ExtentCellTopologyIndexToFlatIndex(const vtkm::Tuple<vtkm::Id,Dimensions> &ijk,
/// Given a cell index, returns the index to the first point incident on that
/// cell.
///
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
VTKM_EXEC_CONT_EXPORT
vtkm::Id ExtentFirstPointOnCell(vtkm::Id cellIndex,
const Extent<Dimensions> &extent)

@ -136,7 +136,8 @@ VTKM_VECTOR_TYPE(vtkm::Vector4, TypeTraitsRealTag);
/// Traits for tuples.
///
template<typename T, int Size> struct TypeTraits<vtkm::Tuple<T, Size> >
template<typename T, vtkm::IdComponent Size>
struct TypeTraits<vtkm::Tuple<T, Size> >
{
typedef typename TypeTraits<T>::NumericTag NumericTag;
typedef TypeTraitsVectorTag DimensionalityTag;

@ -88,28 +88,89 @@ namespace vtkm {
/// Alignment requirements are prescribed by CUDA on device (Table B-1 in NVIDIA
/// CUDA C Programming Guide 4.0)
namespace internal {
#if VTKM_SIZE_FLOAT == 4
typedef float Float32;
#else
#error Could not find a 32-bit float.
#endif
#if VTKM_SIZE_DOUBLE == 8
typedef double Float64;
#else
#error Could not find a 64-bit float.
#endif
#if VTKM_SIZE_CHAR == 1
typedef signed char Int8;
typedef unsigned char UInt8;
#else
#error Could not find an 8-bit integer.
#endif
#if VTKM_SIZE_SHORT == 2
typedef signed short Int16;
typedef unsigned short UInt16;
#else
#error Could not find a 16-bit integer.
#endif
#if VTKM_SIZE_INT == 4
typedef int Int32Type;
typedef unsigned int UInt32Type;
typedef signed int Int32;
typedef unsigned int UInt32;
#else
#error Could not find a 32-bit integer.
#endif
#if VTKM_SIZE_LONG == 8
typedef long Int64Type;
typedef unsigned long UInt64Type;
typedef signed long Int64;
typedef unsigned long UInt64;
#elif VTKM_SIZE_LONG_LONG == 8
typedef long long Int64Type;
typedef unsigned long long UInt64Type;
typedef signed long long Int64;
typedef unsigned long long UInt64;
#else
#error Could not find a 64-bit integer.
#endif
//-----------------------------------------------------------------------------
template<int Size>
#if VTKM_SIZE_ID == 4
/// Represents an ID (index into arrays).
typedef vtkm::Int32 Id;
#elif VTKM_SIZE_ID == 8
/// Represents an ID.
typedef vtkm::Int64 Id;
#else
#error Unknown Id Size
#endif
/// Represents a component ID (index of component in a vector). The number
/// of components, being a value fixed at compile time, is generally assumed
/// to be quite small. However, we are currently using a 32-bit width
/// integer because modern processors tend to access them more efficiently
/// than smaller widths.
typedef vtkm::Int32 IdComponent;
#ifdef VTKM_USE_DOUBLE_PRECISION
/// Scalar corresponds to a floating point number.
typedef vtkm::Float64 Scalar;
#else //VTKM_USE_DOUBLE_PRECISION
/// Scalar corresponds to a floating point number.
typedef vtkm::Float32 Scalar;
#endif //VTKM_USE_DOUBLE_PRECISION
namespace internal {
//-----------------------------------------------------------------------------
template<vtkm::IdComponent Size>
struct equals
{
template<typename T>
@ -149,7 +210,7 @@ struct equals<3>
}
};
template<int Size>
template<vtkm::IdComponent Size>
struct assign_scalar_to_vector
{
template<typename VectorType, typename ComponentType>
@ -197,7 +258,7 @@ struct assign_scalar_to_vector<3>
}
};
template<int Size>
template<vtkm::IdComponent Size>
struct copy_vector
{
template<typename T1, typename T2>
@ -241,7 +302,7 @@ struct copy_vector<3>
}
};
template<int Size>
template<vtkm::IdComponent Size>
struct sum_vector
{
template<typename T>
@ -296,7 +357,7 @@ struct sum_vector<4>
}
};
template<int Size>
template<vtkm::IdComponent Size>
struct product_vector
{
template<typename T>
@ -356,53 +417,25 @@ struct product_vector<4>
//-----------------------------------------------------------------------------
#if VTKM_SIZE_ID == 4
/// Represents an ID.
typedef internal::Int32Type Id;
#elif VTKM_SIZE_ID == 8
/// Represents an ID.
typedef internal::Int64Type Id;
#else
#error Unknown Id Size
#endif
#ifdef VTKM_USE_DOUBLE_PRECISION
/// Scalar corresponds to a floating point number.
typedef double Scalar;
#else //VTKM_USE_DOUBLE_PRECISION
/// Scalar corresponds to a floating point number.
typedef float Scalar;
#endif //VTKM_USE_DOUBLE_PRECISION
//-----------------------------------------------------------------------------
/// Tuple corresponds to a Size-tuple of type T
template<typename T, int Size>
template<typename T, vtkm::IdComponent Size>
class Tuple
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS=Size;
static const vtkm::IdComponent NUM_COMPONENTS=Size;
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
{
for(int i=0; i < NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < NUM_COMPONENTS; ++i)
{
this->Components[i]=value;
}
}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values)
{
for(int i=0; i < NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < NUM_COMPONENTS; ++i)
{
this->Components[i]=values[i];
}
@ -410,7 +443,7 @@ public:
VTKM_EXEC_CONT_EXPORT
Tuple(const Tuple<ComponentType, Size> &src)
{
for (int i = 0; i < NUM_COMPONENTS; i++)
for (vtkm::IdComponent i = 0; i < NUM_COMPONENTS; i++)
{
this->Components[i] = src[i];
}
@ -419,18 +452,19 @@ public:
VTKM_EXEC_CONT_EXPORT
Tuple<ComponentType, Size> &operator=(const Tuple<ComponentType, Size> &src)
{
for (int i = 0; i < NUM_COMPONENTS; i++)
for (vtkm::IdComponent i = 0; i < NUM_COMPONENTS; i++)
{
this->Components[i] = src[i];
}
return *this;
}
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
VTKM_EXEC_CONT_EXPORT
const ComponentType &operator[](vtkm::IdComponent idx) const
{
return this->Components[idx];
}
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](vtkm::IdComponent idx)
{
return this->Components[idx];
}
@ -439,7 +473,9 @@ public:
bool operator==(const Tuple<T,NUM_COMPONENTS> &other) const
{
bool same = true;
for (int componentIndex=0; componentIndex<NUM_COMPONENTS; componentIndex++)
for (vtkm::IdComponent componentIndex = 0;
componentIndex < NUM_COMPONENTS;
componentIndex++)
{
same &= (this->Components[componentIndex] == other[componentIndex]);
}
@ -479,7 +515,7 @@ class Tuple<T, 0>
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS = 1;
static const vtkm::IdComponent NUM_COMPONENTS = 1;
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType&) { }
@ -494,7 +530,8 @@ public:
return *this;
}
VTKM_EXEC_CONT_EXPORT ComponentType operator[](int vtkmNotUsed(idx)) const
VTKM_EXEC_CONT_EXPORT
ComponentType operator[](vtkm::IdComponent vtkmNotUsed(idx)) const
{
return ComponentType();
}
@ -516,7 +553,7 @@ class Tuple<T, 1>
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS = 1;
static const vtkm::IdComponent NUM_COMPONENTS = 1;
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
@ -536,12 +573,12 @@ public:
}
VTKM_EXEC_CONT_EXPORT
const ComponentType &operator[](int vtkmNotUsed(idx)) const
const ComponentType &operator[](vtkm::IdComponent vtkmNotUsed(idx)) const
{
return this->Component;
}
VTKM_EXEC_CONT_EXPORT
ComponentType &operator[](int vtkmNotUsed(idx))
ComponentType &operator[](vtkm::IdComponent vtkmNotUsed(idx))
{
return this->Component;
}
@ -575,7 +612,7 @@ class Tuple<T,2>
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS = 2;
static const vtkm::IdComponent NUM_COMPONENTS = 2;
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
@ -605,11 +642,13 @@ public:
return *this;
}
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
VTKM_EXEC_CONT_EXPORT
const ComponentType &operator[](vtkm::IdComponent idx) const
{
return this->Components[idx];
}
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
VTKM_EXEC_CONT_EXPORT
ComponentType &operator[](vtkm::IdComponent idx)
{
return this->Components[idx];
}
@ -649,7 +688,7 @@ class Tuple<T,3>
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS = 3;
static const vtkm::IdComponent NUM_COMPONENTS = 3;
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
@ -681,11 +720,13 @@ public:
return *this;
}
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
VTKM_EXEC_CONT_EXPORT
const ComponentType &operator[](vtkm::IdComponent idx) const
{
return this->Components[idx];
}
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
VTKM_EXEC_CONT_EXPORT
ComponentType &operator[](vtkm::IdComponent idx)
{
return this->Components[idx];
}
@ -728,7 +769,7 @@ class Tuple<T,4>
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS = 4;
static const vtkm::IdComponent NUM_COMPONENTS = 4;
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
@ -761,11 +802,13 @@ public:
return *this;
}
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
VTKM_EXEC_CONT_EXPORT
const ComponentType &operator[](vtkm::IdComponent idx) const
{
return this->Components[idx];
}
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
VTKM_EXEC_CONT_EXPORT
ComponentType &operator[](vtkm::IdComponent idx)
{
return this->Components[idx];
}
@ -834,12 +877,12 @@ VTKM_EXEC_CONT_EXPORT vtkm::Id3 make_Id3(vtkm::Id x, vtkm::Id y, vtkm::Id z)
return vtkm::Id3(x, y, z);
}
template<typename T, int Size>
template<typename T, vtkm::IdComponent Size>
VTKM_EXEC_CONT_EXPORT T dot(const vtkm::Tuple<T,Size> &a,
const vtkm::Tuple<T,Size> &b)
{
T result = a[0]*b[0];
for (int componentIndex = 1; componentIndex < Size; componentIndex++)
for (vtkm::IdComponent componentIndex = 1; componentIndex < Size; componentIndex++)
{
result += a[componentIndex]*b[componentIndex];
}
@ -858,68 +901,74 @@ VTKM_EXEC_CONT_EXPORT vtkm::Scalar dot(vtkm::Scalar a, vtkm::Scalar b)
} // End of namespace vtkm
template<typename T, int Size>
template<typename T, vtkm::IdComponent Size>
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator+(const vtkm::Tuple<T,Size> &a,
const vtkm::Tuple<T,Size> &b)
const vtkm::Tuple<T,Size> &b)
{
vtkm::Tuple<T,Size> result;
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
for (vtkm::IdComponent componentIndex = 0; componentIndex < Size; componentIndex++)
{
result[componentIndex] = a[componentIndex] + b[componentIndex];
}
return result;
}
template<typename T, int Size>
template<typename T, vtkm::IdComponent Size>
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator-(const vtkm::Tuple<T,Size> &a,
const vtkm::Tuple<T,Size> &b)
const vtkm::Tuple<T,Size> &b)
{
vtkm::Tuple<T,Size> result;
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
for (vtkm::IdComponent componentIndex = 0; componentIndex < Size; componentIndex++)
{
result[componentIndex] = a[componentIndex] - b[componentIndex];
}
return result;
}
template<typename T, int Size>
template<typename T, vtkm::IdComponent Size>
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator*(const vtkm::Tuple<T,Size> &a,
const vtkm::Tuple<T,Size> &b)
const vtkm::Tuple<T,Size> &b)
{
vtkm::Tuple<T,Size> result;
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
for (vtkm::IdComponent componentIndex = 0;
componentIndex < Size;
componentIndex++)
{
result[componentIndex] = a[componentIndex] * b[componentIndex];
}
return result;
}
template<typename T, int Size>
template<typename T, vtkm::IdComponent Size>
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator/(const vtkm::Tuple<T,Size> &a,
const vtkm::Tuple<T,Size> &b)
const vtkm::Tuple<T,Size> &b)
{
vtkm::Tuple<T,Size> result;
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
for (vtkm::IdComponent componentIndex = 0; componentIndex < Size; componentIndex++)
{
result[componentIndex] = a[componentIndex] / b[componentIndex];
}
return result;
}
template<typename Ta, typename Tb, int Size>
template<typename Ta, typename Tb, vtkm::IdComponent Size>
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<Ta,Size> operator*(const vtkm::Tuple<Ta,Size> &a,
const Tb &b)
const Tb &b)
{
vtkm::Tuple<Ta,Size> result;
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
for (vtkm::IdComponent componentIndex = 0;
componentIndex < Size;
componentIndex++)
{
result[componentIndex] = a[componentIndex] * b;
}
return result;
}
template<typename Ta, typename Tb, int Size>
template<typename Ta, typename Tb, vtkm::IdComponent Size>
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<Tb,Size> operator*(const Ta &a,
const vtkm::Tuple<Tb,Size> &b)
const vtkm::Tuple<Tb,Size> &b)
{
vtkm::Tuple<Tb,Size> result;
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
for (vtkm::IdComponent componentIndex = 0;
componentIndex < Size;
componentIndex++)
{
result[componentIndex] = a * b[componentIndex];
}

@ -37,7 +37,7 @@ struct VectorTraitsTagSingleComponent { };
namespace internal {
template<int numComponents>
template<vtkm::IdComponent numComponents>
struct VectorTraitsMultipleComponentChooser
{
typedef VectorTraitsTagMultipleComponents Type;
@ -64,7 +64,7 @@ struct VectorTraits
/// Number of components in the vector.
///
static const int NUM_COMPONENTS = VectorType::NUM_COMPONENTS;
static const vtkm::IdComponent NUM_COMPONENTS = VectorType::NUM_COMPONENTS;
/// A tag specifying whether this vector has multiple components (i.e. is a
/// "real" vector). This tag can be useful for creating specialized functions
@ -77,15 +77,15 @@ struct VectorTraits
///
VTKM_EXEC_CONT_EXPORT static const ComponentType &GetComponent(
const typename boost::remove_const<VectorType>::type &vector,
int component);
vtkm::IdComponent component);
VTKM_EXEC_CONT_EXPORT static ComponentType &GetComponent(
typename boost::remove_const<VectorType>::type &vector,
int component);
vtkm::IdComponent component);
/// Changes the value in a given component of the vector.
///
VTKM_EXEC_CONT_EXPORT static void SetComponent(VectorType &vector,
int component,
vtkm::IdComponent component,
ComponentType value);
/// Converts whatever type this vector is into the standard VTKm Tuple.
@ -105,7 +105,7 @@ template<typename T>
struct VectorTraits<const T> : VectorTraits<T>
{ };
template<typename T, int Size>
template<typename T, vtkm::IdComponent Size>
struct VectorTraits<vtkm::Tuple<T,Size> >
{
typedef vtkm::Tuple<T,Size> VectorType;
@ -116,7 +116,7 @@ struct VectorTraits<vtkm::Tuple<T,Size> >
/// Number of components in the vector.
///
static const int NUM_COMPONENTS = VectorType::NUM_COMPONENTS;
static const vtkm::IdComponent NUM_COMPONENTS = VectorType::NUM_COMPONENTS;
/// A tag specifying whether this vector has multiple components (i.e. is a
/// "real" vector). This tag can be useful for creating specialized functions
@ -129,19 +129,19 @@ struct VectorTraits<vtkm::Tuple<T,Size> >
///
VTKM_EXEC_CONT_EXPORT
static const ComponentType &GetComponent(const VectorType &vector,
int component)
vtkm::IdComponent component)
{
return vector[component];
}
VTKM_EXEC_CONT_EXPORT
static ComponentType &GetComponent(VectorType &vector, int component) {
static ComponentType &GetComponent(VectorType &vector, vtkm::IdComponent component) {
return vector[component];
}
/// Changes the value in a given component of the vector.
///
VTKM_EXEC_CONT_EXPORT static void SetComponent(VectorType &vector,
int component,
vtkm::IdComponent component,
ComponentType value) {
vector[component] = value;
}
@ -162,21 +162,21 @@ namespace internal {
template<typename ScalarType>
struct VectorTraitsBasic {
typedef ScalarType ComponentType;
static const int NUM_COMPONENTS = 1;
static const vtkm::IdComponent NUM_COMPONENTS = 1;
typedef VectorTraitsTagSingleComponent HasMultipleComponents;
VTKM_EXEC_CONT_EXPORT static const ComponentType &GetComponent(
const ScalarType &vector,
int) {
vtkm::IdComponent) {
return vector;
}
VTKM_EXEC_CONT_EXPORT
static ComponentType &GetComponent(ScalarType &vector, int) {
static ComponentType &GetComponent(ScalarType &vector, vtkm::IdComponent) {
return vector;
}
VTKM_EXEC_CONT_EXPORT static void SetComponent(ScalarType &vector,
int,
vtkm::IdComponent,
ComponentType value) {
vector = value;
}

@ -40,9 +40,9 @@ namespace detail {
template<typename ValueType>
struct CompositeVectorSwizzleFunctor
{
static const int NUM_COMPONENTS =
static const vtkm::IdComponent NUM_COMPONENTS =
vtkm::VectorTraits<ValueType>::NUM_COMPONENTS;
typedef vtkm::Tuple<int, NUM_COMPONENTS> ComponentMapType;
typedef vtkm::Tuple<vtkm::IdComponent, NUM_COMPONENTS> ComponentMapType;
// Caution! This is a reference.
const ComponentMapType &SourceComponents;
@ -166,11 +166,11 @@ template<typename SignatureWithPortals>
class ArrayPortalCompositeVector
{
typedef vtkm::internal::FunctionInterface<SignatureWithPortals> PortalTypes;
typedef vtkm::Tuple<int, PortalTypes::ARITY> ComponentMapType;
typedef vtkm::Tuple<vtkm::IdComponent, PortalTypes::ARITY> ComponentMapType;
public:
typedef typename PortalTypes::ResultType ValueType;
static const int NUM_COMPONENTS =
static const vtkm::IdComponent NUM_COMPONENTS =
vtkm::VectorTraits<ValueType>::NUM_COMPONENTS;
BOOST_STATIC_ASSERT(NUM_COMPONENTS == PortalTypes::ARITY);
@ -181,7 +181,7 @@ public:
VTKM_CONT_EXPORT
ArrayPortalCompositeVector(
const PortalTypes portals,
vtkm::Tuple<int, NUM_COMPONENTS> sourceComponents)
vtkm::Tuple<vtkm::IdComponent, NUM_COMPONENTS> sourceComponents)
: Portals(portals), SourceComponents(sourceComponents) { }
VTKM_EXEC_EXPORT
@ -221,9 +221,9 @@ class ArrayPortalCompositeVectorCont
public:
typedef typename FunctionInterfaceArrays::ResultType ValueType;
static const int NUM_COMPONENTS =
static const vtkm::IdComponent NUM_COMPONENTS =
vtkm::VectorTraits<ValueType>::NUM_COMPONENTS;
typedef vtkm::Tuple<int, NUM_COMPONENTS> ComponentMapType;
typedef vtkm::Tuple<vtkm::IdComponent, NUM_COMPONENTS> ComponentMapType;
// If you get a compile error here, it means you probably tried to create
// an ArrayHandleCompositeVector with a return type of a vector with a
@ -283,8 +283,8 @@ class Storage<
{
typedef vtkm::internal::FunctionInterface<SignatureWithArrays>
FunctionInterfaceWithArrays;
static const int NUM_COMPONENTS = FunctionInterfaceWithArrays::ARITY;
typedef vtkm::Tuple<int, NUM_COMPONENTS> ComponentMapType;
static const vtkm::IdComponent NUM_COMPONENTS = FunctionInterfaceWithArrays::ARITY;
typedef vtkm::Tuple<vtkm::IdComponent, NUM_COMPONENTS> ComponentMapType;
public:
typedef ArrayPortalCompositeVectorCont<SignatureWithArrays> PortalType;
@ -529,7 +529,7 @@ public:
template<typename ArrayHandleType1>
VTKM_CONT_EXPORT
ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
int sourceComponent1)
vtkm::IdComponent sourceComponent1)
: Superclass(StorageType(
vtkm::internal::make_FunctionInterface<ValueType>(array1),
ComponentMapType(sourceComponent1)))
@ -538,9 +538,9 @@ public:
typename ArrayHandleType2>
VTKM_CONT_EXPORT
ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
int sourceComponent1,
vtkm::IdComponent sourceComponent1,
const ArrayHandleType2 &array2,
int sourceComponent2)
vtkm::IdComponent sourceComponent2)
: Superclass(StorageType(
vtkm::internal::make_FunctionInterface<ValueType>(
array1, array2),
@ -552,11 +552,11 @@ public:
typename ArrayHandleType3>
VTKM_CONT_EXPORT
ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
int sourceComponent1,
vtkm::IdComponent sourceComponent1,
const ArrayHandleType2 &array2,
int sourceComponent2,
vtkm::IdComponent sourceComponent2,
const ArrayHandleType3 &array3,
int sourceComponent3)
vtkm::IdComponent sourceComponent3)
: Superclass(StorageType(
vtkm::internal::make_FunctionInterface<ValueType>(
array1, array2, array3),
@ -570,13 +570,13 @@ public:
typename ArrayHandleType4>
VTKM_CONT_EXPORT
ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
int sourceComponent1,
vtkm::IdComponent sourceComponent1,
const ArrayHandleType2 &array2,
int sourceComponent2,
vtkm::IdComponent sourceComponent2,
const ArrayHandleType3 &array3,
int sourceComponent3,
vtkm::IdComponent sourceComponent3,
const ArrayHandleType4 &array4,
int sourceComponent4)
vtkm::IdComponent sourceComponent4)
: Superclass(StorageType(
vtkm::internal::make_FunctionInterface<ValueType>(
array1, array2, array3, array4),
@ -662,7 +662,7 @@ typename ArrayHandleCompositeVectorType<
vtkm::cont::ArrayHandle<ValueType1,Storage1> >::type
make_ArrayHandleCompositeVector(
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
int sourceComponent1)
vtkm::IdComponent sourceComponent1)
{
return typename ArrayHandleCompositeVectorType<
vtkm::cont::ArrayHandle<ValueType1,Storage1> >::type(array1,
@ -676,9 +676,9 @@ typename ArrayHandleCompositeVectorType<
vtkm::cont::ArrayHandle<ValueType2,Storage2> >::type
make_ArrayHandleCompositeVector(
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
int sourceComponent1,
vtkm::IdComponent sourceComponent1,
const vtkm::cont::ArrayHandle<ValueType2,Storage2> &array2,
int sourceComponent2)
vtkm::IdComponent sourceComponent2)
{
return typename ArrayHandleCompositeVectorType<
vtkm::cont::ArrayHandle<ValueType1,Storage1>,
@ -697,11 +697,11 @@ typename ArrayHandleCompositeVectorType<
vtkm::cont::ArrayHandle<ValueType3,Storage3> >::type
make_ArrayHandleCompositeVector(
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
int sourceComponent1,
vtkm::IdComponent sourceComponent1,
const vtkm::cont::ArrayHandle<ValueType2,Storage2> &array2,
int sourceComponent2,
vtkm::IdComponent sourceComponent2,
const vtkm::cont::ArrayHandle<ValueType3,Storage3> &array3,
int sourceComponent3)
vtkm::IdComponent sourceComponent3)
{
return typename ArrayHandleCompositeVectorType<
vtkm::cont::ArrayHandle<ValueType1,Storage1>,
@ -725,13 +725,13 @@ typename ArrayHandleCompositeVectorType<
vtkm::cont::ArrayHandle<ValueType4,Storage4> >::type
make_ArrayHandleCompositeVector(
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
int sourceComponent1,
vtkm::IdComponent sourceComponent1,
const vtkm::cont::ArrayHandle<ValueType2,Storage2> &array2,
int sourceComponent2,
vtkm::IdComponent sourceComponent2,
const vtkm::cont::ArrayHandle<ValueType3,Storage3> &array3,
int sourceComponent3,
vtkm::IdComponent sourceComponent3,
const vtkm::cont::ArrayHandle<ValueType4,Storage4> &array4,
int sourceComponent4)
vtkm::IdComponent sourceComponent4)
{
return typename ArrayHandleCompositeVectorType<
vtkm::cont::ArrayHandle<ValueType1,Storage1>,

@ -361,8 +361,8 @@ public:
}
struct TimeStamp
{
vtkm::internal::Int64Type Seconds;
vtkm::internal::Int64Type Microseconds;
vtkm::Int64 Seconds;
vtkm::Int64 Microseconds;
};
TimeStamp StartTime;

@ -97,7 +97,7 @@ public:
VTKM_CONT_EXPORT
detail::IteratorFromArrayPortalValue<ArrayPortalType>
operator[](int idx) const
operator[](vtkm::Id idx) const
{
return detail::IteratorFromArrayPortalValue<ArrayPortalType>(this->Portal,
idx);

@ -64,9 +64,9 @@ struct SortLess
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
vtkm::TypeTraitsVectorTag) const
{
enum {SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
const vtkm::IdComponent SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS;
bool valid = true;
for(unsigned int i=0; i < SIZE && valid; ++i)
for(vtkm::IdComponent i=0; (i < SIZE) && valid; ++i)
{
valid = a[i] < b[i];
}
@ -92,9 +92,9 @@ struct SortGreater
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
vtkm::TypeTraitsVectorTag) const
{
enum {SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
const vtkm::IdComponent SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS;
bool valid = true;
for(unsigned int i=0; i < SIZE && valid; ++i)
for(vtkm::IdComponent i=0; (i < SIZE) && valid; ++i)
{
valid = a[i] > b[i];
}
@ -1029,7 +1029,7 @@ private:
//ie 1, 3, 6, 10, 15, 21 ...
vtkm::Id partialSum = 0;
vtkm::Id triangleNumber = 0;
for(unsigned int i=0, pos=1; i < ARRAY_SIZE; ++i, ++pos)
for(vtkm::Id i=0, pos=1; i < ARRAY_SIZE; ++i, ++pos)
{
const vtkm::Id value = array.GetPortalConstControl().Get(i);
partialSum += value;
@ -1062,7 +1062,7 @@ private:
//ie 0, 1, 3, 6, 10, 15, 21 ...
vtkm::Id partialSum = 0;
vtkm::Id triangleNumber = 0;
for(unsigned int i=0, pos=0; i < ARRAY_SIZE; ++i, ++pos)
for(vtkm::Id i=0, pos=0; i < ARRAY_SIZE; ++i, ++pos)
{
const vtkm::Id value = array.GetPortalConstControl().Get(i);
partialSum += value;

@ -40,7 +40,9 @@ const vtkm::Id ARRAY_SIZE = 10;
typedef vtkm::cont::StorageTagBasic StorageTag;
vtkm::Scalar TestValue(vtkm::Id index, int inComponentIndex, int inArrayId)
vtkm::Scalar TestValue(vtkm::Id index,
vtkm::IdComponent inComponentIndex,
int inArrayId)
{
return index + vtkm::Scalar(0.1)*inComponentIndex + vtkm::Scalar(0.01)*inArrayId;
}
@ -55,7 +57,7 @@ MakeInputArray(int arrayId)
ValueType buffer[ARRAY_SIZE];
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
for (int componentIndex = 0;
for (vtkm::IdComponent componentIndex = 0;
componentIndex < VTraits::NUM_COMPONENTS;
componentIndex++)
{
@ -82,7 +84,7 @@ MakeInputArray(int arrayId)
template<typename ValueType, typename C>
void CheckArray(const vtkm::cont::ArrayHandle<ValueType,C> &outArray,
const int *inComponents,
const vtkm::IdComponent *inComponents,
const int *inArrayIds)
{
// ArrayHandleCompositeVector currently does not implement the ability to
@ -98,7 +100,7 @@ void CheckArray(const vtkm::cont::ArrayHandle<ValueType,C> &outArray,
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
ValueType retreivedValue = portal.Get(index);
for (int componentIndex = 0;
for (vtkm::IdComponent componentIndex = 0;
componentIndex < VTraits::NUM_COMPONENTS;
componentIndex++)
{
@ -113,7 +115,7 @@ void CheckArray(const vtkm::cont::ArrayHandle<ValueType,C> &outArray,
}
}
template<int inComponents>
template<vtkm::IdComponent inComponents>
void TryScalarArray()
{
std::cout << "Creating a scalar array from one of "
@ -126,7 +128,7 @@ void TryScalarArray()
typedef typename vtkm::cont::ArrayHandleCompositeVectorType<InArrayType>::type
OutArrayType;
for (int inComponentIndex = 0;
for (vtkm::IdComponent inComponentIndex = 0;
inComponentIndex < inComponents;
inComponentIndex++)
{
@ -143,7 +145,7 @@ void TryVector4(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
vtkm::cont::ArrayHandle<T4,StorageTag> array4)
{
int arrayIds[4] = {0, 1, 2, 3};
int inComponents[4];
vtkm::IdComponent inComponents[4];
for (inComponents[0] = 0;
inComponents[0] < vtkm::VectorTraits<T1>::NUM_COMPONENTS;
@ -181,7 +183,7 @@ void TryVector3(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
vtkm::cont::ArrayHandle<T3,StorageTag> array3)
{
int arrayIds[3] = {0, 1, 2};
int inComponents[3];
vtkm::IdComponent inComponents[3];
for (inComponents[0] = 0;
inComponents[0] < vtkm::VectorTraits<T1>::NUM_COMPONENTS;
@ -217,7 +219,7 @@ void TryVector2(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
vtkm::cont::ArrayHandle<T2,StorageTag> array2)
{
int arrayIds[2] = {0, 1};
int inComponents[2];
vtkm::IdComponent inComponents[2];
for (inComponents[0] = 0;
inComponents[0] < vtkm::VectorTraits<T1>::NUM_COMPONENTS;
@ -246,7 +248,7 @@ template<typename T1>
void TryVector1(vtkm::cont::ArrayHandle<T1,StorageTag> array1)
{
int arrayIds[1] = {0};
int inComponents[1];
vtkm::IdComponent inComponents[1];
for (inComponents[0] = 0;
inComponents[0] < vtkm::VectorTraits<T1>::NUM_COMPONENTS;

@ -43,10 +43,10 @@ vtkm::Scalar TestValue(vtkm::Id index, vtkm::Scalar) {
return static_cast<vtkm::Scalar>(index)/100;
}
template<typename T, int N>
template<typename T, vtkm::IdComponent N>
vtkm::Tuple<T,N> TestValue(vtkm::Id index, vtkm::Tuple<T,N>) {
vtkm::Tuple<T,N> value;
for (int i = 0; i < N; i++)
for (vtkm::IdComponent i = 0; i < N; i++)
{
value[i] = TestValue(index, T()) + (i + 1);
}

@ -43,21 +43,21 @@ struct TestFunctor
}
};
template<int N>
template<vtkm::IdComponent N>
void CheckSame(const vtkm::Tuple<TypeId,N> &expected,
const std::vector<TypeId> &found)
{
VTKM_TEST_ASSERT(static_cast<int>(found.size()) == N,
VTKM_TEST_ASSERT(static_cast<vtkm::IdComponent>(found.size()) == N,
"Got wrong number of items.");
for (int index = 0; index < N; index++)
for (vtkm::IdComponent index = 0; index < N; index++)
{
VTKM_TEST_ASSERT(expected[index] == found[index],
"Got wrong type.");
}
}
template<int N, typename ListTag>
template<vtkm::IdComponent N, typename ListTag>
void TryList(const vtkm::Tuple<TypeId,N> &expected, ListTag)
{
TestFunctor functor;

@ -39,6 +39,8 @@
#define VTKM_SIZE_FLOAT @VTKm_SIZE_FLOAT@
#define VTKM_SIZE_DOUBLE @VTKm_SIZE_DOUBLE@
#define VTKM_SIZE_CHAR @VTKm_SIZE_CHAR@
#define VTKM_SIZE_SHORT @VTKm_SIZE_SHORT@
#define VTKM_SIZE_INT @VTKm_SIZE_INT@
#define VTKM_SIZE_LONG @VTKm_SIZE_LONG@
#define VTKM_SIZE_LONG_LONG @VTKm_SIZE_LONG_LONG@

@ -56,14 +56,14 @@ struct IdentityFunctor {
};
template<int ParameterIndex, typename FunctionSignature>
template<vtkm::IdComponent ParameterIndex, typename FunctionSignature>
VTKM_EXEC_CONT_EXPORT
typename ParameterContainerAccess<ParameterIndex,FunctionSignature>::ParameterType
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
return ParameterContainerAccess<ParameterIndex,FunctionSignature>::GetParameter(parameters);
}
template<int ParameterIndex, typename FunctionSignature>
template<vtkm::IdComponent ParameterIndex, typename FunctionSignature>
VTKM_EXEC_CONT_EXPORT
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const typename ParameterContainerAccess<ParameterIndex,FunctionSignature>::ParameterType &value) {
@ -72,7 +72,7 @@ void SetParameter(ParameterContainer<FunctionSignature> &parameters,
// These functions exist to help copy components of a FunctionInterface.
template<int NumToCopy, int ParameterIndex = 1>
template<vtkm::IdComponent NumToCopy, vtkm::IdComponent ParameterIndex = 1>
struct FunctionInterfaceCopyParameters {
template<typename DestSignature, typename SrcSignature>
static
@ -86,7 +86,7 @@ struct FunctionInterfaceCopyParameters {
}
};
template<int ParameterIndex>
template<vtkm::IdComponent ParameterIndex>
struct FunctionInterfaceCopyParameters<0, ParameterIndex> {
template<typename DestSignature, typename SrcSignature>
static
@ -151,7 +151,7 @@ class FunctionInterfaceDynamicTransformContContinue;
/// a template parameter.
///
/// \code{.cpp}
/// vtkm::internal::FunctionInterface<void(int,double,char)> functionInterface =
/// vtkm::internal::FunctionInterface<void(vtkm::IdComponent,double,char)> functionInterface =
/// vtkm::internal::make_FunctionInterface<void>(1, 2.5, 'a');
/// \endcode
///
@ -258,7 +258,7 @@ public:
typedef typename boost::function_types::result_type<FunctionSignature>::type
ResultType;
template<int ParameterIndex>
template<vtkm::IdComponent ParameterIndex>
struct ParameterType {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>,
@ -268,13 +268,13 @@ public:
/// The number of parameters in this \c Function Interface.
///
static const int ARITY = SignatureArity::value;
static const vtkm::IdComponent ARITY = SignatureArity::value;
/// Returns the number of parameters held in this \c FunctionInterface. The
/// return value is the same as \c ARITY.
///
VTKM_EXEC_CONT_EXPORT
int GetArity() const { return ARITY; }
vtkm::IdComponent GetArity() const { return ARITY; }
/// Retrieves the return value from the last invocation called. This method
/// will result in a compiler error if used with a function having a void
@ -315,7 +315,7 @@ public:
/// }
/// \endcode
///
template<int ParameterIndex>
template<vtkm::IdComponent ParameterIndex>
VTKM_EXEC_CONT_EXPORT
typename ParameterType<ParameterIndex>::type
GetParameter() const {
@ -328,7 +328,7 @@ public:
/// template (which is almost always the case), then you will have to use the
/// template keyword.
///
template<int ParameterIndex>
template<vtkm::IdComponent ParameterIndex>
VTKM_EXEC_CONT_EXPORT
void SetParameter(typename ParameterType<ParameterIndex>::type parameter)
{
@ -447,7 +447,7 @@ public:
return appendedFuncInterface;
}
template<int ParameterIndex, typename NewType>
template<vtkm::IdComponent ParameterIndex, typename NewType>
class ReplaceType {
typedef boost::function_types::components<FunctionSignature> ThisFunctionComponents;
typedef typename boost::mpl::advance_c<typename boost::mpl::begin<ThisFunctionComponents>::type, ParameterIndex>::type ToRemovePos;
@ -466,7 +466,7 @@ public:
/// changes. The return type can be determined with the \c ReplaceType
/// template.
///
template<int ParameterIndex, typename NewType>
template<vtkm::IdComponent ParameterIndex, typename NewType>
VTKM_EXEC_CONT_EXPORT
typename ReplaceType<ParameterIndex, NewType>::type
Replace(NewType newParameter) const {

@ -304,7 +304,9 @@ bool test_equal(VectorType vector1,
vtkm::Scalar tolerance = 0.0001)
{
typedef typename vtkm::VectorTraits<VectorType> Traits;
for (int component = 0; component < Traits::NUM_COMPONENTS; component++)
for (vtkm::IdComponent component = 0;
component < Traits::NUM_COMPONENTS;
component++)
{
vtkm::Scalar value1 = vtkm::Scalar(Traits::GetComponent(vector1, component));
vtkm::Scalar value2 = vtkm::Scalar(Traits::GetComponent(vector2, component));
@ -340,12 +342,12 @@ bool test_equal(const std::string &string1, const std::string &string2)
/// Helper function for printing out vectors during testing.
///
template<typename T, int Size>
template<typename T, vtkm::IdComponent Size>
VTKM_EXEC_CONT_EXPORT
std::ostream &operator<<(std::ostream &stream, const vtkm::Tuple<T,Size> &tuple)
{
stream << "[";
for (int component = 0; component < Size-1; component++)
for (vtkm::IdComponent component = 0; component < Size-1; component++)
{
stream << tuple[component] << ",";
}

@ -24,14 +24,14 @@
namespace {
const int MIN_VALUES[] = { -5, 8, 40, -8, -3 };
const int MAX_VALUES[] = { 10, 25, 44, -2, 1 };
const int POINT_DIMS[] = { 16, 18, 5, 7, 5 };
const int CELL_DIMS[] = { 15, 17, 4, 6, 4 };
const int NUM_POINTS[] = { 0, 16, 288, 1440, 10080, 50400 };
const int NUM_CELLS[] = { 0, 15, 255, 1020, 6120, 24480 };
const vtkm::Id MIN_VALUES[] = { -5, 8, 40, -8, -3 };
const vtkm::Id MAX_VALUES[] = { 10, 25, 44, -2, 1 };
const vtkm::Id POINT_DIMS[] = { 16, 18, 5, 7, 5 };
const vtkm::Id CELL_DIMS[] = { 15, 17, 4, 6, 4 };
const vtkm::Id NUM_POINTS[] = { 0, 16, 288, 1440, 10080, 50400 };
const vtkm::Id NUM_CELLS[] = { 0, 15, 255, 1020, 6120, 24480 };
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
void TestDimensions(vtkm::Extent<Dimensions>)
{
std::cout << "Testing Dimension sizes for " << Dimensions << " dimensions"
@ -43,13 +43,13 @@ void TestDimensions(vtkm::Extent<Dimensions>)
vtkm::Id numPoints;
vtkm::Id numCells;
for (int dimIndex = 0; dimIndex < Dimensions; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions; dimIndex++)
{
extent.Min[dimIndex] = 0; extent.Max[dimIndex] = 10;
}
pointDims = vtkm::ExtentPointDimensions(extent);
cellDims = vtkm::ExtentCellDimensions(extent);
for (int dimIndex = 0; dimIndex < Dimensions; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions; dimIndex++)
{
VTKM_TEST_ASSERT(pointDims[dimIndex] == 11,
"Got incorrect point dimensions for extent.");
@ -57,14 +57,14 @@ void TestDimensions(vtkm::Extent<Dimensions>)
"Got incorrect point dimensions for extent.");
}
for (int dimIndex = 0; dimIndex < Dimensions; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions; dimIndex++)
{
extent.Min[dimIndex] = MIN_VALUES[dimIndex];
extent.Max[dimIndex] = MAX_VALUES[dimIndex];
}
pointDims = vtkm::ExtentPointDimensions(extent);
cellDims = vtkm::ExtentCellDimensions(extent);
for (int dimIndex = 0; dimIndex < Dimensions; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions; dimIndex++)
{
VTKM_TEST_ASSERT(pointDims[dimIndex] == POINT_DIMS[dimIndex],
"Got incorrect point dimensions for extent.");
@ -79,7 +79,7 @@ void TestDimensions(vtkm::Extent<Dimensions>)
"Got wrong number of cells.");
}
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
void TryIndexConversion(const vtkm::Extent<Dimensions> &extent)
{
typedef vtkm::Tuple<vtkm::Id,Dimensions> IdX;
@ -94,7 +94,7 @@ void TryIndexConversion(const vtkm::Extent<Dimensions> &extent)
correctFlatIndex++)
{
// Increment topology index
for (int dimIndex = 0; dimIndex < Dimensions; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions; dimIndex++)
{
correctTopologyIndex[dimIndex]++;
if (correctTopologyIndex[dimIndex] <= extent.Max[dimIndex]) { break; }
@ -124,7 +124,7 @@ void TryIndexConversion(const vtkm::Extent<Dimensions> &extent)
correctFlatIndex++)
{
// Increment topology index
for (int dimIndex = 0; dimIndex < Dimensions; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions; dimIndex++)
{
correctTopologyIndex[dimIndex]++;
if (correctTopologyIndex[dimIndex] < extent.Max[dimIndex]) { break; }
@ -154,7 +154,7 @@ void TryIndexConversion(const vtkm::Extent<Dimensions> &extent)
"Test code error. Indexing problem.");
}
template<int Dimensions>
template<vtkm::IdComponent Dimensions>
void TestIndexConversion(vtkm::Extent<Dimensions>)
{
std::cout << "Testing index conversion for " << Dimensions << " dimensions."
@ -162,13 +162,13 @@ void TestIndexConversion(vtkm::Extent<Dimensions>)
vtkm::Extent<Dimensions> extent;
for (int dimIndex = 0; dimIndex < Dimensions; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions; dimIndex++)
{
extent.Min[dimIndex] = 0; extent.Max[dimIndex] = 10;
}
TryIndexConversion(extent);
for (int dimIndex = 0; dimIndex < Dimensions; dimIndex++)
for (vtkm::IdComponent dimIndex = 0; dimIndex < Dimensions; dimIndex++)
{
extent.Min[dimIndex] = MIN_VALUES[dimIndex];
extent.Max[dimIndex] = MAX_VALUES[dimIndex];

@ -80,21 +80,21 @@ struct ConstantFunctor
}
};
template<int N>
template<vtkm::IdComponent N>
void CheckSame(const vtkm::Tuple<int,N> &expected,
const std::vector<int> &found)
{
VTKM_TEST_ASSERT(static_cast<int>(found.size()) == N,
"Got wrong number of items.");
for (int index = 0; index < N; index++)
for (vtkm::IdComponent index = 0; index < N; index++)
{
VTKM_TEST_ASSERT(expected[index] == found[index],
"Got wrong type.");
}
}
template<int N, typename ListTag>
template<vtkm::IdComponent N, typename ListTag>
void TryList(const vtkm::Tuple<int,N> &expected, ListTag)
{
std::cout << " Try mutable for each" << std::endl;

@ -57,21 +57,21 @@ struct TestFunctor
}
};
template<int N>
template<vtkm::IdComponent N>
void CheckSame(const vtkm::Tuple<TypeId,N> &expected,
const std::vector<TypeId> &found)
{
VTKM_TEST_ASSERT(static_cast<int>(found.size()) == N,
VTKM_TEST_ASSERT(static_cast<vtkm::IdComponent>(found.size()) == N,
"Got wrong number of items.");
for (int index = 0; index < N; index++)
for (vtkm::IdComponent index = 0; index < N; index++)
{
VTKM_TEST_ASSERT(expected[index] == found[index],
"Got wrong type.");
}
}
template<int N, typename ListTag>
template<vtkm::IdComponent N, typename ListTag>
void TryList(const vtkm::Tuple<TypeId,N> &expected, ListTag)
{
TestFunctor functor;

@ -44,6 +44,20 @@
namespace {
void CheckTypeSizes()
{
VTKM_TEST_ASSERT(sizeof(vtkm::Int8) == 1, "Int8 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::UInt8) == 1, "UInt8 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::Int16) == 2, "Int16 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::UInt16) == 2, "UInt16 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::Int32) == 4, "Int32 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::UInt32) == 4, "UInt32 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::Int64) == 8, "Int64 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::UInt64) == 8, "UInt64 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::Float32) == 4, "Float32 wrong size.");
VTKM_TEST_ASSERT(sizeof(vtkm::Float64) == 8, "Float32 wrong size.");
}
//general type test
template <typename T> void TypeTest()
{
@ -51,7 +65,7 @@ template <typename T> void TypeTest()
T a, b, c;
typename T::ComponentType s(5);
for(int i=0; i < T::NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < T::NUM_COMPONENTS; ++i)
{
a[i]=typename T::ComponentType((i+1)*2);
b[i]=typename T::ComponentType(i+1);
@ -69,31 +83,31 @@ template <typename T> void TypeTest()
T plus = a + b;
T correct_plus;
for(int i=0; i < T::NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < T::NUM_COMPONENTS; ++i)
{ correct_plus[i] = a[i] + b[i]; }
VTKM_TEST_ASSERT(test_equal(plus, correct_plus),"Tuples not added correctly.");
T minus = a - b;
T correct_minus;
for(int i=0; i < T::NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < T::NUM_COMPONENTS; ++i)
{ correct_minus[i] = a[i] - b[i]; }
VTKM_TEST_ASSERT(test_equal(minus, correct_minus),"Tuples not subtracted correctly.");
T mult = a * b;
T correct_mult;
for(int i=0; i < T::NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < T::NUM_COMPONENTS; ++i)
{ correct_mult[i] = a[i] * b[i]; }
VTKM_TEST_ASSERT(test_equal(mult, correct_mult),"Tuples not multiplied correctly.");
T div = a / b;
T correct_div;
for(int i=0; i < T::NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < T::NUM_COMPONENTS; ++i)
{ correct_div[i] = a[i] / b[i]; }
VTKM_TEST_ASSERT(test_equal(div,correct_div),"Tuples not divided correctly.");
mult = s * a;
for(int i=0; i < T::NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < T::NUM_COMPONENTS; ++i)
{ correct_mult[i] = s * a[i]; }
VTKM_TEST_ASSERT(test_equal(mult, correct_mult),
"Scalar and Tuple did not multiply correctly.");
@ -104,7 +118,7 @@ template <typename T> void TypeTest()
typename T::ComponentType d = vtkm::dot(a, b);
typename T::ComponentType correct_d = 0;
for(int i=0; i < T::NUM_COMPONENTS; ++i)
for(vtkm::IdComponent i=0; i < T::NUM_COMPONENTS; ++i)
{correct_d += a[i] * b[i]; }
VTKM_TEST_ASSERT(test_equal(d, correct_d), "dot(Tuple) wrong");
@ -478,6 +492,8 @@ struct TypeTestFunctor
void TestTypes()
{
CheckTypeSizes();
vtkm::testing::Testing::TryAllTypes(TypeTestFunctor());
//try with some custom tuple types

@ -35,7 +35,7 @@ struct TestVectorTypeFunctor
VTKM_TEST_ASSERT(Traits::NUM_COMPONENTS <= MAX_VECTOR_SIZE,
"Need to update test for larger vectors.");
T vector;
for (int index = 0; index < Traits::NUM_COMPONENTS; index++)
for (vtkm::IdComponent index = 0; index < Traits::NUM_COMPONENTS; index++)
{
Traits::SetComponent(vector, index, ComponentType(VectorInit[index]));
}