Remove type lists from ControlSignature arguments for arrays

The typelist arguments for ControlSignature tags are antiquated. Remove
them.
This commit is contained in:
Kenneth Moreland 2018-10-17 18:02:38 -06:00
parent ac61044422
commit 42f810f70e
8 changed files with 88 additions and 193 deletions

@ -0,0 +1,47 @@
# Remove templates from ControlSignature field tags
Previously, several of the `ControlSignature` tags had a template to specify a
type list. This was to specify potential valid value types for an input array.
The importance of this typelist was to limit the number of code paths created
when resolving a `vtkm::cont::DynamicArrayHandle`. This (potentially) reduced
the compile time, the size of libraries/executables, and errors from
unexpected types.
Much has changed since this feature was originally implemented. Since then,
the filter infrastructure has been created, and it is through this that
most dynamic worklet invocations happen. However, since the filter
infrastrcture does its own type resolution (and has its own policies) the
type arguments in `ControlSignature` are now of little value.
## Script to update code
This update requires changes to just about all code implementing a VTK-m
worklet. To facilitate the update of this code to these new changes (not to
mention all the code in VTK-m) a script is provided to automatically remove
these template parameters from VTK-m code.
*** Add information about script ***
## Change in executable size
The whole intention of these template parameters in the first place was to
reduce the number of code paths compiled. The hypothesis of this change was
that in the current structure the code paths were not being reduced much
if at all. If that is true, the size of executables and libraries should
not change.
Here is a recording of the library and executable sizes before this change
(using `ds -h`).
```
3.0M libvtkm_cont-1.2.1.dylib
6.2M libvtkm_rendering-1.2.1.dylib
312K Rendering_SERIAL
312K Rendering_TBB
22M Worklets_SERIAL
23M Worklets_TBB
22M UnitTests_vtkm_filter_testing
5.7M UnitTests_vtkm_cont_serial_testing
6.0M UnitTests_vtkm_cont_tbb_testing
7.1M UnitTests_vtkm_cont_testing
```

@ -36,39 +36,14 @@ namespace arg
/// The Array type check passes for any object that behaves like an \c
/// ArrayHandle class and can be passed to the ArrayIn and ArrayOut transports.
///
template <typename TypeList>
struct TypeCheckTagArray
{
VTKM_IS_LIST_TAG(TypeList);
};
namespace detail
template <typename ArrayType>
struct TypeCheck<TypeCheckTagArray, ArrayType>
{
template <typename TypeList, typename ArrayType, bool IsArray>
struct TypeCheckArrayValueType;
template <typename TypeList, typename ArrayType>
struct TypeCheckArrayValueType<TypeList, ArrayType, true>
{
static constexpr bool value = vtkm::ListContains<TypeList, typename ArrayType::ValueType>::value;
};
template <typename TypeList, typename ArrayType>
struct TypeCheckArrayValueType<TypeList, ArrayType, false>
{
static constexpr bool value = false;
};
} // namespace detail
template <typename TypeList, typename ArrayType>
struct TypeCheck<TypeCheckTagArray<TypeList>, ArrayType>
{
static constexpr bool value = detail::TypeCheckArrayValueType<
TypeList,
ArrayType,
vtkm::cont::internal::ArrayHandleCheck<ArrayType>::type::value>::value;
static constexpr bool value = vtkm::cont::internal::ArrayHandleCheck<ArrayType>::type::value;
};
}
}

@ -41,32 +41,24 @@ namespace arg
/// that is valid for atomic access. There are many restrictions on the
/// type of data that can be used for an atomic array.
///
template <typename TypeList = vtkm::cont::AtomicArrayTypeListTag>
struct TypeCheckTagAtomicArray
{
VTKM_IS_LIST_TAG(TypeList);
};
struct TypeCheckTagAtomicArray;
template <typename TypeList, typename ArrayType>
struct TypeCheck<TypeCheckTagAtomicArray<TypeList>, ArrayType>
template <typename ArrayType>
struct TypeCheck<TypeCheckTagAtomicArray, ArrayType>
{
static constexpr bool value = false;
};
template <typename T, typename TypeList>
struct TypeCheck<TypeCheckTagAtomicArray<TypeList>,
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>>
template <typename T>
struct TypeCheck<TypeCheckTagAtomicArray, vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>>
{
static constexpr bool value = (vtkm::ListContains<TypeList, T>::value &&
vtkm::ListContains<vtkm::cont::AtomicArrayTypeListTag, T>::value);
static constexpr bool value = vtkm::ListContains<vtkm::cont::AtomicArrayTypeListTag, T>::value;
};
template <typename T, typename TypeList>
struct TypeCheck<TypeCheckTagAtomicArray<TypeList>,
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagVirtual>>
template <typename T>
struct TypeCheck<TypeCheckTagAtomicArray, vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagVirtual>>
{
static constexpr bool value = (vtkm::ListContains<TypeList, T>::value &&
vtkm::ListContains<vtkm::cont::AtomicArrayTypeListTag, T>::value);
static constexpr bool value = vtkm::ListContains<vtkm::cont::AtomicArrayTypeListTag, T>::value;
};
}
}

