mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Add in primitive types to vtkm (Id, Scalar, Tuple).
This includes the configure scripts to setup if you want a 32bit or 64bit build.
This commit is contained in:
parent
ad0bc83320
commit
c07301a993
145
vtkm/TypeTraits.h
Normal file
145
vtkm/TypeTraits.h
Normal file
@ -0,0 +1,145 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014. Los Alamos National Security
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtkm_TypeTraits_h
|
||||
#define vtkm_TypeTraits_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
namespace vtkm {
|
||||
|
||||
/// Tag used to identify types that store real (floating-point) numbers. A
|
||||
/// TypeTraits class will typedef this class to NumericTag if it stores real
|
||||
/// numbers (or vectors of real numbers).
|
||||
///
|
||||
struct TypeTraitsRealTag {};
|
||||
|
||||
/// Tag used to identify types that store integer numbers. A TypeTraits class
|
||||
/// will typedef this class to NumericTag if it stores integer numbers (or
|
||||
/// vectors of integers).
|
||||
///
|
||||
struct TypeTraitsIntegerTag {};
|
||||
|
||||
/// Tag used to identify 0 dimensional types (scalars). Scalars can also be
|
||||
/// treated like vectors when used with VectorTraits. A TypeTraits class will
|
||||
/// typedef this class to DimensionalityTag.
|
||||
///
|
||||
struct TypeTraitsScalarTag {};
|
||||
|
||||
/// Tag used to identify 1 dimensional types (vectors). A TypeTraits class will
|
||||
/// typedef this class to DimensionalityTag.
|
||||
///
|
||||
struct TypeTraitsVectorTag {};
|
||||
|
||||
template<typename T> struct TypeTraits;
|
||||
|
||||
#ifdef VTKM_DOXYGEN_ONLY
|
||||
|
||||
/// The TypeTraits class provides helpful compile-time information about the
|
||||
/// basic types used in VTKm (and a few others for convienience). The majority
|
||||
/// of TypeTraits contents are typedefs to tags that can be used to easily
|
||||
/// override behavior of called functions.
|
||||
///
|
||||
template<typename T>
|
||||
class TypeTraits {
|
||||
typedef int tag_type; // Shut up, test compile.
|
||||
public:
|
||||
|
||||
/// \brief A tag to determing whether the type is integer or real.
|
||||
///
|
||||
/// This tag is either TypeTraitsRealTag or TypeTraitsIntegerTag.
|
||||
typedef tag_type NumericTag;
|
||||
|
||||
/// \brief A tag to determine whether the type has multiple components.
|
||||
///
|
||||
/// This tag is either TypeTraitsScalarTag or TypeTraitsVectorTag. Scalars can
|
||||
/// also be treated as vectors.
|
||||
typedef tag_type DimensionalityTag;
|
||||
};
|
||||
|
||||
#endif //VTKM_DOXYGEN_ONLY
|
||||
|
||||
// Const types should have the same traits as their non-const counterparts.
|
||||
//
|
||||
template<typename T>
|
||||
struct TypeTraits<const T> : TypeTraits<T>
|
||||
{ };
|
||||
|
||||
#define VTKM_BASIC_REAL_TYPE(T) \
|
||||
template<> struct TypeTraits<T> { \
|
||||
typedef TypeTraitsRealTag NumericTag; \
|
||||
typedef TypeTraitsScalarTag DimensionalityTag; \
|
||||
}
|
||||
|
||||
#define VTKM_BASIC_INTEGER_TYPE(T) \
|
||||
template<> struct TypeTraits<T> { \
|
||||
typedef TypeTraitsIntegerTag NumericTag; \
|
||||
typedef TypeTraitsScalarTag DimensionalityTag; \
|
||||
}
|
||||
|
||||
/// Traits for basic C++ types.
|
||||
///
|
||||
|
||||
VTKM_BASIC_REAL_TYPE(float);
|
||||
VTKM_BASIC_REAL_TYPE(double);
|
||||
VTKM_BASIC_INTEGER_TYPE(char);
|
||||
VTKM_BASIC_INTEGER_TYPE(unsigned char);
|
||||
VTKM_BASIC_INTEGER_TYPE(short);
|
||||
VTKM_BASIC_INTEGER_TYPE(unsigned short);
|
||||
VTKM_BASIC_INTEGER_TYPE(int);
|
||||
VTKM_BASIC_INTEGER_TYPE(unsigned int);
|
||||
#if VTKM_SIZE_LONG == 8
|
||||
VTKM_BASIC_INTEGER_TYPE(long);
|
||||
VTKM_BASIC_INTEGER_TYPE(unsigned long);
|
||||
#elif VTKM_SIZE_LONG_LONG == 8
|
||||
VTKM_BASIC_INTEGER_TYPE(long long);
|
||||
VTKM_BASIC_INTEGER_TYPE(unsigned long long);
|
||||
#else
|
||||
#error No implementation for 64-bit integer traits.
|
||||
#endif
|
||||
|
||||
#undef VTKM_BASIC_REAL_TYPE
|
||||
#undef VTKM_BASIC_INTEGER_TYPE
|
||||
|
||||
#define VTKM_VECTOR_TYPE(T, NTag) \
|
||||
template<> struct TypeTraits<T> { \
|
||||
typedef NTag NumericTag; \
|
||||
typedef TypeTraitsVectorTag DimensionalityTag; \
|
||||
}
|
||||
|
||||
/// Traits for vector types.
|
||||
///
|
||||
|
||||
VTKM_VECTOR_TYPE(vtkm::Id3, TypeTraitsIntegerTag);
|
||||
VTKM_VECTOR_TYPE(vtkm::Vector2, TypeTraitsRealTag);
|
||||
VTKM_VECTOR_TYPE(vtkm::Vector3, TypeTraitsRealTag);
|
||||
VTKM_VECTOR_TYPE(vtkm::Vector4, TypeTraitsRealTag);
|
||||
|
||||
#undef VTKM_VECTOR_TYPE
|
||||
|
||||
/// Traits for tuples.
|
||||
///
|
||||
template<typename T, int Size> struct TypeTraits<vtkm::Tuple<T, Size> > {
|
||||
typedef typename TypeTraits<T>::NumericTag NumericTag;
|
||||
typedef TypeTraitsVectorTag DimensionalityTag;
|
||||
};
|
||||
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtkm_TypeTraits_h
|
704
vtkm/Types.h
Normal file
704
vtkm/Types.h
Normal file
@ -0,0 +1,704 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014. Los Alamos National Security
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtkm_Types_h
|
||||
#define vtkm_Types_h
|
||||
|
||||
#include <vtkm/internal/Configure.h>
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
|
||||
/*!
|
||||
* \namespace vtkm
|
||||
* \brief VTKm Toolkit.
|
||||
*
|
||||
* vtkm is the namespace for the VTKm Toolkit. It contains other sub namespaces,
|
||||
* as well as basic data types and functions callable from all components in VTKm
|
||||
* toolkit.
|
||||
*
|
||||
* \namespace vtkm::cont
|
||||
* \brief VTKm Control Environment.
|
||||
*
|
||||
* vtkm::cont defines the publicly accessible API for the VTKm Control
|
||||
* Environment. Users of the VTKm Toolkit can use this namespace to access the
|
||||
* Control Environment.
|
||||
*
|
||||
* \namespace vtkm::cuda
|
||||
* \brief CUDA implementation.
|
||||
*
|
||||
* vtkm::cuda includes the code to implement the VTKm for CUDA-based platforms.
|
||||
*
|
||||
* \namespace vtkm::cuda::cont
|
||||
* \brief CUDA implementation for Control Environment.
|
||||
*
|
||||
* vtkm::cuda::cont includes the code to implement the VTKm Control Environment
|
||||
* for CUDA-based platforms.
|
||||
*
|
||||
* \namespace vtkm::cuda::exec
|
||||
* \brief CUDA implementation for Execution Environment.
|
||||
*
|
||||
* vtkm::cuda::exec includes the code to implement the VTKm Execution Environment
|
||||
* for CUDA-based platforms.
|
||||
*
|
||||
* \namespace vtkm::exec
|
||||
* \brief VTKm Execution Environment.
|
||||
*
|
||||
* vtkm::exec defines the publicly accessible API for the VTKm Execution
|
||||
* Environment. Worklets typically use classes/apis defined within this
|
||||
* namespace alone.
|
||||
*
|
||||
* \namespace vtkm::internal
|
||||
* \brief VTKm Internal Environment
|
||||
*
|
||||
* vtkm::internal defines API which is internal and subject to frequent
|
||||
* change. This should not be used for projects using VTKm. Instead it servers
|
||||
* are a reference for the developers of VTKm.
|
||||
*
|
||||
* \namespace vtkm::math
|
||||
* \brief Utility math functions
|
||||
*
|
||||
* vtkm::math defines the publicly accessible API for Utility Math functions.
|
||||
*
|
||||
* \namespace vtkm::testing
|
||||
* \brief Internal testing classes
|
||||
*
|
||||
*/
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
//*****************************************************************************
|
||||
// Typedefs for basic types.
|
||||
//*****************************************************************************
|
||||
|
||||
/// Alignment requirements are prescribed by CUDA on device (Table B-1 in NVIDIA
|
||||
/// CUDA C Programming Guide 4.0)
|
||||
|
||||
namespace internal {
|
||||
|
||||
#if VTKM_SIZE_INT == 4
|
||||
typedef int Int32Type;
|
||||
typedef unsigned int UInt32Type;
|
||||
#else
|
||||
#error Could not find a 32-bit integer.
|
||||
#endif
|
||||
|
||||
#if VTKM_SIZE_LONG == 8
|
||||
typedef long Int64Type;
|
||||
typedef unsigned long UInt64Type;
|
||||
#elif VTKM_SIZE_LONG_LONG == 8
|
||||
typedef long long Int64Type;
|
||||
typedef unsigned long long UInt64Type;
|
||||
#else
|
||||
#error Could not find a 64-bit integer.
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
template<int Size>
|
||||
struct equals
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const
|
||||
{
|
||||
return equals<Size-1>()(a,b) && a[Size-1] == b[Size-1];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct equals<1>
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const
|
||||
{
|
||||
return a[0] == b[0];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct equals<2>
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const
|
||||
{
|
||||
return a[0] == b[0] && a[1] == b[1];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct equals<3>
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a, const T& b) const
|
||||
{
|
||||
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2];
|
||||
}
|
||||
};
|
||||
|
||||
template<int Size>
|
||||
struct assign_scalar_to_vector
|
||||
{
|
||||
template<typename VectorType, typename ComponentType>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void operator()(VectorType &dest, const ComponentType &src)
|
||||
{
|
||||
assign_scalar_to_vector<Size-1>()(dest, src);
|
||||
dest[Size-1] = src;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct assign_scalar_to_vector<1>
|
||||
{
|
||||
template<typename VectorType, typename ComponentType>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void operator()(VectorType &dest, const ComponentType &src)
|
||||
{
|
||||
dest[0] = src;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct assign_scalar_to_vector<2>
|
||||
{
|
||||
template<typename VectorType, typename ComponentType>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void operator()(VectorType &dest, const ComponentType &src)
|
||||
{
|
||||
dest[0] = src; dest[1] = src;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct assign_scalar_to_vector<3>
|
||||
{
|
||||
template<typename VectorType, typename ComponentType>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void operator()(VectorType &dest, const ComponentType &src)
|
||||
{
|
||||
dest[0] = src; dest[1] = src; dest[2] = src;
|
||||
}
|
||||
};
|
||||
|
||||
template<int Size>
|
||||
struct copy_vector
|
||||
{
|
||||
template<typename T1, typename T2>
|
||||
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
|
||||
{
|
||||
copy_vector<Size-1>()(dest, src);
|
||||
dest[Size-1] = src[Size-1];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct copy_vector<1>
|
||||
{
|
||||
template<typename T1, typename T2>
|
||||
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
|
||||
{
|
||||
dest[0] = src[0];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct copy_vector<2>
|
||||
{
|
||||
template<typename T1, typename T2>
|
||||
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
|
||||
{
|
||||
dest[0] = src[0]; dest[1] = src[1];
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct copy_vector<3>
|
||||
{
|
||||
template<typename T1, typename T2>
|
||||
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
|
||||
{
|
||||
dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace internal
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if VTKM_SIZE_ID == 4
|
||||
|
||||
/// Represents an ID.
|
||||
typedef internal::Int32Type Id __attribute__ ((aligned(VTKM_SIZE_ID)));
|
||||
|
||||
#elif VTKM_SIZE_ID == 8
|
||||
|
||||
/// Represents an ID.
|
||||
typedef internal::Int64Type Id __attribute__ ((aligned(VTKM_SIZE_ID)));
|
||||
|
||||
#else
|
||||
#error Unknown Id Size
|
||||
#endif
|
||||
|
||||
#ifdef VTKM_USE_DOUBLE_PRECISION
|
||||
|
||||
/// Scalar corresponds to a floating point number.
|
||||
typedef double Scalar __attribute__ ((aligned(VTKM_SIZE_SCALAR)));
|
||||
|
||||
#else //VTKM_USE_DOUBLE_PRECISION
|
||||
|
||||
/// Scalar corresponds to a floating point number.
|
||||
typedef float Scalar __attribute__ ((aligned(VTKM_SIZE_SCALAR)));
|
||||
|
||||
#endif //VTKM_USE_DOUBLE_PRECISION
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/// Tuple corresponds to a Size-tuple of type T
|
||||
template<typename T, int Size>
|
||||
class Tuple {
|
||||
public:
|
||||
typedef T ComponentType;
|
||||
static const int 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)
|
||||
{
|
||||
this->Components[i]=value;
|
||||
}
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values)
|
||||
{
|
||||
for(int i=0; i < NUM_COMPONENTS;++i)
|
||||
{
|
||||
this->Components[i]=values[i];
|
||||
}
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple(const Tuple<ComponentType, Size> &src)
|
||||
{
|
||||
for (int i = 0; i < NUM_COMPONENTS; i++)
|
||||
{
|
||||
this->Components[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple<ComponentType, Size> &operator=(const Tuple<ComponentType, Size> &src)
|
||||
{
|
||||
for (int i = 0; i < NUM_COMPONENTS; i++)
|
||||
{
|
||||
this->Components[i] = src[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
|
||||
return this->Components[idx];
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
|
||||
return this->Components[idx];
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator==(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
bool same = true;
|
||||
for (int componentIndex=0; componentIndex<NUM_COMPONENTS; componentIndex++)
|
||||
{
|
||||
same &= (this->Components[componentIndex] == other[componentIndex]);
|
||||
}
|
||||
return same;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
for(vtkm::Id i=0; i < NUM_COMPONENTS; ++i)
|
||||
{
|
||||
//ignore equals as that represents check next value
|
||||
if(this->Components[i] < other[i])
|
||||
return true;
|
||||
else if(other[i] < this->Components[i])
|
||||
return false;
|
||||
} //if all same we are not less
|
||||
return false;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator!=(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return !(this->operator==(other));
|
||||
}
|
||||
|
||||
protected:
|
||||
ComponentType Components[NUM_COMPONENTS];
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Specializations for common tuple sizes (with special names).
|
||||
|
||||
template<typename T>
|
||||
class Tuple<T,2>{
|
||||
public:
|
||||
typedef T ComponentType;
|
||||
static const int NUM_COMPONENTS = 2;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT Tuple(){}
|
||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
||||
{
|
||||
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT Tuple(ComponentType x, ComponentType y) {
|
||||
this->Components[0] = x;
|
||||
this->Components[1] = y;
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple(const Tuple<ComponentType, NUM_COMPONENTS> &src)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, src.Components);
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple<ComponentType, NUM_COMPONENTS> &
|
||||
operator=(const Tuple<ComponentType, NUM_COMPONENTS> &src)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, src.Components);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
|
||||
return this->Components[idx];
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
|
||||
return this->Components[idx];
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator==(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return internal::equals<NUM_COMPONENTS>()(*this, other);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator!=(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return !(this->operator==(other));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return( (this->Components[0] < other[0]) ||
|
||||
(!(other[0] < this->Components[0]) && (this->Components[1] < other[1]))
|
||||
);
|
||||
}
|
||||
|
||||
protected:
|
||||
ComponentType Components[NUM_COMPONENTS];
|
||||
};
|
||||
|
||||
/// Vector2 corresponds to a 2-tuple
|
||||
typedef vtkm::Tuple<vtkm::Scalar,2>
|
||||
Vector2 __attribute__ ((aligned(VTKM_ALIGNMENT_TWO_SCALAR)));
|
||||
|
||||
|
||||
/// Id2 corresponds to a 2-dimensional index
|
||||
typedef vtkm::Tuple<vtkm::Id,2> Id2 __attribute__ ((aligned(VTKM_SIZE_ID)));
|
||||
|
||||
template<typename T>
|
||||
class Tuple<T,3>{
|
||||
public:
|
||||
typedef T ComponentType;
|
||||
static const int NUM_COMPONENTS = 3;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT Tuple(){}
|
||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
||||
{
|
||||
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple(ComponentType x, ComponentType y, ComponentType z) {
|
||||
this->Components[0] = x;
|
||||
this->Components[1] = y;
|
||||
this->Components[2] = z;
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple(const Tuple<ComponentType, NUM_COMPONENTS> &src)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, src.Components);
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple<ComponentType, NUM_COMPONENTS> &
|
||||
operator=(const Tuple<ComponentType, NUM_COMPONENTS> &src)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, src.Components);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
|
||||
return this->Components[idx];
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
|
||||
return this->Components[idx];
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator==(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return internal::equals<NUM_COMPONENTS>()(*this, other);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator!=(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return !(this->operator==(other));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return((this->Components[0] < other[0]) ||
|
||||
( !(other[0] < this->Components[0]) &&
|
||||
(this->Components[1] < other[1])) ||
|
||||
( !(other[0] < this->Components[0]) &&
|
||||
!(other[1] < this->Components[1]) &&
|
||||
(this->Components[2] < other[2]) ) );
|
||||
}
|
||||
|
||||
protected:
|
||||
ComponentType Components[NUM_COMPONENTS];
|
||||
};
|
||||
|
||||
/// Vector3 corresponds to a 3-tuple
|
||||
typedef vtkm::Tuple<vtkm::Scalar,3>
|
||||
Vector3 __attribute__ ((aligned(VTKM_SIZE_SCALAR)));
|
||||
|
||||
template<typename T>
|
||||
class Tuple<T,4>{
|
||||
public:
|
||||
typedef T ComponentType;
|
||||
static const int NUM_COMPONENTS = 4;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT Tuple(){}
|
||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
|
||||
{
|
||||
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple(ComponentType x, ComponentType y, ComponentType z, ComponentType w) {
|
||||
this->Components[0] = x;
|
||||
this->Components[1] = y;
|
||||
this->Components[2] = z;
|
||||
this->Components[3] = w;
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple(const Tuple<ComponentType, NUM_COMPONENTS> &src)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, src.Components);
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
Tuple<ComponentType, NUM_COMPONENTS> &
|
||||
operator=(const Tuple<ComponentType, NUM_COMPONENTS> &src)
|
||||
{
|
||||
internal::copy_vector<NUM_COMPONENTS>()(this->Components, src.Components);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
|
||||
return this->Components[idx];
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
|
||||
return this->Components[idx];
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator==(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return internal::equals<NUM_COMPONENTS>()(*this, other);
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator!=(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return !(this->operator==(other));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator<(const Tuple<T,NUM_COMPONENTS> &other) const
|
||||
{
|
||||
return((this->Components[0] < other[0]) ||
|
||||
( !(other[0] < this->Components[0]) &&
|
||||
this->Components[1] < other[1]) ||
|
||||
( !(other[0] < this->Components[0]) &&
|
||||
!(other[1] < this->Components[1]) &&
|
||||
(this->Components[2] < other[2]) ) ||
|
||||
( !(other[0] < this->Components[0]) &&
|
||||
!(other[1] < this->Components[1]) &&
|
||||
!(other[2] < this->Components[2]) &&
|
||||
(this->Components[3] < other[3])) );
|
||||
}
|
||||
|
||||
protected:
|
||||
ComponentType Components[NUM_COMPONENTS];
|
||||
};
|
||||
|
||||
/// Vector4 corresponds to a 4-tuple
|
||||
typedef vtkm::Tuple<vtkm::Scalar,4>
|
||||
Vector4 __attribute__ ((aligned(VTKM_ALIGNMENT_FOUR_SCALAR)));
|
||||
|
||||
|
||||
/// Id3 corresponds to a 3-dimensional index for 3d arrays. Note that
|
||||
/// the precision of each index may be less than vtkm::Id.
|
||||
typedef vtkm::Tuple<vtkm::Id,3> Id3 __attribute__ ((aligned(VTKM_SIZE_ID)));
|
||||
|
||||
/// Initializes and returns a Vector2.
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Vector2 make_Vector2(vtkm::Scalar x,
|
||||
vtkm::Scalar y)
|
||||
{
|
||||
return vtkm::Vector2(x, y);
|
||||
}
|
||||
|
||||
/// Initializes and returns a Vector3.
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Vector3 make_Vector3(vtkm::Scalar x,
|
||||
vtkm::Scalar y,
|
||||
vtkm::Scalar z)
|
||||
{
|
||||
return vtkm::Vector3(x, y, z);
|
||||
}
|
||||
|
||||
/// Initializes and returns a Vector4.
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Vector4 make_Vector4(vtkm::Scalar x,
|
||||
vtkm::Scalar y,
|
||||
vtkm::Scalar z,
|
||||
vtkm::Scalar w)
|
||||
{
|
||||
return vtkm::Vector4(x, y, z, w);
|
||||
}
|
||||
|
||||
/// Initializes and returns an Id3
|
||||
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>
|
||||
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++)
|
||||
{
|
||||
result += a[componentIndex]*b[componentIndex];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Id dot(vtkm::Id a, vtkm::Id b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Scalar dot(vtkm::Scalar a, vtkm::Scalar b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
} // End of namespace vtkm
|
||||
|
||||
template<typename T, int Size>
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator+(const vtkm::Tuple<T,Size> &a,
|
||||
const vtkm::Tuple<T,Size> &b)
|
||||
{
|
||||
vtkm::Tuple<T,Size> result;
|
||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||
{
|
||||
result[componentIndex] = a[componentIndex] + b[componentIndex];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
template<typename T, int Size>
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator-(const vtkm::Tuple<T,Size> &a,
|
||||
const vtkm::Tuple<T,Size> &b)
|
||||
{
|
||||
vtkm::Tuple<T,Size> result;
|
||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||
{
|
||||
result[componentIndex] = a[componentIndex] - b[componentIndex];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
template<typename T, int Size>
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator*(const vtkm::Tuple<T,Size> &a,
|
||||
const vtkm::Tuple<T,Size> &b)
|
||||
{
|
||||
vtkm::Tuple<T,Size> result;
|
||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||
{
|
||||
result[componentIndex] = a[componentIndex] * b[componentIndex];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
template<typename T, int Size>
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<T,Size> operator/(const vtkm::Tuple<T,Size> &a,
|
||||
const vtkm::Tuple<T,Size> &b)
|
||||
{
|
||||
vtkm::Tuple<T,Size> result;
|
||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||
{
|
||||
result[componentIndex] = a[componentIndex] / b[componentIndex];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Ta, typename Tb, int Size>
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<Ta,Size> operator*(const vtkm::Tuple<Ta,Size> &a,
|
||||
const Tb &b)
|
||||
{
|
||||
vtkm::Tuple<Ta,Size> result;
|
||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||
{
|
||||
result[componentIndex] = a[componentIndex] * b;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
template<typename Ta, typename Tb, int Size>
|
||||
VTKM_EXEC_CONT_EXPORT vtkm::Tuple<Tb,Size> operator*(const Ta &a,
|
||||
const vtkm::Tuple<Tb,Size> &b)
|
||||
{
|
||||
vtkm::Tuple<Tb,Size> result;
|
||||
for (int componentIndex = 0; componentIndex < Size; componentIndex++)
|
||||
{
|
||||
result[componentIndex] = a * b[componentIndex];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif //vtkm_Types_h
|
222
vtkm/VectorTraits.h
Normal file
222
vtkm/VectorTraits.h
Normal file
@ -0,0 +1,222 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014. Los Alamos National Security
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtkm_VectorTraits_h
|
||||
#define vtkm_VectorTraits_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace vtkm {
|
||||
|
||||
/// A tag for vectors that are "true" vectors (i.e. have more than one
|
||||
/// component).
|
||||
///
|
||||
struct VectorTraitsTagMultipleComponents { };
|
||||
|
||||
/// A tag for vectors that a really just scalars (i.e. have only one component)
|
||||
///
|
||||
struct VectorTraitsTagSingleComponent { };
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<int numComponents>
|
||||
struct VectorTraitsMultipleComponentChooser {
|
||||
typedef VectorTraitsTagMultipleComponents Type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct VectorTraitsMultipleComponentChooser<1> {
|
||||
typedef VectorTraitsTagSingleComponent Type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// The VectorTraits class gives several static members that define how
|
||||
/// to use a given type as a vector.
|
||||
///
|
||||
template<class VectorType>
|
||||
struct VectorTraits
|
||||
#ifdef VTKM_DOXYGEN_ONLY
|
||||
{
|
||||
/// Type of the components in the vector.
|
||||
///
|
||||
typedef typename VectorType::ComponentType ComponentType;
|
||||
|
||||
/// Number of components in the vector.
|
||||
///
|
||||
static const int 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
|
||||
/// when a vector is really just a scalar.
|
||||
///
|
||||
typedef typename internal::VectorTraitsMultipleComponentChooser<
|
||||
NUM_COMPONENTS>::Type HasMultipleComponents;
|
||||
|
||||
/// Returns the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT static const ComponentType &GetComponent(
|
||||
const typename boost::remove_const<VectorType>::type &vector,
|
||||
int component);
|
||||
VTKM_EXEC_CONT_EXPORT static ComponentType &GetComponent(
|
||||
typename boost::remove_const<VectorType>::type &vector,
|
||||
int component);
|
||||
|
||||
/// Changes the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT static void SetComponent(VectorType &vector,
|
||||
int component,
|
||||
ComponentType value);
|
||||
|
||||
/// Converts whatever type this vector is into the standard VTKm Tuple.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static vtkm::Tuple<ComponentType,NUM_COMPONENTS>
|
||||
ToTuple(const VectorType &vector);
|
||||
};
|
||||
#else // VTKM_DOXYGEN_ONLY
|
||||
;
|
||||
#endif // VTKM_DOXYGEN_ONLY
|
||||
|
||||
// This partial specialization allows you to define a non-const version of
|
||||
// VectorTraits and have it still work for const version.
|
||||
//
|
||||
template<typename T>
|
||||
struct VectorTraits<const T> : VectorTraits<T>
|
||||
{ };
|
||||
|
||||
template<typename T, int Size>
|
||||
struct VectorTraits<vtkm::Tuple<T,Size> >
|
||||
{
|
||||
typedef vtkm::Tuple<T,Size> VectorType;
|
||||
|
||||
/// Type of the components in the vector.
|
||||
///
|
||||
typedef typename VectorType::ComponentType ComponentType;
|
||||
|
||||
/// Number of components in the vector.
|
||||
///
|
||||
static const int 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
|
||||
/// when a vector is really just a scalar.
|
||||
///
|
||||
typedef typename internal::VectorTraitsMultipleComponentChooser<
|
||||
NUM_COMPONENTS>::Type HasMultipleComponents;
|
||||
|
||||
/// Returns the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static const ComponentType &GetComponent(const VectorType &vector,
|
||||
int component)
|
||||
{
|
||||
return vector[component];
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static ComponentType &GetComponent(VectorType &vector, int 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,
|
||||
ComponentType value) {
|
||||
vector[component] = value;
|
||||
}
|
||||
|
||||
/// Converts whatever type this vector is into the standard VTKm Tuple.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static vtkm::Tuple<ComponentType,NUM_COMPONENTS>
|
||||
ToTuple(const VectorType &vector)
|
||||
{
|
||||
return vector;
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
/// Used for overriding VectorTraits for basic scalar types.
|
||||
///
|
||||
template<typename ScalarType>
|
||||
struct VectorTraitsBasic {
|
||||
typedef ScalarType ComponentType;
|
||||
static const int NUM_COMPONENTS = 1;
|
||||
typedef VectorTraitsTagSingleComponent HasMultipleComponents;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT static const ComponentType &GetComponent(
|
||||
const ScalarType &vector,
|
||||
int) {
|
||||
return vector;
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static ComponentType &GetComponent(ScalarType &vector, int) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT static void SetComponent(ScalarType &vector,
|
||||
int,
|
||||
ComponentType value) {
|
||||
vector = value;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static vtkm::Tuple<ScalarType,1> ToTuple(const ScalarType &vector)
|
||||
{
|
||||
return vtkm::Tuple<ScalarType,1>(vector);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#define VTKM_BASIC_TYPE_VECTOR(type) \
|
||||
template<> \
|
||||
struct VectorTraits<type> \
|
||||
: public vtkm::internal::VectorTraitsBasic<type> { };/* \
|
||||
template<> \
|
||||
struct VectorTraits<const type> \
|
||||
: public vtkm::internal::VectorTraitsBasic<type> { }*/
|
||||
|
||||
/// Allows you to treat basic types as if they were vectors.
|
||||
|
||||
VTKM_BASIC_TYPE_VECTOR(float);
|
||||
VTKM_BASIC_TYPE_VECTOR(double);
|
||||
VTKM_BASIC_TYPE_VECTOR(char);
|
||||
VTKM_BASIC_TYPE_VECTOR(unsigned char);
|
||||
VTKM_BASIC_TYPE_VECTOR(short);
|
||||
VTKM_BASIC_TYPE_VECTOR(unsigned short);
|
||||
VTKM_BASIC_TYPE_VECTOR(int);
|
||||
VTKM_BASIC_TYPE_VECTOR(unsigned int);
|
||||
#if VTKM_SIZE_LONG == 8
|
||||
VTKM_BASIC_TYPE_VECTOR(long);
|
||||
VTKM_BASIC_TYPE_VECTOR(unsigned long);
|
||||
#elif VTKM_SIZE_LONG_LONG == 8
|
||||
VTKM_BASIC_TYPE_VECTOR(long long);
|
||||
VTKM_BASIC_TYPE_VECTOR(unsigned long long);
|
||||
#else
|
||||
#error No implementation for 64-bit vector traits.
|
||||
#endif
|
||||
|
||||
#undef VTKM_BASIC_TYPE_VECTOR
|
||||
|
||||
}
|
||||
|
||||
#endif //vtkm_VectorTraits_h
|
30
vtkm/internal/CMakeLists.txt
Normal file
30
vtkm/internal/CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
||||
##============================================================================
|
||||
## Copyright (c) Kitware, Inc.
|
||||
## All rights reserved.
|
||||
## See LICENSE.txt for details.
|
||||
## This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##
|
||||
## Copyright 2014 Sandia Corporation.
|
||||
## Copyright 2014 UT-Battelle, LLC.
|
||||
## Copyright 2014. Los Alamos National Security
|
||||
##
|
||||
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
## the U.S. Government retains certain rights in this software.
|
||||
##
|
||||
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
## Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
## this software.
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
ConfigureFor32.h
|
||||
ConfigureFor64.h
|
||||
ExportMacros.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
||||
|
||||
add_subdirectory(testing)
|
||||
|
94
vtkm/internal/Configure.h.in
Normal file
94
vtkm/internal/Configure.h.in
Normal file
@ -0,0 +1,94 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014. Los Alamos National Security
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtkm_internal_Configure_h
|
||||
#define vtkm_internal_Configure_h
|
||||
|
||||
|
||||
#if !defined(VTKM_USE_DOUBLE_PRECISION) && !defined(VTKM_NO_DOUBLE_PRECISION)
|
||||
#cmakedefine VTKM_USE_DOUBLE_PRECISION
|
||||
#endif
|
||||
|
||||
#if defined(VTKM_USE_DOUBLE_PRECISION) && defined(VTKM_NO_DOUBLE_PRECISION)
|
||||
# error Both VTKM_USE_DOUBLE_PRECISION and VTKM_NO_DOUBLE_PRECISION defined. Do not know what to do.
|
||||
#endif
|
||||
|
||||
#if !defined(VTKM_USE_64BIT_IDS) && !defined(VTKM_NO_64BIT_IDS)
|
||||
#cmakedefine VTKM_USE_64BIT_IDS
|
||||
#endif
|
||||
|
||||
#if defined(VTKM_USE_64BIT_IDS) && defined(VTKM_NO_64BIT_IDS)
|
||||
# error Both VTKM_USE_64BIT_IDS and VTKM_NO_64BIT_IDS defined. Do not know what to do.
|
||||
#endif
|
||||
|
||||
#define VTKM_SIZE_FLOAT @VTKm_SIZE_FLOAT@
|
||||
#define VTKM_SIZE_DOUBLE @VTKm_SIZE_DOUBLE@
|
||||
#define VTKM_SIZE_INT @VTKm_SIZE_INT@
|
||||
#define VTKM_SIZE_LONG @VTKm_SIZE_LONG@
|
||||
#define VTKM_SIZE_LONG_LONG @VTKm_SIZE_LONG_LONG@
|
||||
|
||||
#ifdef VTKM_USE_DOUBLE_PRECISION
|
||||
# ifndef VTKM_SIZE_SCALAR
|
||||
# define VTKM_SIZE_SCALAR VTKM_SIZE_DOUBLE
|
||||
# endif
|
||||
# ifndef VTKM_ALIGNMENT_TWO_SCALAR
|
||||
# define VTKM_ALIGNMENT_TWO_SCALAR 16
|
||||
# endif
|
||||
# ifndef VTKM_ALIGNMENT_FOUR_SCALAR
|
||||
# define VTKM_ALIGNMENT_FOUR_SCALAR 8
|
||||
# endif
|
||||
#else
|
||||
# ifndef VTKM_SIZE_SCALAR
|
||||
# define VTKM_SIZE_SCALAR VTKM_SIZE_FLOAT
|
||||
# define VTKM_ALIGNMENT_SCALAR VTKM_SIZE_SCALAR
|
||||
# endif
|
||||
# ifndef VTKM_ALIGNMENT_TWO_SCALAR
|
||||
# define VTKM_ALIGNMENT_TWO_SCALAR 8
|
||||
# endif
|
||||
# ifndef VTKM_ALIGNMENT_FOUR_SCALAR
|
||||
# define VTKM_ALIGNMENT_FOUR_SCALAR 16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef VTKM_USE_64BIT_IDS
|
||||
# ifndef VTKM_SIZE_ID
|
||||
# define VTKM_SIZE_ID 8
|
||||
# endif
|
||||
#else
|
||||
# ifndef VTKM_SIZE_ID
|
||||
# define VTKM_SIZE_ID 4
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Determine whether we will use variadic templates (a new feature in C++11).
|
||||
// Currently have VARIADIC_TEMPLATE support off.
|
||||
#cmakedefine VTKM_NO_VARIADIC_TEMPLATE
|
||||
#if !defined(VTKM_USE_VARIADIC_TEMPLATE) && !defined(VTKM_NO_VARIADIC_TEMPLATE)
|
||||
// Currently using Boost to determine support.
|
||||
# include <boost/config.hpp>
|
||||
# if defined(BOOST_HAS_VARIADIC_TMPL)
|
||||
# define VTKM_USE_VARIADIC_TEMPLATE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(VTKM_USE_VARIADIC_TEMPLATE) && defined(VTKM_NO_VARIADIC_TEMPLATE)
|
||||
# error Both VTKM_USE_VARIADIC_TEMPLATE and VTKM_NO_VARIADIC_TEMPLATE defined. Do not know what to do.
|
||||
#endif
|
||||
|
||||
#endif //vtkm_internal_Configure_h
|
37
vtkm/internal/ConfigureFor32.h
Normal file
37
vtkm/internal/ConfigureFor32.h
Normal file
@ -0,0 +1,37 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014. Los Alamos National Security
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
//This header can be used by external application that are consuming VTKm
|
||||
//to define if VTKm should be set to use 32bit data types. If you need to
|
||||
//customize more of the vtkm type system, or what Device Adapters
|
||||
//need to be included look at vtkm/internal/Configure.h for all defines that
|
||||
//you can over-ride.
|
||||
#ifdef vtkm_internal_Configure_h
|
||||
# error Incorrect header order. Include this header before any other VTKm headers.
|
||||
#endif
|
||||
|
||||
#ifndef vtkm_internal_Configure32_h
|
||||
#define vtkm_internal_Configure32_h
|
||||
|
||||
#define VTKM_NO_DOUBLE_PRECISION
|
||||
#define VTKM_NO_64BIT_IDS
|
||||
|
||||
#include <vtkm/internal/Configure.h>
|
||||
|
||||
#endif
|
37
vtkm/internal/ConfigureFor64.h
Normal file
37
vtkm/internal/ConfigureFor64.h
Normal file
@ -0,0 +1,37 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014. Los Alamos National Security
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
//This header can be used by external application that are consuming VTKm
|
||||
//to define if VTKm should be set to use 64bit data types. If you need to
|
||||
//customize more of the vtkm type system, or what Device Adapters
|
||||
//need to be included look at vtkm/internal/Configure.h for all defines that
|
||||
//you can over-ride.
|
||||
#ifdef vtkm_internal_Configure_h
|
||||
# error Incorrect header order. Include this header before any other VTKm headers.
|
||||
#endif
|
||||
|
||||
#ifndef vtkm_internal_Configure32_h
|
||||
#define vtkm_internal_Configure32_h
|
||||
|
||||
#define VTKM_USE_DOUBLE_PRECISION
|
||||
#define VTKM_USE_64BIT_IDS
|
||||
|
||||
#include <vtkm/internal/Configure.h>
|
||||
|
||||
#endif
|
78
vtkm/internal/ExportMacros.h
Normal file
78
vtkm/internal/ExportMacros.h
Normal file
@ -0,0 +1,78 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014. Los Alamos National Security
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtkm_internal__ExportMacros_h
|
||||
#define vtkm_internal__ExportMacros_h
|
||||
|
||||
/*!
|
||||
* Export macros for various parts of the VTKm library.
|
||||
*/
|
||||
|
||||
#ifdef __CUDACC__
|
||||
#define VTKM_CUDA
|
||||
#endif
|
||||
|
||||
#ifdef _OPENMP
|
||||
#define VTKM_OPENMP
|
||||
#endif
|
||||
|
||||
#ifdef VTKM_CUDA
|
||||
#define VTKM_EXEC_EXPORT inline __device__
|
||||
#define VTKM_EXEC_CONT_EXPORT inline __device__ __host__
|
||||
#define VTKM_EXEC_CONSTANT_EXPORT __device__ __constant__
|
||||
#else
|
||||
#define VTKM_EXEC_EXPORT inline
|
||||
#define VTKM_EXEC_CONT_EXPORT inline
|
||||
#define VTKM_EXEC_CONSTANT_EXPORT
|
||||
#endif
|
||||
|
||||
#define VTKM_CONT_EXPORT inline
|
||||
|
||||
/// Simple macro to identify a parameter as unused. This allows you to name a
|
||||
/// parameter that is not used. There are several instances where you might
|
||||
/// want to do this. For example, when using a parameter to overload or
|
||||
/// template a function but do not actually use the parameter. Another example
|
||||
/// is providing a specialization that does not need that parameter.
|
||||
#define vtkmNotUsed(parameter_name)
|
||||
|
||||
|
||||
// Check boost support under CUDA
|
||||
#ifdef VTKM_CUDA
|
||||
#if !defined(BOOST_SP_DISABLE_THREADS) && !defined(BOOST_SP_USE_SPINLOCK) && !defined(BOOST_SP_USE_PTHREADS)
|
||||
#warning -------------------------------------------------------------------
|
||||
#warning The CUDA compiler (nvcc) has trouble with some of the optimizations
|
||||
#warning boost uses for thread saftey. To get around this, please define
|
||||
#warning one of the following macros to specify the thread handling boost
|
||||
#warning should use:
|
||||
#warning
|
||||
#warning BOOST_SP_DISABLE_THREADS
|
||||
#warning BOOST_SP_USE_SPINLOCK
|
||||
#warning BOOST_SP_USE_PTHREADS
|
||||
#warning
|
||||
#warning Failure to define one of these for a CUDA build will probably cause
|
||||
#warning other annoying warnings and might even cause incorrect code. Note
|
||||
#warning that specifying BOOST_SP_DISABLE_THREADS does not preclude using
|
||||
#warning VTKm with a threaded device (like OpenMP). Specifying one of these
|
||||
#warning modes for boost does not effect the scheduling in VTKm.
|
||||
#warning -------------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif //vtkm_internal__ExportMacros_h
|
Loading…
Reference in New Issue
Block a user