diff --git a/vtkm/Extent.h b/vtkm/Extent.h index 77abf2951..10a044a55 100644 --- a/vtkm/Extent.h +++ b/vtkm/Extent.h @@ -52,17 +52,17 @@ struct Extent this->Max = rhs.Max; return *this; } -} __attribute__ ((aligned(VTKM_SIZE_ID))); +}; /// This is the Extent to use for structured grids with 3 topological /// dimensions. /// -typedef vtkm::Extent<3> Extent3 __attribute__ ((aligned(VTKM_SIZE_ID))); +typedef vtkm::Extent<3> Extent3; /// This is the Extent to use for structured grids with 2 topological /// dimensions. /// -typedef vtkm::Extent<2> Extent2 __attribute__ ((aligned(VTKM_SIZE_ID))); +typedef vtkm::Extent<2> Extent2; /// Given an extent, returns the array dimensions for the points. /// diff --git a/vtkm/Types.h b/vtkm/Types.h index bbdf21702..5f895da69 100644 --- a/vtkm/Types.h +++ b/vtkm/Types.h @@ -470,6 +470,103 @@ protected: ComponentType Components[NUM_COMPONENTS]; }; +//----------------------------------------------------------------------------- +// Specializations for small tuples. These are not exactly common but can occur +// with generalizations. We implement them a bit special. + +template +class Tuple +{ +public: + typedef T ComponentType; + static const int NUM_COMPONENTS = 1; + + VTKM_EXEC_CONT_EXPORT Tuple() {} + VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType&) { } + VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType*) { } + VTKM_EXEC_CONT_EXPORT + Tuple(const Tuple &) { } + + VTKM_EXEC_CONT_EXPORT + Tuple & + operator=(const Tuple &) + { + return *this; + } + + VTKM_EXEC_CONT_EXPORT ComponentType operator[](int vtkmNotUsed(idx)) const + { + return ComponentType(); + } + + VTKM_EXEC_CONT_EXPORT + bool operator==(const Tuple &vtkmNotUsed(other)) const + { + return true; + } + VTKM_EXEC_CONT_EXPORT + bool operator!=(const Tuple &vtkmNotUsed(other)) const + { + return false; + } +}; + +template +class Tuple +{ +public: + typedef T ComponentType; + static const int NUM_COMPONENTS = 1; + + VTKM_EXEC_CONT_EXPORT Tuple() {} + VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value) + : Component(value) { } + VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values) + : Component(*values) { } + VTKM_EXEC_CONT_EXPORT + Tuple(const Tuple &src) + : Component(src.Component) { } + + VTKM_EXEC_CONT_EXPORT + Tuple & + operator=(const Tuple &src) + { + this->Component = src.Component; + return *this; + } + + VTKM_EXEC_CONT_EXPORT + const ComponentType &operator[](int vtkmNotUsed(idx)) const + { + return this->Component; + } + VTKM_EXEC_CONT_EXPORT + ComponentType &operator[](int vtkmNotUsed(idx)) + { + return this->Component; + } + + VTKM_EXEC_CONT_EXPORT + bool operator==(const Tuple &other) const + { + return this->Component == other.Component; + } + VTKM_EXEC_CONT_EXPORT + bool operator!=(const Tuple &other) const + { + return !(this->operator==(other)); + } + + VTKM_EXEC_CONT_EXPORT + bool operator<(const Tuple &other) const + { + return this->Component < other.Component; + } + +protected: + ComponentType Component; +}; + //----------------------------------------------------------------------------- // Specializations for common tuple sizes (with special names). diff --git a/vtkm/cont/internal/DeviceAdapterAlgorithm.h b/vtkm/cont/internal/DeviceAdapterAlgorithm.h index c26bd3ca8..151686820 100644 --- a/vtkm/cont/internal/DeviceAdapterAlgorithm.h +++ b/vtkm/cont/internal/DeviceAdapterAlgorithm.h @@ -25,7 +25,10 @@ #include #include -#ifndef _WIN32 +#ifdef _WIN32 +#include +#include +#else //!_WIN32 #include #include #include @@ -349,9 +352,10 @@ public: TimeStamp currentTime = this->GetCurrentTime(); vtkm::Scalar elapsedTime; - elapsedTime = currentTime.Seconds - this->StartTime.Seconds; - elapsedTime += ((currentTime.Microseconds - this->StartTime.Microseconds) - /vtkm::Scalar(1000000)); + elapsedTime = vtkm::Scalar(currentTime.Seconds - this->StartTime.Seconds); + elapsedTime += + (vtkm::Scalar(currentTime.Microseconds - this->StartTime.Microseconds) + /vtkm::Scalar(1000000)); return elapsedTime; } diff --git a/vtkm/cont/testing/TestingDeviceAdapter.h b/vtkm/cont/testing/TestingDeviceAdapter.h index 379b3ec7e..81923ba5d 100644 --- a/vtkm/cont/testing/TestingDeviceAdapter.h +++ b/vtkm/cont/testing/TestingDeviceAdapter.h @@ -363,7 +363,7 @@ private: vtkm::Scalar inputArray[ARRAY_SIZE*2]; for (vtkm::Id index = 0; index < ARRAY_SIZE*2; index++) { - inputArray[index] = index; + inputArray[index] = vtkm::Scalar(index); } ::vtkm::cont::internal::ArrayPortalFromIterators inputPortal(inputArray, inputArray+ARRAY_SIZE*2); @@ -465,7 +465,7 @@ private: for (vtkm::Id index = 0; index < 1; index++) { - vtkm::Scalar value = container.GetPortalConst().Get(index); + vtkm::Id value = container.GetPortalConst().Get(index); VTKM_TEST_ASSERT(value == index + OFFSET, "Got bad value for single value scheduled kernel."); } @@ -505,7 +505,7 @@ private: std::cout << "Allocating execution array" << std::endl; IdContainer container; IdArrayManagerExecution manager; - vtkm::Id DIM_SIZE = std::pow(ARRAY_SIZE, 1/3.0f); + vtkm::Id DIM_SIZE = vtkm::Id(std::pow(ARRAY_SIZE, 1/3.0f)); manager.AllocateArrayForOutput(container, DIM_SIZE * DIM_SIZE * DIM_SIZE); vtkm::Id3 maxRange(DIM_SIZE); diff --git a/vtkm/cont/testing/UnitTestArrayHandleCompositeVector.cxx b/vtkm/cont/testing/UnitTestArrayHandleCompositeVector.cxx index b5f70dce1..4d2954b40 100644 --- a/vtkm/cont/testing/UnitTestArrayHandleCompositeVector.cxx +++ b/vtkm/cont/testing/UnitTestArrayHandleCompositeVector.cxx @@ -278,9 +278,9 @@ void TestBadArrayLengths() { std::cout << "Checking behavior when size of input arrays do not agree." << std::endl; - typedef vtkm::cont::ArrayHandle InArrayType; - InArrayType longInArray = MakeInputArray(0); - InArrayType shortInArray = MakeInputArray(1); + typedef vtkm::cont::ArrayHandle InArrayType; + InArrayType longInArray = MakeInputArray(0); + InArrayType shortInArray = MakeInputArray(1); shortInArray.Shrink(ARRAY_SIZE/2); try diff --git a/vtkm/cont/testing/UnitTestArrayHandleUniformPointCoordinates.cxx b/vtkm/cont/testing/UnitTestArrayHandleUniformPointCoordinates.cxx index 7300407f5..ecf07729e 100644 --- a/vtkm/cont/testing/UnitTestArrayHandleUniformPointCoordinates.cxx +++ b/vtkm/cont/testing/UnitTestArrayHandleUniformPointCoordinates.cxx @@ -30,7 +30,7 @@ const vtkm::Id3 POINT_DIMS(16, 18, 5); const vtkm::Id NUM_POINTS = 1440; const vtkm::Vector3 ORIGIN(30, -3, -14); -const vtkm::Vector3 SPACING(10, 1, 0.1); +const vtkm::Vector3 SPACING(10, 1, 0.1f); const vtkm::Vector3 LOWER_LEFT(-20, 5, -10); // MIN_VALUES*SPACING + ORIGIN void TestArrayHandleUniformPointCoordinates() diff --git a/vtkm/cont/testing/UnitTestDynamicPointCoordinates.cxx b/vtkm/cont/testing/UnitTestDynamicPointCoordinates.cxx index 72327dc3f..4ed6eaedc 100644 --- a/vtkm/cont/testing/UnitTestDynamicPointCoordinates.cxx +++ b/vtkm/cont/testing/UnitTestDynamicPointCoordinates.cxx @@ -41,7 +41,9 @@ const vtkm::Id ARRAY_SIZE = DIMENSION[0]*DIMENSION[1]*DIMENSION[2]; vtkm::Vector3 TestValue(vtkm::Id index) { vtkm::Id3 index3d = vtkm::ExtentPointFlatIndexToTopologyIndex(index, EXTENT); - return vtkm::Vector3(index3d[0], index3d[1], index3d[2]); + return vtkm::Vector3(vtkm::Scalar(index3d[0]), + vtkm::Scalar(index3d[1]), + vtkm::Scalar(index3d[2])); } int g_CheckArrayInvocations; diff --git a/vtkm/cont/testing/UnitTestPointCoordinates.cxx b/vtkm/cont/testing/UnitTestPointCoordinates.cxx index 3fa69da99..40c09a65d 100644 --- a/vtkm/cont/testing/UnitTestPointCoordinates.cxx +++ b/vtkm/cont/testing/UnitTestPointCoordinates.cxx @@ -55,7 +55,9 @@ struct ContainerListTag : vtkm::cont::ContainerListTagBasic { }; vtkm::Vector3 TestValue(vtkm::Id index) { vtkm::Id3 index3d = vtkm::ExtentPointFlatIndexToTopologyIndex(index, EXTENT); - return vtkm::Vector3(index3d[0], index3d[1], index3d[2]); + return vtkm::Vector3(vtkm::Scalar(index3d[0]), + vtkm::Scalar(index3d[1]), + vtkm::Scalar(index3d[2])); } struct CheckArray diff --git a/vtkm/internal/testing/UnitTestFunctionInterface.cxx b/vtkm/internal/testing/UnitTestFunctionInterface.cxx index 091fff801..be070ce4e 100644 --- a/vtkm/internal/testing/UnitTestFunctionInterface.cxx +++ b/vtkm/internal/testing/UnitTestFunctionInterface.cxx @@ -39,7 +39,7 @@ typedef std::string Type3; const Type3 Arg3("Third argument"); typedef vtkm::Vector3 Type4; -const Type4 Arg4(1.2, 3.4, 5.6); +const Type4 Arg4(1.2f, 3.4f, 5.6f); typedef vtkm::Id3 Type5; const Type5 Arg5(4, 5, 6); diff --git a/vtkm/testing/Testing.h b/vtkm/testing/Testing.h index 8fa3667b8..d05ea855e 100644 --- a/vtkm/testing/Testing.h +++ b/vtkm/testing/Testing.h @@ -305,8 +305,8 @@ VTKM_EXEC_CONT_EXPORT bool test_equal(VectorType vector1, typedef typename vtkm::VectorTraits Traits; for (int component = 0; component < Traits::NUM_COMPONENTS; component++) { - vtkm::Scalar value1 = Traits::GetComponent(vector1, component); - vtkm::Scalar value2 = Traits::GetComponent(vector2, component); + vtkm::Scalar value1 = vtkm::Scalar(Traits::GetComponent(vector1, component)); + vtkm::Scalar value2 = vtkm::Scalar(Traits::GetComponent(vector2, component)); if ((fabs(value1) < 2*tolerance) && (fabs(value2) < 2*tolerance)) { continue; diff --git a/vtkm/testing/UnitTestVectorTraits.cxx b/vtkm/testing/UnitTestVectorTraits.cxx index 2e02bbe85..ec5ac02f5 100644 --- a/vtkm/testing/UnitTestVectorTraits.cxx +++ b/vtkm/testing/UnitTestVectorTraits.cxx @@ -31,12 +31,13 @@ struct TestVectorTypeFunctor template void operator()(const T&) const { typedef vtkm::VectorTraits Traits; + typedef typename Traits::ComponentType ComponentType; 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++) { - Traits::SetComponent(vector, index, VectorInit[index]); + Traits::SetComponent(vector, index, ComponentType(VectorInit[index])); } vtkm::testing::TestVectorType(vector); }