mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
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.
This commit is contained in:
parent
b2584f92a6
commit
21823500c3
@ -22,9 +22,10 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControl.h>
|
||||
#include <vtkm/cont/Assert.h>
|
||||
#include <vtkm/cont/ErrorControlBadValue.h>
|
||||
#include <vtkm/cont/Storage.h>
|
||||
|
||||
#include <vtkm/cont/internal/ArrayHandleExecutionManager.h>
|
||||
#include <vtkm/cont/internal/ArrayTransfer.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
@ -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<typename T, typename ArrayContainerControlTag>
|
||||
template<typename T, typename StorageTag>
|
||||
struct IsValidArrayHandle {
|
||||
typedef typename boost::mpl::not_<
|
||||
typename boost::is_base_of<
|
||||
vtkm::cont::internal::UndefinedArrayContainerControl,
|
||||
vtkm::cont::internal::ArrayContainerControl<T,ArrayContainerControlTag>
|
||||
vtkm::cont::internal::UndefinedStorage,
|
||||
vtkm::cont::internal::Storage<T,StorageTag>
|
||||
>::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<T,ArrayContainerControlTag_>
|
||||
ArrayContainerControlType;
|
||||
typedef vtkm::cont::internal
|
||||
::ArrayHandleExecutionManagerBase<T,ArrayContainerControlTag_>
|
||||
typedef vtkm::cont::internal::Storage<T,StorageTag_> StorageType;
|
||||
typedef vtkm::cont::internal::ArrayHandleExecutionManagerBase<T,StorageTag_>
|
||||
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 <typename DeviceAdapterTag>
|
||||
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<InternalStruct*>(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<InternalStruct> 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<typename T, typename ArrayContainerControlTag>
|
||||
template<typename T, typename StorageTag>
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::cont::ArrayHandle<T, ArrayContainerControlTag>
|
||||
vtkm::cont::ArrayHandle<T, StorageTag>
|
||||
make_ArrayHandle(const T *array,
|
||||
vtkm::Id length,
|
||||
ArrayContainerControlTag)
|
||||
StorageTag)
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<T, ArrayContainerControlTag> ArrayHandleType;
|
||||
typedef vtkm::cont::ArrayHandle<T, StorageTag> ArrayHandleType;
|
||||
typedef typename ArrayHandleType::PortalConstControl PortalType;
|
||||
return ArrayHandleType(PortalType(array, array+length));
|
||||
}
|
||||
template<typename T>
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::cont::ArrayHandle<T, VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG>
|
||||
vtkm::cont::ArrayHandle<T, VTKM_DEFAULT_STORAGE_TAG>
|
||||
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 T,
|
||||
typename Allocator,
|
||||
typename ArrayContainerControlTag>
|
||||
typename StorageTag>
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::cont::ArrayHandle<T, ArrayContainerControlTag>
|
||||
vtkm::cont::ArrayHandle<T, StorageTag>
|
||||
make_ArrayHandle(const std::vector<T,Allocator> &array,
|
||||
ArrayContainerControlTag)
|
||||
StorageTag)
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<T, ArrayContainerControlTag> ArrayHandleType;
|
||||
typedef vtkm::cont::ArrayHandle<T, StorageTag> ArrayHandleType;
|
||||
typedef typename ArrayHandleType::PortalConstControl PortalType;
|
||||
return ArrayHandleType(PortalType(&array.front(), &array.back() + 1));
|
||||
}
|
||||
template<typename T, typename Allocator>
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::cont::ArrayHandle<T, VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG>
|
||||
vtkm::cont::ArrayHandle<T, VTKM_DEFAULT_STORAGE_TAG>
|
||||
make_ArrayHandle(const std::vector<T,Allocator> &array)
|
||||
{
|
||||
return make_ArrayHandle(array, VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG());
|
||||
return make_ArrayHandle(array, VTKM_DEFAULT_STORAGE_TAG());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -272,28 +272,27 @@ private:
|
||||
};
|
||||
|
||||
template<typename SignatureWithArrays>
|
||||
struct ArrayContainerControlTagCompositeVector { };
|
||||
struct StorageTagCompositeVector { };
|
||||
|
||||
/// A convenience class that provides a typedef to the appropriate tag for
|
||||
/// a counting array container.
|
||||
/// a composite storage.
|
||||
template<typename SignatureWithArrays>
|
||||
struct ArrayHandleCompositeVectorTraits
|
||||
{
|
||||
typedef vtkm::cont::internal::ArrayContainerControlTagCompositeVector<
|
||||
SignatureWithArrays> Tag;
|
||||
typedef vtkm::cont::internal::StorageTagCompositeVector<SignatureWithArrays>
|
||||
Tag;
|
||||
typedef typename vtkm::internal::FunctionInterface<SignatureWithArrays>::ResultType
|
||||
ValueType;
|
||||
typedef vtkm::cont::internal::ArrayContainerControl<
|
||||
ValueType, Tag> ContainerType;
|
||||
typedef vtkm::cont::internal::Storage<ValueType, Tag> 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<typename SignatureWithArrays>
|
||||
class ArrayContainerControl<
|
||||
class Storage<
|
||||
typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ValueType,
|
||||
vtkm::cont::internal::ArrayContainerControlTagCompositeVector<SignatureWithArrays> >
|
||||
vtkm::cont::internal::StorageTagCompositeVector<SignatureWithArrays> >
|
||||
{
|
||||
typedef vtkm::internal::FunctionInterface<SignatureWithArrays>
|
||||
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<typename SignatureWithArrays, typename DeviceAdapterTag>
|
||||
class ArrayTransfer<
|
||||
typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ValueType,
|
||||
vtkm::cont::internal::ArrayContainerControlTagCompositeVector<SignatureWithArrays>,
|
||||
vtkm::cont::internal::StorageTagCompositeVector<SignatureWithArrays>,
|
||||
DeviceAdapterTag>
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
||||
|
||||
typedef typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ContainerType
|
||||
ContainerType;
|
||||
typedef typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::StorageType
|
||||
StorageType;
|
||||
|
||||
typedef vtkm::internal::FunctionInterface<SignatureWithArrays>
|
||||
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<SignatureWithPortals> PortalExecution;
|
||||
typedef ArrayPortalCompositeVector<SignatureWithPortals> 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<DeviceAdapterTag>()),
|
||||
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<Signature>::ValueType,
|
||||
typename internal::ArrayHandleCompositeVectorTraits<Signature>::Tag>
|
||||
{
|
||||
typedef typename internal::ArrayHandleCompositeVectorTraits<Signature>::ContainerType
|
||||
ArrayContainerControlType;
|
||||
typedef typename internal::ArrayHandleCompositeVectorTraits<Signature>::StorageType
|
||||
StorageType;
|
||||
typedef typename internal::ArrayPortalCompositeVectorCont<Signature>::ComponentMapType
|
||||
ComponentMapType;
|
||||
|
||||
@ -533,7 +532,7 @@ public:
|
||||
ArrayHandleCompositeVector(
|
||||
const vtkm::internal::FunctionInterface<Signature> &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<ValueType>(array1),
|
||||
ComponentMapType(sourceComponent1)))
|
||||
{ }
|
||||
@ -555,7 +554,7 @@ public:
|
||||
int sourceComponent1,
|
||||
const ArrayHandleType2 &array2,
|
||||
int sourceComponent2)
|
||||
: Superclass(ArrayContainerControlType(
|
||||
: Superclass(StorageType(
|
||||
vtkm::internal::make_FunctionInterface<ValueType>(
|
||||
array1, array2),
|
||||
ComponentMapType(sourceComponent1,
|
||||
@ -571,7 +570,7 @@ public:
|
||||
int sourceComponent2,
|
||||
const ArrayHandleType3 &array3,
|
||||
int sourceComponent3)
|
||||
: Superclass(ArrayContainerControlType(
|
||||
: Superclass(StorageType(
|
||||
vtkm::internal::make_FunctionInterface<ValueType>(
|
||||
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<ValueType>(
|
||||
array1, array2, array3, array4),
|
||||
ComponentMapType(sourceComponent1,
|
||||
@ -670,95 +669,95 @@ public:
|
||||
|
||||
/// Create a composite vector array from other arrays.
|
||||
///
|
||||
template<typename ValueType1, typename Container1>
|
||||
template<typename ValueType1, typename Storage1>
|
||||
VTKM_CONT_EXPORT
|
||||
typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Container1> >::type
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1> >::type
|
||||
make_ArrayHandleCompositeVector(
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Container1> &array1,
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
|
||||
int sourceComponent1)
|
||||
{
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Container1> >::type(array1,
|
||||
sourceComponent1);
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1> >::type(array1,
|
||||
sourceComponent1);
|
||||
}
|
||||
template<typename ValueType1, typename Container1,
|
||||
typename ValueType2, typename Container2>
|
||||
template<typename ValueType1, typename Storage1,
|
||||
typename ValueType2, typename Storage2>
|
||||
VTKM_CONT_EXPORT
|
||||
typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Container1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Container2> >::type
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Storage2> >::type
|
||||
make_ArrayHandleCompositeVector(
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Container1> &array1,
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
|
||||
int sourceComponent1,
|
||||
const vtkm::cont::ArrayHandle<ValueType2,Container2> &array2,
|
||||
const vtkm::cont::ArrayHandle<ValueType2,Storage2> &array2,
|
||||
int sourceComponent2)
|
||||
{
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Container1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Container2> >::type(array1,
|
||||
sourceComponent1,
|
||||
array2,
|
||||
sourceComponent2);
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Storage2> >::type(array1,
|
||||
sourceComponent1,
|
||||
array2,
|
||||
sourceComponent2);
|
||||
}
|
||||
template<typename ValueType1, typename Container1,
|
||||
typename ValueType2, typename Container2,
|
||||
typename ValueType3, typename Container3>
|
||||
template<typename ValueType1, typename Storage1,
|
||||
typename ValueType2, typename Storage2,
|
||||
typename ValueType3, typename Storage3>
|
||||
VTKM_CONT_EXPORT
|
||||
typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Container1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Container2>,
|
||||
vtkm::cont::ArrayHandle<ValueType3,Container3> >::type
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Storage2>,
|
||||
vtkm::cont::ArrayHandle<ValueType3,Storage3> >::type
|
||||
make_ArrayHandleCompositeVector(
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Container1> &array1,
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
|
||||
int sourceComponent1,
|
||||
const vtkm::cont::ArrayHandle<ValueType2,Container2> &array2,
|
||||
const vtkm::cont::ArrayHandle<ValueType2,Storage2> &array2,
|
||||
int sourceComponent2,
|
||||
const vtkm::cont::ArrayHandle<ValueType3,Container3> &array3,
|
||||
const vtkm::cont::ArrayHandle<ValueType3,Storage3> &array3,
|
||||
int sourceComponent3)
|
||||
{
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Container1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Container2>,
|
||||
vtkm::cont::ArrayHandle<ValueType3,Container3> >::type(array1,
|
||||
sourceComponent1,
|
||||
array2,
|
||||
sourceComponent2,
|
||||
array3,
|
||||
sourceComponent3);
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Storage2>,
|
||||
vtkm::cont::ArrayHandle<ValueType3,Storage3> >::type(array1,
|
||||
sourceComponent1,
|
||||
array2,
|
||||
sourceComponent2,
|
||||
array3,
|
||||
sourceComponent3);
|
||||
}
|
||||
template<typename ValueType1, typename Container1,
|
||||
typename ValueType2, typename Container2,
|
||||
typename ValueType3, typename Container3,
|
||||
typename ValueType4, typename Container4>
|
||||
template<typename ValueType1, typename Storage1,
|
||||
typename ValueType2, typename Storage2,
|
||||
typename ValueType3, typename Storage3,
|
||||
typename ValueType4, typename Storage4>
|
||||
VTKM_CONT_EXPORT
|
||||
typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Container1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Container2>,
|
||||
vtkm::cont::ArrayHandle<ValueType3,Container3>,
|
||||
vtkm::cont::ArrayHandle<ValueType4,Container4> >::type
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Storage2>,
|
||||
vtkm::cont::ArrayHandle<ValueType3,Storage3>,
|
||||
vtkm::cont::ArrayHandle<ValueType4,Storage4> >::type
|
||||
make_ArrayHandleCompositeVector(
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Container1> &array1,
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
|
||||
int sourceComponent1,
|
||||
const vtkm::cont::ArrayHandle<ValueType2,Container2> &array2,
|
||||
const vtkm::cont::ArrayHandle<ValueType2,Storage2> &array2,
|
||||
int sourceComponent2,
|
||||
const vtkm::cont::ArrayHandle<ValueType3,Container3> &array3,
|
||||
const vtkm::cont::ArrayHandle<ValueType3,Storage3> &array3,
|
||||
int sourceComponent3,
|
||||
const vtkm::cont::ArrayHandle<ValueType4,Container4> &array4,
|
||||
const vtkm::cont::ArrayHandle<ValueType4,Storage4> &array4,
|
||||
int sourceComponent4)
|
||||
{
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Container1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Container2>,
|
||||
vtkm::cont::ArrayHandle<ValueType3,Container3>,
|
||||
vtkm::cont::ArrayHandle<ValueType4,Container4> >::type(array1,
|
||||
sourceComponent1,
|
||||
array2,
|
||||
sourceComponent2,
|
||||
array3,
|
||||
sourceComponent3,
|
||||
array4,
|
||||
sourceComponent4);
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1>,
|
||||
vtkm::cont::ArrayHandle<ValueType2,Storage2>,
|
||||
vtkm::cont::ArrayHandle<ValueType3,Storage3>,
|
||||
vtkm::cont::ArrayHandle<ValueType4,Storage4> >::type(array1,
|
||||
sourceComponent1,
|
||||
array2,
|
||||
sourceComponent2,
|
||||
array3,
|
||||
sourceComponent3,
|
||||
array4,
|
||||
sourceComponent4);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,8 +20,9 @@
|
||||
#ifndef vtk_m_cont_ArrayHandleCounting_h
|
||||
#define vtk_m_cont_ArrayHandleCounting_h
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlImplicit.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/StorageImplicit.h>
|
||||
|
||||
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
|
||||
|
||||
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<typename ConstantValueType>
|
||||
struct ArrayHandleCountingTraits
|
||||
{
|
||||
typedef vtkm::cont::ArrayContainerControlTagImplicit<
|
||||
typedef vtkm::cont::StorageTagImplicit<
|
||||
vtkm::cont::internal::ArrayPortalCounting<ConstantValueType> > Tag;
|
||||
};
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
|
||||
#include <vtkm/Extent.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlImplicit.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/StorageImplicit.h>
|
||||
|
||||
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
|
||||
|
||||
@ -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:
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include <vtkm/TypeListTag.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ContainerListTag.h>
|
||||
#include <vtkm/cont/ErrorControlBadValue.h>
|
||||
#include <vtkm/cont/StorageListTag.h>
|
||||
|
||||
#include <vtkm/cont/internal/DynamicTransform.h>
|
||||
#include <vtkm/cont/internal/SimplePolymorphicContainer.h>
|
||||
@ -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<typename TypeList, typename ContainerList>
|
||||
template<typename TypeList, typename StorageList>
|
||||
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<typename Type, typename Container>
|
||||
template<typename Type, typename Storage>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicArrayHandle(const vtkm::cont::ArrayHandle<Type,Container> &array)
|
||||
: ArrayContainer(new vtkm::cont::internal::SimplePolymorphicContainer<
|
||||
vtkm::cont::ArrayHandle<Type,Container> >(array))
|
||||
DynamicArrayHandle(const vtkm::cont::ArrayHandle<Type,Storage> &array)
|
||||
: ArrayStorage(new vtkm::cont::internal::SimplePolymorphicContainer<
|
||||
vtkm::cont::ArrayHandle<Type,Storage> >(array))
|
||||
{ }
|
||||
|
||||
template<typename TypeList, typename ContainerList>
|
||||
template<typename TypeList, typename StorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicArrayHandle(
|
||||
const internal::DynamicArrayHandleCast<TypeList,ContainerList> &dynamicArray)
|
||||
: ArrayContainer(dynamicArray.ArrayContainer) { }
|
||||
const internal::DynamicArrayHandleCast<TypeList,StorageList> &dynamicArray)
|
||||
: ArrayStorage(dynamicArray.ArrayStorage) { }
|
||||
|
||||
/// Returns true if this array is of the provided type and uses the provided
|
||||
/// container.
|
||||
/// storage.
|
||||
///
|
||||
template<typename Type, typename Container>
|
||||
template<typename Type, typename Storage>
|
||||
VTKM_CONT_EXPORT
|
||||
bool IsTypeAndContainer(Type = Type(), Container = Container()) const {
|
||||
return (this->TryCastArrayContainer<Type,Container>() != NULL);
|
||||
bool IsTypeAndStorage(Type = Type(), Storage = Storage()) const {
|
||||
return (this->TryCastStorage<Type,Storage>() != 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<typename Type, typename Container>
|
||||
template<typename Type, typename Storage>
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::cont::ArrayHandle<Type, Container>
|
||||
CastToArrayHandle(Type = Type(), Container = Container()) const {
|
||||
vtkm::cont::ArrayHandle<Type, Storage>
|
||||
CastToArrayHandle(Type = Type(), Storage = Storage()) const {
|
||||
vtkm::cont::internal::SimplePolymorphicContainer<
|
||||
vtkm::cont::ArrayHandle<Type,Container> > *container =
|
||||
this->TryCastArrayContainer<Type,Container>();
|
||||
vtkm::cont::ArrayHandle<Type,Storage> > *container =
|
||||
this->TryCastStorage<Type,Storage>();
|
||||
if (container == NULL)
|
||||
{
|
||||
throw vtkm::cont::ErrorControlBadValue("Bad cast of dynamic array.");
|
||||
@ -128,104 +128,104 @@ public:
|
||||
///
|
||||
template<typename NewTypeList>
|
||||
VTKM_CONT_EXPORT
|
||||
internal::DynamicArrayHandleCast<NewTypeList,VTKM_DEFAULT_CONTAINER_LIST_TAG>
|
||||
internal::DynamicArrayHandleCast<NewTypeList,VTKM_DEFAULT_STORAGE_LIST_TAG>
|
||||
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<typename NewContainerList>
|
||||
template<typename NewStorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
internal::DynamicArrayHandleCast<VTKM_DEFAULT_TYPE_LIST_TAG,NewContainerList>
|
||||
ResetContainerList(NewContainerList = NewContainerList()) const {
|
||||
internal::DynamicArrayHandleCast<VTKM_DEFAULT_TYPE_LIST_TAG,NewStorageList>
|
||||
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<typename Functor>
|
||||
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<typename Functor, typename TypeList, typename ContainerList>
|
||||
template<typename Functor, typename TypeList, typename StorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
void CastAndCall(const Functor &f, TypeList, ContainerList) const;
|
||||
void CastAndCall(const Functor &f, TypeList, StorageList) const;
|
||||
|
||||
private:
|
||||
boost::shared_ptr<vtkm::cont::internal::SimplePolymorphicContainerBase>
|
||||
ArrayContainer;
|
||||
ArrayStorage;
|
||||
|
||||
template<typename Type, typename Container>
|
||||
template<typename Type, typename Storage>
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::cont::internal::SimplePolymorphicContainer<
|
||||
vtkm::cont::ArrayHandle<Type,Container> > *
|
||||
TryCastArrayContainer() const {
|
||||
vtkm::cont::ArrayHandle<Type,Storage> > *
|
||||
TryCastStorage() const {
|
||||
return
|
||||
dynamic_cast<
|
||||
vtkm::cont::internal::SimplePolymorphicContainer<
|
||||
vtkm::cont::ArrayHandle<Type,Container> > *>(
|
||||
this->ArrayContainer.get());
|
||||
vtkm::cont::ArrayHandle<Type,Storage> > *>(
|
||||
this->ArrayStorage.get());
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Functor, typename Type>
|
||||
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<typename Container>
|
||||
template<typename Storage>
|
||||
VTKM_CONT_EXPORT
|
||||
typename boost::enable_if<
|
||||
typename vtkm::cont::internal::IsValidArrayHandle<Type,Container>::type
|
||||
typename vtkm::cont::internal::IsValidArrayHandle<Type,Storage>::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<typename Container>
|
||||
template<typename Storage>
|
||||
VTKM_CONT_EXPORT
|
||||
typename boost::disable_if<
|
||||
typename vtkm::cont::internal::IsValidArrayHandle<Type,Container>::type
|
||||
typename vtkm::cont::internal::IsValidArrayHandle<Type,Storage>::type
|
||||
>::type
|
||||
operator()(Container) {
|
||||
operator()(Storage) {
|
||||
// This type of array handle cannot exist, so do nothing.
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Functor, typename ContainerList>
|
||||
template<typename Functor, typename StorageList>
|
||||
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<Functor, Type> TryContainerType;
|
||||
TryContainerType tryContainer =
|
||||
TryContainerType(this->Array, this->Function);
|
||||
vtkm::ListForEach(tryContainer, ContainerList());
|
||||
if (tryContainer.FoundCast)
|
||||
typedef DynamicArrayHandleTryStorage<Functor, Type> 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<typename Functor, typename TypeList, typename ContainerList>
|
||||
template<typename Functor, typename TypeList, typename StorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
void DynamicArrayHandle::CastAndCall(const Functor &f,
|
||||
TypeList,
|
||||
ContainerList) const
|
||||
StorageList) const
|
||||
{
|
||||
typedef detail::DynamicArrayHandleTryType<Functor, ContainerList> TryTypeType;
|
||||
typedef detail::DynamicArrayHandleTryType<Functor, StorageList> 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<typename TypeList, typename ContainerList>
|
||||
template<typename TypeList, typename StorageList>
|
||||
class DynamicArrayHandleCast : public vtkm::cont::DynamicArrayHandle
|
||||
{
|
||||
public:
|
||||
@ -281,31 +281,31 @@ public:
|
||||
DynamicArrayHandleCast(const vtkm::cont::DynamicArrayHandle &array)
|
||||
: DynamicArrayHandle(array) { }
|
||||
|
||||
template<typename SrcTypeList, typename SrcContainerList>
|
||||
template<typename SrcTypeList, typename SrcStorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicArrayHandleCast(
|
||||
const DynamicArrayHandleCast<SrcTypeList,SrcContainerList> &array)
|
||||
const DynamicArrayHandleCast<SrcTypeList,SrcStorageList> &array)
|
||||
: DynamicArrayHandle(array) { }
|
||||
|
||||
template<typename NewTypeList>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicArrayHandleCast<NewTypeList,ContainerList>
|
||||
DynamicArrayHandleCast<NewTypeList,StorageList>
|
||||
ResetTypeList(NewTypeList = NewTypeList()) const {
|
||||
return DynamicArrayHandleCast<NewTypeList,ContainerList>(*this);
|
||||
return DynamicArrayHandleCast<NewTypeList,StorageList>(*this);
|
||||
}
|
||||
|
||||
template<typename NewContainerList>
|
||||
template<typename NewStorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
internal::DynamicArrayHandleCast<TypeList,NewContainerList>
|
||||
ResetContainerList(NewContainerList = NewContainerList()) const {
|
||||
return internal::DynamicArrayHandleCast<TypeList,NewContainerList>(*this);
|
||||
internal::DynamicArrayHandleCast<TypeList,NewStorageList>
|
||||
ResetStorageList(NewStorageList = NewStorageList()) const {
|
||||
return internal::DynamicArrayHandleCast<TypeList,NewStorageList>(*this);
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
VTKM_CONT_EXPORT
|
||||
void CastAndCall(const Functor &f) const
|
||||
{
|
||||
this->CastAndCall(f, TypeList(), ContainerList());
|
||||
this->CastAndCall(f, TypeList(), StorageList());
|
||||
}
|
||||
|
||||
template<typename Functor, typename TL, typename CL>
|
||||
@ -321,9 +321,9 @@ struct DynamicTransformTraits<vtkm::cont::DynamicArrayHandle> {
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
||||
template<typename TypeList, typename ContainerList>
|
||||
template<typename TypeList, typename StorageList>
|
||||
struct DynamicTransformTraits<
|
||||
vtkm::cont::internal::DynamicArrayHandleCast<TypeList,ContainerList> >
|
||||
vtkm::cont::internal::DynamicArrayHandleCast<TypeList,StorageList> >
|
||||
{
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
@ -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 PointCoordinatesList,
|
||||
typename TypeList,
|
||||
typename ContainerList>
|
||||
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<typename Container>
|
||||
template<typename Storage>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicPointCoordinates(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vector3,Container> &array)
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vector3,Storage> &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<typename NewContainerList>
|
||||
template<typename NewStorageList>
|
||||
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<typename Functor>
|
||||
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 Functor,
|
||||
typename PointCoordinatesList,
|
||||
typename TypeList,
|
||||
typename ContainerList>
|
||||
typename StorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
void CastAndCall(const Functor &f,
|
||||
PointCoordinatesList,
|
||||
TypeList,
|
||||
ContainerList) const;
|
||||
StorageList) const;
|
||||
|
||||
private:
|
||||
boost::shared_ptr<vtkm::cont::internal::PointCoordinatesBase>
|
||||
@ -250,15 +250,15 @@ private:
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Functor, typename TypeList, typename ContainerList>
|
||||
struct DynamicPointCoordinatesTryContainer
|
||||
template<typename Functor, typename TypeList, typename StorageList>
|
||||
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 Functor,
|
||||
typename PointCoordinatesList,
|
||||
typename TypeList,
|
||||
typename ContainerList>
|
||||
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 PointCoordinatesList,
|
||||
typename TypeList,
|
||||
typename ContainerList>
|
||||
typename StorageList>
|
||||
class DynamicPointCoordinatesCast : public vtkm::cont::DynamicPointCoordinates
|
||||
{
|
||||
public:
|
||||
@ -318,43 +318,43 @@ public:
|
||||
|
||||
template<typename SrcPointCoordinatesList,
|
||||
typename SrcTypeList,
|
||||
typename SrcContainerList>
|
||||
typename SrcStorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicPointCoordinatesCast(
|
||||
const DynamicPointCoordinatesCast<SrcPointCoordinatesList,SrcTypeList,SrcContainerList> &coords)
|
||||
const DynamicPointCoordinatesCast<SrcPointCoordinatesList,SrcTypeList,SrcStorageList> &coords)
|
||||
: DynamicPointCoordinates(coords)
|
||||
{ }
|
||||
|
||||
template<typename NewPointCoordinatesList>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicPointCoordinatesCast<NewPointCoordinatesList,TypeList,ContainerList>
|
||||
DynamicPointCoordinatesCast<NewPointCoordinatesList,TypeList,StorageList>
|
||||
ResetPointCoordinatesList(
|
||||
NewPointCoordinatesList = NewPointCoordinatesList()) const {
|
||||
return DynamicPointCoordinatesCast<
|
||||
NewPointCoordinatesList,TypeList,ContainerList>(*this);
|
||||
NewPointCoordinatesList,TypeList,StorageList>(*this);
|
||||
}
|
||||
|
||||
template<typename NewTypeList>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicPointCoordinatesCast<PointCoordinatesList,NewTypeList,ContainerList>
|
||||
DynamicPointCoordinatesCast<PointCoordinatesList,NewTypeList,StorageList>
|
||||
ResetTypeList(NewTypeList = NewTypeList()) const {
|
||||
return DynamicPointCoordinatesCast<
|
||||
PointCoordinatesList,NewTypeList,ContainerList>(*this);
|
||||
PointCoordinatesList,NewTypeList,StorageList>(*this);
|
||||
}
|
||||
|
||||
template<typename NewContainerList>
|
||||
template<typename NewStorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicPointCoordinatesCast<PointCoordinatesList,TypeList,NewContainerList>
|
||||
ResetContainerList(NewContainerList = NewContainerList()) const {
|
||||
DynamicPointCoordinatesCast<PointCoordinatesList,TypeList,NewStorageList>
|
||||
ResetStorageList(NewStorageList = NewStorageList()) const {
|
||||
return DynamicPointCoordinatesCast<
|
||||
PointCoordinatesList,TypeList,NewContainerList>(*this);
|
||||
PointCoordinatesList,TypeList,NewStorageList>(*this);
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
VTKM_CONT_EXPORT
|
||||
void CastAndCall(const Functor &f) const
|
||||
{
|
||||
this->CastAndCall(f, PointCoordinatesList(), TypeList(), ContainerList());
|
||||
this->CastAndCall(f, PointCoordinatesList(), TypeList(), StorageList());
|
||||
}
|
||||
|
||||
template<typename Functor, typename PCL, typename TL, typename CL>
|
||||
@ -372,10 +372,10 @@ struct DynamicTransformTraits<vtkm::cont::DynamicPointCoordinates> {
|
||||
|
||||
template<typename PointCoordinatesList,
|
||||
typename TypeList,
|
||||
typename ContainerList>
|
||||
typename StorageList>
|
||||
struct DynamicTransformTraits<
|
||||
vtkm::cont::internal::DynamicPointCoordinatesCast<
|
||||
PointCoordinatesList,TypeList,ContainerList> >
|
||||
PointCoordinatesList,TypeList,StorageList> >
|
||||
{
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
@ -49,20 +49,20 @@ public:
|
||||
PointCoordinatesArray(const vtkm::cont::DynamicArrayHandle &array)
|
||||
: Array(array) { }
|
||||
|
||||
template<typename Container>
|
||||
template<typename Storage>
|
||||
VTKM_CONT_EXPORT
|
||||
PointCoordinatesArray(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vector3,Container> &array)
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vector3,Storage> &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<typename Functor, typename TypeList, typename ContainerList>
|
||||
template<typename Functor, typename TypeList, typename StorageList>
|
||||
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:
|
||||
|
@ -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<typename Functor, typename TypeList, typename ContainerList>
|
||||
template<typename Functor, typename TypeList, typename StorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
void CastAndCall(const Functor &f, TypeList, ContainerList) const
|
||||
void CastAndCall(const Functor &f, TypeList, StorageList) const
|
||||
{
|
||||
f(this->Array);
|
||||
}
|
||||
|
@ -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 <boost/static_assert.hpp>
|
||||
@ -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<typename T>
|
||||
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<typename T, class ArrayContainerControlTag>
|
||||
class ArrayContainerControl
|
||||
template<typename T, class StorageTag>
|
||||
class Storage
|
||||
#ifndef VTKM_DOXYGEN_ONLY
|
||||
: public vtkm::cont::internal::UndefinedArrayContainerControl
|
||||
: public vtkm::cont::internal::UndefinedStorage
|
||||
{
|
||||
public:
|
||||
typedef vtkm::cont::internal::detail::UndefinedArrayPortal<T> 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 <vtkm/cont/ArrayContainerControlBasic.h>
|
||||
#define VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG \
|
||||
::vtkm::cont::ArrayContainerControlTagBasic
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
#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 <vtkm/cont/internal/ArrayContainerControlError.h>
|
||||
#define VTKM_DEFAULT_ARRAY_CONTAINER_CONTROL_TAG \
|
||||
::vtkm::cont::internal::ArrayContainerControlTagError
|
||||
#include <vtkm/cont/internal/StorageError.h>
|
||||
#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
|
@ -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 <vtkm/Types.h>
|
||||
#include <vtkm/cont/ArrayContainerControl.h>
|
||||
#include <vtkm/cont/Assert.h>
|
||||
#include <vtkm/cont/ErrorControlBadValue.h>
|
||||
#include <vtkm/cont/ErrorControlOutOfMemory.h>
|
||||
#include <vtkm/cont/Storage.h>
|
||||
|
||||
#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
|
||||
|
||||
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 <typename ValueT>
|
||||
class ArrayContainerControl<ValueT, vtkm::cont::ArrayContainerControlTagBasic>
|
||||
class Storage<ValueT, vtkm::cont::StorageTagBasic>
|
||||
{
|
||||
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<ValueType> 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<ValueType, ArrayContainerControlTagBasic> &src);
|
||||
void operator=(const ArrayContainerControl<ValueType, ArrayContainerControlTagBasic> &src);
|
||||
Storage(const Storage<ValueType, StorageTagBasic> &src);
|
||||
void operator=(const Storage<ValueType, StorageTagBasic> &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
|
@ -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 <vtkm/Types.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControl.h>
|
||||
#include <vtkm/cont/Assert.h>
|
||||
#include <vtkm/cont/ErrorControlBadValue.h>
|
||||
#include <vtkm/cont/Storage.h>
|
||||
|
||||
#include <vtkm/cont/internal/ArrayTransfer.h>
|
||||
|
||||
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<class ArrayPortalType>
|
||||
struct ArrayContainerControlTagImplicit
|
||||
struct StorageTagImplicit
|
||||
{
|
||||
typedef ArrayPortalType PortalType;
|
||||
};
|
||||
@ -52,9 +50,9 @@ struct ArrayContainerControlTagImplicit
|
||||
namespace internal {
|
||||
|
||||
template<class ArrayPortalType>
|
||||
class ArrayContainerControl<
|
||||
class Storage<
|
||||
typename ArrayPortalType::ValueType,
|
||||
ArrayContainerControlTagImplicit<ArrayPortalType> >
|
||||
StorageTagImplicit<ArrayPortalType> >
|
||||
{
|
||||
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<typename T, typename ArrayPortalType>
|
||||
//class ArrayContainerControl<T, ArrayContainerControlTagImplicit<ArrayPortalType> >
|
||||
//{
|
||||
//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<typename T, class ArrayPortalType, class DeviceAdapterTag>
|
||||
class ArrayTransfer<
|
||||
T, ArrayContainerControlTagImplicit<ArrayPortalType>, DeviceAdapterTag>
|
||||
class ArrayTransfer<T, StorageTagImplicit<ArrayPortalType>, DeviceAdapterTag>
|
||||
{
|
||||
private:
|
||||
typedef ArrayContainerControlTagImplicit<ArrayPortalType>
|
||||
ArrayContainerControlTag;
|
||||
typedef vtkm::cont::internal::ArrayContainerControl<T,ArrayContainerControlTag>
|
||||
ContainerType;
|
||||
typedef StorageTagImplicit<ArrayPortalType> StorageTag;
|
||||
typedef vtkm::cont::internal::Storage<T,StorageTag> 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
|
@ -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 <vtkm/ListTag.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControl.h>
|
||||
#include <vtkm/cont/ArrayContainerControlBasic.h>
|
||||
#include <vtkm/cont/Storage.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
struct ContainerListTagBasic
|
||||
: vtkm::ListTagBase<vtkm::cont::ArrayContainerControlTagBasic> { };
|
||||
struct StorageListTagBasic
|
||||
: vtkm::ListTagBase<vtkm::cont::StorageTagBasic> { };
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#endif //vtk_m_ContainerListTag_h
|
||||
#endif //vtk_m_StorageListTag_h
|
@ -20,8 +20,9 @@
|
||||
#ifndef vtk_m_cont_exec_ArrayHandleExecutionManager_h
|
||||
#define vtk_m_cont_exec_ArrayHandleExecutionManager_h
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControl.h>
|
||||
#include <vtkm/cont/ErrorControlInternal.h>
|
||||
#include <vtkm/cont/Storage.h>
|
||||
|
||||
#include <vtkm/cont/internal/ArrayTransfer.h>
|
||||
|
||||
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<typename T, typename Container>
|
||||
template<typename T, typename Storage>
|
||||
class ArrayHandleExecutionManagerBase
|
||||
{
|
||||
private:
|
||||
typedef vtkm::cont::internal::ArrayContainerControl<T,Container>
|
||||
ContainerType;
|
||||
typedef vtkm::cont::internal::Storage<T,Storage> StorageType;
|
||||
|
||||
public:
|
||||
template <typename DeviceAdapter>
|
||||
struct ExecutionTypes
|
||||
{
|
||||
private:
|
||||
typedef vtkm::cont::internal::ArrayTransfer<T,Container,DeviceAdapter>
|
||||
typedef vtkm::cont::internal::ArrayTransfer<T,Storage,DeviceAdapter>
|
||||
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<typename T,
|
||||
typename Container,
|
||||
typename Storage,
|
||||
typename DeviceAdapter>
|
||||
class ArrayHandleExecutionManager
|
||||
: public ArrayHandleExecutionManagerBase<T, Container>
|
||||
: public ArrayHandleExecutionManagerBase<T, Storage>
|
||||
{
|
||||
typedef ArrayHandleExecutionManagerBase<T, Container> Superclass;
|
||||
typedef vtkm::cont::internal::ArrayTransfer<T,Container,DeviceAdapter>
|
||||
typedef ArrayHandleExecutionManagerBase<T, Storage> Superclass;
|
||||
typedef vtkm::cont::internal::ArrayTransfer<T,Storage,DeviceAdapter>
|
||||
ArrayTransferType;
|
||||
typedef vtkm::cont::internal::ArrayContainerControl<T,Container> ContainerType;
|
||||
typedef vtkm::cont::internal::Storage<T,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);
|
||||
}
|
||||
|
@ -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<typename T, class ArrayContainerControlTag, class DeviceAdapterTag>
|
||||
template<typename T, class StorageTag, class DeviceAdapterTag>
|
||||
class ArrayManagerExecution
|
||||
#ifdef VTKM_DOXYGEN_ONLY
|
||||
{
|
||||
private:
|
||||
typedef vtkm::cont::internal::ArrayContainerControl<T,ArrayContainerControlTag>
|
||||
ContainerType;
|
||||
typedef vtkm::cont::internal::Storage<T,StorageTag> 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.
|
||||
///
|
||||
|
@ -28,15 +28,14 @@ namespace vtkm {
|
||||
namespace cont {
|
||||
namespace internal {
|
||||
|
||||
template <typename T, class ArrayContainerControlTag>
|
||||
class ArrayManagerExecution
|
||||
<T, ArrayContainerControlTag, vtkm::cont::DeviceAdapterTagSerial>
|
||||
template <typename T, class StorageTag>
|
||||
class ArrayManagerExecution<T, StorageTag, vtkm::cont::DeviceAdapterTagSerial>
|
||||
: public vtkm::cont::internal::ArrayManagerExecutionShareWithControl
|
||||
<T, ArrayContainerControlTag>
|
||||
<T, StorageTag>
|
||||
{
|
||||
public:
|
||||
typedef vtkm::cont::internal::ArrayManagerExecutionShareWithControl
|
||||
<T, ArrayContainerControlTag> Superclass;
|
||||
<T, StorageTag> Superclass;
|
||||
typedef typename Superclass::ValueType ValueType;
|
||||
typedef typename Superclass::PortalType PortalType;
|
||||
typedef typename Superclass::PortalConstType PortalConstType;
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <vtkm/cont/Assert.h>
|
||||
#include <vtkm/cont/ArrayContainerControl.h>
|
||||
#include <vtkm/cont/Storage.h>
|
||||
|
||||
#include <vtkm/cont/internal/ArrayPortalShrink.h>
|
||||
|
||||
#include <algorithm>
|
||||
@ -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<typename T, class ArrayContainerControlTag>
|
||||
template<typename T, class StorageTag>
|
||||
class ArrayManagerExecutionShareWithControl
|
||||
{
|
||||
public:
|
||||
typedef T ValueType;
|
||||
typedef vtkm::cont::internal
|
||||
::ArrayContainerControl<ValueType, ArrayContainerControlTag>
|
||||
ContainerType;
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> 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<T, ArrayContainerControlTag> &);
|
||||
ArrayManagerExecutionShareWithControl<T, StorageTag> &);
|
||||
void operator=(
|
||||
ArrayManagerExecutionShareWithControl<T, ArrayContainerControlTag> &);
|
||||
ArrayManagerExecutionShareWithControl<T, StorageTag> &);
|
||||
|
||||
PortalType Portal;
|
||||
bool PortalValid;
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef vtk_m_cont_internal_ArrayTransfer_h
|
||||
#define vtk_m_cont_internal_ArrayTransfer_h
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControl.h>
|
||||
#include <vtkm/cont/Storage.h>
|
||||
#include <vtkm/cont/internal/ArrayManagerExecution.h>
|
||||
|
||||
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<typename T, class ArrayContainerControlTag, class DeviceAdapterTag>
|
||||
template<typename T, class StorageTag, class DeviceAdapterTag>
|
||||
class ArrayTransfer
|
||||
{
|
||||
private:
|
||||
typedef vtkm::cont::internal::ArrayContainerControl<T,ArrayContainerControlTag>
|
||||
ContainerType;
|
||||
typedef vtkm::cont::internal::Storage<T,StorageTag> 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);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ set(headers
|
||||
IteratorFromArrayPortal.h
|
||||
PointCoordinatesBase.h
|
||||
SimplePolymorphicContainer.h
|
||||
StorageError.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
||||
|
@ -188,18 +188,18 @@ struct DeviceAdapterAlgorithm
|
||||
/// Sorts the contents of \c values so that they in ascending value. Doesn't
|
||||
/// guarantee stability
|
||||
///
|
||||
template<typename T, class Container>
|
||||
template<typename T, class Storage>
|
||||
VTKM_CONT_EXPORT static void Sort(
|
||||
vtkm::cont::ArrayHandle<T,Container,DeviceAdapterTag> &values);
|
||||
vtkm::cont::ArrayHandle<T,Storage,DeviceAdapterTag> &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<typename T, class Container, class Compare>
|
||||
template<typename T, class Storage, class Compare>
|
||||
VTKM_CONT_EXPORT static void Sort(
|
||||
vtkm::cont::ArrayHandle<T,Container,DeviceAdapterTag> &values,
|
||||
vtkm::cont::ArrayHandle<T,Storage,DeviceAdapterTag> &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<typename T, class Container>
|
||||
template<typename T, class Storage>
|
||||
VTKM_CONT_EXPORT static void Unique(
|
||||
vtkm::cont::ArrayHandle<T,Container,DeviceAdapterTag>& values);
|
||||
vtkm::cont::ArrayHandle<T,Storage,DeviceAdapterTag>& 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<typename T, class Container, class Compare>
|
||||
template<typename T, class Storage, class Compare>
|
||||
VTKM_CONT_EXPORT static void Unique(
|
||||
vtkm::cont::ArrayHandle<T,Container,DeviceAdapterTag>& values,
|
||||
vtkm::cont::ArrayHandle<T,Storage,DeviceAdapterTag>& 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));
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/ArrayContainerControlBasic.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
|
||||
#include <vtkm/exec/FunctorBase.h>
|
||||
|
||||
@ -111,7 +111,7 @@ private:
|
||||
vtkm::Id index)
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<T,CIn> InputArrayType;
|
||||
typedef vtkm::cont::ArrayHandle<T,vtkm::cont::ArrayContainerControlTagBasic>
|
||||
typedef vtkm::cont::ArrayHandle<T,vtkm::cont::StorageTagBasic>
|
||||
OutputArrayType;
|
||||
|
||||
OutputArrayType output;
|
||||
@ -353,7 +353,7 @@ public:
|
||||
const vtkm::cont::ArrayHandle<T,CIn> &input,
|
||||
vtkm::cont::ArrayHandle<T,COut>& output)
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<T,vtkm::cont::ArrayContainerControlTagBasic>
|
||||
typedef vtkm::cont::ArrayHandle<T,vtkm::cont::StorageTagBasic>
|
||||
TempArrayType;
|
||||
typedef vtkm::cont::ArrayHandle<T,COut> OutputArrayType;
|
||||
|
||||
@ -553,12 +553,12 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
template<typename T, class Container, class CompareType>
|
||||
template<typename T, class Storage, class CompareType>
|
||||
VTKM_CONT_EXPORT static void Sort(
|
||||
vtkm::cont::ArrayHandle<T,Container> &values,
|
||||
vtkm::cont::ArrayHandle<T,Storage> &values,
|
||||
CompareType compare)
|
||||
{
|
||||
typedef typename vtkm::cont::ArrayHandle<T,Container> ArrayType;
|
||||
typedef typename vtkm::cont::ArrayHandle<T,Storage> ArrayType;
|
||||
typedef typename ArrayType::template ExecutionTypes<DeviceAdapterTag>
|
||||
::Portal PortalType;
|
||||
|
||||
@ -588,9 +588,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, class Container>
|
||||
template<typename T, class Storage>
|
||||
VTKM_CONT_EXPORT static void Sort(
|
||||
vtkm::cont::ArrayHandle<T,Container> &values)
|
||||
vtkm::cont::ArrayHandle<T,Storage> &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<U,CStencil>
|
||||
@ -809,22 +809,22 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
template<typename T, class Container>
|
||||
template<typename T, class Storage>
|
||||
VTKM_CONT_EXPORT static void Unique(
|
||||
vtkm::cont::ArrayHandle<T,Container> &values)
|
||||
vtkm::cont::ArrayHandle<T,Storage> &values)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::ArrayContainerControlTagBasic>
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic>
|
||||
stencilArray;
|
||||
vtkm::Id inputSize = values.GetNumberOfValues();
|
||||
|
||||
ClassifyUniqueKernel<
|
||||
typename vtkm::cont::ArrayHandle<T,Container>::template ExecutionTypes<DeviceAdapterTag>::PortalConst,
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Id,vtkm::cont::ArrayContainerControlTagBasic>::template ExecutionTypes<DeviceAdapterTag>::Portal>
|
||||
typename vtkm::cont::ArrayHandle<T,Storage>::template ExecutionTypes<DeviceAdapterTag>::PortalConst,
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Id,vtkm::cont::StorageTagBasic>::template ExecutionTypes<DeviceAdapterTag>::Portal>
|
||||
classifyKernel(values.PrepareForInput(DeviceAdapterTag()),
|
||||
stencilArray.PrepareForOutput(inputSize, DeviceAdapterTag()));
|
||||
DerivedAlgorithm::Schedule(classifyKernel, inputSize);
|
||||
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::ArrayContainerControlTagBasic>
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>
|
||||
outputArray;
|
||||
|
||||
DerivedAlgorithm::StreamCompact(values, stencilArray, outputArray);
|
||||
@ -832,25 +832,25 @@ public:
|
||||
DerivedAlgorithm::Copy(outputArray, values);
|
||||
}
|
||||
|
||||
template<typename T, class Container, class Compare>
|
||||
template<typename T, class Storage, class Compare>
|
||||
VTKM_CONT_EXPORT static void Unique(
|
||||
vtkm::cont::ArrayHandle<T,Container> &values,
|
||||
vtkm::cont::ArrayHandle<T,Storage> &values,
|
||||
Compare comp)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::ArrayContainerControlTagBasic>
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic>
|
||||
stencilArray;
|
||||
vtkm::Id inputSize = values.GetNumberOfValues();
|
||||
|
||||
ClassifyUniqueComparisonKernel<
|
||||
typename vtkm::cont::ArrayHandle<T,Container>::template ExecutionTypes<DeviceAdapterTag>::PortalConst,
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Id,vtkm::cont::ArrayContainerControlTagBasic>::template ExecutionTypes<DeviceAdapterTag>::Portal,
|
||||
typename vtkm::cont::ArrayHandle<T,Storage>::template ExecutionTypes<DeviceAdapterTag>::PortalConst,
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Id,vtkm::cont::StorageTagBasic>::template ExecutionTypes<DeviceAdapterTag>::Portal,
|
||||
Compare>
|
||||
classifyKernel(values.PrepareForInput(DeviceAdapterTag()),
|
||||
stencilArray.PrepareForOutput(inputSize, DeviceAdapterTag()),
|
||||
comp);
|
||||
DerivedAlgorithm::Schedule(classifyKernel, inputSize);
|
||||
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::ArrayContainerControlTagBasic>
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>
|
||||
outputArray;
|
||||
|
||||
DerivedAlgorithm::StreamCompact(values, stencilArray, outputArray);
|
||||
|
@ -156,21 +156,21 @@ public:
|
||||
rangeMax[0] * rangeMax[1] * rangeMax[2] );
|
||||
}
|
||||
|
||||
template<typename T, class Container>
|
||||
VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle<T,Container>& values)
|
||||
template<typename T, class Storage>
|
||||
VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle<T,Storage>& values)
|
||||
{
|
||||
typedef typename vtkm::cont::ArrayHandle<T,Container>
|
||||
typedef typename vtkm::cont::ArrayHandle<T,Storage>
|
||||
::template ExecutionTypes<Device>::Portal PortalType;
|
||||
|
||||
PortalType arrayPortal = values.PrepareForInPlace(Device());
|
||||
std::sort(arrayPortal.GetIteratorBegin(), arrayPortal.GetIteratorEnd());
|
||||
}
|
||||
|
||||
template<typename T, class Container, class Compare>
|
||||
VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle<T,Container>& values,
|
||||
template<typename T, class Storage, class Compare>
|
||||
VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle<T,Storage>& values,
|
||||
Compare comp)
|
||||
{
|
||||
typedef typename vtkm::cont::ArrayHandle<T,Container>
|
||||
typedef typename vtkm::cont::ArrayHandle<T,Storage>
|
||||
::template ExecutionTypes<Device>::Portal PortalType;
|
||||
|
||||
PortalType arrayPortal = values.PrepareForInPlace(Device());
|
||||
|
@ -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
|
@ -20,7 +20,8 @@
|
||||
|
||||
#include <vtkm/cont/internal/ArrayManagerExecutionShareWithControl.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlBasic.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <algorithm>
|
||||
@ -33,14 +34,14 @@ const vtkm::Id ARRAY_SIZE = 10;
|
||||
template <typename T>
|
||||
struct TemplatedTests
|
||||
{
|
||||
typedef vtkm::cont::internal::ArrayManagerExecutionShareWithControl
|
||||
<T, vtkm::cont::ArrayContainerControlTagBasic>
|
||||
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<T, vtkm::cont::StorageTagBasic>
|
||||
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()()
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
@ -20,10 +20,10 @@
|
||||
#ifndef vtk_m_cont_testing_TestingDeviceAdapter_h
|
||||
#define vtk_m_cont_testing_TestingDeviceAdapter_h
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlBasic.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ErrorControlOutOfMemory.h>
|
||||
#include <vtkm/cont/ErrorExecution.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
#include <vtkm/cont/Timer.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterAlgorithm.h>
|
||||
|
||||
@ -114,27 +114,26 @@ template<class DeviceAdapterTag>
|
||||
struct TestingDeviceAdapter
|
||||
{
|
||||
private:
|
||||
typedef vtkm::cont::ArrayContainerControlTagBasic ArrayContainerControlTag;
|
||||
typedef vtkm::cont::StorageTagBasic StorageTag;
|
||||
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Id, ArrayContainerControlTag>
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Id, StorageTag>
|
||||
IdArrayHandle;
|
||||
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Scalar,ArrayContainerControlTag>
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Scalar,StorageTag>
|
||||
ScalarArrayHandle;
|
||||
|
||||
typedef vtkm::cont::internal::ArrayManagerExecution<
|
||||
vtkm::Id, ArrayContainerControlTag, DeviceAdapterTag>
|
||||
vtkm::Id, StorageTag, DeviceAdapterTag>
|
||||
IdArrayManagerExecution;
|
||||
|
||||
typedef vtkm::cont::internal::ArrayContainerControl<vtkm::Id,
|
||||
ArrayContainerControlTag> IdContainer;
|
||||
typedef vtkm::cont::internal::Storage<vtkm::Id, StorageTag> IdStorage;
|
||||
|
||||
typedef typename IdArrayHandle::template ExecutionTypes<DeviceAdapterTag>
|
||||
::Portal IdPortalType;
|
||||
typedef typename IdArrayHandle::template ExecutionTypes<DeviceAdapterTag>
|
||||
::PortalConst IdPortalConstType;
|
||||
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Vector3,ArrayContainerControlTag>
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Vector3,StorageTag>
|
||||
Vector3ArrayHandle;
|
||||
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>
|
||||
@ -315,21 +314,21 @@ private:
|
||||
|
||||
template<typename T>
|
||||
static VTKM_CONT_EXPORT
|
||||
vtkm::cont::ArrayHandle<T, ArrayContainerControlTagBasic>
|
||||
vtkm::cont::ArrayHandle<T, StorageTagBasic>
|
||||
MakeArrayHandle(const T *array, vtkm::Id length)
|
||||
{
|
||||
return vtkm::cont::make_ArrayHandle(array,
|
||||
length,
|
||||
ArrayContainerControlTagBasic());
|
||||
StorageTagBasic());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static VTKM_CONT_EXPORT
|
||||
vtkm::cont::ArrayHandle<T, ArrayContainerControlTagBasic>
|
||||
vtkm::cont::ArrayHandle<T, StorageTagBasic>
|
||||
MakeArrayHandle(const std::vector<T>& 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<GridType,ArrayContainerControlTagBasic>
|
||||
// vtkm::cont::testing::TestGrid<GridType,StorageTagBasic>
|
||||
// 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<GridType,ArrayContainerControlTagBasic>
|
||||
// vtkm::cont::testing::TestGrid<GridType,StorageTagBasic>
|
||||
// grid(DIM);
|
||||
|
||||
// std::cout << "Running field map worklet that errors" << std::endl;
|
||||
@ -1201,7 +1200,7 @@ private:
|
||||
// template<typename GridType>
|
||||
// static VTKM_CONT_EXPORT void TestWorkletMapCellImpl()
|
||||
// {
|
||||
// vtkm::cont::testing::TestGrid<GridType,ArrayContainerControlTagBasic>
|
||||
// vtkm::cont::testing::TestGrid<GridType,StorageTagBasic>
|
||||
// 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<GridType,ArrayContainerControlTagBasic>
|
||||
// vtkm::cont::testing::TestGrid<GridType,StorageTagBasic>
|
||||
// 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());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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 <vtkm/cont/ArrayHandle.h>
|
||||
|
@ -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 <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||
|
||||
#include <vtkm/VectorTraits.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlBasic.h>
|
||||
#include <vtkm/cont/DeviceAdapterSerial.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
@ -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<typename ValueType>
|
||||
vtkm::cont::ArrayHandle<ValueType, Container>
|
||||
vtkm::cont::ArrayHandle<ValueType, StorageTag>
|
||||
MakeInputArray(int arrayId)
|
||||
{
|
||||
typedef vtkm::VectorTraits<ValueType> VTraits;
|
||||
@ -66,9 +66,9 @@ MakeInputArray(int arrayId)
|
||||
}
|
||||
|
||||
// Make an array handle that points to this buffer.
|
||||
typedef vtkm::cont::ArrayHandle<ValueType, Container> ArrayHandleType;
|
||||
typedef vtkm::cont::ArrayHandle<ValueType, StorageTag> 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<ValueType,C> &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<ValueType, Container> ArrayHandleType;
|
||||
typedef vtkm::cont::ArrayHandle<ValueType, StorageTag> ArrayHandleType;
|
||||
ArrayHandleType arrayCopy;
|
||||
vtkm::cont::DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>::Copy(
|
||||
outArray, arrayCopy);
|
||||
@ -120,7 +120,7 @@ void TryScalarArray()
|
||||
<< inComponents << " components." << std::endl;
|
||||
|
||||
typedef vtkm::Tuple<vtkm::Scalar,inComponents> InValueType;
|
||||
typedef vtkm::cont::ArrayHandle<InValueType, Container> InArrayType;
|
||||
typedef vtkm::cont::ArrayHandle<InValueType, StorageTag> InArrayType;
|
||||
int inArrayId = 0;
|
||||
InArrayType inArray = MakeInputArray<InValueType>(inArrayId);
|
||||
|
||||
@ -137,10 +137,10 @@ void TryScalarArray()
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3, typename T4>
|
||||
void TryVector4(vtkm::cont::ArrayHandle<T1,Container> array1,
|
||||
vtkm::cont::ArrayHandle<T2,Container> array2,
|
||||
vtkm::cont::ArrayHandle<T3,Container> array3,
|
||||
vtkm::cont::ArrayHandle<T4,Container> array4)
|
||||
void TryVector4(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
|
||||
vtkm::cont::ArrayHandle<T2,StorageTag> array2,
|
||||
vtkm::cont::ArrayHandle<T3,StorageTag> array3,
|
||||
vtkm::cont::ArrayHandle<T4,StorageTag> array4)
|
||||
{
|
||||
int arrayIds[4] = {0, 1, 2, 3};
|
||||
int inComponents[4];
|
||||
@ -176,9 +176,9 @@ void TryVector4(vtkm::cont::ArrayHandle<T1,Container> array1,
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
void TryVector3(vtkm::cont::ArrayHandle<T1,Container> array1,
|
||||
vtkm::cont::ArrayHandle<T2,Container> array2,
|
||||
vtkm::cont::ArrayHandle<T3,Container> array3)
|
||||
void TryVector3(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
|
||||
vtkm::cont::ArrayHandle<T2,StorageTag> array2,
|
||||
vtkm::cont::ArrayHandle<T3,StorageTag> array3)
|
||||
{
|
||||
int arrayIds[3] = {0, 1, 2};
|
||||
int inComponents[3];
|
||||
@ -213,8 +213,8 @@ void TryVector3(vtkm::cont::ArrayHandle<T1,Container> array1,
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
void TryVector2(vtkm::cont::ArrayHandle<T1,Container> array1,
|
||||
vtkm::cont::ArrayHandle<T2,Container> array2)
|
||||
void TryVector2(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
|
||||
vtkm::cont::ArrayHandle<T2,StorageTag> array2)
|
||||
{
|
||||
int arrayIds[2] = {0, 1};
|
||||
int inComponents[2];
|
||||
@ -243,7 +243,7 @@ void TryVector2(vtkm::cont::ArrayHandle<T1,Container> array1,
|
||||
}
|
||||
|
||||
template<typename T1>
|
||||
void TryVector1(vtkm::cont::ArrayHandle<T1,Container> array1)
|
||||
void TryVector1(vtkm::cont::ArrayHandle<T1,StorageTag> 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<vtkm::Scalar, Container> InArrayType;
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Scalar, StorageTag> InArrayType;
|
||||
InArrayType longInArray = MakeInputArray<vtkm::Scalar>(0);
|
||||
InArrayType shortInArray = MakeInputArray<vtkm::Scalar>(1);
|
||||
shortInArray.Shrink(ARRAY_SIZE/2);
|
||||
|
@ -77,17 +77,15 @@ public:
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename T, class ArrayContainerControlTag>
|
||||
template <typename T, class StorageTag>
|
||||
class ArrayManagerExecution
|
||||
<T,
|
||||
ArrayContainerControlTag,
|
||||
vtkm::cont::DeviceAdapterTagTestAlgorithmGeneral>
|
||||
<T, StorageTag, vtkm::cont::DeviceAdapterTagTestAlgorithmGeneral>
|
||||
: public vtkm::cont::internal::ArrayManagerExecution
|
||||
<T, ArrayContainerControlTag, vtkm::cont::DeviceAdapterTagSerial>
|
||||
<T, StorageTag, vtkm::cont::DeviceAdapterTagSerial>
|
||||
{
|
||||
public:
|
||||
typedef vtkm::cont::internal::ArrayManagerExecution
|
||||
<T, ArrayContainerControlTag, vtkm::cont::DeviceAdapterTagSerial>
|
||||
<T, StorageTag, vtkm::cont::DeviceAdapterTagSerial>
|
||||
Superclass;
|
||||
typedef typename Superclass::ValueType ValueType;
|
||||
typedef typename Superclass::PortalType PortalType;
|
||||
|
@ -21,7 +21,8 @@
|
||||
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlImplicit.h>
|
||||
#include <vtkm/cont/StorageImplicit.h>
|
||||
|
||||
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -85,35 +86,35 @@ struct UnusualPortal
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class ArrayHandleWithUnusualContainer
|
||||
: public vtkm::cont::ArrayHandle<T, vtkm::cont::ArrayContainerControlTagImplicit<UnusualPortal<T> > >
|
||||
class ArrayHandleWithUnusualStorage
|
||||
: public vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagImplicit<UnusualPortal<T> > >
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<T, vtkm::cont::ArrayContainerControlTagImplicit<UnusualPortal<T> > >
|
||||
typedef vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagImplicit<UnusualPortal<T> > >
|
||||
Superclass;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
ArrayHandleWithUnusualContainer()
|
||||
ArrayHandleWithUnusualStorage()
|
||||
: Superclass(typename Superclass::PortalConstControl()) { }
|
||||
};
|
||||
|
||||
struct ContainerListTagUnusual :
|
||||
struct StorageListTagUnusual :
|
||||
vtkm::ListTagBase2<
|
||||
ArrayHandleWithUnusualContainer<vtkm::Id>::ArrayContainerControlTag,
|
||||
ArrayHandleWithUnusualContainer<std::string>::ArrayContainerControlTag>
|
||||
ArrayHandleWithUnusualStorage<vtkm::Id>::StorageTag,
|
||||
ArrayHandleWithUnusualStorage<std::string>::StorageTag>
|
||||
{ };
|
||||
|
||||
bool CheckCalled;
|
||||
|
||||
struct CheckFunctor
|
||||
{
|
||||
template<typename T, typename Container>
|
||||
void operator()(vtkm::cont::ArrayHandle<T, Container> array) const {
|
||||
template<typename T, typename Storage>
|
||||
void operator()(vtkm::cont::ArrayHandle<T, Storage> array) const {
|
||||
CheckCalled = true;
|
||||
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE,
|
||||
"Unexpected array size.");
|
||||
|
||||
typename vtkm::cont::ArrayHandle<T,Container>::PortalConstControl portal =
|
||||
typename vtkm::cont::ArrayHandle<T,Storage>::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<vtkm::Id>();
|
||||
ArrayHandleWithUnusualStorage<vtkm::Id>();
|
||||
|
||||
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<std::string>();
|
||||
ArrayHandleWithUnusualStorage<std::string>();
|
||||
|
||||
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
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
#include <vtkm/cont/DynamicPointCoordinates.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlImplicit.h>
|
||||
#include <vtkm/cont/ContainerListTag.h>
|
||||
#include <vtkm/cont/StorageImplicit.h>
|
||||
#include <vtkm/cont/StorageListTag.h>
|
||||
|
||||
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
|
||||
|
||||
@ -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<typename Container>
|
||||
template<typename Storage>
|
||||
void operator()(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vector3,Container> &array) const
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vector3,Storage> &array) const
|
||||
{
|
||||
std::cout << " In CastAndCall functor" << std::endl;
|
||||
g_CheckArrayInvocations++;
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Vector3,Container>::PortalConstControl portal =
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Vector3,Storage>::PortalConstControl portal =
|
||||
array.GetPortalConstControl();
|
||||
|
||||
VTKM_TEST_ASSERT(portal.GetNumberOfValues() == ARRAY_SIZE,
|
||||
@ -100,27 +100,27 @@ struct UnusualPortal
|
||||
}
|
||||
};
|
||||
|
||||
class ArrayHandleWithUnusualContainer
|
||||
: public vtkm::cont::ArrayHandle<vtkm::Vector3, vtkm::cont::ArrayContainerControlTagImplicit<UnusualPortal> >
|
||||
class ArrayHandleWithUnusualStorage
|
||||
: public vtkm::cont::ArrayHandle<vtkm::Vector3, vtkm::cont::StorageTagImplicit<UnusualPortal> >
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Vector3, vtkm::cont::ArrayContainerControlTagImplicit<UnusualPortal> >
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Vector3, vtkm::cont::StorageTagImplicit<UnusualPortal> >
|
||||
Superclass;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
ArrayHandleWithUnusualContainer()
|
||||
ArrayHandleWithUnusualStorage()
|
||||
: Superclass(Superclass::PortalConstControl()) { }
|
||||
};
|
||||
|
||||
struct ContainerListTagUnusual :
|
||||
vtkm::ListTagBase<ArrayHandleWithUnusualContainer::ArrayContainerControlTag>
|
||||
struct StorageListTagUnusual :
|
||||
vtkm::ListTagBase<ArrayHandleWithUnusualStorage::StorageTag>
|
||||
{ };
|
||||
|
||||
struct PointCoordinatesUnusual : vtkm::cont::internal::PointCoordinatesBase
|
||||
{
|
||||
template<typename Functor, typename TypeList, typename ContainerList>
|
||||
void CastAndCall(const Functor &f, TypeList, ContainerList) const
|
||||
template<typename Functor, typename TypeList, typename StorageList>
|
||||
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<vtkm::Vector3> 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();
|
||||
}
|
||||
|
@ -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 <vtkm/cont/PointCoordinatesArray.h>
|
||||
#include <vtkm/cont/PointCoordinatesUniform.h>
|
||||
@ -32,8 +32,8 @@
|
||||
#include <vtkm/Extent.h>
|
||||
#include <vtkm/TypeListTag.h>
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlBasic.h>
|
||||
#include <vtkm/cont/DeviceAdapterSerial.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
@ -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<vtkm::Vector3,Container> array =
|
||||
vtkm::cont::make_ArrayHandle(buffer, Container());
|
||||
vtkm::cont::ArrayHandle<vtkm::Vector3,StorageTag> 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()
|
||||
|
@ -18,9 +18,9 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#define VTKM_ARRAY_CONTAINER_CONTROL VTKM_ARRAY_CONTAINER_CONTROL_ERROR
|
||||
#define VTKM_STORAGE VTKM_STORAGE_ERROR
|
||||
|
||||
#include <vtkm/cont/ArrayContainerControlBasic.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/VectorTraits.h>
|
||||
@ -32,13 +32,13 @@ const vtkm::Id ARRAY_SIZE = 10;
|
||||
template <typename T>
|
||||
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<T, vtkm::cont::StorageTagBasic>
|
||||
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);
|
||||
}
|
@ -18,29 +18,31 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#define VTKM_ARRAY_CONTAINER_CONTROL VTKM_ARRAY_CONTAINER_CONTROL_ERROR
|
||||
#define VTKM_STORAGE VTKM_STORAGE_ERROR
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/cont/ArrayContainerControlImplicit.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/VectorTraits.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/StorageImplicit.h>
|
||||
|
||||
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
struct TestImplicitContainer
|
||||
struct TestImplicitStorage
|
||||
{
|
||||
typedef T ValueType;
|
||||
ValueType Temp;
|
||||
typedef vtkm::cont::internal::IteratorFromArrayPortal<
|
||||
TestImplicitContainer<T> > IteratorType;
|
||||
TestImplicitStorage<T> > 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 <typename T>
|
||||
struct TemplatedTests
|
||||
{
|
||||
typedef vtkm::cont::ArrayContainerControlTagImplicit<
|
||||
TestImplicitContainer<T> > ContainerTagType;
|
||||
typedef vtkm::cont::internal::ArrayContainerControl<
|
||||
T, ContainerTagType > ArrayContainerType;
|
||||
typedef vtkm::cont::StorageTagImplicit< TestImplicitStorage<T> >
|
||||
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<T> portal;
|
||||
vtkm::cont::ArrayHandle<T,ContainerTagType> implictHandle(portal);
|
||||
TestImplicitStorage<T> portal;
|
||||
vtkm::cont::ArrayHandle<T,StorageTagType> 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);
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/ContainerListTag.h>
|
||||
#include <vtkm/cont/StorageListTag.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
@ -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<TypeId,N> &expected, ListTag)
|
||||
|
||||
void TestLists()
|
||||
{
|
||||
std::cout << "ContainerListTagBasic" << std::endl;
|
||||
TryList(vtkm::Tuple<TypeId,1>(BASIC), vtkm::cont::ContainerListTagBasic());
|
||||
std::cout << "StorageListTagBasic" << std::endl;
|
||||
TryList(vtkm::Tuple<TypeId,1>(BASIC), vtkm::cont::StorageListTagBasic());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestContainerListTag(int, char *[])
|
||||
int UnitTestStorageListTag(int, char *[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestLists);
|
||||
}
|
Loading…
Reference in New Issue
Block a user