@ -58,10 +58,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldIn : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayIn;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectIn;
};
@ -71,10 +70,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectOut;
};
@ -84,10 +82,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldInOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayInOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectInOut;
};

@ -78,10 +78,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldInTo : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagTopologyFieldIn<ToTopologyType>;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectIn;
};
@ -91,10 +90,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldInFrom : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagTopologyFieldIn<FromTopologyType>;
using FetchTag = vtkm::exec::arg::FetchTagArrayTopologyMapIn;
};
@ -104,10 +102,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectOut;
};
@ -117,10 +114,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldInOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayInOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectInOut;
};
@ -190,17 +186,13 @@ class WorkletMapPointToCell
: public WorkletMapTopology<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
{
public:
template <typename TypeList = AllTypes>
using FieldInPoint = FieldInFrom<TypeList>;
using FieldInPoint = FieldInFrom;
template <typename TypeList = AllTypes>
using FieldInCell = FieldInTo<TypeList>;
using FieldInCell = FieldInTo;
template <typename TypeList = AllTypes>
using FieldOutCell = FieldOut<TypeList>;
using FieldOutCell = FieldOut;
template <typename TypeList = AllTypes>
using FieldInOutCell = FieldInOut<TypeList>;
using FieldInOutCell = FieldInOut;
using PointCount = FromCount;
@ -213,17 +205,13 @@ class WorkletMapCellToPoint
: public WorkletMapTopology<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>
{
public:
template <typename TypeList = AllTypes>
using FieldInCell = FieldInFrom<TypeList>;
using FieldInCell = FieldInFrom;
template <typename TypeList = AllTypes>
using FieldInPoint = FieldInTo<TypeList>;
using FieldInPoint = FieldInTo;
template <typename TypeList = AllTypes>
using FieldOutPoint = FieldOut<TypeList>;
using FieldOutPoint = FieldOut;
template <typename TypeList = AllTypes>
using FieldInOutPoint = FieldInOut<TypeList>;
using FieldInOutPoint = FieldInOut;
using CellCount = FromCount;

@ -119,10 +119,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldIn : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayIn;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectIn;
};
@ -132,10 +131,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectOut;
};
@ -145,10 +143,9 @@ public:
/// This tag takes a template argument that is a type list tag that limits
/// the possible value types in the array.
///
template <typename TypeList = AllTypes>
struct FieldInOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayInOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectInOut;
};
@ -178,10 +175,9 @@ public:
/// This tag specifies an \c ArrayHandle object that holds the values. It is
/// an input array with entries for each point.
///
template <typename TypeList = AllTypes>
struct FieldInNeighborhood : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayIn;
using FetchTag = vtkm::exec::arg::FetchTagArrayNeighborhoodIn;
};

@ -77,10 +77,9 @@ public:
/// all values with a matching key. This tag specifies an \c ArrayHandle
/// object that holds the values.
///
template <typename TypeList = AllTypes>
struct ValuesIn : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagKeyedValuesIn;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectIn;
};
@ -94,10 +93,9 @@ public:
///
/// This tag might not work with scatter operations.
///
template <typename TypeList = AllTypes>
struct ValuesInOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagKeyedValuesInOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectIn;
};
@ -111,10 +109,9 @@ public:
///
/// This tag might not work with scatter operations.
///
template <typename TypeList = AllTypes>
struct ValuesOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagKeyedValuesOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectIn;
};
@ -129,10 +126,9 @@ public:
/// an input array with entries for each reduced value. This could be useful
/// to access values from a previous run of WorkletReduceByKey.
///
template <typename TypeList = AllTypes>
struct ReducedValuesIn : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayIn;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectIn;
};
@ -147,10 +143,9 @@ public:
/// an input/output array with entries for each reduced value. This could be
/// useful to access values from a previous run of WorkletReduceByKey.
///
template <typename TypeList = AllTypes>
struct ReducedValuesInOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayInOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectInOut;
};
@ -162,10 +157,9 @@ public:
/// then produces a "reduced" value per key. This tag specifies an \c
/// ArrayHandle object that holds the values.
///
template <typename TypeList = AllTypes>
struct ReducedValuesOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagArrayOut;
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectOut;
};

@ -129,96 +129,6 @@ public:
/// identity scatter (1-to-1 input to output).
using ScatterType = vtkm::worklet::ScatterIdentity;
/// \brief A type list containing the type vtkm::Id.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using IdType = vtkm::TypeListTagId;
/// \brief A type list containing the type vtkm::Id2.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using Id2Type = vtkm::TypeListTagId2;
/// \brief A type list containing the type vtkm::Id3.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using Id3Type = vtkm::TypeListTagId3;
/// \brief A type list containing the type vtkm::IdComponent.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using IdComponentType = vtkm::TypeListTagIdComponent;
/// \brief A list of types commonly used for indexing.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using Index = vtkm::TypeListTagIndex;
/// \brief A list of types commonly used for scalar fields.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using Scalar = vtkm::TypeListTagFieldScalar;
/// \brief A list of all basic types used for scalar fields.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using ScalarAll = vtkm::TypeListTagScalarAll;
/// \brief A list of types commonly used for vector fields of 2 components.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using Vec2 = vtkm::TypeListTagFieldVec2;
/// \brief A list of types commonly used for vector fields of 3 components.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using Vec3 = vtkm::TypeListTagFieldVec3;
/// \brief A list of types commonly used for vector fields of 4 components.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using Vec4 = vtkm::TypeListTagFieldVec4;
/// \brief A list of all basic types used for vector fields.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using VecAll = vtkm::TypeListTagVecAll;
/// \brief A list of types (scalar and vector) commonly used in fields.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using FieldCommon = vtkm::TypeListTagField;
/// \brief A list of vector types commonly used in fields.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using VecCommon = vtkm::TypeListTagVecCommon;
/// \brief A list of generally common types.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using CommonTypes = vtkm::TypeListTagCommon;
/// \brief A list of all basic types.
///
/// This is a convenience type to use as template arguments to \c
/// ControlSignature tags to specify the types of worklet arguments.
using AllTypes = vtkm::TypeListTagAll;
/// \c ControlSignature tag for whole input arrays.
///
/// The \c WholeArrayIn control signature tag specifies an \c ArrayHandle
@ -229,10 +139,9 @@ public:
/// The template operator specifies all the potential value types of the
/// array. The default value type is all types.
///
template <typename TypeList = AllTypes>
struct WholeArrayIn : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagWholeArrayIn;
using FetchTag = vtkm::exec::arg::FetchTagExecObject;
};
@ -248,10 +157,9 @@ public:
/// The template operator specifies all the potential value types of the
/// array. The default value type is all types.
///
template <typename TypeList = AllTypes>
struct WholeArrayOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagWholeArrayOut;
using FetchTag = vtkm::exec::arg::FetchTagExecObject;
};
@ -268,10 +176,9 @@ public:
/// The template operator specifies all the potential value types of the
/// array. The default value type is all types.
///
template <typename TypeList = AllTypes>
struct WholeArrayInOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
using TransportTag = vtkm::cont::arg::TransportTagWholeArrayInOut;
using FetchTag = vtkm::exec::arg::FetchTagExecObject;
};
@ -288,10 +195,9 @@ public:
/// The template operator specifies all the potential value types of the
/// array. The default value type is all types.
///
template <typename TypeList = AllTypes>
struct AtomicArrayInOut : vtkm::cont::arg::ControlSignatureTagBase
{
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagAtomicArray<TypeList>;
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagAtomicArray;
using TransportTag = vtkm::cont::arg::TransportTagAtomicArray;
using FetchTag = vtkm::exec::arg::FetchTagExecObject;
};