From 40c579f119f2b03b247c39a765fecea27384c9cd Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 19 May 2014 13:17:04 -0400 Subject: [PATCH] Correcting alignment issues so we compile on windows. --- vtkm/Types.h | 33 ++++++++++++------- vtkm/cont/ArrayContainerControlImplicit.h | 2 +- vtkm/cont/ArrayHandle.h | 2 +- .../internal/ArrayHandleExecutionManager.h | 4 +-- vtkm/cont/internal/ArrayManagerExecution.h | 2 +- .../ArrayManagerExecutionShareWithControl.h | 2 +- vtkm/cont/internal/ArrayPortalFromIterators.h | 2 +- vtkm/cont/internal/ArrayTransfer.h | 2 +- .../UnitTestArrayContainerControlBasic.cxx | 2 +- 9 files changed, 30 insertions(+), 21 deletions(-) diff --git a/vtkm/Types.h b/vtkm/Types.h index d13a9b186..d5f2049cb 100644 --- a/vtkm/Types.h +++ b/vtkm/Types.h @@ -107,6 +107,16 @@ typedef unsigned long long UInt64Type; #error Could not find a 64-bit integer. #endif +//for windows support we need a macro to wrap the alignment call, +//since for windows you need declspec(align) +#ifdef _MSC_VER +# define VTKM_ALIGN_BEGIN(size) __declspec(align(size)) +# define VTKM_ALIGN_END(size) +#else //we presume clang or gcc +# define VTKM_ALIGN_BEGIN(size) +# define VTKM_ALIGN_END(size) __attribute__((aligned(size))) +#endif + //----------------------------------------------------------------------------- template @@ -249,12 +259,12 @@ struct copy_vector<3> #if VTKM_SIZE_ID == 4 /// Represents an ID. -typedef internal::Int32Type Id __attribute__ ((aligned(VTKM_SIZE_ID))); +typedef internal::Int32Type Id; #elif VTKM_SIZE_ID == 8 /// Represents an ID. -typedef internal::Int64Type Id __attribute__ ((aligned(VTKM_SIZE_ID))); +typedef internal::Int64Type Id; #else #error Unknown Id Size @@ -263,12 +273,12 @@ typedef internal::Int64Type Id __attribute__ ((aligned(VTKM_SIZE_ID))); #ifdef VTKM_USE_DOUBLE_PRECISION /// Scalar corresponds to a floating point number. -typedef double Scalar __attribute__ ((aligned(VTKM_SIZE_SCALAR))); +typedef double Scalar; #else //VTKM_USE_DOUBLE_PRECISION /// Scalar corresponds to a floating point number. -typedef float Scalar __attribute__ ((aligned(VTKM_SIZE_SCALAR))); +typedef float Scalar; #endif //VTKM_USE_DOUBLE_PRECISION @@ -431,12 +441,13 @@ protected: }; /// Vector2 corresponds to a 2-tuple -typedef vtkm::Tuple - Vector2 __attribute__ ((aligned(VTKM_ALIGNMENT_TWO_SCALAR))); +namespace internal + { typedef VTKM_ALIGN_BEGIN(VTKM_ALIGNMENT_TWO_SCALAR) vtkm::Tuple Vector2 VTKM_ALIGN_END(VTKM_ALIGNMENT_TWO_SCALAR); } +typedef internal::Vector2 Vector2; /// Id2 corresponds to a 2-dimensional index -typedef vtkm::Tuple Id2 __attribute__ ((aligned(VTKM_SIZE_ID))); +typedef VTKM_ALIGN_BEGIN(VTKM_SIZE_ID) vtkm::Tuple Id2 VTKM_ALIGN_END(VTKM_SIZE_ID); template class Tuple @@ -511,8 +522,7 @@ protected: }; /// Vector3 corresponds to a 3-tuple -typedef vtkm::Tuple - Vector3 __attribute__ ((aligned(VTKM_SIZE_SCALAR))); +typedef VTKM_ALIGN_BEGIN(VTKM_SIZE_SCALAR) vtkm::Tuple Vector3 VTKM_ALIGN_END(VTKM_SIZE_SCALAR); template class Tuple @@ -592,13 +602,12 @@ protected: }; /// Vector4 corresponds to a 4-tuple -typedef vtkm::Tuple - Vector4 __attribute__ ((aligned(VTKM_ALIGNMENT_FOUR_SCALAR))); +typedef VTKM_ALIGN_BEGIN(VTKM_ALIGNMENT_FOUR_SCALAR) vtkm::Tuple Vector4 VTKM_ALIGN_END(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 Id3 __attribute__ ((aligned(VTKM_SIZE_ID))); +typedef VTKM_ALIGN_BEGIN(VTKM_SIZE_ID) vtkm::Tuple Id3 VTKM_ALIGN_END(VTKM_SIZE_ID); /// Initializes and returns a Vector2. VTKM_EXEC_CONT_EXPORT vtkm::Vector2 make_Vector2(vtkm::Scalar x, diff --git a/vtkm/cont/ArrayContainerControlImplicit.h b/vtkm/cont/ArrayContainerControlImplicit.h index 4acb1c682..9287fe8f3 100644 --- a/vtkm/cont/ArrayContainerControlImplicit.h +++ b/vtkm/cont/ArrayContainerControlImplicit.h @@ -131,7 +131,7 @@ public: return this->Portal.GetNumberOfValues(); } - VTKM_CONT_EXPORT void LoadDataForInput(PortalConstControl portal) + VTKM_CONT_EXPORT void LoadDataForInput(const PortalConstControl& portal) { this->Portal = portal; this->PortalValid = true; diff --git a/vtkm/cont/ArrayHandle.h b/vtkm/cont/ArrayHandle.h index 1ddba28db..067bb38ed 100644 --- a/vtkm/cont/ArrayHandle.h +++ b/vtkm/cont/ArrayHandle.h @@ -101,7 +101,7 @@ public: /// Constructs an ArrayHandle pointing to the data in the given array portal. /// - VTKM_CONT_EXPORT ArrayHandle(PortalConstControl userData) + VTKM_CONT_EXPORT ArrayHandle(const PortalConstControl& userData) : Internals(new InternalStruct) { this->Internals->UserPortal = userData; diff --git a/vtkm/cont/internal/ArrayHandleExecutionManager.h b/vtkm/cont/internal/ArrayHandleExecutionManager.h index c0c3babab..01528facd 100644 --- a/vtkm/cont/internal/ArrayHandleExecutionManager.h +++ b/vtkm/cont/internal/ArrayHandleExecutionManager.h @@ -73,7 +73,7 @@ public: /// arrays, then this method may save the iterators to be returned in the \c /// GetPortalConst methods. /// - virtual void LoadDataForInput(PortalConstControl portal) = 0; + virtual void LoadDataForInput(cosnt PortalConstControl& portal) = 0; /// Allocates a large enough array in the execution environment and copies /// the given data to that array. The allocated array can later be accessed @@ -212,7 +212,7 @@ public: } VTKM_CONT_EXPORT - void LoadDataForInput(PortalConstControl portal) + void LoadDataForInput(const PortalConstControl& portal) { this->Transfer.LoadDataForInput(portal); } diff --git a/vtkm/cont/internal/ArrayManagerExecution.h b/vtkm/cont/internal/ArrayManagerExecution.h index f5e14ec8d..c10a2e881 100644 --- a/vtkm/cont/internal/ArrayManagerExecution.h +++ b/vtkm/cont/internal/ArrayManagerExecution.h @@ -83,7 +83,7 @@ public: /// GetPortalConst method. /// VTKM_CONT_EXPORT void LoadDataForInput( - typename ContainerType::PortalConstType portal); + const typename ContainerType::PortalConstType& portal); /// Allocates a large enough array in the execution environment and copies /// the given data to that array. The allocated array can later be accessed diff --git a/vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h b/vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h index 4adb54566..d231d59a7 100644 --- a/vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h +++ b/vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h @@ -64,7 +64,7 @@ public: /// Saves the given iterators to be returned later. /// - VTKM_CONT_EXPORT void LoadDataForInput(PortalConstType portal) + VTKM_CONT_EXPORT void LoadDataForInput(const PortalConstType& portal) { this->ConstPortal = portal; this->ConstPortalValid = true; diff --git a/vtkm/cont/internal/ArrayPortalFromIterators.h b/vtkm/cont/internal/ArrayPortalFromIterators.h index 17c311e6b..ea1f6770c 100644 --- a/vtkm/cont/internal/ArrayPortalFromIterators.h +++ b/vtkm/cont/internal/ArrayPortalFromIterators.h @@ -73,7 +73,7 @@ public: } VTKM_CONT_EXPORT - void Set(vtkm::Id index, ValueType value) const + void Set(vtkm::Id index, const ValueType& value) const { *this->IteratorAt(index) = value; } diff --git a/vtkm/cont/internal/ArrayTransfer.h b/vtkm/cont/internal/ArrayTransfer.h index cf7f59c55..c38d9db79 100644 --- a/vtkm/cont/internal/ArrayTransfer.h +++ b/vtkm/cont/internal/ArrayTransfer.h @@ -82,7 +82,7 @@ public: /// arrays, then this method may save the iterators to be returned in the \c /// GetPortalConst methods. /// - VTKM_CONT_EXPORT void LoadDataForInput(PortalConstControl portal) + VTKM_CONT_EXPORT void LoadDataForInput(const PortalConstControl& portal) { this->ArrayManager.LoadDataForInput(portal); } diff --git a/vtkm/cont/testing/UnitTestArrayContainerControlBasic.cxx b/vtkm/cont/testing/UnitTestArrayContainerControlBasic.cxx index d607181c3..dd4213d5c 100644 --- a/vtkm/cont/testing/UnitTestArrayContainerControlBasic.cxx +++ b/vtkm/cont/testing/UnitTestArrayContainerControlBasic.cxx @@ -48,7 +48,7 @@ struct TemplatedTests } } - bool CheckContainer(ArrayContainerType &array, ValueType value) + bool CheckContainer(ArrayContainerType &array, const ValueType& value) { for (IteratorType iter = array.GetPortal().GetIteratorBegin(); iter != array.GetPortal().GetIteratorEnd();