From 21823500c3333c9a6077fbcb54a62a6889879609 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Mon, 23 Jun 2014 17:33:04 -0600 Subject: [PATCH] Change ArrayContainerControl to Storage. After a talk with Robert Maynard, we decided to change the name ArrayContainerControl to Storage. There are several reasons for this change. 1. The name ArrayContainerControl is unwieldy. It is long, hard for humans to parse, and makes for long lines and wraparound. It is also hard to distinguish from other names like ArrayHandleFoo and ArrayExecutionManager. 2. The word container is getting overloaded. For example, there is a SimplePolymorphicContainer. Container is being used for an object that literally acts like a container for data. This class really manages data. 3. The data does not necessarily have to be on the control side. Implicit containers store the data nowhere. Derivative containers might have all the real data on the execution side. It is possible in the future to have storage on the execution environment instead of the control (think interfacing with a simulator on the GPU). Storage is not a perfect word (what does implicit storage really mean?), but its the best English word we came up with. --- vtkm/cont/ArrayHandle.h | 83 ++++---- vtkm/cont/ArrayHandleCompositeVector.h | 197 +++++++++--------- vtkm/cont/ArrayHandleCounting.h | 7 +- .../cont/ArrayHandleUniformPointCoordinates.h | 6 +- vtkm/cont/ArrayPortal.h | 2 +- vtkm/cont/CMakeLists.txt | 8 +- vtkm/cont/DynamicArrayHandle.h | 158 +++++++------- vtkm/cont/DynamicPointCoordinates.h | 88 ++++---- vtkm/cont/PointCoordinatesArray.h | 10 +- vtkm/cont/PointCoordinatesUniform.h | 6 +- .../{ArrayContainerControl.h => Storage.h} | 101 +++++---- ...ContainerControlBasic.h => StorageBasic.h} | 43 ++-- ...nerControlImplicit.h => StorageImplicit.h} | 81 +++---- .../{ContainerListTag.h => StorageListTag.h} | 18 +- .../internal/ArrayHandleExecutionManager.h | 52 ++--- vtkm/cont/internal/ArrayManagerExecution.h | 21 +- .../internal/ArrayManagerExecutionSerial.h | 9 +- .../ArrayManagerExecutionShareWithControl.h | 28 ++- vtkm/cont/internal/ArrayTransfer.h | 52 +++-- vtkm/cont/internal/CMakeLists.txt | 1 + vtkm/cont/internal/DeviceAdapterAlgorithm.h | 18 +- .../internal/DeviceAdapterAlgorithmGeneral.h | 42 ++-- .../internal/DeviceAdapterAlgorithmSerial.h | 12 +- ...ContainerControlError.h => StorageError.h} | 16 +- ...tArrayManagerExecutionShareWithControl.cxx | 29 +-- vtkm/cont/testing/CMakeLists.txt | 6 +- vtkm/cont/testing/TestingDeviceAdapter.h | 65 +++--- vtkm/cont/testing/UnitTestArrayHandle.cxx | 2 +- .../UnitTestArrayHandleCompositeVector.cxx | 40 ++-- .../UnitTestDeviceAdapterAlgorithmGeneral.cxx | 10 +- .../testing/UnitTestDynamicArrayHandle.cxx | 65 +++--- .../UnitTestDynamicPointCoordinates.cxx | 52 ++--- .../cont/testing/UnitTestPointCoordinates.cxx | 18 +- ...trolBasic.cxx => UnitTestStorageBasic.cxx} | 54 ++--- ...plicit.cxx => UnitTestStorageImplicit.cxx} | 55 ++--- ...ListTag.cxx => UnitTestStorageListTag.cxx} | 10 +- 36 files changed, 713 insertions(+), 752 deletions(-) rename vtkm/cont/{ArrayContainerControl.h => Storage.h} (53%) rename vtkm/cont/{ArrayContainerControlBasic.h => StorageBasic.h} (75%) rename vtkm/cont/{ArrayContainerControlImplicit.h => StorageImplicit.h} (64%) rename vtkm/cont/{ContainerListTag.h => StorageListTag.h} (70%) rename vtkm/cont/internal/{ArrayContainerControlError.h => StorageError.h} (67%) rename vtkm/cont/testing/{UnitTestArrayContainerControlBasic.cxx => UnitTestStorageBasic.cxx} (70%) rename vtkm/cont/testing/{UnitTestArrayContainerControlImplicit.cxx => UnitTestStorageImplicit.cxx} (70%) rename vtkm/cont/testing/{UnitTestContainerListTag.cxx => UnitTestStorageListTag.cxx} (86%) diff --git a/vtkm/cont/ArrayHandle.h b/vtkm/cont/ArrayHandle.h index 53a81bf2d..45f312a1a 100644 --- a/vtkm/cont/ArrayHandle.h +++ b/vtkm/cont/ArrayHandle.h @@ -22,9 +22,10 @@ #include -#include #include #include +#include + #include #include #include @@ -42,18 +43,18 @@ namespace cont { namespace internal { -/// Checks to see if the given type and container can form a valid array handle -/// (some containers cannot support all types). This check is compatable with -/// the Boost meta-template programming library (MPL). It contains a typedef -/// named type that is either boost::mpl::true_ or boost::mpl::false_. Both of -/// these have a typedef named value with the respective boolean value. +/// Checks to see if the given type and storage can form a valid array handle +/// (some storage objects cannot support all types). This check is compatable +/// with the Boost meta-template programming library (MPL). It contains a +/// typedef named type that is either boost::mpl::true_ or boost::mpl::false_. +/// Both of these have a typedef named value with the respective boolean value. /// -template +template struct IsValidArrayHandle { typedef typename boost::mpl::not_< typename boost::is_base_of< - vtkm::cont::internal::UndefinedArrayContainerControl, - vtkm::cont::internal::ArrayContainerControl + vtkm::cont::internal::UndefinedStorage, + vtkm::cont::internal::Storage >::type >::type type; }; @@ -83,22 +84,18 @@ struct IsValidArrayHandle { /// template< typename T, - typename ArrayContainerControlTag_ = VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG> + typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG> class ArrayHandle { private: - typedef vtkm::cont::internal - ::ArrayContainerControl - ArrayContainerControlType; - typedef vtkm::cont::internal - ::ArrayHandleExecutionManagerBase + typedef vtkm::cont::internal::Storage StorageType; + typedef vtkm::cont::internal::ArrayHandleExecutionManagerBase ExecutionManagerType; public: typedef T ValueType; - typedef ArrayContainerControlTag_ ArrayContainerControlTag; - typedef typename ArrayContainerControlType::PortalType PortalControl; - typedef typename ArrayContainerControlType::PortalConstType - PortalConstControl; + typedef StorageTag_ StorageTag; + typedef typename StorageType::PortalType PortalControl; + typedef typename StorageType::PortalConstType PortalConstControl; template struct ExecutionTypes { @@ -398,11 +395,11 @@ public: /// initial state of the control array. When this constructor is used, it /// is assumed that the control array is valid. /// - ArrayHandle(const ArrayContainerControlType &container) + ArrayHandle(const StorageType &storage) : Internals(new InternalStruct) { this->Internals->UserPortalValid = false; - this->Internals->ControlArray = container; + this->Internals->ControlArray = storage; this->Internals->ControlArrayValid = true; this->Internals->ExecutionArrayValid = false; } @@ -413,12 +410,12 @@ public: PortalConstControl UserPortal; bool UserPortalValid; - ArrayContainerControlType ControlArray; + StorageType ControlArray; bool ControlArrayValid; boost::scoped_ptr< vtkm::cont::internal::ArrayHandleExecutionManagerBase< - ValueType,ArrayContainerControlTag> > ExecutionArray; + ValueType,StorageTag> > ExecutionArray; bool ExecutionArrayValid; }; @@ -468,7 +465,7 @@ public: = const_cast(this->Internals.get()); internals->ExecutionArray.reset( new vtkm::cont::internal::ArrayHandleExecutionManager< - T, ArrayContainerControlTag, DeviceAdapterTag>); + T, StorageTag, DeviceAdapterTag>); } /// Synchronizes the control array with the execution array. If either the @@ -502,55 +499,55 @@ public: boost::shared_ptr Internals; }; -/// A convenience function for creating an ArrayHandle from a standard C -/// array. Unless properly specialized, this only works with container types -/// that use an array portal that accepts a pair of pointers to signify the -/// beginning and end of the array. +/// A convenience function for creating an ArrayHandle from a standard C array. +/// Unless properly specialized, this only works with storage types that use an +/// array portal that accepts a pair of pointers to signify the beginning and +/// end of the array. /// -template +template VTKM_CONT_EXPORT -vtkm::cont::ArrayHandle +vtkm::cont::ArrayHandle make_ArrayHandle(const T *array, vtkm::Id length, - ArrayContainerControlTag) + StorageTag) { - typedef vtkm::cont::ArrayHandle ArrayHandleType; + typedef vtkm::cont::ArrayHandle ArrayHandleType; typedef typename ArrayHandleType::PortalConstControl PortalType; return ArrayHandleType(PortalType(array, array+length)); } template VTKM_CONT_EXPORT -vtkm::cont::ArrayHandle +vtkm::cont::ArrayHandle make_ArrayHandle(const T *array, vtkm::Id length) { return make_ArrayHandle(array, length, - VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG()); + VTKM_DEFAULT_STORAGE_TAG()); } /// A convenience function for creating an ArrayHandle from an std::vector. -/// Unless properly specialized, this only works with container types that use -/// an array portal that accepts a pair of pointers to signify the beginning -/// and end of the array. +/// Unless properly specialized, this only works with storage types that use an +/// array portal that accepts a pair of pointers to signify the beginning and +/// end of the array. /// template + typename StorageTag> VTKM_CONT_EXPORT -vtkm::cont::ArrayHandle +vtkm::cont::ArrayHandle make_ArrayHandle(const std::vector &array, - ArrayContainerControlTag) + StorageTag) { - typedef vtkm::cont::ArrayHandle ArrayHandleType; + typedef vtkm::cont::ArrayHandle ArrayHandleType; typedef typename ArrayHandleType::PortalConstControl PortalType; return ArrayHandleType(PortalType(&array.front(), &array.back() + 1)); } template VTKM_CONT_EXPORT -vtkm::cont::ArrayHandle +vtkm::cont::ArrayHandle make_ArrayHandle(const std::vector &array) { - return make_ArrayHandle(array, VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG()); + return make_ArrayHandle(array, VTKM_DEFAULT_STORAGE_TAG()); } } diff --git a/vtkm/cont/ArrayHandleCompositeVector.h b/vtkm/cont/ArrayHandleCompositeVector.h index 4f9918e6c..f727951f1 100644 --- a/vtkm/cont/ArrayHandleCompositeVector.h +++ b/vtkm/cont/ArrayHandleCompositeVector.h @@ -272,28 +272,27 @@ private: }; template -struct ArrayContainerControlTagCompositeVector { }; +struct StorageTagCompositeVector { }; /// A convenience class that provides a typedef to the appropriate tag for -/// a counting array container. +/// a composite storage. template struct ArrayHandleCompositeVectorTraits { - typedef vtkm::cont::internal::ArrayContainerControlTagCompositeVector< - SignatureWithArrays> Tag; + typedef vtkm::cont::internal::StorageTagCompositeVector + Tag; typedef typename vtkm::internal::FunctionInterface::ResultType ValueType; - typedef vtkm::cont::internal::ArrayContainerControl< - ValueType, Tag> ContainerType; + typedef vtkm::cont::internal::Storage StorageType; }; // It may seem weird that this specialization throws an exception for // everything, but that is because all the functionality is handled in the // ArrayTransfer class. template -class ArrayContainerControl< +class Storage< typename ArrayHandleCompositeVectorTraits::ValueType, - vtkm::cont::internal::ArrayContainerControlTagCompositeVector > + vtkm::cont::internal::StorageTagCompositeVector > { typedef vtkm::internal::FunctionInterface FunctionInterfaceWithArrays; @@ -306,11 +305,11 @@ public: typedef typename PortalType::ValueType ValueType; VTKM_CONT_EXPORT - ArrayContainerControl() : Valid(false) { } + Storage() : Valid(false) { } VTKM_CONT_EXPORT - ArrayContainerControl(const FunctionInterfaceWithArrays &arrays, - const ComponentMapType &sourceComponents) + Storage(const FunctionInterfaceWithArrays &arrays, + const ComponentMapType &sourceComponents) : Arrays(arrays), SourceComponents(sourceComponents), Valid(true) { arrays.ForEachCont( @@ -347,11 +346,11 @@ public: void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) { throw vtkm::cont::ErrorControlInternal( - "The allocate method for the composite vector control array " - "container should never have been called. The allocate is generally " - "only called by the execution array manager, and the array transfer " - "for the transform container should prevent the execution array " - "manager from being directly used."); + "The allocate method for the composite vector storage should never " + "have been called. The allocate is generally only called by the " + "execution array manager, and the array transfer for the composite " + "storage should prevent the execution array manager from being " + "directly used."); } VTKM_CONT_EXPORT @@ -389,13 +388,13 @@ private: template class ArrayTransfer< typename ArrayHandleCompositeVectorTraits::ValueType, - vtkm::cont::internal::ArrayContainerControlTagCompositeVector, + vtkm::cont::internal::StorageTagCompositeVector, DeviceAdapterTag> { VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag); - typedef typename ArrayHandleCompositeVectorTraits::ContainerType - ContainerType; + typedef typename ArrayHandleCompositeVectorTraits::StorageType + StorageType; typedef vtkm::internal::FunctionInterface FunctionWithArrays; @@ -409,19 +408,19 @@ public: ValueType; // These are not currently fully implemented. - typedef typename ContainerType::PortalType PortalControl; - typedef typename ContainerType::PortalConstType PortalConstControl; + typedef typename StorageType::PortalType PortalControl; + typedef typename StorageType::PortalConstType PortalConstControl; typedef ArrayPortalCompositeVector PortalExecution; typedef ArrayPortalCompositeVector PortalConstExecution; VTKM_CONT_EXPORT - ArrayTransfer() : ContainerValid(false) { } + ArrayTransfer() : StorageValid(false) { } VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const { - VTKM_ASSERT_CONT(this->ContainerValid); - return this->Container.GetNumberOfValues(); + VTKM_ASSERT_CONT(this->StorageValid); + return this->Storage.GetNumberOfValues(); } VTKM_CONT_EXPORT @@ -433,21 +432,21 @@ public: } VTKM_CONT_EXPORT - void LoadDataForInput(const ContainerType &controlArray) + void LoadDataForInput(const StorageType &controlArray) { - this->Container = controlArray; - this->ContainerValid = true; + this->Storage = controlArray; + this->StorageValid = true; } VTKM_CONT_EXPORT - void LoadDataForInPlace(ContainerType &vtkmNotUsed(controlArray)) + void LoadDataForInPlace(StorageType &vtkmNotUsed(controlArray)) { throw vtkm::cont::ErrorControlBadValue( "Composite vector arrays cannot be used for output or in place."); } VTKM_CONT_EXPORT - void AllocateArrayForOutput(ContainerType &vtkmNotUsed(controlArray), + void AllocateArrayForOutput(StorageType &vtkmNotUsed(controlArray), vtkm::Id vtkmNotUsed(numberOfValues)) { throw vtkm::cont::ErrorControlBadValue( @@ -455,7 +454,7 @@ public: } VTKM_CONT_EXPORT - void RetrieveOutputData(ContainerType &vtkmNotUsed(controlArray)) const + void RetrieveOutputData(StorageType &vtkmNotUsed(controlArray)) const { throw vtkm::cont::ErrorControlBadValue( "Composite vector arrays cannot be used for output."); @@ -478,22 +477,22 @@ public: VTKM_CONT_EXPORT PortalConstExecution GetPortalConstExecution() const { - VTKM_ASSERT_CONT(this->ContainerValid); + VTKM_ASSERT_CONT(this->StorageValid); return PortalConstExecution( - this->Container.GetArrays().StaticTransformCont( + this->Storage.GetArrays().StaticTransformCont( detail::CompositeVectorArrayToPortalExec()), - this->Container.GetSourceComponents()); + this->Storage.GetSourceComponents()); } VTKM_CONT_EXPORT void ReleaseResources() { - this->Container.ReleaseResources(); + this->Storage.ReleaseResources(); } private: - bool ContainerValid; - ContainerType Container; + bool StorageValid; + StorageType Storage; }; } // namespace internal @@ -514,8 +513,8 @@ class ArrayHandleCompositeVector typename internal::ArrayHandleCompositeVectorTraits::ValueType, typename internal::ArrayHandleCompositeVectorTraits::Tag> { - typedef typename internal::ArrayHandleCompositeVectorTraits::ContainerType - ArrayContainerControlType; + typedef typename internal::ArrayHandleCompositeVectorTraits::StorageType + StorageType; typedef typename internal::ArrayPortalCompositeVectorCont::ComponentMapType ComponentMapType; @@ -533,7 +532,7 @@ public: ArrayHandleCompositeVector( const vtkm::internal::FunctionInterface &arrays, const ComponentMapType &sourceComponents) - : Superclass(ArrayContainerControlType(arrays, sourceComponents)) + : Superclass(StorageType(arrays, sourceComponents)) { } /// Template constructors for passing in types. You'll get weird compile @@ -544,7 +543,7 @@ public: VTKM_CONT_EXPORT ArrayHandleCompositeVector(const ArrayHandleType1 &array1, int sourceComponent1) - : Superclass(ArrayContainerControlType( + : Superclass(StorageType( vtkm::internal::make_FunctionInterface(array1), ComponentMapType(sourceComponent1))) { } @@ -555,7 +554,7 @@ public: int sourceComponent1, const ArrayHandleType2 &array2, int sourceComponent2) - : Superclass(ArrayContainerControlType( + : Superclass(StorageType( vtkm::internal::make_FunctionInterface( array1, array2), ComponentMapType(sourceComponent1, @@ -571,7 +570,7 @@ public: int sourceComponent2, const ArrayHandleType3 &array3, int sourceComponent3) - : Superclass(ArrayContainerControlType( + : Superclass(StorageType( vtkm::internal::make_FunctionInterface( array1, array2, array3), ComponentMapType(sourceComponent1, @@ -591,7 +590,7 @@ public: int sourceComponent3, const ArrayHandleType4 &array4, int sourceComponent4) - : Superclass(ArrayContainerControlType( + : Superclass(StorageType( vtkm::internal::make_FunctionInterface( array1, array2, array3, array4), ComponentMapType(sourceComponent1, @@ -670,95 +669,95 @@ public: /// Create a composite vector array from other arrays. /// -template +template VTKM_CONT_EXPORT typename ArrayHandleCompositeVectorType< - vtkm::cont::ArrayHandle >::type + vtkm::cont::ArrayHandle >::type make_ArrayHandleCompositeVector( - const vtkm::cont::ArrayHandle &array1, + const vtkm::cont::ArrayHandle &array1, int sourceComponent1) { return typename ArrayHandleCompositeVectorType< - vtkm::cont::ArrayHandle >::type(array1, - sourceComponent1); + vtkm::cont::ArrayHandle >::type(array1, + sourceComponent1); } -template +template VTKM_CONT_EXPORT typename ArrayHandleCompositeVectorType< - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle >::type + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::type make_ArrayHandleCompositeVector( - const vtkm::cont::ArrayHandle &array1, + const vtkm::cont::ArrayHandle &array1, int sourceComponent1, - const vtkm::cont::ArrayHandle &array2, + const vtkm::cont::ArrayHandle &array2, int sourceComponent2) { return typename ArrayHandleCompositeVectorType< - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle >::type(array1, - sourceComponent1, - array2, - sourceComponent2); + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::type(array1, + sourceComponent1, + array2, + sourceComponent2); } -template +template VTKM_CONT_EXPORT typename ArrayHandleCompositeVectorType< - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle >::type + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::type make_ArrayHandleCompositeVector( - const vtkm::cont::ArrayHandle &array1, + const vtkm::cont::ArrayHandle &array1, int sourceComponent1, - const vtkm::cont::ArrayHandle &array2, + const vtkm::cont::ArrayHandle &array2, int sourceComponent2, - const vtkm::cont::ArrayHandle &array3, + const vtkm::cont::ArrayHandle &array3, int sourceComponent3) { return typename ArrayHandleCompositeVectorType< - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle >::type(array1, - sourceComponent1, - array2, - sourceComponent2, - array3, - sourceComponent3); + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::type(array1, + sourceComponent1, + array2, + sourceComponent2, + array3, + sourceComponent3); } -template +template VTKM_CONT_EXPORT typename ArrayHandleCompositeVectorType< - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle >::type + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::type make_ArrayHandleCompositeVector( - const vtkm::cont::ArrayHandle &array1, + const vtkm::cont::ArrayHandle &array1, int sourceComponent1, - const vtkm::cont::ArrayHandle &array2, + const vtkm::cont::ArrayHandle &array2, int sourceComponent2, - const vtkm::cont::ArrayHandle &array3, + const vtkm::cont::ArrayHandle &array3, int sourceComponent3, - const vtkm::cont::ArrayHandle &array4, + const vtkm::cont::ArrayHandle &array4, int sourceComponent4) { return typename ArrayHandleCompositeVectorType< - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle, - vtkm::cont::ArrayHandle >::type(array1, - sourceComponent1, - array2, - sourceComponent2, - array3, - sourceComponent3, - array4, - sourceComponent4); + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::type(array1, + sourceComponent1, + array2, + sourceComponent2, + array3, + sourceComponent3, + array4, + sourceComponent4); } } diff --git a/vtkm/cont/ArrayHandleCounting.h b/vtkm/cont/ArrayHandleCounting.h index 5b9dd33c4..baf4ac896 100644 --- a/vtkm/cont/ArrayHandleCounting.h +++ b/vtkm/cont/ArrayHandleCounting.h @@ -20,8 +20,9 @@ #ifndef vtk_m_cont_ArrayHandleCounting_h #define vtk_m_cont_ArrayHandleCounting_h -#include #include +#include + #include namespace vtkm { @@ -92,11 +93,11 @@ private: }; /// A convenience class that provides a typedef to the appropriate tag for -/// a counting array container. +/// a counting storage. template struct ArrayHandleCountingTraits { - typedef vtkm::cont::ArrayContainerControlTagImplicit< + typedef vtkm::cont::StorageTagImplicit< vtkm::cont::internal::ArrayPortalCounting > Tag; }; diff --git a/vtkm/cont/ArrayHandleUniformPointCoordinates.h b/vtkm/cont/ArrayHandleUniformPointCoordinates.h index 7134cd8fb..f3cef0581 100644 --- a/vtkm/cont/ArrayHandleUniformPointCoordinates.h +++ b/vtkm/cont/ArrayHandleUniformPointCoordinates.h @@ -22,8 +22,8 @@ #include -#include #include +#include #include @@ -131,12 +131,12 @@ private: class ArrayHandleUniformPointCoordinates : public vtkm::cont::ArrayHandle< vtkm::Vector3, - vtkm::cont::ArrayContainerControlTagImplicit< + vtkm::cont::StorageTagImplicit< internal::ArrayPortalUniformPointCoordinates> > { typedef vtkm::cont::ArrayHandle< vtkm::Vector3, - vtkm::cont::ArrayContainerControlTagImplicit< + vtkm::cont::StorageTagImplicit< internal::ArrayPortalUniformPointCoordinates> > Superclass; public: diff --git a/vtkm/cont/ArrayPortal.h b/vtkm/cont/ArrayPortal.h index 438ef32e2..951d423f1 100644 --- a/vtkm/cont/ArrayPortal.h +++ b/vtkm/cont/ArrayPortal.h @@ -42,7 +42,7 @@ namespace cont { /// An ArrayPortal differs from an ArrayHandle in that the ArrayPortal is a /// much lighterweight object and that it does not manage things like /// allocation and control/execution sharing. An ArrayPortal also differs from -/// an ArrayContainer in that it does not actually contain the data but rather +/// a Storage in that it does not actually contain the data but rather /// points to it. In this way the ArrayPortal can be copied and passed and /// still point to the same data. /// diff --git a/vtkm/cont/CMakeLists.txt b/vtkm/cont/CMakeLists.txt index 4bf16ea0a..3fb862ec0 100644 --- a/vtkm/cont/CMakeLists.txt +++ b/vtkm/cont/CMakeLists.txt @@ -21,16 +21,12 @@ include_directories(${Boost_INCLUDE_DIRS}) set(headers - ArrayContainerControl.h - ArrayContainerControlBasic.h - ArrayContainerControlImplicit.h ArrayHandle.h ArrayHandleCompositeVector.h ArrayHandleCounting.h ArrayHandleUniformPointCoordinates.h ArrayPortal.h Assert.h - ContainerListTag.h DeviceAdapter.h DeviceAdapterSerial.h DynamicArrayHandle.h @@ -45,6 +41,10 @@ set(headers PointCoordinatesArray.h PointCoordinatesListTag.h PointCoordinatesUniform.h + Storage.h + StorageBasic.h + StorageImplicit.h + StorageListTag.h Timer.h ) diff --git a/vtkm/cont/DynamicArrayHandle.h b/vtkm/cont/DynamicArrayHandle.h index 31496cf8d..fa9ea90b9 100644 --- a/vtkm/cont/DynamicArrayHandle.h +++ b/vtkm/cont/DynamicArrayHandle.h @@ -23,8 +23,8 @@ #include #include -#include #include +#include #include #include @@ -38,10 +38,10 @@ namespace cont { namespace internal { /// Behaves like (and is interchangable with) a DynamicArrayHandle. The -/// difference is that the list of types and list of containers to try when +/// difference is that the list of types and list of storage to try when /// calling CastAndCall is set to the class template arguments. /// -template +template class DynamicArrayHandleCast; } // namespace internal @@ -57,15 +57,15 @@ class DynamicArrayHandleCast; /// /// To interface between the runtime polymorphism and the templated algorithms /// in VTK-m, \c DynamicArrayHandle contains a method named \c CastAndCall that -/// will determine the correct type from some known list of types and -/// containers. This mechanism is used internally by VTK-m's worklet invocation +/// will determine the correct type from some known list of types and storage +/// objects. This mechanism is used internally by VTK-m's worklet invocation /// mechanism to determine the type when running algorithms. /// /// By default, \c DynamicArrayHandle will assume that the value type in the /// array matches one of the types specified by \c VTKM_DEFAULT_TYPE_LIST_TAG -/// and the container matches one of the tags specified by \c -/// VTKM_DEFAULT_CONTAINER_LIST_TAG. These lists can be changed by using the \c -/// ResetTypeList and \c ResetContainerList methods, respectively. It is +/// and the storage matches one of the tags specified by \c +/// VTKM_DEFAULT_STORAGE_LIST_TAG. These lists can be changed by using the \c +/// ResetTypeList and \c ResetStorageList methods, respectively. It is /// worthwhile to match these lists closely to the possible types that might be /// used. If a type is missing you will get a runtime error. If there are more /// types than necessary, then the template mechanism will create a lot of @@ -79,39 +79,39 @@ public: VTKM_CONT_EXPORT DynamicArrayHandle() { } - template + template VTKM_CONT_EXPORT - DynamicArrayHandle(const vtkm::cont::ArrayHandle &array) - : ArrayContainer(new vtkm::cont::internal::SimplePolymorphicContainer< - vtkm::cont::ArrayHandle >(array)) + DynamicArrayHandle(const vtkm::cont::ArrayHandle &array) + : ArrayStorage(new vtkm::cont::internal::SimplePolymorphicContainer< + vtkm::cont::ArrayHandle >(array)) { } - template + template VTKM_CONT_EXPORT DynamicArrayHandle( - const internal::DynamicArrayHandleCast &dynamicArray) - : ArrayContainer(dynamicArray.ArrayContainer) { } + const internal::DynamicArrayHandleCast &dynamicArray) + : ArrayStorage(dynamicArray.ArrayStorage) { } /// Returns true if this array is of the provided type and uses the provided - /// container. + /// storage. /// - template + template VTKM_CONT_EXPORT - bool IsTypeAndContainer(Type = Type(), Container = Container()) const { - return (this->TryCastArrayContainer() != NULL); + bool IsTypeAndStorage(Type = Type(), Storage = Storage()) const { + return (this->TryCastStorage() != NULL); } /// Returns this array cast to an ArrayHandle object of the given type and - /// container. Throws ErrorControlBadValue if the cast does not work. Use - /// IsTypeAndContainer to check if the cast can happen. + /// storage. Throws ErrorControlBadValue if the cast does not work. Use + /// IsTypeAndStorage to check if the cast can happen. /// - template + template VTKM_CONT_EXPORT - vtkm::cont::ArrayHandle - CastToArrayHandle(Type = Type(), Container = Container()) const { + vtkm::cont::ArrayHandle + CastToArrayHandle(Type = Type(), Storage = Storage()) const { vtkm::cont::internal::SimplePolymorphicContainer< - vtkm::cont::ArrayHandle > *container = - this->TryCastArrayContainer(); + vtkm::cont::ArrayHandle > *container = + this->TryCastStorage(); if (container == NULL) { throw vtkm::cont::ErrorControlBadValue("Bad cast of dynamic array."); @@ -128,104 +128,104 @@ public: /// template VTKM_CONT_EXPORT - internal::DynamicArrayHandleCast + internal::DynamicArrayHandleCast ResetTypeList(NewTypeList = NewTypeList()) const { return internal::DynamicArrayHandleCast< - NewTypeList,VTKM_DEFAULT_CONTAINER_LIST_TAG>(*this); + NewTypeList,VTKM_DEFAULT_STORAGE_LIST_TAG>(*this); } - /// Changes the array containers to try casting to when resolving this + /// Changes the array storage types to try casting to when resolving this /// dynamic array, which is specified with a list tag like those in - /// ContainerListTag.h. Since C++ does not allow you to actually change the + /// StorageListTag.h. Since C++ does not allow you to actually change the /// template arguments, this method returns a new dynamic array object. This /// method is particularly useful to narrow down (or expand) the types when /// using an array of particular constraints. /// - template + template VTKM_CONT_EXPORT - internal::DynamicArrayHandleCast - ResetContainerList(NewContainerList = NewContainerList()) const { + internal::DynamicArrayHandleCast + ResetStorageList(NewStorageList = NewStorageList()) const { return internal::DynamicArrayHandleCast< - VTKM_DEFAULT_TYPE_LIST_TAG,NewContainerList>(*this); + VTKM_DEFAULT_TYPE_LIST_TAG,NewStorageList>(*this); } - /// Attempts to cast the held array to a specific value type and container, - /// then call the given functor with the cast array. The types and containers + /// Attempts to cast the held array to a specific value type and storage, + /// then call the given functor with the cast array. The types and storage /// tried in the cast are those in the lists defined by - /// VTKM_DEFAULT_TYPE_LIST_TAG and VTKM_DEFAULT_CONTAINER_LIST_TAG, + /// VTKM_DEFAULT_TYPE_LIST_TAG and VTK_DEFAULT_STORAGE_LIST_TAG, /// respectively, unless they have been changed with a previous call to - /// ResetTypeList or ResetContainerList. + /// ResetTypeList or ResetStorageList. /// template VTKM_CONT_EXPORT void CastAndCall(const Functor &f) const { this->CastAndCall( - f, VTKM_DEFAULT_TYPE_LIST_TAG(), VTKM_DEFAULT_CONTAINER_LIST_TAG()); + f, VTKM_DEFAULT_TYPE_LIST_TAG(), VTKM_DEFAULT_STORAGE_LIST_TAG()); } /// A version of CastAndCall that tries specified lists of types and - /// containers. + /// storage types. /// - template + template VTKM_CONT_EXPORT - void CastAndCall(const Functor &f, TypeList, ContainerList) const; + void CastAndCall(const Functor &f, TypeList, StorageList) const; private: boost::shared_ptr - ArrayContainer; + ArrayStorage; - template + template VTKM_CONT_EXPORT vtkm::cont::internal::SimplePolymorphicContainer< - vtkm::cont::ArrayHandle > * - TryCastArrayContainer() const { + vtkm::cont::ArrayHandle > * + TryCastStorage() const { return dynamic_cast< vtkm::cont::internal::SimplePolymorphicContainer< - vtkm::cont::ArrayHandle > *>( - this->ArrayContainer.get()); + vtkm::cont::ArrayHandle > *>( + this->ArrayStorage.get()); } }; namespace detail { template -struct DynamicArrayHandleTryContainer { +struct DynamicArrayHandleTryStorage { const DynamicArrayHandle Array; const Functor &Function; bool FoundCast; VTKM_CONT_EXPORT - DynamicArrayHandleTryContainer(const DynamicArrayHandle &array, + DynamicArrayHandleTryStorage(const DynamicArrayHandle &array, const Functor &f) : Array(array), Function(f), FoundCast(false) { } - template + template VTKM_CONT_EXPORT typename boost::enable_if< - typename vtkm::cont::internal::IsValidArrayHandle::type + typename vtkm::cont::internal::IsValidArrayHandle::type >::type - operator()(Container) { + operator()(Storage) { if (!this->FoundCast && - this->Array.IsTypeAndContainer(Type(), Container())) + this->Array.IsTypeAndStorage(Type(), Storage())) { - this->Function(this->Array.CastToArrayHandle(Type(), Container())); + this->Function(this->Array.CastToArrayHandle(Type(), Storage())); this->FoundCast = true; } } - template + template VTKM_CONT_EXPORT typename boost::disable_if< - typename vtkm::cont::internal::IsValidArrayHandle::type + typename vtkm::cont::internal::IsValidArrayHandle::type >::type - operator()(Container) { + operator()(Storage) { // This type of array handle cannot exist, so do nothing. } }; -template +template struct DynamicArrayHandleTryType { const DynamicArrayHandle Array; const Functor &Function; @@ -239,11 +239,11 @@ struct DynamicArrayHandleTryType { VTKM_CONT_EXPORT void operator()(Type) { if (this->FoundCast) { return; } - typedef DynamicArrayHandleTryContainer TryContainerType; - TryContainerType tryContainer = - TryContainerType(this->Array, this->Function); - vtkm::ListForEach(tryContainer, ContainerList()); - if (tryContainer.FoundCast) + typedef DynamicArrayHandleTryStorage TryStorageType; + TryStorageType tryStorage = + TryStorageType(this->Array, this->Function); + vtkm::ListForEach(tryStorage, StorageList()); + if (tryStorage.FoundCast) { this->FoundCast = true; } @@ -252,13 +252,13 @@ struct DynamicArrayHandleTryType { } // namespace detail -template +template VTKM_CONT_EXPORT void DynamicArrayHandle::CastAndCall(const Functor &f, TypeList, - ContainerList) const + StorageList) const { - typedef detail::DynamicArrayHandleTryType TryTypeType; + typedef detail::DynamicArrayHandleTryType TryTypeType; TryTypeType tryType = TryTypeType(*this, f); vtkm::ListForEach(tryType, TypeList()); if (!tryType.FoundCast) @@ -270,7 +270,7 @@ void DynamicArrayHandle::CastAndCall(const Functor &f, namespace internal { -template +template class DynamicArrayHandleCast : public vtkm::cont::DynamicArrayHandle { public: @@ -281,31 +281,31 @@ public: DynamicArrayHandleCast(const vtkm::cont::DynamicArrayHandle &array) : DynamicArrayHandle(array) { } - template + template VTKM_CONT_EXPORT DynamicArrayHandleCast( - const DynamicArrayHandleCast &array) + const DynamicArrayHandleCast &array) : DynamicArrayHandle(array) { } template VTKM_CONT_EXPORT - DynamicArrayHandleCast + DynamicArrayHandleCast ResetTypeList(NewTypeList = NewTypeList()) const { - return DynamicArrayHandleCast(*this); + return DynamicArrayHandleCast(*this); } - template + template VTKM_CONT_EXPORT - internal::DynamicArrayHandleCast - ResetContainerList(NewContainerList = NewContainerList()) const { - return internal::DynamicArrayHandleCast(*this); + internal::DynamicArrayHandleCast + ResetStorageList(NewStorageList = NewStorageList()) const { + return internal::DynamicArrayHandleCast(*this); } template VTKM_CONT_EXPORT void CastAndCall(const Functor &f) const { - this->CastAndCall(f, TypeList(), ContainerList()); + this->CastAndCall(f, TypeList(), StorageList()); } template @@ -321,9 +321,9 @@ struct DynamicTransformTraits { typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag; }; -template +template struct DynamicTransformTraits< - vtkm::cont::internal::DynamicArrayHandleCast > + vtkm::cont::internal::DynamicArrayHandleCast > { typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag; }; diff --git a/vtkm/cont/DynamicPointCoordinates.h b/vtkm/cont/DynamicPointCoordinates.h index def0560a2..c9ade9703 100644 --- a/vtkm/cont/DynamicPointCoordinates.h +++ b/vtkm/cont/DynamicPointCoordinates.h @@ -36,12 +36,12 @@ namespace internal { /// Behaves like (and is interchangable with) a \c DynamicPointCoordinates. The /// difference is that the lists of point coordinates, base types, and -/// containers to try when calling \c CastAndCall is set to the class template +/// storage to try when calling \c CastAndCall is set to the class template /// arguments. /// template + typename StorageList> class DynamicPointCoordinatesCast; } // namespace internal @@ -67,9 +67,9 @@ class DynamicPointCoordinatesCast; /// /// Internally, some \c PointCoordinates objects will reference dynamic arrays. /// Thus, \c DynamicPointCoordinates also maintains lists of types and -/// containers that these subarrays might use. These default to \c -/// VTKM_DEFAULT_TYPE_LIST_TAG and \c VTKM_DEFAULT_CONTAINER_LIST_TAG and can -/// be changed with the \c ResetTypeList and \c ResetContainerList methods. +/// storage that these subarrays might use. These default to \c +/// VTKM_DEFAULT_TYPE_LIST_TAG and \c VTKM_DEFAULT_STORAGE_LIST_TAG and can +/// be changed with the \c ResetTypeList and \c ResetStorageList methods. /// class DynamicPointCoordinates { @@ -88,10 +88,10 @@ public: /// Special constructor for the common case of using a basic array to store /// point coordinates. /// - template + template VTKM_CONT_EXPORT DynamicPointCoordinates( - const vtkm::cont::ArrayHandle &array) + const vtkm::cont::ArrayHandle &array) : PointCoordinatesContainer(new vtkm::cont::PointCoordinatesArray(array)) { } @@ -152,13 +152,13 @@ public: internal::DynamicPointCoordinatesCast< NewPointCoordinatesList, VTKM_DEFAULT_TYPE_LIST_TAG, - VTKM_DEFAULT_CONTAINER_LIST_TAG> + VTKM_DEFAULT_STORAGE_LIST_TAG> ResetPointCoordinatesList( NewPointCoordinatesList = NewPointCoordinatesList()) const { return internal::DynamicPointCoordinatesCast< NewPointCoordinatesList, VTKM_DEFAULT_TYPE_LIST_TAG, - VTKM_DEFAULT_CONTAINER_LIST_TAG>(*this); + VTKM_DEFAULT_STORAGE_LIST_TAG>(*this); } /// Changes the types to try casting to when resolving dynamic arrays within @@ -173,32 +173,32 @@ public: internal::DynamicPointCoordinatesCast< VTKM_DEFAULT_POINT_COORDINATES_LIST_TAG, NewTypeList, - VTKM_DEFAULT_CONTAINER_LIST_TAG> + VTKM_DEFAULT_STORAGE_LIST_TAG> ResetTypeList(NewTypeList = NewTypeList()) const { return internal::DynamicPointCoordinatesCast< VTKM_DEFAULT_POINT_COORDINATES_LIST_TAG, NewTypeList, - VTKM_DEFAULT_CONTAINER_LIST_TAG>(*this); + VTKM_DEFAULT_STORAGE_LIST_TAG>(*this); } - /// Changes the array containers to try casting to when resolving dynamic + /// Changes the array storage to try casting to when resolving dynamic /// arrays within the point coordinates container, which is specified with a - /// list tag like those in ContainerListTag.h. Since C++ does not allow you + /// list tag like those in StorageListTag.h. Since C++ does not allow you /// to actually change the template arguments, this method returns a new /// dynamic array object. This method is particularly useful to narrow down /// (or expand) the types when using an array of particular constraints. /// - template + template VTKM_CONT_EXPORT internal::DynamicPointCoordinatesCast< VTKM_DEFAULT_POINT_COORDINATES_LIST_TAG, VTKM_DEFAULT_TYPE_LIST_TAG, - NewContainerList> - ResetContainerList(NewContainerList = NewContainerList()) const { + NewStorageList> + ResetStorageList(NewStorageList = NewStorageList()) const { return internal::DynamicPointCoordinatesCast< VTKM_DEFAULT_POINT_COORDINATES_LIST_TAG, VTKM_DEFAULT_TYPE_LIST_TAG, - NewContainerList>(*this); + NewStorageList>(*this); } /// Attempts to cast the held point coordinates to a specific array @@ -209,7 +209,7 @@ public: /// /// The second part then asks the concrete \c PointCoordinates object to cast /// and call to a concrete array. This second cast might rely on \c - /// VTKM_DEFAULT_TYPE_LIST_TAG and \c VTKM_DEFAULT_CONTAINER_LIST_TAG. + /// VTKM_DEFAULT_TYPE_LIST_TAG and \c VTKM_DEFAULT_STORAGE_LIST_TAG. /// template VTKM_CONT_EXPORT @@ -218,21 +218,21 @@ public: this->CastAndCall(f, VTKM_DEFAULT_POINT_COORDINATES_LIST_TAG(), VTKM_DEFAULT_TYPE_LIST_TAG(), - VTKM_DEFAULT_CONTAINER_LIST_TAG()); + VTKM_DEFAULT_STORAGE_LIST_TAG()); } /// A version of \c CastAndCall that tries specified lists of point - /// coordinates, types, and containers. + /// coordinates, types, and storage. /// template + typename StorageList> VTKM_CONT_EXPORT void CastAndCall(const Functor &f, PointCoordinatesList, TypeList, - ContainerList) const; + StorageList) const; private: boost::shared_ptr @@ -250,15 +250,15 @@ private: namespace detail { -template -struct DynamicPointCoordinatesTryContainer +template +struct DynamicPointCoordinatesTryStorage { const DynamicPointCoordinates PointCoordinates; const Functor &Function; bool FoundCast; VTKM_CONT_EXPORT - DynamicPointCoordinatesTryContainer( + DynamicPointCoordinatesTryStorage( const DynamicPointCoordinates &pointCoordinates, const Functor &f) : PointCoordinates(pointCoordinates), Function(f), FoundCast(false) @@ -272,7 +272,7 @@ struct DynamicPointCoordinatesTryContainer { PointCoordinatesType pointCoordinates = this->PointCoordinates.CastToPointCoordinates(PointCoordinatesType()); - pointCoordinates.CastAndCall(this->Function, TypeList(), ContainerList()); + pointCoordinates.CastAndCall(this->Function, TypeList(), StorageList()); this->FoundCast = true; } } @@ -283,15 +283,15 @@ struct DynamicPointCoordinatesTryContainer template + typename StorageList> VTKM_CONT_EXPORT void DynamicPointCoordinates::CastAndCall(const Functor &f, PointCoordinatesList, TypeList, - ContainerList) const + StorageList) const { - typedef detail::DynamicPointCoordinatesTryContainer< - Functor, TypeList, ContainerList> TryTypeType; + typedef detail::DynamicPointCoordinatesTryStorage< + Functor, TypeList, StorageList> TryTypeType; TryTypeType tryType = TryTypeType(*this, f); vtkm::ListForEach(tryType, PointCoordinatesList()); if (!tryType.FoundCast) @@ -305,7 +305,7 @@ namespace internal { template + typename StorageList> class DynamicPointCoordinatesCast : public vtkm::cont::DynamicPointCoordinates { public: @@ -318,43 +318,43 @@ public: template + typename SrcStorageList> VTKM_CONT_EXPORT DynamicPointCoordinatesCast( - const DynamicPointCoordinatesCast &coords) + const DynamicPointCoordinatesCast &coords) : DynamicPointCoordinates(coords) { } template VTKM_CONT_EXPORT - DynamicPointCoordinatesCast + DynamicPointCoordinatesCast ResetPointCoordinatesList( NewPointCoordinatesList = NewPointCoordinatesList()) const { return DynamicPointCoordinatesCast< - NewPointCoordinatesList,TypeList,ContainerList>(*this); + NewPointCoordinatesList,TypeList,StorageList>(*this); } template VTKM_CONT_EXPORT - DynamicPointCoordinatesCast + DynamicPointCoordinatesCast ResetTypeList(NewTypeList = NewTypeList()) const { return DynamicPointCoordinatesCast< - PointCoordinatesList,NewTypeList,ContainerList>(*this); + PointCoordinatesList,NewTypeList,StorageList>(*this); } - template + template VTKM_CONT_EXPORT - DynamicPointCoordinatesCast - ResetContainerList(NewContainerList = NewContainerList()) const { + DynamicPointCoordinatesCast + ResetStorageList(NewStorageList = NewStorageList()) const { return DynamicPointCoordinatesCast< - PointCoordinatesList,TypeList,NewContainerList>(*this); + PointCoordinatesList,TypeList,NewStorageList>(*this); } template VTKM_CONT_EXPORT void CastAndCall(const Functor &f) const { - this->CastAndCall(f, PointCoordinatesList(), TypeList(), ContainerList()); + this->CastAndCall(f, PointCoordinatesList(), TypeList(), StorageList()); } template @@ -372,10 +372,10 @@ struct DynamicTransformTraits { template + typename StorageList> struct DynamicTransformTraits< vtkm::cont::internal::DynamicPointCoordinatesCast< - PointCoordinatesList,TypeList,ContainerList> > + PointCoordinatesList,TypeList,StorageList> > { typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag; }; diff --git a/vtkm/cont/PointCoordinatesArray.h b/vtkm/cont/PointCoordinatesArray.h index 373e1a7fb..129177665 100644 --- a/vtkm/cont/PointCoordinatesArray.h +++ b/vtkm/cont/PointCoordinatesArray.h @@ -49,20 +49,20 @@ public: PointCoordinatesArray(const vtkm::cont::DynamicArrayHandle &array) : Array(array) { } - template + template VTKM_CONT_EXPORT PointCoordinatesArray( - const vtkm::cont::ArrayHandle &array) + const vtkm::cont::ArrayHandle &array) : Array(array) { } /// In this \c CastAndCall, \c TypeList is ignored. All point coordinates are /// expressed as Vector3, so that must be how the array is represented. /// - template + template VTKM_CONT_EXPORT - void CastAndCall(const Functor &f, TypeList, ContainerList) const + void CastAndCall(const Functor &f, TypeList, StorageList) const { - this->Array.CastAndCall(f, vtkm::TypeListTagVector3(), ContainerList()); + this->Array.CastAndCall(f, vtkm::TypeListTagVector3(), StorageList()); } private: diff --git a/vtkm/cont/PointCoordinatesUniform.h b/vtkm/cont/PointCoordinatesUniform.h index e55eb84aa..303bcb6ba 100644 --- a/vtkm/cont/PointCoordinatesUniform.h +++ b/vtkm/cont/PointCoordinatesUniform.h @@ -49,13 +49,13 @@ public: : Array(extent, origin, spacing) { } - /// In this \c CastAndCall, both \c TypeList and \c ContainerList are + /// In this \c CastAndCall, both \c TypeList and \c StorageList are /// ignored. All point coordinates are expressed as Vector3, so that must be /// how the array is represented. /// - template + template VTKM_CONT_EXPORT - void CastAndCall(const Functor &f, TypeList, ContainerList) const + void CastAndCall(const Functor &f, TypeList, StorageList) const { f(this->Array); } diff --git a/vtkm/cont/ArrayContainerControl.h b/vtkm/cont/Storage.h similarity index 53% rename from vtkm/cont/ArrayContainerControl.h rename to vtkm/cont/Storage.h index 2c982d94c..d54bfa152 100644 --- a/vtkm/cont/ArrayContainerControl.h +++ b/vtkm/cont/Storage.h @@ -17,15 +17,15 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ -#ifndef vtk_m_cont__ArrayContainerControl_h -#define vtk_m_cont__ArrayContainerControl_h +#ifndef vtk_m_cont_Storage_h +#define vtk_m_cont_Storage_h -#define VTKM_ARRAY_CONTAINER_CONTROL_ERROR -2 -#define VTKM_ARRAY_CONTAINER_CONTROL_UNDEFINED -1 -#define VTKM_ARRAY_CONTAINER_CONTROL_BASIC 1 +#define VTKM_STORAGE_ERROR -2 +#define VTKM_STORAGE_UNDEFINED -1 +#define VTKM_STORAGE_BASIC 1 -#ifndef VTKM_ARRAY_CONTAINER_CONTROL -#define VTKM_ARRAY_CONTAINER_CONTROL VTKM_ARRAY_CONTAINER_CONTROL_BASIC +#ifndef VTKM_STORAGE +#define VTKM_STORAGE VTKM_STORAGE_BASIC #endif #include @@ -36,42 +36,40 @@ namespace cont { #ifdef VTKM_DOXYGEN_ONLY /// \brief A tag specifying client memory allocation. /// -/// An ArrayContainerControl tag specifies how an ArrayHandle allocates and -/// frees memory. The tag ArrayContainerControlTag___ does not actually exist. -/// Rather, this documentation is provided to describe how array containers are -/// specified. Loading the vtkm/cont/ArrayContainerControl.h header will set a -/// default array container. You can specify the default array container by -/// first setting the VTKM_ARRAY_CONTAINER_CONTROL macro. Currently it can only -/// be set to VTKM_ARRAY_CONTAINER_CONTROL_BASIC. +/// A Storage tag specifies how an ArrayHandle allocates and frees memory. The +/// tag StorageTag___ does not actually exist. Rather, this documentation is +/// provided to describe how array storage objects are specified. Loading the +/// vtkm/cont/Storage.h header will set a default array storage. You can +/// specify the default storage by first setting the VTKM_STORAGE macro. +/// Currently it can only be set to VTKM_STORAGE_BASIC. /// -/// User code external to VTKm is free to make its own ArrayContainerControlTag. -/// This is a good way to get VTKm to read data directly in and out of arrays -/// from other libraries. However, care should be taken when creating an -/// ArrayContainerControl. One particular problem that is likely is a container -/// that "constructs" all the items in the array. If done incorrectly, then -/// memory of the array can be incorrectly bound to the wrong process. If you -/// do provide your own ArrayContainerControlTag, please be diligent in -/// comparing its performance to the ArrayContainerControlTagBasic. +/// User code external to VTK-m is free to make its own StorageTag. This is a +/// good way to get VTK-m to read data directly in and out of arrays from other +/// libraries. However, care should be taken when creating a Storage. One +/// particular problem that is likely is a storage that "constructs" all the +/// items in the array. If done incorrectly, then memory of the array can be +/// incorrectly bound to the wrong processor. If you do provide your own +/// StorageTag, please be diligent in comparing its performance to the +/// StorageTagBasic. /// -/// To implement your own ArrayContainerControlTag, you first must create a tag -/// class (an empty struct) defining your tag (i.e. struct -/// ArrayContainerControlTagMyAlloc { };). Then provide a partial template -/// specialization of vtkm::cont::internal::ArrayContainerControl for your new -/// tag. +/// To implement your own StorageTag, you first must create a tag class (an +/// empty struct) defining your tag (i.e. struct StorageTagMyAlloc { };). Then +/// provide a partial template specialization of vtkm::cont::internal::Storage +/// for your new tag. /// -struct ArrayContainerControlTag___ { }; +struct StorageTag___ { }; #endif // VTKM_DOXYGEN_ONLY namespace internal { -struct UndefinedArrayContainerControl { }; +struct UndefinedStorage { }; namespace detail { // This class should never be used. It is used as a placeholder for undefined -// ArrayContainerControl objects. If you get a compiler error involving this -// object, then it probably comes from trying to use an ArrayHandle with bad -// template arguments. +// Storage objects. If you get a compiler error involving this object, then it +// probably comes from trying to use an ArrayHandle with bad template +// arguments. template struct UndefinedArrayPortal { BOOST_STATIC_ASSERT(sizeof(T) == -1); @@ -79,14 +77,13 @@ struct UndefinedArrayPortal { } // namespace detail -/// This templated class must be partially specialized for each -/// ArrayContainerControlTag created, which will define the implementation for -/// that tag. +/// This templated class must be partially specialized for each StorageTag +/// created, which will define the implementation for that tag. /// -template -class ArrayContainerControl +template +class Storage #ifndef VTKM_DOXYGEN_ONLY - : public vtkm::cont::internal::UndefinedArrayContainerControl + : public vtkm::cont::internal::UndefinedStorage { public: typedef vtkm::cont::internal::detail::UndefinedArrayPortal PortalType; @@ -152,7 +149,7 @@ public: /// /// After calling this method GetNumberOfValues will return 0 and /// GetIteratorBegin and GetIteratorEnd will return the same iterator. The - /// resources should also be released when the ArrayContainerControl class is + /// resources should also be released when the Storage class is /// destroyed. VTKM_CONT_EXPORT void ReleaseResources(); @@ -164,27 +161,25 @@ public: } } // namespace vtkm::cont -// This is put at the bottom of the header so that the ArrayContainerControl -// template is declared before any implementations are called. +// This is put at the bottom of the header so that the Storage template is +// declared before any implementations are called. -#if VTKM_ARRAY_CONTAINER_CONTROL == VTKM_ARRAY_CONTAINER_CONTROL_BASIC +#if VTKM_STORAGE == VTKM_STORAGE_BASIC -#include -#define VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG \ - ::vtkm::cont::ArrayContainerControlTagBasic +#include +#define VTKM_DEFAULT_STORAGE_TAG ::vtkm::cont::StorageTagBasic -#elif VTKM_ARRAY_CONTAINER_CONTROL == VTKM_ARRAY_CONTAINER_CONTROL_ERROR +#elif VTKM_STORAGE == VTKM_STORAGE_ERROR -#include -#define VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG \ - ::vtkm::cont::internal::ArrayContainerControlTagError +#include +#define VTKM_DEFAULT_STORAGE_TAG ::vtkm::cont::internal::StorageTagError -#elif (VTKM_ARRAY_CONTAINER_CONTROL == VTKM_ARRAY_CONTAINER_CONTROL_UNDEFINED) || !defined(VTKM_ARRAY_CONTAINER_CONTROL) +#elif (VTKM_STORAGE == VTKM_STORAGE_UNDEFINED) || !defined(VTKM_STORAGE) -#ifndef VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG -#warning If array container for control is undefined, VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG must be defined. +#ifndef VTKM_DEFAULT_STORAGE_TAG +#warning If array storage is undefined, VTKM_DEFAULT_STORAGE_TAG must be defined. #endif #endif -#endif //vtk_m_cont__ArrayContainerControl_h +#endif //vtk_m_cont_Storage_h diff --git a/vtkm/cont/ArrayContainerControlBasic.h b/vtkm/cont/StorageBasic.h similarity index 75% rename from vtkm/cont/ArrayContainerControlBasic.h rename to vtkm/cont/StorageBasic.h index 864aabfa1..d05582f43 100644 --- a/vtkm/cont/ArrayContainerControlBasic.h +++ b/vtkm/cont/StorageBasic.h @@ -17,34 +17,35 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ -#ifndef vtk_m_cont__ArrayContainerControlBasic_h -#define vtk_m_cont__ArrayContainerControlBasic_h +#ifndef vtk_m_cont_StorageBasic_h +#define vtk_m_cont_StorageBasic_h #include -#include #include #include #include +#include + #include namespace vtkm { namespace cont { -/// A tag for the basic implementation of an ArrayContainerControl object. -struct ArrayContainerControlTagBasic { }; +/// A tag for the basic implementation of a Storage object. +struct StorageTagBasic { }; namespace internal { -/// A basic implementation of an ArrayContainerControl object. +/// A basic implementation of an Storage object. /// -/// \todo This container does \em not construct the values within the array. +/// \todo This storage does \em not construct the values within the array. /// Thus, it is important to not use this class with any type that will fail if /// not constructed. These are things like basic types (int, float, etc.) and /// the VTKm Tuple classes. In the future it would be nice to have a compile /// time check to enforce this. /// template -class ArrayContainerControl +class Storage { public: typedef ValueT ValueType; @@ -54,18 +55,18 @@ public: private: /// The original design of this class provided an allocator as a template /// parameters. That messed things up, though, because other templated - /// classes assume that the \c ArrayContainerControl has one template - /// parameter. There are other ways to allow you to specify the allocator, - /// but it is uncertain whether that would ever be useful. So, instead of - /// jumping through hoops implementing them, just fix the allocator for now. + /// classes assume that the \c Storage has one template parameter. There are + /// other ways to allow you to specify the allocator, but it is uncertain + /// whether that would ever be useful. So, instead of jumping through hoops + /// implementing them, just fix the allocator for now. /// typedef std::allocator AllocatorType; public: - ArrayContainerControl() : Array(NULL), NumberOfValues(0), AllocatedSize(0) { } + Storage() : Array(NULL), NumberOfValues(0), AllocatedSize(0) { } - ~ArrayContainerControl() + ~Storage() { this->ReleaseResources(); } @@ -152,10 +153,10 @@ public: /// /// This method returns the pointer to the array held by this array. It then /// clears the internal array pointer to NULL, thereby ensuring that the - /// ArrayContainerControl will never deallocate the array. This is - /// helpful for taking a reference for an array created internally by VTKm and - /// not having to keep a VTKm object around. Obviously the caller becomes - /// responsible for destroying the memory. + /// Storage will never deallocate the array. This is helpful for taking a + /// reference for an array created internally by VTK-m and not having to keep + /// a VTK-m object around. Obviously the caller becomes responsible for + /// destroying the memory. /// ValueType *StealArray() { @@ -168,8 +169,8 @@ public: private: // Not implemented. - ArrayContainerControl(const ArrayContainerControl &src); - void operator=(const ArrayContainerControl &src); + Storage(const Storage &src); + void operator=(const Storage &src); ValueType *Array; vtkm::Id NumberOfValues; @@ -181,4 +182,4 @@ private: } } // namespace vtkm::cont -#endif //vtk_m_cont__ArrayContainerControlBasic_h +#endif //vtk_m_cont_StorageBasic_h diff --git a/vtkm/cont/ArrayContainerControlImplicit.h b/vtkm/cont/StorageImplicit.h similarity index 64% rename from vtkm/cont/ArrayContainerControlImplicit.h rename to vtkm/cont/StorageImplicit.h index 061330f49..009f7470e 100644 --- a/vtkm/cont/ArrayContainerControlImplicit.h +++ b/vtkm/cont/StorageImplicit.h @@ -17,14 +17,15 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ -#ifndef vtk_m_cont_ArrayContainerControlImplicit -#define vtk_m_cont_ArrayContainerControlImplicit +#ifndef vtk_m_cont_StorageImplicit +#define vtk_m_cont_StorageImplicit #include -#include #include #include +#include + #include namespace vtkm { @@ -32,19 +33,16 @@ namespace cont { /// \brief An implementation for read-only implicit arrays. /// -/// It is sometimes the case that you want VTKm to operate on an array of +/// It is sometimes the case that you want VTK-m to operate on an array of /// implicit values. That is, rather than store the data in an actual array, it -/// is gerenated on the fly by a function. This is handled in VTKm by creating -/// an ArrayHandle in VTKm with an ArrayContainerControlTagImplicit type of -/// ArrayContainerControl. This tag itself is templated to specify an -/// ArrayPortal that generates the desired values. An ArrayHandle created with -/// this tag will raise an error on any operation that tries to modify it. -/// -/// \todo The ArrayHandle currently copies the array in cases where the control -/// and environment do not share memory. This is wasteful and should be fixed. +/// is gerenated on the fly by a function. This is handled in VTK-m by creating +/// an ArrayHandle in VTK-m with a StorageTagImplicit type of \c Storage. This +/// tag itself is templated to specify an ArrayPortal that generates the +/// desired values. An ArrayHandle created with this tag will raise an error on +/// any operation that tries to modify it. /// template -struct ArrayContainerControlTagImplicit +struct StorageTagImplicit { typedef ArrayPortalType PortalType; }; @@ -52,9 +50,9 @@ struct ArrayContainerControlTagImplicit namespace internal { template -class ArrayContainerControl< +class Storage< typename ArrayPortalType::ValueType, - ArrayContainerControlTagImplicit > + StorageTagImplicit > { public: typedef typename ArrayPortalType::ValueType ValueType; @@ -76,18 +74,18 @@ public: PortalConstType GetPortalConst() const { // This does not work because the ArrayHandle holds the constant - // ArrayPortal, not the container. + // ArrayPortal, not the storage. throw vtkm::cont::ErrorControlBadValue( - "Implicit container does not store array portal. " + "Implicit storage does not store array portal. " "Perhaps you did not set the ArrayPortal when " "constructing the ArrayHandle."); } vtkm::Id GetNumberOfValues() const { // This does not work because the ArrayHandle holds the constant - // ArrayPortal, not the container. + // ArrayPortal, not the Storage. throw vtkm::cont::ErrorControlBadValue( - "Implicit container does not store array portal. " + "Implicit storage does not store array portal. " "Perhaps you did not set the ArrayPortal when " "constructing the ArrayHandle."); } @@ -105,43 +103,18 @@ public: } }; -//// If you are using this specalization of ArrayContainerControl, it means the -//// type of an ArrayHandle does not match the type of the array portal for the -//// array portal in an implicit array. Currently this use is invalid, but there -//// could be a case for implementing casting where appropriate. -//template -//class ArrayContainerControl > -//{ -//public: -// // This is meant to be invalid because this class should not actually be used. -// struct PortalType -// { -// typedef void *ValueType; -// typedef void *IteratorType; -// }; -// // This is meant to be invalid because this class should not actually be used. -// struct PortalConstType -// { -// typedef void *ValueType; -// typedef void *IteratorType; -// }; -//}; - template -class ArrayTransfer< - T, ArrayContainerControlTagImplicit, DeviceAdapterTag> +class ArrayTransfer, DeviceAdapterTag> { private: - typedef ArrayContainerControlTagImplicit - ArrayContainerControlTag; - typedef vtkm::cont::internal::ArrayContainerControl - ContainerType; + typedef StorageTagImplicit StorageTag; + typedef vtkm::cont::internal::Storage StorageType; public: typedef T ValueType; - typedef typename ContainerType::PortalType PortalControl; - typedef typename ContainerType::PortalConstType PortalConstControl; + typedef typename StorageType::PortalType PortalControl; + typedef typename StorageType::PortalConstType PortalConstControl; typedef PortalControl PortalExecution; typedef PortalConstControl PortalConstExecution; @@ -159,27 +132,27 @@ public: this->PortalValid = true; } - VTKM_CONT_EXPORT void LoadDataForInput(const ContainerType &controlArray) + VTKM_CONT_EXPORT void LoadDataForInput(const StorageType &controlArray) { this->LoadDataForInput(controlArray.GetPortalConst()); } VTKM_CONT_EXPORT - void LoadDataForInPlace(ContainerType &vtkmNotUsed(controlArray)) + void LoadDataForInPlace(StorageType &vtkmNotUsed(controlArray)) { throw vtkm::cont::ErrorControlBadValue( "Implicit arrays cannot be used for output or in place."); } VTKM_CONT_EXPORT void AllocateArrayForOutput( - ContainerType &vtkmNotUsed(controlArray), + StorageType &vtkmNotUsed(controlArray), vtkm::Id vtkmNotUsed(numberOfValues)) { throw vtkm::cont::ErrorControlBadValue( "Implicit arrays cannot be used for output."); } VTKM_CONT_EXPORT void RetrieveOutputData( - ContainerType &vtkmNotUsed(controlArray)) const + StorageType &vtkmNotUsed(controlArray)) const { throw vtkm::cont::ErrorControlBadValue( "Implicit arrays cannot be used for output."); @@ -213,4 +186,4 @@ private: } } // namespace vtkm::cont -#endif //vtk_m_cont_ArrayContainerControlImplicit +#endif //vtk_m_cont_StorageImplicit diff --git a/vtkm/cont/ContainerListTag.h b/vtkm/cont/StorageListTag.h similarity index 70% rename from vtkm/cont/ContainerListTag.h rename to vtkm/cont/StorageListTag.h index 2159f8e52..f6f1d1b6c 100644 --- a/vtkm/cont/ContainerListTag.h +++ b/vtkm/cont/StorageListTag.h @@ -17,25 +17,25 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ -#ifndef vtk_m_ContainerListTag_h -#define vtk_m_ContainerListTag_h +#ifndef vtk_m_StorageListTag_h +#define vtk_m_StorageListTag_h -#ifndef VTKM_DEFAULT_CONTAINER_LIST_TAG -#define VTKM_DEFAULT_CONTAINER_LIST_TAG ::vtkm::cont::ContainerListTagBasic +#ifndef VTKM_DEFAULT_STORAGE_LIST_TAG +#define VTKM_DEFAULT_STORAGE_LIST_TAG ::vtkm::cont::StorageListTagBasic #endif #include -#include -#include +#include +#include namespace vtkm { namespace cont { -struct ContainerListTagBasic - : vtkm::ListTagBase { }; +struct StorageListTagBasic + : vtkm::ListTagBase { }; } } // namespace vtkm::cont -#endif //vtk_m_ContainerListTag_h +#endif //vtk_m_StorageListTag_h diff --git a/vtkm/cont/internal/ArrayHandleExecutionManager.h b/vtkm/cont/internal/ArrayHandleExecutionManager.h index fc1fc28bc..00b4ca0bf 100644 --- a/vtkm/cont/internal/ArrayHandleExecutionManager.h +++ b/vtkm/cont/internal/ArrayHandleExecutionManager.h @@ -20,8 +20,9 @@ #ifndef vtk_m_cont_exec_ArrayHandleExecutionManager_h #define vtk_m_cont_exec_ArrayHandleExecutionManager_h -#include #include +#include + #include namespace vtkm { @@ -31,19 +32,18 @@ namespace internal { /// The common base for ArrayHandleExecutionManager. This is the interface /// used when the type of the device is not known at run time. /// -template +template class ArrayHandleExecutionManagerBase { private: - typedef vtkm::cont::internal::ArrayContainerControl - ContainerType; + typedef vtkm::cont::internal::Storage StorageType; public: template struct ExecutionTypes { private: - typedef vtkm::cont::internal::ArrayTransfer + typedef vtkm::cont::internal::ArrayTransfer ArrayTransferType; public: typedef typename ArrayTransferType::PortalExecution Portal; @@ -56,8 +56,8 @@ public: /// An array portal that can be used in the control environment. /// - typedef typename ContainerType::PortalType PortalControl; - typedef typename ContainerType::PortalConstType PortalConstControl; + typedef typename StorageType::PortalType PortalControl; + typedef typename StorageType::PortalConstType PortalConstControl; VTKM_CONT_EXPORT virtual ~ArrayHandleExecutionManagerBase() { } @@ -81,31 +81,31 @@ public: /// arrays, then this method may save the iterators to be returned in the \c /// GetPortalConst methods. /// - virtual void LoadDataForInput(const ContainerType &controlArray) = 0; + virtual void LoadDataForInput(const StorageType &controlArray) = 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 /// via the GetPortalExection method. If control and execution share arrays, - /// then this method may save the iterators of the container to be returned + /// then this method may save the iterators of the storage to be returned /// in the \c GetPortal* methods. /// - virtual void LoadDataForInPlace(ContainerType &controlArray) = 0; + virtual void LoadDataForInPlace(StorageType &controlArray) = 0; - /// Allocates an array in the execution environment of the specified size. - /// If control and execution share arrays, then this class can allocate - /// data using the given ArrayContainerExecution and remember its iterators - /// so that it can be used directly in the execution environment. + /// Allocates an array in the execution environment of the specified size. If + /// control and execution share arrays, then this class can allocate data + /// using the given Storage and remember its iterators so that it can be used + /// directly in the execution environment. /// - virtual void AllocateArrayForOutput(ContainerType &controlArray, + virtual void AllocateArrayForOutput(StorageType &controlArray, vtkm::Id numberOfValues) = 0; - /// Allocates data in the given ArrayContainerControl and copies data held + /// Allocates data in the given Storage and copies data held /// in the execution environment (managed by this class) into the control /// array. If control and execution share arrays, this can be no operation. /// This method should only be called after AllocateArrayForOutput is /// called. /// - virtual void RetrieveOutputData(ContainerType &controlArray) const = 0; + virtual void RetrieveOutputData(StorageType &controlArray) const = 0; /// \brief Reduces the size of the array without changing its values. /// @@ -191,15 +191,15 @@ private: /// ArrayHandle to change its device at run time. /// template class ArrayHandleExecutionManager - : public ArrayHandleExecutionManagerBase + : public ArrayHandleExecutionManagerBase { - typedef ArrayHandleExecutionManagerBase Superclass; - typedef vtkm::cont::internal::ArrayTransfer + typedef ArrayHandleExecutionManagerBase Superclass; + typedef vtkm::cont::internal::ArrayTransfer ArrayTransferType; - typedef vtkm::cont::internal::ArrayContainerControl ContainerType; + typedef vtkm::cont::internal::Storage StorageType; public: typedef typename ArrayTransferType::PortalControl PortalControl; @@ -218,25 +218,25 @@ public: } VTKM_CONT_EXPORT - void LoadDataForInput(const ContainerType &controlArray) + void LoadDataForInput(const StorageType &controlArray) { this->Transfer.LoadDataForInput(controlArray); } VTKM_CONT_EXPORT - void LoadDataForInPlace(ContainerType &controlArray) + void LoadDataForInPlace(StorageType &controlArray) { this->Transfer.LoadDataForInPlace(controlArray); } VTKM_CONT_EXPORT - void AllocateArrayForOutput(ContainerType &controlArray, Id numberOfValues) + void AllocateArrayForOutput(StorageType &controlArray, Id numberOfValues) { this->Transfer.AllocateArrayForOutput(controlArray, numberOfValues); } VTKM_CONT_EXPORT - void RetrieveOutputData(ContainerType &controlArray) const + void RetrieveOutputData(StorageType &controlArray) const { this->Transfer.RetrieveOutputData(controlArray); } diff --git a/vtkm/cont/internal/ArrayManagerExecution.h b/vtkm/cont/internal/ArrayManagerExecution.h index cc21bcad2..8ec8bde65 100644 --- a/vtkm/cont/internal/ArrayManagerExecution.h +++ b/vtkm/cont/internal/ArrayManagerExecution.h @@ -41,17 +41,16 @@ namespace internal { /// behaves how you would expect. It allocates/deallocates arrays and copies /// data. However, if the control and execution environments share the same /// memory space, this class should delegate all its operations to the -/// ArrayContainerControl. The latter can probably be implemented with a +/// \c Storage. The latter can probably be implemented with a /// trivial subclass of /// vtkm::cont::internal::ArrayManagerExecutionShareWithControl. /// -template +template class ArrayManagerExecution #ifdef VTKM_DOXYGEN_ONLY { private: - typedef vtkm::cont::internal::ArrayContainerControl - ContainerType; + typedef vtkm::cont::internal::Storage StorageType; public: /// The type of value held in the array (vtkm::Scalar, vtkm::Vector3, etc.) @@ -83,31 +82,31 @@ public: /// GetPortalConst method. /// VTKM_CONT_EXPORT void LoadDataForInput( - const typename ContainerType::PortalConstType& portal); + const typename StorageType::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 /// via the GetPortal method. If control and execution share arrays, then - /// this method may save the iterators of the container to be returned in the + /// this method may save the iterators of the storage to be returned in the /// \c GetPortal* methods. /// VTKM_CONT_EXPORT void LoadDataForInPlace(PortalType portal); /// Allocates an array in the execution environment of the specified size. /// If control and execution share arrays, then this class can allocate - /// data using the given ArrayContainerExecution and remember its iterators + /// data using the given Storage object and remember its iterators /// so that it can be used directly in the execution environment. /// - VTKM_CONT_EXPORT void AllocateArrayForOutput(ContainerType &controlArray, - vtkm::Id numberOfValues); + VTKM_CONT_EXPORT void AllocateArrayForOutput(StorageType &controlArray, + vtkm::Id numberOfValues); - /// Allocates data in the given ArrayContainerControl and copies data held + /// Allocates data in the given Storage and copies data held /// in the execution environment (managed by this class) into the control /// array. If control and execution share arrays, this can be no operation. /// This method should only be called after AllocateArrayForOutput is /// called. /// - VTKM_CONT_EXPORT void RetrieveOutputData(ContainerType &controlArray) const; + VTKM_CONT_EXPORT void RetrieveOutputData(StorageType &controlArray) const; /// \brief Reduces the size of the array without changing its values. /// diff --git a/vtkm/cont/internal/ArrayManagerExecutionSerial.h b/vtkm/cont/internal/ArrayManagerExecutionSerial.h index a0d4de99b..67d8fdcda 100644 --- a/vtkm/cont/internal/ArrayManagerExecutionSerial.h +++ b/vtkm/cont/internal/ArrayManagerExecutionSerial.h @@ -28,15 +28,14 @@ namespace vtkm { namespace cont { namespace internal { -template -class ArrayManagerExecution - +template +class ArrayManagerExecution : public vtkm::cont::internal::ArrayManagerExecutionShareWithControl - + { public: typedef vtkm::cont::internal::ArrayManagerExecutionShareWithControl - Superclass; + Superclass; typedef typename Superclass::ValueType ValueType; typedef typename Superclass::PortalType PortalType; typedef typename Superclass::PortalConstType PortalConstType; diff --git a/vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h b/vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h index e098d8dd8..c34a688f6 100644 --- a/vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h +++ b/vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h @@ -23,7 +23,8 @@ #include #include -#include +#include + #include #include @@ -35,21 +36,18 @@ namespace internal { /// \c ArrayManagerExecutionShareWithControl provides an implementation for a /// \c ArrayManagerExecution class for a device adapter when the execution /// and control environments share memory. This class basically defers all its -/// calls to an \c ArrayContainerControl class and uses the array allocated -/// there. +/// calls to a \c Storage class and uses the array allocated there. /// -template +template class ArrayManagerExecutionShareWithControl { public: typedef T ValueType; - typedef vtkm::cont::internal - ::ArrayContainerControl - ContainerType; + typedef vtkm::cont::internal::Storage StorageType; typedef vtkm::cont::internal::ArrayPortalShrink< - typename ContainerType::PortalType> PortalType; + typename StorageType::PortalType> PortalType; typedef vtkm::cont::internal::ArrayPortalShrink< - typename ContainerType::PortalConstType> PortalConstType; + typename StorageType::PortalConstType> PortalConstType; VTKM_CONT_EXPORT ArrayManagerExecutionShareWithControl() : PortalValid(false), ConstPortalValid(false) { } @@ -87,8 +85,8 @@ public: /// Actually just allocates memory in the given \p controlArray. /// - VTKM_CONT_EXPORT void AllocateArrayForOutput(ContainerType &controlArray, - vtkm::Id numberOfValues) + VTKM_CONT_EXPORT void AllocateArrayForOutput(StorageType &controlArray, + vtkm::Id numberOfValues) { controlArray.Allocate(numberOfValues); @@ -103,7 +101,7 @@ public: /// this class's iterators should already be written to the given \c /// controlArray (under correct operation). /// - VTKM_CONT_EXPORT void RetrieveOutputData(ContainerType &controlArray) const + VTKM_CONT_EXPORT void RetrieveOutputData(StorageType &controlArray) const { VTKM_ASSERT_CONT(this->ConstPortalValid); VTKM_ASSERT_CONT(controlArray.GetPortalConst().GetIteratorBegin() == @@ -124,7 +122,7 @@ public: } } - /// Returns the portal previously saved from an \c ArrayContainerControl. + /// Returns the portal previously saved from a \c Storage. /// VTKM_CONT_EXPORT PortalType GetPortal() { @@ -147,9 +145,9 @@ public: private: // Not implemented. ArrayManagerExecutionShareWithControl( - ArrayManagerExecutionShareWithControl &); + ArrayManagerExecutionShareWithControl &); void operator=( - ArrayManagerExecutionShareWithControl &); + ArrayManagerExecutionShareWithControl &); PortalType Portal; bool PortalValid; diff --git a/vtkm/cont/internal/ArrayTransfer.h b/vtkm/cont/internal/ArrayTransfer.h index 9fd6d5a6c..5939fb8cd 100644 --- a/vtkm/cont/internal/ArrayTransfer.h +++ b/vtkm/cont/internal/ArrayTransfer.h @@ -20,7 +20,7 @@ #ifndef vtk_m_cont_internal_ArrayTransfer_h #define vtk_m_cont_internal_ArrayTransfer_h -#include +#include #include namespace vtkm { @@ -37,20 +37,19 @@ namespace internal { /// /// The primary motivation for having a separate class is that the /// ArrayManagerExecution is meant to be specialized for each device adapter -/// whee as the ArrayTransfer is meant to be specialized for each array -/// container (or specific combination of container and device adapter). Thus, -/// transfers for most containers will be delegated through the -/// ArrayManagerExecution, but some containers, like implicit containers, will -/// be specialized to transfer through a different path. +/// whereas the ArrayTransfer is meant to be specialized for each storage type +/// (or specific combination of storage and device adapter). Thus, transfers +/// for most storage tyeps will be delegated through the ArrayManagerExecution, +/// but some storage types, like implicit storage, will be specialized to +/// transfer through a different path. /// -template +template class ArrayTransfer { private: - typedef vtkm::cont::internal::ArrayContainerControl - ContainerType; + typedef vtkm::cont::internal::Storage StorageType; typedef vtkm::cont::internal::ArrayManagerExecution< - T,ArrayContainerControlTag,DeviceAdapterTag> ArrayManagerType; + T,StorageTag,DeviceAdapterTag> ArrayManagerType; public: /// The type of value held in the array (vtkm::Scalar, vtkm::Vector3, etc.) @@ -59,8 +58,8 @@ public: /// An array portal that can be used in the control environment. /// - typedef typename ContainerType::PortalType PortalControl; - typedef typename ContainerType::PortalConstType PortalConstControl; + typedef typename StorageType::PortalType PortalControl; + typedef typename StorageType::PortalConstType PortalConstControl; /// An array portal that can be used in the execution environment. /// @@ -93,7 +92,7 @@ public: /// arrays, then this method may save the iterators to be returned in the \c /// GetPortalConst methods. /// - VTKM_CONT_EXPORT void LoadDataForInput(const ContainerType &controlArray) + VTKM_CONT_EXPORT void LoadDataForInput(const StorageType &controlArray) { this->ArrayManager.LoadDataForInput(controlArray.GetPortalConst()); } @@ -101,32 +100,31 @@ public: /// Allocates a large enough array in the execution environment and copies /// the given data to that array. The allocated array can later be accessed /// via the GetPortalExection method. If control and execution share arrays, - /// then this method may save the iterators of the container to be returned + /// then this method may save the iterators of the storage to be returned /// in the \c GetPortal* methods. /// - VTKM_CONT_EXPORT void LoadDataForInPlace(ContainerType &controlArray) + VTKM_CONT_EXPORT void LoadDataForInPlace(StorageType &controlArray) { this->ArrayManager.LoadDataForInPlace(controlArray.GetPortal()); } - /// Allocates an array in the execution environment of the specified size. - /// If control and execution share arrays, then this class can allocate - /// data using the given ArrayContainerExecution and remember its iterators - /// so that it can be used directly in the execution environment. + /// Allocates an array in the execution environment of the specified size. If + /// control and execution share arrays, then this class can allocate data + /// using the given Storage and remember its iterators so that it can be used + /// directly in the execution environment. /// - VTKM_CONT_EXPORT void AllocateArrayForOutput(ContainerType &controlArray, - vtkm::Id numberOfValues) + VTKM_CONT_EXPORT void AllocateArrayForOutput(StorageType &controlArray, + vtkm::Id numberOfValues) { this->ArrayManager.AllocateArrayForOutput(controlArray, numberOfValues); } - /// Allocates data in the given ArrayContainerControl and copies data held - /// in the execution environment (managed by this class) into the control - /// array. If control and execution share arrays, this can be no operation. - /// This method should only be called after AllocateArrayForOutput is - /// called. + /// Allocates data in the given Storage and copies data held in the execution + /// environment (managed by this class) into the control array. If control + /// and execution share arrays, this can be no operation. This method should + /// only be called after AllocateArrayForOutput is called. /// - VTKM_CONT_EXPORT void RetrieveOutputData(ContainerType &controlArray) const + VTKM_CONT_EXPORT void RetrieveOutputData(StorageType &controlArray) const { this->ArrayManager.RetrieveOutputData(controlArray); } diff --git a/vtkm/cont/internal/CMakeLists.txt b/vtkm/cont/internal/CMakeLists.txt index 3b70c7a2c..41f67c62f 100644 --- a/vtkm/cont/internal/CMakeLists.txt +++ b/vtkm/cont/internal/CMakeLists.txt @@ -36,6 +36,7 @@ set(headers IteratorFromArrayPortal.h PointCoordinatesBase.h SimplePolymorphicContainer.h + StorageError.h ) vtkm_declare_headers(${headers}) diff --git a/vtkm/cont/internal/DeviceAdapterAlgorithm.h b/vtkm/cont/internal/DeviceAdapterAlgorithm.h index 7a3b2de3d..42930eb74 100644 --- a/vtkm/cont/internal/DeviceAdapterAlgorithm.h +++ b/vtkm/cont/internal/DeviceAdapterAlgorithm.h @@ -188,18 +188,18 @@ struct DeviceAdapterAlgorithm /// Sorts the contents of \c values so that they in ascending value. Doesn't /// guarantee stability /// - template + template VTKM_CONT_EXPORT static void Sort( - vtkm::cont::ArrayHandle &values); + vtkm::cont::ArrayHandle &values); /// \brief Unstable ascending sort of input array. /// /// Sorts the contents of \c values so that they in ascending value based /// on the custom compare functor. /// - template + template VTKM_CONT_EXPORT static void Sort( - vtkm::cont::ArrayHandle &values, + vtkm::cont::ArrayHandle &values, Compare comp); /// \brief Performs stream compaction to remove unwanted elements in the input array. Output becomes the index values of input that are valid. @@ -246,9 +246,9 @@ struct DeviceAdapterAlgorithm /// duplicate values that aren't adjacent. Note the values array size might /// be modified by this operation. /// - template + template VTKM_CONT_EXPORT static void Unique( - vtkm::cont::ArrayHandle& values); + vtkm::cont::ArrayHandle& values); /// \brief Reduce an array to only the unique values it contains /// @@ -260,9 +260,9 @@ struct DeviceAdapterAlgorithm /// Uses the custom binary predicate Comparison to determine if something /// is unique. The predicate must return true if the two items are the same. /// - template + template VTKM_CONT_EXPORT static void Unique( - vtkm::cont::ArrayHandle& values, + vtkm::cont::ArrayHandle& values, Compare comp); /// \brief Output is the last index in input for each item in values that wouldn't alter the ordering of input @@ -353,7 +353,7 @@ public: vtkm::Scalar elapsedTime; elapsedTime = vtkm::Scalar(currentTime.Seconds - this->StartTime.Seconds); - elapsedTime += + elapsedTime += (vtkm::Scalar(currentTime.Microseconds - this->StartTime.Microseconds) /vtkm::Scalar(1000000)); diff --git a/vtkm/cont/internal/DeviceAdapterAlgorithmGeneral.h b/vtkm/cont/internal/DeviceAdapterAlgorithmGeneral.h index 21d66a54e..407b2ff6e 100644 --- a/vtkm/cont/internal/DeviceAdapterAlgorithmGeneral.h +++ b/vtkm/cont/internal/DeviceAdapterAlgorithmGeneral.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -111,7 +111,7 @@ private: vtkm::Id index) { typedef vtkm::cont::ArrayHandle InputArrayType; - typedef vtkm::cont::ArrayHandle + typedef vtkm::cont::ArrayHandle OutputArrayType; OutputArrayType output; @@ -353,7 +353,7 @@ public: const vtkm::cont::ArrayHandle &input, vtkm::cont::ArrayHandle& output) { - typedef vtkm::cont::ArrayHandle + typedef vtkm::cont::ArrayHandle TempArrayType; typedef vtkm::cont::ArrayHandle OutputArrayType; @@ -553,12 +553,12 @@ private: }; public: - template + template VTKM_CONT_EXPORT static void Sort( - vtkm::cont::ArrayHandle &values, + vtkm::cont::ArrayHandle &values, CompareType compare) { - typedef typename vtkm::cont::ArrayHandle ArrayType; + typedef typename vtkm::cont::ArrayHandle ArrayType; typedef typename ArrayType::template ExecutionTypes ::Portal PortalType; @@ -588,9 +588,9 @@ public: } } - template + template VTKM_CONT_EXPORT static void Sort( - vtkm::cont::ArrayHandle &values) + vtkm::cont::ArrayHandle &values) { DerivedAlgorithm::Sort(values, DefaultCompareFunctor()); } @@ -677,7 +677,7 @@ public: vtkm::Id arrayLength = stencil.GetNumberOfValues(); typedef vtkm::cont::ArrayHandle< - vtkm::Id, vtkm::cont::ArrayContainerControlTagBasic> IndexArrayType; + vtkm::Id, vtkm::cont::StorageTagBasic> IndexArrayType; IndexArrayType indices; typedef typename vtkm::cont::ArrayHandle @@ -809,22 +809,22 @@ private: }; public: - template + template VTKM_CONT_EXPORT static void Unique( - vtkm::cont::ArrayHandle &values) + vtkm::cont::ArrayHandle &values) { - vtkm::cont::ArrayHandle + vtkm::cont::ArrayHandle stencilArray; vtkm::Id inputSize = values.GetNumberOfValues(); ClassifyUniqueKernel< - typename vtkm::cont::ArrayHandle::template ExecutionTypes::PortalConst, - typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal> + typename vtkm::cont::ArrayHandle::template ExecutionTypes::PortalConst, + typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal> classifyKernel(values.PrepareForInput(DeviceAdapterTag()), stencilArray.PrepareForOutput(inputSize, DeviceAdapterTag())); DerivedAlgorithm::Schedule(classifyKernel, inputSize); - vtkm::cont::ArrayHandle + vtkm::cont::ArrayHandle outputArray; DerivedAlgorithm::StreamCompact(values, stencilArray, outputArray); @@ -832,25 +832,25 @@ public: DerivedAlgorithm::Copy(outputArray, values); } - template + template VTKM_CONT_EXPORT static void Unique( - vtkm::cont::ArrayHandle &values, + vtkm::cont::ArrayHandle &values, Compare comp) { - vtkm::cont::ArrayHandle + vtkm::cont::ArrayHandle stencilArray; vtkm::Id inputSize = values.GetNumberOfValues(); ClassifyUniqueComparisonKernel< - typename vtkm::cont::ArrayHandle::template ExecutionTypes::PortalConst, - typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal, + typename vtkm::cont::ArrayHandle::template ExecutionTypes::PortalConst, + typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal, Compare> classifyKernel(values.PrepareForInput(DeviceAdapterTag()), stencilArray.PrepareForOutput(inputSize, DeviceAdapterTag()), comp); DerivedAlgorithm::Schedule(classifyKernel, inputSize); - vtkm::cont::ArrayHandle + vtkm::cont::ArrayHandle outputArray; DerivedAlgorithm::StreamCompact(values, stencilArray, outputArray); diff --git a/vtkm/cont/internal/DeviceAdapterAlgorithmSerial.h b/vtkm/cont/internal/DeviceAdapterAlgorithmSerial.h index a7b227229..c7546309c 100644 --- a/vtkm/cont/internal/DeviceAdapterAlgorithmSerial.h +++ b/vtkm/cont/internal/DeviceAdapterAlgorithmSerial.h @@ -156,21 +156,21 @@ public: rangeMax[0] * rangeMax[1] * rangeMax[2] ); } - template - VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle& values) + template + VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle& values) { - typedef typename vtkm::cont::ArrayHandle + typedef typename vtkm::cont::ArrayHandle ::template ExecutionTypes::Portal PortalType; PortalType arrayPortal = values.PrepareForInPlace(Device()); std::sort(arrayPortal.GetIteratorBegin(), arrayPortal.GetIteratorEnd()); } - template - VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle& values, + template + VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle& values, Compare comp) { - typedef typename vtkm::cont::ArrayHandle + typedef typename vtkm::cont::ArrayHandle ::template ExecutionTypes::Portal PortalType; PortalType arrayPortal = values.PrepareForInPlace(Device()); diff --git a/vtkm/cont/internal/ArrayContainerControlError.h b/vtkm/cont/internal/StorageError.h similarity index 67% rename from vtkm/cont/internal/ArrayContainerControlError.h rename to vtkm/cont/internal/StorageError.h index ed1e6071a..cec839c05 100644 --- a/vtkm/cont/internal/ArrayContainerControlError.h +++ b/vtkm/cont/internal/StorageError.h @@ -17,20 +17,20 @@ // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ -#ifndef vtkm_cont_internal_ArrayContainerControlError_h -#define vtkm_cont_internal_ArrayContainerControlError_h +#ifndef vtkm_cont_internal_StorageError_h +#define vtkm_cont_internal_StorageError_h namespace vtkm { namespace cont { namespace internal { -/// This is an invalid ArrayContainerControl. The point of this class is to -/// include the header file to make this invalid class the default -/// ArrayContainerControl. From that point, you have to specify an appropriate -/// ArrayContainerControl or else get a compile error. +/// This is an invalid Storage. The point of this class is to include the +/// header file to make this invalid class the default Storage. From that +/// point, you have to specify an appropriate Storage or else get a compile +/// error. /// -struct ArrayContainerControlTagError +struct StorageTagError { // Not implemented. }; @@ -39,4 +39,4 @@ struct ArrayContainerControlTagError } } // namespace vtkm::cont::internal -#endif //vtkm_cont_internal_ArrayContainerControlError_h +#endif //vtkm_cont_internal_StorageError_h diff --git a/vtkm/cont/internal/testing/UnitTestArrayManagerExecutionShareWithControl.cxx b/vtkm/cont/internal/testing/UnitTestArrayManagerExecutionShareWithControl.cxx index 51ed75b0c..3afe4c807 100644 --- a/vtkm/cont/internal/testing/UnitTestArrayManagerExecutionShareWithControl.cxx +++ b/vtkm/cont/internal/testing/UnitTestArrayManagerExecutionShareWithControl.cxx @@ -20,7 +20,8 @@ #include -#include +#include + #include #include @@ -33,14 +34,14 @@ const vtkm::Id ARRAY_SIZE = 10; template struct TemplatedTests { - typedef vtkm::cont::internal::ArrayManagerExecutionShareWithControl - + typedef vtkm::cont::internal::ArrayManagerExecutionShareWithControl< + T, vtkm::cont::StorageTagBasic> ArrayManagerType; typedef typename ArrayManagerType::ValueType ValueType; - typedef vtkm::cont::internal::ArrayContainerControl< - T, vtkm::cont::ArrayContainerControlTagBasic> ArrayContainerType; + typedef vtkm::cont::internal::Storage + StorageType; - void SetContainer(ArrayContainerType &array, const ValueType& value) + void SetStorage(StorageType &array, const ValueType& value) { std::fill(array.GetPortal().GetIteratorBegin(), array.GetPortal().GetIteratorEnd(), @@ -57,7 +58,7 @@ struct TemplatedTests return true; } - bool CheckContainer(ArrayContainerType &array, const ValueType& value) + bool CheckStorage(StorageType &array, const ValueType& value) { return CheckArray(array.GetPortalConst().GetIteratorBegin(), array.GetPortalConst().GetIteratorEnd(), @@ -75,9 +76,9 @@ struct TemplatedTests { const ValueType INPUT_VALUE(4145); - ArrayContainerType controlArray; + StorageType controlArray; controlArray.Allocate(ARRAY_SIZE); - SetContainer(controlArray, INPUT_VALUE); + SetStorage(controlArray, INPUT_VALUE); ArrayManagerType executionArray; executionArray.LoadDataForInput(controlArray.GetPortalConst()); @@ -98,9 +99,9 @@ struct TemplatedTests { const ValueType INPUT_VALUE(2350); - ArrayContainerType controlArray; + StorageType controlArray; controlArray.Allocate(ARRAY_SIZE); - SetContainer(controlArray, INPUT_VALUE); + SetStorage(controlArray, INPUT_VALUE); ArrayManagerType executionArray; executionArray.LoadDataForInPlace(controlArray.GetPortal()); @@ -125,7 +126,7 @@ struct TemplatedTests { const ValueType OUTPUT_VALUE(6712); - ArrayContainerType controlArray; + StorageType controlArray; ArrayManagerType executionArray; executionArray.AllocateArrayForOutput(controlArray, ARRAY_SIZE); @@ -139,8 +140,8 @@ struct TemplatedTests executionArray.RetrieveOutputData(controlArray); - VTKM_TEST_ASSERT(CheckContainer(controlArray, OUTPUT_VALUE), - "Did not get the right value in the control container."); + VTKM_TEST_ASSERT(CheckStorage(controlArray, OUTPUT_VALUE), + "Did not get the right value in the storage."); } void operator()() diff --git a/vtkm/cont/testing/CMakeLists.txt b/vtkm/cont/testing/CMakeLists.txt index 2194cd647..8bfa3f4e8 100644 --- a/vtkm/cont/testing/CMakeLists.txt +++ b/vtkm/cont/testing/CMakeLists.txt @@ -26,13 +26,10 @@ set(headers vtkm_declare_headers(${headers}) set(unit_tests - UnitTestArrayContainerControlBasic.cxx - UnitTestArrayContainerControlImplicit.cxx UnitTestArrayHandle.cxx UnitTestArrayHandleCompositeVector.cxx UnitTestArrayHandleCounting.cxx UnitTestArrayHandleUniformPointCoordinates.cxx - UnitTestContainerListTag.cxx UnitTestContTesting.cxx UnitTestDeviceAdapterAlgorithmDependency.cxx UnitTestDeviceAdapterAlgorithmGeneral.cxx @@ -40,6 +37,9 @@ set(unit_tests UnitTestDynamicArrayHandle.cxx UnitTestDynamicPointCoordinates.cxx UnitTestPointCoordinates.cxx + UnitTestStorageBasic.cxx + UnitTestStorageImplicit.cxx + UnitTestStorageListTag.cxx UnitTestTimer.cxx ) diff --git a/vtkm/cont/testing/TestingDeviceAdapter.h b/vtkm/cont/testing/TestingDeviceAdapter.h index 4d687aa19..d983b41c6 100644 --- a/vtkm/cont/testing/TestingDeviceAdapter.h +++ b/vtkm/cont/testing/TestingDeviceAdapter.h @@ -20,10 +20,10 @@ #ifndef vtk_m_cont_testing_TestingDeviceAdapter_h #define vtk_m_cont_testing_TestingDeviceAdapter_h -#include #include #include #include +#include #include #include @@ -114,27 +114,26 @@ template struct TestingDeviceAdapter { private: - typedef vtkm::cont::ArrayContainerControlTagBasic ArrayContainerControlTag; + typedef vtkm::cont::StorageTagBasic StorageTag; - typedef vtkm::cont::ArrayHandle + typedef vtkm::cont::ArrayHandle IdArrayHandle; - typedef vtkm::cont::ArrayHandle + typedef vtkm::cont::ArrayHandle ScalarArrayHandle; typedef vtkm::cont::internal::ArrayManagerExecution< - vtkm::Id, ArrayContainerControlTag, DeviceAdapterTag> + vtkm::Id, StorageTag, DeviceAdapterTag> IdArrayManagerExecution; - typedef vtkm::cont::internal::ArrayContainerControl IdContainer; + typedef vtkm::cont::internal::Storage IdStorage; typedef typename IdArrayHandle::template ExecutionTypes ::Portal IdPortalType; typedef typename IdArrayHandle::template ExecutionTypes ::PortalConst IdPortalConstType; - typedef vtkm::cont::ArrayHandle + typedef vtkm::cont::ArrayHandle Vector3ArrayHandle; typedef vtkm::cont::DeviceAdapterAlgorithm @@ -315,21 +314,21 @@ private: template static VTKM_CONT_EXPORT - vtkm::cont::ArrayHandle + vtkm::cont::ArrayHandle MakeArrayHandle(const T *array, vtkm::Id length) { return vtkm::cont::make_ArrayHandle(array, length, - ArrayContainerControlTagBasic()); + StorageTagBasic()); } template static VTKM_CONT_EXPORT - vtkm::cont::ArrayHandle + vtkm::cont::ArrayHandle MakeArrayHandle(const std::vector& array) { return vtkm::cont::make_ArrayHandle(array, - ArrayContainerControlTagBasic()); + StorageTagBasic()); } static VTKM_CONT_EXPORT void TestDeviceAdapterTag() @@ -357,7 +356,7 @@ private: std::cout << "Testing ArrayManagerExecution" << std::endl; typedef vtkm::cont::internal::ArrayManagerExecution< - vtkm::Scalar,ArrayContainerControlTagBasic,DeviceAdapterTag> + vtkm::Scalar,StorageTagBasic,DeviceAdapterTag> ArrayManagerExecution; // Create original input array. @@ -401,10 +400,10 @@ private: { std::cout << "Do array allocation that should fail." << std::endl; vtkm::cont::internal::ArrayManagerExecution< - vtkm::Vector4,ArrayContainerControlTagBasic,DeviceAdapterTag> + vtkm::Vector4,StorageTagBasic,DeviceAdapterTag> bigManager; - vtkm::cont::internal::ArrayContainerControl< - vtkm::Vector4, ArrayContainerControlTagBasic> supportArray; + vtkm::cont::internal::Storage< + vtkm::Vector4, StorageTagBasic> supportArray; const vtkm::Id bigSize = 0x7FFFFFFFFFFFFFFFLL; bigManager.AllocateArrayForOutput(supportArray, bigSize); // It does not seem reasonable to get here. The previous call should fail. @@ -453,9 +452,9 @@ private: { std::cout << "Allocating execution array" << std::endl; - IdContainer container; + IdStorage storage; IdArrayManagerExecution manager; - manager.AllocateArrayForOutput(container, 1); + manager.AllocateArrayForOutput(storage, 1); std::cout << "Running clear." << std::endl; Algorithm::Schedule(ClearArrayKernel(manager.GetPortal()), 1); @@ -464,11 +463,11 @@ private: Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), 1); std::cout << "Checking results." << std::endl; - manager.RetrieveOutputData(container); + manager.RetrieveOutputData(storage); for (vtkm::Id index = 0; index < 1; index++) { - vtkm::Id value = container.GetPortalConst().Get(index); + vtkm::Id value = storage.GetPortalConst().Get(index); VTKM_TEST_ASSERT(value == index + OFFSET, "Got bad value for single value scheduled kernel."); } @@ -479,9 +478,9 @@ private: { std::cout << "Allocating execution array" << std::endl; - IdContainer container; + IdStorage storage; IdArrayManagerExecution manager; - manager.AllocateArrayForOutput(container, ARRAY_SIZE); + manager.AllocateArrayForOutput(storage, ARRAY_SIZE); std::cout << "Running clear." << std::endl; Algorithm::Schedule(ClearArrayKernel(manager.GetPortal()), ARRAY_SIZE); @@ -490,11 +489,11 @@ private: Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), ARRAY_SIZE); std::cout << "Checking results." << std::endl; - manager.RetrieveOutputData(container); + manager.RetrieveOutputData(storage); for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) { - vtkm::Id value = container.GetPortalConst().Get(index); + vtkm::Id value = storage.GetPortalConst().Get(index); VTKM_TEST_ASSERT(value == index + OFFSET, "Got bad value for scheduled kernels."); } @@ -506,10 +505,10 @@ private: { std::cout << "Allocating execution array" << std::endl; - IdContainer container; + IdStorage storage; IdArrayManagerExecution manager; vtkm::Id DIM_SIZE = vtkm::Id(std::pow(ARRAY_SIZE, 1/3.0f)); - manager.AllocateArrayForOutput(container, + manager.AllocateArrayForOutput(storage, DIM_SIZE * DIM_SIZE * DIM_SIZE); vtkm::Id3 maxRange(DIM_SIZE); @@ -520,12 +519,12 @@ private: Algorithm::Schedule(AddArrayKernel(manager.GetPortal()), maxRange); std::cout << "Checking results." << std::endl; - manager.RetrieveOutputData(container); + manager.RetrieveOutputData(storage); const vtkm::Id maxId = DIM_SIZE * DIM_SIZE * DIM_SIZE; for (vtkm::Id index = 0; index < maxId; index++) { - vtkm::Id value = container.GetPortalConst().Get(index); + vtkm::Id value = storage.GetPortalConst().Get(index); VTKM_TEST_ASSERT(value == index + OFFSET, "Got bad value for scheduled vtkm::Id3 kernels."); } @@ -1111,7 +1110,7 @@ private: // //use a scoped pointer that constructs and fills a grid of the // //right type - // vtkm::cont::testing::TestGrid + // vtkm::cont::testing::TestGrid // grid(DIM); // vtkm::Vector3 trueGradient = vtkm::make_Vector3(1.0, 1.0, 1.0); @@ -1157,7 +1156,7 @@ private: // std::cout << "-------------------------------------------" << std::endl; // std::cout << "Testing map field worklet error" << std::endl; - // vtkm::cont::testing::TestGrid + // vtkm::cont::testing::TestGrid // grid(DIM); // std::cout << "Running field map worklet that errors" << std::endl; @@ -1201,7 +1200,7 @@ private: // template // static VTKM_CONT_EXPORT void TestWorkletMapCellImpl() // { - // vtkm::cont::testing::TestGrid + // vtkm::cont::testing::TestGrid // grid(DIM); // vtkm::Vector3 trueGradient = vtkm::make_Vector3(1.0, 1.0, 1.0); @@ -1247,7 +1246,7 @@ private: // std::cout << "-------------------------------------------" << std::endl; // std::cout << "Testing map cell worklet error" << std::endl; - // vtkm::cont::testing::TestGrid + // vtkm::cont::testing::TestGrid // grid(DIM); // std::cout << "Running cell map worklet that errors" << std::endl; @@ -1306,7 +1305,7 @@ private: // std::cout << "Doing Worklet tests with all grid type" << std::endl; // vtkm::cont::testing::GridTesting::TryAllGridTypes( - // TestWorklets(), ArrayContainerControlTagBasic()); + // TestWorklets(), StorageTagBasic()); } }; diff --git a/vtkm/cont/testing/UnitTestArrayHandle.cxx b/vtkm/cont/testing/UnitTestArrayHandle.cxx index b8a36977d..c2ed447c3 100644 --- a/vtkm/cont/testing/UnitTestArrayHandle.cxx +++ b/vtkm/cont/testing/UnitTestArrayHandle.cxx @@ -20,7 +20,7 @@ //This sets up the ArrayHandle semantics to allocate pointers and share memory //between control and execution. -#define VTKM_ARRAY_CONTAINER_CONTROL VTKM_ARRAY_CONTAINER_CONTROL_BASIC +#define VTKM_STORAGE VTKM_STORAGE_BASIC #define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL #include diff --git a/vtkm/cont/testing/UnitTestArrayHandleCompositeVector.cxx b/vtkm/cont/testing/UnitTestArrayHandleCompositeVector.cxx index 4d2954b40..88a95899c 100644 --- a/vtkm/cont/testing/UnitTestArrayHandleCompositeVector.cxx +++ b/vtkm/cont/testing/UnitTestArrayHandleCompositeVector.cxx @@ -18,17 +18,17 @@ // this software. //============================================================================ -// Make sure ArrayHandleCompositeVector does not rely on default container or +// Make sure ArrayHandleCompositeVector does not rely on default storage or // device adapter. -#define VTKM_ARRAY_CONTAINER_CONTROL VTKM_ARRAY_CONTAINER_CONTROL_ERROR +#define VTKM_STORAGE VTKM_STORAGE_ERROR #define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_ERROR #include #include -#include #include +#include #include @@ -38,7 +38,7 @@ namespace { const vtkm::Id ARRAY_SIZE = 10; -typedef vtkm::cont::ArrayContainerControlTagBasic Container; +typedef vtkm::cont::StorageTagBasic StorageTag; vtkm::Scalar TestValue(vtkm::Id index, int inComponentIndex, int inArrayId) { @@ -46,7 +46,7 @@ vtkm::Scalar TestValue(vtkm::Id index, int inComponentIndex, int inArrayId) } template -vtkm::cont::ArrayHandle +vtkm::cont::ArrayHandle MakeInputArray(int arrayId) { typedef vtkm::VectorTraits VTraits; @@ -66,9 +66,9 @@ MakeInputArray(int arrayId) } // Make an array handle that points to this buffer. - typedef vtkm::cont::ArrayHandle ArrayHandleType; + typedef vtkm::cont::ArrayHandle ArrayHandleType; ArrayHandleType bufferHandle = - vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE, Container()); + vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE, StorageTag()); // When this function returns, the array is going to go out of scope, which // will invalidate the array handle we just created. So copy to a new buffer @@ -87,7 +87,7 @@ void CheckArray(const vtkm::cont::ArrayHandle &outArray, { // ArrayHandleCompositeVector currently does not implement the ability to // get to values on the control side, so copy to an array that is accessible. - typedef vtkm::cont::ArrayHandle ArrayHandleType; + typedef vtkm::cont::ArrayHandle ArrayHandleType; ArrayHandleType arrayCopy; vtkm::cont::DeviceAdapterAlgorithm::Copy( outArray, arrayCopy); @@ -120,7 +120,7 @@ void TryScalarArray() << inComponents << " components." << std::endl; typedef vtkm::Tuple InValueType; - typedef vtkm::cont::ArrayHandle InArrayType; + typedef vtkm::cont::ArrayHandle InArrayType; int inArrayId = 0; InArrayType inArray = MakeInputArray(inArrayId); @@ -137,10 +137,10 @@ void TryScalarArray() } template -void TryVector4(vtkm::cont::ArrayHandle array1, - vtkm::cont::ArrayHandle array2, - vtkm::cont::ArrayHandle array3, - vtkm::cont::ArrayHandle array4) +void TryVector4(vtkm::cont::ArrayHandle array1, + vtkm::cont::ArrayHandle array2, + vtkm::cont::ArrayHandle array3, + vtkm::cont::ArrayHandle array4) { int arrayIds[4] = {0, 1, 2, 3}; int inComponents[4]; @@ -176,9 +176,9 @@ void TryVector4(vtkm::cont::ArrayHandle array1, } template -void TryVector3(vtkm::cont::ArrayHandle array1, - vtkm::cont::ArrayHandle array2, - vtkm::cont::ArrayHandle array3) +void TryVector3(vtkm::cont::ArrayHandle array1, + vtkm::cont::ArrayHandle array2, + vtkm::cont::ArrayHandle array3) { int arrayIds[3] = {0, 1, 2}; int inComponents[3]; @@ -213,8 +213,8 @@ void TryVector3(vtkm::cont::ArrayHandle array1, } template -void TryVector2(vtkm::cont::ArrayHandle array1, - vtkm::cont::ArrayHandle array2) +void TryVector2(vtkm::cont::ArrayHandle array1, + vtkm::cont::ArrayHandle array2) { int arrayIds[2] = {0, 1}; int inComponents[2]; @@ -243,7 +243,7 @@ void TryVector2(vtkm::cont::ArrayHandle array1, } template -void TryVector1(vtkm::cont::ArrayHandle array1) +void TryVector1(vtkm::cont::ArrayHandle array1) { int arrayIds[1] = {0}; int inComponents[1]; @@ -278,7 +278,7 @@ void TestBadArrayLengths() { std::cout << "Checking behavior when size of input arrays do not agree." << std::endl; - typedef vtkm::cont::ArrayHandle InArrayType; + typedef vtkm::cont::ArrayHandle InArrayType; InArrayType longInArray = MakeInputArray(0); InArrayType shortInArray = MakeInputArray(1); shortInArray.Shrink(ARRAY_SIZE/2); diff --git a/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx b/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx index bd8895efb..db2267ea7 100644 --- a/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx +++ b/vtkm/cont/testing/UnitTestDeviceAdapterAlgorithmGeneral.cxx @@ -77,17 +77,15 @@ public: namespace internal { -template +template class ArrayManagerExecution - + : public vtkm::cont::internal::ArrayManagerExecution - + { public: typedef vtkm::cont::internal::ArrayManagerExecution - + Superclass; typedef typename Superclass::ValueType ValueType; typedef typename Superclass::PortalType PortalType; diff --git a/vtkm/cont/testing/UnitTestDynamicArrayHandle.cxx b/vtkm/cont/testing/UnitTestDynamicArrayHandle.cxx index 54e82235d..122289d89 100644 --- a/vtkm/cont/testing/UnitTestDynamicArrayHandle.cxx +++ b/vtkm/cont/testing/UnitTestDynamicArrayHandle.cxx @@ -21,7 +21,8 @@ #include -#include +#include + #include #include @@ -85,35 +86,35 @@ struct UnusualPortal }; template -class ArrayHandleWithUnusualContainer - : public vtkm::cont::ArrayHandle > > +class ArrayHandleWithUnusualStorage + : public vtkm::cont::ArrayHandle > > { - typedef vtkm::cont::ArrayHandle > > + typedef vtkm::cont::ArrayHandle > > Superclass; public: VTKM_CONT_EXPORT - ArrayHandleWithUnusualContainer() + ArrayHandleWithUnusualStorage() : Superclass(typename Superclass::PortalConstControl()) { } }; -struct ContainerListTagUnusual : +struct StorageListTagUnusual : vtkm::ListTagBase2< - ArrayHandleWithUnusualContainer::ArrayContainerControlTag, - ArrayHandleWithUnusualContainer::ArrayContainerControlTag> + ArrayHandleWithUnusualStorage::StorageTag, + ArrayHandleWithUnusualStorage::StorageTag> { }; bool CheckCalled; struct CheckFunctor { - template - void operator()(vtkm::cont::ArrayHandle array) const { + template + void operator()(vtkm::cont::ArrayHandle array) const { CheckCalled = true; VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Unexpected array size."); - typename vtkm::cont::ArrayHandle::PortalConstControl portal = + typename vtkm::cont::ArrayHandle::PortalConstControl portal = array.GetPortalConstControl(); for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) { @@ -187,58 +188,58 @@ void TryUnusualType() std::cout << " Found type when type list was reset." << std:: endl; } -void TryUnusualContainer() +void TryUnusualStorage() { vtkm::cont::DynamicArrayHandle array = - ArrayHandleWithUnusualContainer(); + ArrayHandleWithUnusualStorage(); try { array.CastAndCall(CheckFunctor()); - VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized container."); + VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage."); } catch (vtkm::cont::ErrorControlBadValue) { - std::cout << " Caught exception for unrecognized container." << std::endl; + std::cout << " Caught exception for unrecognized storage." << std::endl; } CheckCalled = false; - array.ResetContainerList(ContainerListTagUnusual()).CastAndCall(CheckFunctor()); + array.ResetStorageList(StorageListTagUnusual()).CastAndCall(CheckFunctor()); VTKM_TEST_ASSERT(CheckCalled, "The functor was never called (and apparently a bad value exception not thrown)."); - std::cout << " Found instance when container list was reset." << std:: endl; + std::cout << " Found instance when storage list was reset." << std:: endl; } -void TryUnusualTypeAndContainer() +void TryUnusualTypeAndStorage() { vtkm::cont::DynamicArrayHandle array = - ArrayHandleWithUnusualContainer(); + ArrayHandleWithUnusualStorage(); try { array.CastAndCall(CheckFunctor()); VTKM_TEST_FAIL( - "CastAndCall failed to error for unrecognized type/container."); + "CastAndCall failed to error for unrecognized type/storage."); } catch (vtkm::cont::ErrorControlBadValue) { - std::cout << " Caught exception for unrecognized type/container." + std::cout << " Caught exception for unrecognized type/storage." << std::endl; } try { array.ResetTypeList(TypeListTagString()).CastAndCall(CheckFunctor()); - VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized container."); + VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage."); } catch (vtkm::cont::ErrorControlBadValue) { - std::cout << " Caught exception for unrecognized container." << std::endl; + std::cout << " Caught exception for unrecognized storage." << std::endl; } try { - array.ResetContainerList(ContainerListTagUnusual()). + array.ResetStorageList(StorageListTagUnusual()). CastAndCall(CheckFunctor()); VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized type."); } @@ -250,20 +251,20 @@ void TryUnusualTypeAndContainer() CheckCalled = false; array .ResetTypeList(TypeListTagString()) - .ResetContainerList(ContainerListTagUnusual()) + .ResetStorageList(StorageListTagUnusual()) .CastAndCall(CheckFunctor()); VTKM_TEST_ASSERT(CheckCalled, "The functor was never called (and apparently a bad value exception not thrown)."); - std::cout << " Found instance when type and container lists were reset." << std:: endl; + std::cout << " Found instance when type and storage lists were reset." << std:: endl; CheckCalled = false; array - .ResetContainerList(ContainerListTagUnusual()) + .ResetStorageList(StorageListTagUnusual()) .ResetTypeList(TypeListTagString()) .CastAndCall(CheckFunctor()); VTKM_TEST_ASSERT(CheckCalled, "The functor was never called (and apparently a bad value exception not thrown)."); - std::cout << " Found instance when container and type lists were reset." << std:: endl; + std::cout << " Found instance when storage and type lists were reset." << std:: endl; } void TestDynamicArrayHandle() @@ -279,11 +280,11 @@ void TestDynamicArrayHandle() std::cout << "Try unusual type." << std::endl; TryUnusualType(); - std::cout << "Try unusual container." << std::endl; - TryUnusualContainer(); + std::cout << "Try unusual storage." << std::endl; + TryUnusualStorage(); - std::cout << "Try unusual type in unusual container." << std::endl; - TryUnusualTypeAndContainer(); + std::cout << "Try unusual type in unusual storage." << std::endl; + TryUnusualTypeAndStorage(); } } // anonymous namespace diff --git a/vtkm/cont/testing/UnitTestDynamicPointCoordinates.cxx b/vtkm/cont/testing/UnitTestDynamicPointCoordinates.cxx index 4ed6eaedc..095afdd57 100644 --- a/vtkm/cont/testing/UnitTestDynamicPointCoordinates.cxx +++ b/vtkm/cont/testing/UnitTestDynamicPointCoordinates.cxx @@ -20,8 +20,8 @@ #include -#include -#include +#include +#include #include @@ -42,7 +42,7 @@ vtkm::Vector3 TestValue(vtkm::Id index) { vtkm::Id3 index3d = vtkm::ExtentPointFlatIndexToTopologyIndex(index, EXTENT); return vtkm::Vector3(vtkm::Scalar(index3d[0]), - vtkm::Scalar(index3d[1]), + vtkm::Scalar(index3d[1]), vtkm::Scalar(index3d[2])); } @@ -54,13 +54,13 @@ struct CheckArray g_CheckArrayInvocations = 0; } - template + template void operator()( - const vtkm::cont::ArrayHandle &array) const + const vtkm::cont::ArrayHandle &array) const { std::cout << " In CastAndCall functor" << std::endl; g_CheckArrayInvocations++; - typename vtkm::cont::ArrayHandle::PortalConstControl portal = + typename vtkm::cont::ArrayHandle::PortalConstControl portal = array.GetPortalConstControl(); VTKM_TEST_ASSERT(portal.GetNumberOfValues() == ARRAY_SIZE, @@ -100,27 +100,27 @@ struct UnusualPortal } }; -class ArrayHandleWithUnusualContainer - : public vtkm::cont::ArrayHandle > +class ArrayHandleWithUnusualStorage + : public vtkm::cont::ArrayHandle > { - typedef vtkm::cont::ArrayHandle > + typedef vtkm::cont::ArrayHandle > Superclass; public: VTKM_CONT_EXPORT - ArrayHandleWithUnusualContainer() + ArrayHandleWithUnusualStorage() : Superclass(Superclass::PortalConstControl()) { } }; -struct ContainerListTagUnusual : - vtkm::ListTagBase +struct StorageListTagUnusual : + vtkm::ListTagBase { }; struct PointCoordinatesUnusual : vtkm::cont::internal::PointCoordinatesBase { - template - void CastAndCall(const Functor &f, TypeList, ContainerList) const + template + void CastAndCall(const Functor &f, TypeList, StorageList) const { - f(ArrayHandleWithUnusualContainer()); + f(ArrayHandleWithUnusualStorage()); } }; @@ -129,7 +129,7 @@ struct PointCoordinatesListUnusual void TryDefaultArray() { - std::cout << "Trying a basic point coordinates array with a default container." + std::cout << "Trying a basic point coordinates array with a default storage." << std::endl; std::vector buffer(ARRAY_SIZE); for (vtkm::Id index = 0; index < ARRAY_SIZE; index++) @@ -147,30 +147,30 @@ void TryDefaultArray() "CastAndCall functor not called expected number of times."); } -void TryUnusualContainer() +void TryUnusualStorage() { - std::cout << "Trying a basic point coordinates array with an unusual container." + std::cout << "Trying a basic point coordinates array with an unusual storage." << std::endl; vtkm::cont::DynamicPointCoordinates pointCoordinates = vtkm::cont::DynamicPointCoordinates( - vtkm::cont::PointCoordinatesArray(ArrayHandleWithUnusualContainer())); + vtkm::cont::PointCoordinatesArray(ArrayHandleWithUnusualStorage())); std::cout << " Make sure we get an exception when we can't find the type." << std::endl; try { pointCoordinates.CastAndCall(CheckArray()); - VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized container."); + VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage."); } catch (vtkm::cont::ErrorControlBadValue error) { - std::cout << " Caught expected exception for unrecognized container: " + std::cout << " Caught expected exception for unrecognized storage: " << std::endl << " " << error.GetMessage() << std::endl; } - std::cout << " Recast containers and try again." << std::endl; - pointCoordinates.ResetContainerList(ContainerListTagUnusual()) + std::cout << " Recast storage and try again." << std::endl; + pointCoordinates.ResetStorageList(StorageListTagUnusual()) .CastAndCall(CheckArray()); VTKM_TEST_ASSERT(g_CheckArrayInvocations == 1, "CastAndCall functor not called expected number of times."); @@ -202,7 +202,7 @@ void TryUnusualPointCoordinates() try { pointCoordinates.CastAndCall(CheckArray()); - VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized container."); + VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage."); } catch (vtkm::cont::ErrorControlBadValue error) { @@ -210,7 +210,7 @@ void TryUnusualPointCoordinates() << std::endl << " " << error.GetMessage() << std::endl; } - std::cout << " Recast containers and try again." << std::endl; + std::cout << " Recast storage and try again." << std::endl; pointCoordinates.ResetPointCoordinatesList(PointCoordinatesListUnusual()) .CastAndCall(CheckArray()); VTKM_TEST_ASSERT(g_CheckArrayInvocations == 1, @@ -220,7 +220,7 @@ void TryUnusualPointCoordinates() void DynamicPointCoordiantesTest() { TryDefaultArray(); - TryUnusualContainer(); + TryUnusualStorage(); TryUniformPointCoordinates(); TryUnusualPointCoordinates(); } diff --git a/vtkm/cont/testing/UnitTestPointCoordinates.cxx b/vtkm/cont/testing/UnitTestPointCoordinates.cxx index 40c09a65d..a118f58ac 100644 --- a/vtkm/cont/testing/UnitTestPointCoordinates.cxx +++ b/vtkm/cont/testing/UnitTestPointCoordinates.cxx @@ -18,13 +18,13 @@ // this software. //============================================================================ -// Make sure nothing relies on default container or device adapter. -#define VTKM_ARRAY_CONTAINER_CONTROL VTKM_ARRAY_CONTAINER_CONTROL_ERROR +// Make sure nothing relies on default storage or device adapter. +#define VTKM_STORAGE VTKM_STORAGE_ERROR #define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_ERROR // Make sure nothing relies on default lists. #define VTKM_DEFAULT_TYPE_LIST_TAG ::vtkm::ListTagEmpty -#define VTKM_DEFAULT_CONTAINER_LIST_TAG ::vtkm::ListTagEmpty +#define VTKM_DEFAULT_STORAGE_LIST_TAG ::vtkm::ListTagEmpty #include #include @@ -32,8 +32,8 @@ #include #include -#include #include +#include #include @@ -48,9 +48,9 @@ const vtkm::Vector3 SPACING = vtkm::Vector3(1, 1, 1); const vtkm::Id3 DIMENSION = vtkm::ExtentPointDimensions(EXTENT); const vtkm::Id ARRAY_SIZE = DIMENSION[0]*DIMENSION[1]*DIMENSION[2]; -typedef vtkm::cont::ArrayContainerControlTagBasic Container; +typedef vtkm::cont::StorageTagBasic StorageTag; -struct ContainerListTag : vtkm::cont::ContainerListTagBasic { }; +struct StorageListTag : vtkm::cont::StorageListTagBasic { }; vtkm::Vector3 TestValue(vtkm::Id index) { @@ -95,8 +95,8 @@ void TestPointCoordinatesArray() } std::cout << " Creating and checking array handle" << std::endl; - vtkm::cont::ArrayHandle array = - vtkm::cont::make_ArrayHandle(buffer, Container()); + vtkm::cont::ArrayHandle array = + vtkm::cont::make_ArrayHandle(buffer, StorageTag()); CheckArray()(array); std::cout << " Creating and checking PointCoordinatesArray" << std::endl; @@ -105,7 +105,7 @@ void TestPointCoordinatesArray() pointCoordinates.CastAndCall( CheckArray(), vtkm::ListTagEmpty(), // Internally sets to Vector3 - vtkm::cont::ContainerListTagBasic()); + vtkm::cont::StorageListTagBasic()); } void TestPointCoordinatesUniform() diff --git a/vtkm/cont/testing/UnitTestArrayContainerControlBasic.cxx b/vtkm/cont/testing/UnitTestStorageBasic.cxx similarity index 70% rename from vtkm/cont/testing/UnitTestArrayContainerControlBasic.cxx rename to vtkm/cont/testing/UnitTestStorageBasic.cxx index c213072a7..d566dfb51 100644 --- a/vtkm/cont/testing/UnitTestArrayContainerControlBasic.cxx +++ b/vtkm/cont/testing/UnitTestStorageBasic.cxx @@ -18,9 +18,9 @@ // this software. //============================================================================ -#define VTKM_ARRAY_CONTAINER_CONTROL VTKM_ARRAY_CONTAINER_CONTROL_ERROR +#define VTKM_STORAGE VTKM_STORAGE_ERROR -#include +#include #include #include @@ -32,13 +32,13 @@ const vtkm::Id ARRAY_SIZE = 10; template struct TemplatedTests { - typedef vtkm::cont::internal::ArrayContainerControl< - T, vtkm::cont::ArrayContainerControlTagBasic> ArrayContainerType; - typedef typename ArrayContainerType::ValueType ValueType; - typedef typename ArrayContainerType::PortalType PortalType; + typedef vtkm::cont::internal::Storage + StorageType; + typedef typename StorageType::ValueType ValueType; + typedef typename StorageType::PortalType PortalType; typedef typename PortalType::IteratorType IteratorType; - void SetContainer(ArrayContainerType &array, const ValueType& value) + void SetStorage(StorageType &array, const ValueType& value) { for (IteratorType iter = array.GetPortal().GetIteratorBegin(); iter != array.GetPortal().GetIteratorEnd(); @@ -48,7 +48,7 @@ struct TemplatedTests } } - bool CheckContainer(ArrayContainerType &array, const ValueType& value) + bool CheckStorage(StorageType &array, const ValueType& value) { for (IteratorType iter = array.GetPortal().GetIteratorBegin(); iter != array.GetPortal().GetIteratorEnd(); @@ -73,9 +73,9 @@ struct TemplatedTests ValueType stolenArrayValue = ValueType(STOLEN_ARRAY_VALUE()); - ArrayContainerType stealMyArray; + StorageType stealMyArray; stealMyArray.Allocate(ARRAY_SIZE); - SetContainer(stealMyArray, stolenArrayValue); + SetStorage(stealMyArray, stolenArrayValue); VTKM_TEST_ASSERT(stealMyArray.GetNumberOfValues() == ARRAY_SIZE, "Array not properly allocated."); @@ -100,34 +100,34 @@ struct TemplatedTests void BasicAllocation() { - ArrayContainerType arrayContainer; - VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == 0, - "New array container not zero sized."); + StorageType arrayStorage; + VTKM_TEST_ASSERT(arrayStorage.GetNumberOfValues() == 0, + "New array storage not zero sized."); - arrayContainer.Allocate(ARRAY_SIZE); - VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE, + arrayStorage.Allocate(ARRAY_SIZE); + VTKM_TEST_ASSERT(arrayStorage.GetNumberOfValues() == ARRAY_SIZE, "Array not properly allocated."); const ValueType BASIC_ALLOC_VALUE = ValueType(548); - SetContainer(arrayContainer, BASIC_ALLOC_VALUE); - VTKM_TEST_ASSERT(CheckContainer(arrayContainer, BASIC_ALLOC_VALUE), + SetStorage(arrayStorage, BASIC_ALLOC_VALUE); + VTKM_TEST_ASSERT(CheckStorage(arrayStorage, BASIC_ALLOC_VALUE), "Array not holding value."); - arrayContainer.Allocate(ARRAY_SIZE * 2); - VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE * 2, + arrayStorage.Allocate(ARRAY_SIZE * 2); + VTKM_TEST_ASSERT(arrayStorage.GetNumberOfValues() == ARRAY_SIZE * 2, "Array not reallocated correctly."); - arrayContainer.Shrink(ARRAY_SIZE); - VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == ARRAY_SIZE, + arrayStorage.Shrink(ARRAY_SIZE); + VTKM_TEST_ASSERT(arrayStorage.GetNumberOfValues() == ARRAY_SIZE, "Array Shrnk failed to resize."); - arrayContainer.ReleaseResources(); - VTKM_TEST_ASSERT(arrayContainer.GetNumberOfValues() == 0, + arrayStorage.ReleaseResources(); + VTKM_TEST_ASSERT(arrayStorage.GetNumberOfValues() == 0, "Array not released correctly."); try { - arrayContainer.Shrink(ARRAY_SIZE); + arrayStorage.Shrink(ARRAY_SIZE); VTKM_TEST_ASSERT(true==false, "Array shrink do a larger size was possible. This can't be allowed."); } @@ -155,14 +155,14 @@ struct TestFunctor } }; -void TestArrayContainerControlBasic() +void TestStorageBasic() { vtkm::testing::Testing::TryAllTypes(TestFunctor()); } } // Anonymous namespace -int UnitTestArrayContainerControlBasic(int, char *[]) +int UnitTestStorageBasic(int, char *[]) { - return vtkm::cont::testing::Testing::Run(TestArrayContainerControlBasic); + return vtkm::cont::testing::Testing::Run(TestStorageBasic); } diff --git a/vtkm/cont/testing/UnitTestArrayContainerControlImplicit.cxx b/vtkm/cont/testing/UnitTestStorageImplicit.cxx similarity index 70% rename from vtkm/cont/testing/UnitTestArrayContainerControlImplicit.cxx rename to vtkm/cont/testing/UnitTestStorageImplicit.cxx index 1ef2c8600..7b906b2b3 100644 --- a/vtkm/cont/testing/UnitTestArrayContainerControlImplicit.cxx +++ b/vtkm/cont/testing/UnitTestStorageImplicit.cxx @@ -18,29 +18,31 @@ // this software. //============================================================================ -#define VTKM_ARRAY_CONTAINER_CONTROL VTKM_ARRAY_CONTAINER_CONTROL_ERROR +#define VTKM_STORAGE VTKM_STORAGE_ERROR #include -#include -#include -#include -#include - #include +#include +#include + +#include + +#include + namespace { template -struct TestImplicitContainer +struct TestImplicitStorage { typedef T ValueType; ValueType Temp; typedef vtkm::cont::internal::IteratorFromArrayPortal< - TestImplicitContainer > IteratorType; + TestImplicitStorage > IteratorType; VTKM_EXEC_CONT_EXPORT - TestImplicitContainer(): Temp(1) { } + TestImplicitStorage(): Temp(1) { } VTKM_EXEC_CONT_EXPORT vtkm::Id GetNumberOfValues() const @@ -74,38 +76,37 @@ const vtkm::Id ARRAY_SIZE = 1; template struct TemplatedTests { - typedef vtkm::cont::ArrayContainerControlTagImplicit< - TestImplicitContainer > ContainerTagType; - typedef vtkm::cont::internal::ArrayContainerControl< - T, ContainerTagType > ArrayContainerType; + typedef vtkm::cont::StorageTagImplicit< TestImplicitStorage > + StorageTagType; + typedef vtkm::cont::internal::Storage< T, StorageTagType > StorageType; - typedef typename ArrayContainerType::ValueType ValueType; - typedef typename ArrayContainerType::PortalType PortalType; + typedef typename StorageType::ValueType ValueType; + typedef typename StorageType::PortalType PortalType; typedef typename PortalType::IteratorType IteratorType; void BasicAllocation() { - ArrayContainerType arrayContainer; + StorageType arrayStorage; try { - arrayContainer.GetNumberOfValues(); + arrayStorage.GetNumberOfValues(); VTKM_TEST_ASSERT(false == true, - "Implicit Container GetNumberOfValues method didn't throw error."); + "Implicit Storage GetNumberOfValues method didn't throw error."); } catch(vtkm::cont::ErrorControlBadValue e) {} try { - arrayContainer.Allocate(ARRAY_SIZE); + arrayStorage.Allocate(ARRAY_SIZE); VTKM_TEST_ASSERT(false == true, - "Implicit Container Allocate method didn't throw error."); + "Implicit Storage Allocate method didn't throw error."); } catch(vtkm::cont::ErrorControlBadValue e) {} try { - arrayContainer.Shrink(ARRAY_SIZE); + arrayStorage.Shrink(ARRAY_SIZE); VTKM_TEST_ASSERT(true==false, "Array shrink do a larger size was possible. This can't be allowed."); } @@ -113,7 +114,7 @@ struct TemplatedTests try { - arrayContainer.ReleaseResources(); + arrayStorage.ReleaseResources(); VTKM_TEST_ASSERT(true==false, "Can't Release an implicit array"); } @@ -122,8 +123,8 @@ struct TemplatedTests void BasicAccess() { - TestImplicitContainer portal; - vtkm::cont::ArrayHandle implictHandle(portal); + TestImplicitStorage portal; + vtkm::cont::ArrayHandle implictHandle(portal); VTKM_TEST_ASSERT(implictHandle.GetNumberOfValues() == 1, "handle should have size 1"); VTKM_TEST_ASSERT(implictHandle.GetPortalConstControl().Get(0) == T(1), @@ -149,14 +150,14 @@ struct TestFunctor } }; -void TestArrayContainerControlBasic() +void TestStorageBasic() { vtkm::testing::Testing::TryAllTypes(TestFunctor()); } } // Anonymous namespace -int UnitTestArrayContainerControlImplicit(int, char *[]) +int UnitTestStorageImplicit(int, char *[]) { - return vtkm::cont::testing::Testing::Run(TestArrayContainerControlBasic); + return vtkm::cont::testing::Testing::Run(TestStorageBasic); } diff --git a/vtkm/cont/testing/UnitTestContainerListTag.cxx b/vtkm/cont/testing/UnitTestStorageListTag.cxx similarity index 86% rename from vtkm/cont/testing/UnitTestContainerListTag.cxx rename to vtkm/cont/testing/UnitTestStorageListTag.cxx index c40eb73a1..f58eae855 100644 --- a/vtkm/cont/testing/UnitTestContainerListTag.cxx +++ b/vtkm/cont/testing/UnitTestStorageListTag.cxx @@ -18,7 +18,7 @@ // this software. //============================================================================ -#include +#include #include @@ -30,7 +30,7 @@ enum TypeId { BASIC }; -TypeId GetTypeId(vtkm::cont::ArrayContainerControlTagBasic) { return BASIC; } +TypeId GetTypeId(vtkm::cont::StorageTagBasic) { return BASIC; } struct TestFunctor { @@ -67,13 +67,13 @@ void TryList(const vtkm::Tuple &expected, ListTag) void TestLists() { - std::cout << "ContainerListTagBasic" << std::endl; - TryList(vtkm::Tuple(BASIC), vtkm::cont::ContainerListTagBasic()); + std::cout << "StorageListTagBasic" << std::endl; + TryList(vtkm::Tuple(BASIC), vtkm::cont::StorageListTagBasic()); } } // anonymous namespace -int UnitTestContainerListTag(int, char *[]) +int UnitTestStorageListTag(int, char *[]) { return vtkm::cont::testing::Testing::Run(TestLists); }