Commit 1d9a9dd1 authored by Robert Maynard's avatar Robert Maynard

Simplify VTK-m detection of the size of different types.

Most of the code was unneeded as the primitive types have a minimum required
size that we can rely on.
parent 4f131d82
......@@ -180,11 +180,6 @@ endif (VTKm_ENABLE_TESTING)
# Check basic type sizes.
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)
......
......@@ -2309,11 +2309,7 @@ static inline VTKM_EXEC_CONT vtkm::Float64 ModF(vtkm::Float64 x, vtkm::Float64&
///
static inline VTKM_EXEC_CONT vtkm::Int32 Abs(vtkm::Int32 x)
{
#if VTKM_SIZE_INT == 4
return abs(x);
#else
#error Unknown size of Int32.
#endif
}
static inline VTKM_EXEC_CONT vtkm::Int64 Abs(vtkm::Int64 x)
{
......
......@@ -964,11 +964,7 @@ static inline VTKM_EXEC_CONT vtkm::Float64 ModF(vtkm::Float64 x, vtkm::Float64&
///
static inline VTKM_EXEC_CONT vtkm::Int32 Abs(vtkm::Int32 x)
{
#if VTKM_SIZE_INT == 4
return abs(x);
#else
#error Unknown size of Int32.
#endif
}
static inline VTKM_EXEC_CONT vtkm::Int64 Abs(vtkm::Int64 x)
{
......
......@@ -143,39 +143,21 @@ namespace vtkm
//*****************************************************************************
// Typedefs for basic types.
//*****************************************************************************
#if VTKM_SIZE_FLOAT == 4
using Float32 = float;
#else
#error Could not find a 32-bit float.
#endif
#if VTKM_SIZE_DOUBLE == 8
using Float64 = double;
#else
#error Could not find a 64-bit float.
#endif
#if VTKM_SIZE_CHAR == 1
using Int8 = signed char;
using UInt8 = unsigned char;
#else
#error Could not find an 8-bit integer.
#endif
#if VTKM_SIZE_SHORT == 2
using Int16 = short;
using UInt16 = unsigned short;
#else
#error Could not find a 16-bit integer.
#endif
#if VTKM_SIZE_INT == 4
using Int32 = int;
using UInt32 = unsigned int;
#else
#error Could not find a 32-bit integer.
#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.
using IdComponent = vtkm::Int32;
//In this order so that we exactly match the logic that exists in VTK
#if VTKM_SIZE_LONG_LONG == 8
......@@ -188,40 +170,19 @@ using UInt64 = unsigned long;
#error Could not find a 64-bit integer.
#endif
//-----------------------------------------------------------------------------
#if VTKM_SIZE_ID == 4
/// Represents an ID (index into arrays).
using Id = vtkm::Int32;
#elif VTKM_SIZE_ID == 8
/// Represents an ID.
#ifdef VTKM_USE_64BIT_IDS
using Id = vtkm::Int64;
#else
#error Unknown Id Size
using Id = vtkm::Int32;
#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.
using IdComponent = vtkm::Int32;
#ifdef VTKM_USE_DOUBLE_PRECISION
/// The floating point type to use when no other precision is specified.
#ifdef VTKM_USE_DOUBLE_PRECISION
using FloatDefault = vtkm::Float64;
#else //VTKM_USE_DOUBLE_PRECISION
/// The floating point type to use when no other precision is specified.
#else
using FloatDefault = vtkm::Float32;
#endif //VTKM_USE_DOUBLE_PRECISION
#endif
namespace internal
{
......
......@@ -82,47 +82,9 @@
# 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_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@
#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
// Define a pair of macros, VTKM_THIRDPARTY_PRE_INCLUDE and VTKM_THIRDPARTY_POST_INCLUDE,
// that should be wrapped around any #include for a tbb or thrust header file. Mostly
// this is used to set pragmas that dissable warnings that VTK-m checks for
......
......@@ -27,12 +27,12 @@
// Size of 32 bits.
#define EXPECTED_SIZE 4
#if VTKM_SIZE_ID != EXPECTED_SIZE
#error VTKM_SIZE_ID an unexpected size.
#if defined(VTKM_USE_64BIT_IDS)
#error vtkm::Id an unexpected size.
#endif
#if VTKM_SIZE_SCALAR != EXPECTED_SIZE
#error VTKM_SIZE_SCALAR an unexpected size.
#if defined(VTKM_USE_DOUBLE_PRECISION)
#error vtkm::FloatDefault an unexpected size.
#endif
namespace
......@@ -40,9 +40,7 @@ namespace
void TestTypeSizes()
{
VTKM_TEST_ASSERT(VTKM_SIZE_ID == EXPECTED_SIZE, "VTKM_SIZE_ID an unexpected size.");
VTKM_TEST_ASSERT(sizeof(vtkm::Id) == EXPECTED_SIZE, "vtkm::Id an unexpected size.");
VTKM_TEST_ASSERT(VTKM_SIZE_SCALAR == EXPECTED_SIZE, "VTKM_SIZE_SCALAR an unexpected size.");
VTKM_TEST_ASSERT(sizeof(vtkm::FloatDefault) == EXPECTED_SIZE,
"vtkm::FloatDefault an unexpected size.");
}
......
......@@ -27,12 +27,12 @@
// Size of 64 bits.
#define EXPECTED_SIZE 8
#if VTKM_SIZE_ID != EXPECTED_SIZE
#error VTKM_SIZE_ID an unexpected size.
#if defined(VTKM_NO_64BIT_IDS)
#error vtkm::Id an unexpected size.
#endif
#if VTKM_SIZE_SCALAR != EXPECTED_SIZE
#error VTKM_SIZE_SCALAR an unexpected size.
#if defined(VTKM_NO_DOUBLE_PRECISION)
#error vtkm::FloatDefault an unexpected size.
#endif
namespace
......@@ -40,9 +40,7 @@ namespace
void TestTypeSizes()
{
VTKM_TEST_ASSERT(VTKM_SIZE_ID == EXPECTED_SIZE, "VTKM_SIZE_ID an unexpected size.");
VTKM_TEST_ASSERT(sizeof(vtkm::Id) == EXPECTED_SIZE, "vtkm::Id an unexpected size.");
VTKM_TEST_ASSERT(VTKM_SIZE_SCALAR == EXPECTED_SIZE, "VTKM_SIZE_SCALAR an unexpected size.");
VTKM_TEST_ASSERT(sizeof(vtkm::FloatDefault) == EXPECTED_SIZE,
"vtkm::FloatDefault an unexpected size.");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment