Merge topic 'faster_compile_times'

90099d1c Simplify ThreadIndicies so link time is reduced.
08b888f7 Improve the compile speed and binary output by tweaking FunctionInterface.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !400
This commit is contained in:
Robert Maynard 2016-05-04 16:34:49 -04:00 committed by Kitware Robot
commit 5502db999b
10 changed files with 470 additions and 229 deletions

@ -42,12 +42,11 @@ namespace arg {
class ThreadIndicesBasic
{
public:
template<typename Invocation>
VTKM_EXEC_EXPORT
ThreadIndicesBasic(vtkm::Id threadIndex, const Invocation &invocation)
: InputIndex(invocation.OutputToInputMap.Get(threadIndex)),
ThreadIndicesBasic(vtkm::Id threadIndex, vtkm::Id inIndex, vtkm::IdComponent visitIndex)
: InputIndex(inIndex),
OutputIndex(threadIndex),
VisitIndex(invocation.VisitArray.Get(threadIndex))
VisitIndex(visitIndex)
{
}

@ -72,10 +72,13 @@ public:
typedef typename ConnectivityType::IndicesType IndicesFromType;
typedef typename ConnectivityType::CellShapeTag CellShapeTag;
template<typename Invocation>
template<typename OutToInArrayType, typename VisitArrayType>
VTKM_EXEC_EXPORT
ThreadIndicesTopologyMap(vtkm::Id threadIndex, const Invocation &invocation)
: Superclass(threadIndex, invocation),
ThreadIndicesTopologyMap(vtkm::Id threadIndex,
const OutToInArrayType& inToOut,
const VisitArrayType& visit,
const ConnectivityType& connectivity)
: Superclass(threadIndex, inToOut.Get(threadIndex), visit.Get(threadIndex)),
CellShape(detail::CellShapeInitializer<CellShapeTag>::GetDefault())
{
// The connectivity is stored in the invocation parameter at the given
@ -83,8 +86,6 @@ public:
// of the domain will match the connectivity type used here. If there is
// a compile error here about a type mismatch, chances are a worklet has
// set its input domain incorrectly.
const ConnectivityType &connectivity = invocation.GetInputDomain();
this->IndicesFrom = connectivity.GetIndices(this->GetInputIndex());
this->CellShape = connectivity.GetCellShape(this->GetInputIndex());
}
@ -183,44 +184,39 @@ public:
typedef typename ConnectivityType::CellShapeTag CellShapeTag;
typedef typename ConnectivityType::SchedulingRangeType LogicalIndexType;
template<typename Invocation>
template<typename OutToInArrayType, typename VisitArrayType>
VTKM_EXEC_EXPORT
ThreadIndicesTopologyMap(vtkm::Id threadIndex, const Invocation &invocation)
ThreadIndicesTopologyMap(vtkm::Id threadIndex,
const OutToInArrayType& inToOut,
const VisitArrayType& visit,
const ConnectivityType& connectivity)
{
// The connectivity is stored in the invocation parameter at the given
// input domain index. If this class is being used correctly, the type
// of the domain will match the connectivity type used here. If there is
// a compile error here about a type mismatch, chances are a worklet has
// set its input domain incorrectly.
const ConnectivityType &connectivity = invocation.GetInputDomain();
this->InputIndex = invocation.OutputToInputMap.Get(threadIndex);
this->InputIndex = inToOut.Get(threadIndex);
this->OutputIndex = threadIndex;
this->VisitIndex = invocation.VisitArray.Get(threadIndex);
this->VisitIndex = visit.Get(threadIndex);
this->LogicalIndex = connectivity.FlatToLogicalToIndex(this->InputIndex);
this->IndicesFrom = connectivity.GetIndices(this->LogicalIndex);
this->CellShape = connectivity.GetCellShape(this->InputIndex);
}
template<typename Invocation>
template<typename OutToInArrayType, typename VisitArrayType>
VTKM_EXEC_EXPORT
ThreadIndicesTopologyMap(vtkm::Id3 threadIndex, const Invocation &invocation)
ThreadIndicesTopologyMap(const vtkm::Id3& threadIndex,
const OutToInArrayType&,
const VisitArrayType& visit,
const ConnectivityType& connectivity)
{
// The connectivity is stored in the invocation parameter at the given
// input domain index. If this class is being used correctly, the type
// of the domain will match the connectivity type used here. If there is
// a compile error here about a type mismatch, chances are a worklet has
// set its input domain incorrectly.
const ConnectivityType &connectivity = invocation.GetInputDomain();
// We currently only support multidimensional indices on one-to-one input-
// to-output mappings. (We don't have a use case otherwise.)
// that is why the OutToInArrayType is ignored
const LogicalIndexType logicalIndex =
detail::Deflate(threadIndex, LogicalIndexType());
const vtkm::Id index = connectivity.LogicalToFlatToIndex(logicalIndex);
// We currently only support multidimensional indices on one-to-one input-
// to-output mappings. (We don't have a use case otherwise.)
this->InputIndex = this->OutputIndex = index;
this->VisitIndex = invocation.VisitArray.Get(index);
this->InputIndex = index;
this->OutputIndex = index;
this->VisitIndex = visit.Get(index);
this->LogicalIndex = logicalIndex;
this->IndicesFrom = connectivity.GetIndices(logicalIndex);
this->CellShape = connectivity.GetCellShape(index);

@ -84,7 +84,11 @@ struct FetchArrayTopologyMapInTests
FetchType fetch;
ThreadIndicesType indices(0, invocation);
ThreadIndicesType indices(0,
invocation.OutputToInputMap,
invocation.VisitArray,
invocation.GetInputDomain()
);
typename FetchType::ValueType value = fetch.Load(
indices, invocation.Parameters.template GetParameter<ParamIndex>());
@ -175,14 +179,20 @@ void TryStructuredPointCoordinatesInvocation(const Invocation &invocation)
TestValue(1, vtkm::Vec<vtkm::FloatDefault,3>());
vtkm::VecRectilinearPointCoordinates<NumDimensions> value = fetch.Load(
ThreadIndicesType(0, invocation),
ThreadIndicesType(0,
invocation.OutputToInputMap,
invocation.VisitArray,
invocation.GetInputDomain()),
invocation.Parameters.template GetParameter<ParamIndex>());
VTKM_TEST_ASSERT(test_equal(value.GetOrigin(), origin), "Bad origin.");
VTKM_TEST_ASSERT(test_equal(value.GetSpacing(), spacing), "Bad spacing.");
origin[0] += spacing[0];
value = fetch.Load(
ThreadIndicesType(1, invocation),
ThreadIndicesType(1,
invocation.OutputToInputMap,
invocation.VisitArray,
invocation.GetInputDomain()),
invocation.Parameters.template GetParameter<ParamIndex>());
VTKM_TEST_ASSERT(test_equal(value.GetOrigin(), origin), "Bad origin.");
VTKM_TEST_ASSERT(test_equal(value.GetSpacing(), spacing), "Bad spacing.");

@ -56,8 +56,11 @@ public:
{
detail::DoWorkletInvokeFunctor(this->Worklet,
this->Invocation,
this->Worklet.GetThreadIndices(
index, this->Invocation));
this->Worklet.GetThreadIndices(index,
this->Invocation.OutputToInputMap,
this->Invocation.VisitArray,
this->Invocation.GetInputDomain())
);
}
private:

@ -181,12 +181,17 @@ struct TestWorkletProxy : vtkm::exec::FunctorBase
return input + 200;
}
template<typename Invocation>
template<typename T, typename OutToInArrayType, typename VisitArrayType, typename InputDomainType>
VTKM_EXEC_EXPORT
vtkm::exec::arg::ThreadIndicesBasic
GetThreadIndices(vtkm::Id threadIndex, const Invocation &invocation) const
GetThreadIndices(const T& threadIndex,
const OutToInArrayType& outToIn,
const VisitArrayType& visit,
const InputDomainType &) const
{
return vtkm::exec::arg::ThreadIndicesBasic(threadIndex, invocation);
return vtkm::exec::arg::ThreadIndicesBasic(threadIndex,
outToIn.Get(threadIndex),
visit.Get(threadIndex) );
}
};
@ -201,12 +206,17 @@ struct TestWorkletErrorProxy : vtkm::exec::FunctorBase
this->RaiseError(ERROR_MESSAGE);
}
template<typename Invocation>
template<typename T, typename OutToInArrayType, typename VisitArrayType, typename InputDomainType>
VTKM_EXEC_EXPORT
vtkm::exec::arg::ThreadIndicesBasic
GetThreadIndices(vtkm::Id threadIndex, const Invocation &invocation) const
GetThreadIndices(const T& threadIndex,
const OutToInArrayType& outToIn,
const VisitArrayType& visit,
const InputDomainType &) const
{
return vtkm::exec::arg::ThreadIndicesBasic(threadIndex, invocation);
return vtkm::exec::arg::ThreadIndicesBasic(threadIndex,
outToIn.Get(threadIndex),
visit.Get(threadIndex) );
}
};
@ -230,7 +240,10 @@ void CallDoWorkletInvokeFunctor(const Invocation &invocation, vtkm::Id index)
vtkm::exec::internal::detail::DoWorkletInvokeFunctor(
TestWorkletProxy(),
invocation,
vtkm::exec::arg::ThreadIndicesBasic(index, invocation));
vtkm::exec::arg::ThreadIndicesBasic(index,
invocation.OutputToInputMap.Get(index),
invocation.VisitArray.Get(index) )
);
}
void TestDoWorkletInvoke()

@ -39,6 +39,8 @@ VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/mpl/insert.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/single_view.hpp>
#include <boost/utility/enable_if.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
@ -61,21 +63,6 @@ struct IdentityFunctor {
const T &operator()(const T &x) const { return x; }
};
template<vtkm::IdComponent ParameterIndex, typename FunctionSignature>
VTKM_EXEC_CONT_EXPORT
const typename ParameterContainerAccess<ParameterIndex,FunctionSignature>::ParameterType &
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
return ParameterContainerAccess<ParameterIndex,FunctionSignature>::GetParameter(parameters);
}
template<vtkm::IdComponent ParameterIndex, typename FunctionSignature>
VTKM_EXEC_CONT_EXPORT
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const typename ParameterContainerAccess<ParameterIndex,FunctionSignature>::ParameterType &value) {
return ParameterContainerAccess<ParameterIndex,FunctionSignature>::SetParameter(parameters, value);
}
// These functions exist to help copy components of a FunctionInterface.
template<vtkm::IdComponent NumToCopy, vtkm::IdComponent ParameterIndex = 1>
@ -87,8 +74,8 @@ struct FunctionInterfaceCopyParameters {
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
vtkm::internal::detail::SetParameter<ParameterIndex>(
dest,vtkm::internal::detail::GetParameter<ParameterIndex>(src));
ParameterContainerAccess<ParameterIndex> pca;
pca.Set( dest, pca.Get(src) );
FunctionInterfaceCopyParameters<NumToCopy-1,ParameterIndex+1>::Copy(dest, src);
}
};
@ -273,12 +260,13 @@ public:
typedef typename boost::function_types::result_type<FunctionSignature>::type
ResultType;
typedef typename boost::function_types::components<FunctionSignature> FunctionSignatureComponents;
template<vtkm::IdComponent ParameterIndex>
struct ParameterType {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>,
ParameterIndex>::type type;
typedef typename detail::AtType<FunctionSignature, ParameterIndex>::type type;
};
static const bool RETURN_VALID = FunctionInterfaceReturnContainer<ResultType>::VALID;
/// The number of parameters in this \c Function Interface.
@ -351,7 +339,7 @@ public:
GetParameter(
vtkm::internal::IndexTag<ParameterIndex> =
vtkm::internal::IndexTag<ParameterIndex>()) const {
return detail::GetParameter<ParameterIndex>(this->Parameters);
return (detail::ParameterContainerAccess<ParameterIndex>()).Get(this->Parameters);
}
/// Sets the value for the parameter of the given index. Parameters are
@ -398,7 +386,7 @@ public:
vtkm::internal::IndexTag<ParameterIndex> =
vtkm::internal::IndexTag<ParameterIndex>())
{
detail::SetParameter<ParameterIndex>(this->Parameters, parameter);
return (detail::ParameterContainerAccess<ParameterIndex>()).Set(this->Parameters, parameter);
}
/// Copies the parameters and return values from the given \c
@ -411,9 +399,16 @@ public:
void Copy(const FunctionInterface<SrcFunctionSignature> &src)
{
this->Result = src.GetReturnValueSafe();
detail::FunctionInterfaceCopyParameters<
boost::static_unsigned_min<ARITY, FunctionInterface<SrcFunctionSignature>::ARITY>::value>::
Copy(this->Parameters, src.Parameters);
typedef boost::static_unsigned_min< ARITY,
FunctionInterface<SrcFunctionSignature>::ARITY > MinArity;
(detail::CopyAllParameters<MinArity::value>()).Copy(this->Parameters, src.Parameters);
}
void Copy(const FunctionInterface<FunctionSignature> &src)
{ //optimized version for assignment/copy
this->Result = src.GetReturnValueSafe();
this->Parameters = src.Parameters;
}
/// Invoke a function \c f using the arguments stored in this
@ -488,16 +483,15 @@ public:
template<typename NewType>
struct AppendType {
typedef FunctionInterface<
typename boost::function_types::function_type<
typename boost::mpl::push_back<
boost::function_types::components<FunctionSignature>,
NewType
>::type
>::type
> type;
private:
typedef boost::mpl::single_view<NewType> NewTypeSeq;
typedef boost::mpl::joint_view<FunctionSignatureComponents, NewTypeSeq> JointType;
typedef boost::function_types::function_type<JointType> FuntionType;
public:
typedef FunctionInterface< typename FuntionType::type > type;
};
/// Returns a new \c FunctionInterface with all the parameters of this \c
/// FunctionInterface and the given method argument appended to these
/// parameters. The return type can be determined with the \c AppendType
@ -506,8 +500,11 @@ public:
template<typename NewType>
VTKM_CONT_EXPORT
typename AppendType<NewType>::type
Append(const NewType& newParameter) const {
typename AppendType<NewType>::type appendedFuncInterface;
Append(const NewType& newParameter) const
{
typedef typename AppendType<NewType>::type AppendInterfaceType;
AppendInterfaceType appendedFuncInterface;
appendedFuncInterface.Copy(*this);
appendedFuncInterface.template SetParameter<ARITY+1>(newParameter);
return appendedFuncInterface;
@ -515,9 +512,8 @@ public:
template<vtkm::IdComponent ParameterIndex, typename NewType>
class ReplaceType {
typedef boost::function_types::components<FunctionSignature> ThisFunctionComponents;
typedef typename boost::mpl::advance_c<typename boost::mpl::begin<ThisFunctionComponents>::type, ParameterIndex>::type ToRemovePos;
typedef typename boost::mpl::erase<ThisFunctionComponents, ToRemovePos>::type ComponentRemoved;
typedef typename boost::mpl::advance_c<typename boost::mpl::begin<FunctionSignatureComponents>::type, ParameterIndex>::type ToRemovePos;
typedef typename boost::mpl::erase<FunctionSignatureComponents, ToRemovePos>::type ComponentRemoved;
typedef typename boost::mpl::advance_c<typename boost::mpl::begin<ComponentRemoved>::type, ParameterIndex>::type ToInsertPos;
typedef typename boost::mpl::insert<ComponentRemoved, ToInsertPos, NewType>::type ComponentInserted;
typedef typename boost::function_types::function_type<ComponentInserted>::type NewSignature;
@ -567,11 +563,16 @@ public:
typename ReplaceType<ParameterIndex, NewType>::type
Replace(const NewType& newParameter,
vtkm::internal::IndexTag<ParameterIndex> =
vtkm::internal::IndexTag<ParameterIndex>()) const {
vtkm::internal::IndexTag<ParameterIndex>()) const
{
typename ReplaceType<ParameterIndex, NewType>::type replacedFuncInterface;
detail::FunctionInterfaceCopyParameters<ParameterIndex-1>::
Copy(replacedFuncInterface.Parameters, this->Parameters);
replacedFuncInterface.template SetParameter<ParameterIndex>(newParameter);
detail::FunctionInterfaceCopyParameters<ARITY-ParameterIndex,ParameterIndex+1>::
Copy(replacedFuncInterface.Parameters, this->Parameters);
return replacedFuncInterface;
@ -803,8 +804,12 @@ public:
VTKM_CONT_EXPORT
void operator()(const T& newParameter) const
{
typedef typename vtkm::internal::FunctionInterface<NewFunction>::template AppendType<T>::type
NextInterfaceType;
typedef typename FunctionInterface<NewFunction>::FunctionSignatureComponents NewFSigComp;
typedef boost::mpl::single_view<T> NewTypeSeq;
typedef boost::mpl::joint_view<NewFSigComp, NewTypeSeq> JointType;
typedef boost::function_types::function_type<JointType> FuntionType;
typedef FunctionInterface< typename FuntionType::type > NextInterfaceType;
//Determine if we should do the next transform, and if so convert from
//boost mpl to boost::true_type/false_type ( for readability of sigs)

@ -223,241 +223,415 @@ struct ParameterContainer<R(P1,P2,P3,P4,P5,P6,P7,P8,P9,P10)> {
//============================================================================
template< typename FS, int Index>
struct AtType
{
typedef boost::function_types::components<FS> ParamterTypes;
typedef typename boost::mpl::at_c<ParamterTypes, Index>::type type;
};
template<int ParameterIndex, typename FunctionSignature>
//============================================================================
template<int ParameterIndex>
struct ParameterContainerAccess;
template<typename FunctionSignature>
struct ParameterContainerAccess<1, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 1>::type
ParameterType;
template<>
struct ParameterContainerAccess<1> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 1>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter1;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 1>::type &value) {
parameters.Parameter1 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<2, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 2>::type
ParameterType;
template<>
struct ParameterContainerAccess<2> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 2>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter2;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 2>::type &value) {
parameters.Parameter2 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<3, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 3>::type
ParameterType;
template<>
struct ParameterContainerAccess<3> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 3>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter3;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 3>::type &value) {
parameters.Parameter3 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<4, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 4>::type
ParameterType;
template<>
struct ParameterContainerAccess<4> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 4>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter4;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 4>::type &value) {
parameters.Parameter4 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<5, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 5>::type
ParameterType;
template<>
struct ParameterContainerAccess<5> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 5>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter5;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 5>::type &value) {
parameters.Parameter5 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<6, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 6>::type
ParameterType;
template<>
struct ParameterContainerAccess<6> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 6>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter6;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 6>::type &value) {
parameters.Parameter6 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<7, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 7>::type
ParameterType;
template<>
struct ParameterContainerAccess<7> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 7>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter7;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 7>::type &value) {
parameters.Parameter7 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<8, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 8>::type
ParameterType;
template<>
struct ParameterContainerAccess<8> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 8>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter8;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 8>::type &value) {
parameters.Parameter8 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<9, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 9>::type
ParameterType;
template<>
struct ParameterContainerAccess<9> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 9>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter9;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 9>::type &value) {
parameters.Parameter9 = value;
}
};
template<typename FunctionSignature>
struct ParameterContainerAccess<10, FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, 10>::type
ParameterType;
template<>
struct ParameterContainerAccess<10> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, 10>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter10;
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, 10>::type &value) {
parameters.Parameter10 = value;
}
};
//============================================================================
template<vtkm::IdComponent NumToCopy>
struct CopyAllParameters;
template<>
struct CopyAllParameters<1> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
}
};
template<>
struct CopyAllParameters<2> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
}
};
template<>
struct CopyAllParameters<3> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
dest.Parameter3 = src.Parameter3;
}
};
template<>
struct CopyAllParameters<4> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
dest.Parameter3 = src.Parameter3;
dest.Parameter4 = src.Parameter4;
}
};
template<>
struct CopyAllParameters<5> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
dest.Parameter3 = src.Parameter3;
dest.Parameter4 = src.Parameter4;
dest.Parameter5 = src.Parameter5;
}
};
template<>
struct CopyAllParameters<6> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
dest.Parameter3 = src.Parameter3;
dest.Parameter4 = src.Parameter4;
dest.Parameter5 = src.Parameter5;
dest.Parameter6 = src.Parameter6;
}
};
template<>
struct CopyAllParameters<7> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
dest.Parameter3 = src.Parameter3;
dest.Parameter4 = src.Parameter4;
dest.Parameter5 = src.Parameter5;
dest.Parameter6 = src.Parameter6;
dest.Parameter7 = src.Parameter7;
}
};
template<>
struct CopyAllParameters<8> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
dest.Parameter3 = src.Parameter3;
dest.Parameter4 = src.Parameter4;
dest.Parameter5 = src.Parameter5;
dest.Parameter6 = src.Parameter6;
dest.Parameter7 = src.Parameter7;
dest.Parameter8 = src.Parameter8;
}
};
template<>
struct CopyAllParameters<9> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
dest.Parameter3 = src.Parameter3;
dest.Parameter4 = src.Parameter4;
dest.Parameter5 = src.Parameter5;
dest.Parameter6 = src.Parameter6;
dest.Parameter7 = src.Parameter7;
dest.Parameter8 = src.Parameter8;
dest.Parameter9 = src.Parameter9;
}
};
template<>
struct CopyAllParameters<10> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
dest.Parameter1 = src.Parameter1;
dest.Parameter2 = src.Parameter2;
dest.Parameter3 = src.Parameter3;
dest.Parameter4 = src.Parameter4;
dest.Parameter5 = src.Parameter5;
dest.Parameter6 = src.Parameter6;
dest.Parameter7 = src.Parameter7;
dest.Parameter8 = src.Parameter8;
dest.Parameter9 = src.Parameter9;
dest.Parameter10 = src.Parameter10;
}
};
template<>
struct CopyAllParameters<0> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &)
{
// Nothing to copy.
}
};
//============================================================================
VTKM_SUPPRESS_EXEC_WARNINGS

@ -124,36 +124,79 @@ $endfor\
$endfor\
//============================================================================
template< typename FS, int Index>
struct AtType
{
typedef boost::function_types::components<FS> ParamterTypes;
typedef typename boost::mpl::at_c<ParamterTypes, Index>::type type;
};
template<int ParameterIndex, typename FunctionSignature>
//============================================================================
template<int ParameterIndex>
struct ParameterContainerAccess;
$for(param_index in range(1, max_parameters+1))\
template<typename FunctionSignature>
struct ParameterContainerAccess<$(param_index), FunctionSignature> {
typedef typename boost::mpl::at_c<
boost::function_types::components<FunctionSignature>, $(param_index)>::type
ParameterType;
template<>
struct ParameterContainerAccess<$(param_index)> {
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
const ParameterType&
GetParameter(const ParameterContainer<FunctionSignature> &parameters) {
const typename AtType<FunctionSignature, $(param_index)>::type &
Get(const ParameterContainer<FunctionSignature> &parameters) {
return parameters.Parameter$(param_index);
}
template<typename FunctionSignature>
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
static
void SetParameter(ParameterContainer<FunctionSignature> &parameters,
const ParameterType &value) {
void Set(ParameterContainer<FunctionSignature> &parameters,
const typename AtType<FunctionSignature, $(param_index)>::type &value) {
parameters.Parameter$(param_index) = value;
}
};
$endfor\
//============================================================================
template<vtkm::IdComponent NumToCopy>
struct CopyAllParameters;
$for(num_params in range(1, max_parameters+1))\
template<>
struct CopyAllParameters<$(num_params)> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &dest,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &src)
{
$for(param_index in range(1, num_params+1))\
dest.Parameter$(param_index) = src.Parameter$(param_index);
$endfor\
}
};
$endfor\
template<>
struct CopyAllParameters<0> {
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename DestSignature, typename SrcSignature>
VTKM_EXEC_CONT_EXPORT
void Copy(vtkm::internal::detail::ParameterContainer<DestSignature> &,
const vtkm::internal::detail::ParameterContainer<SrcSignature> &)
{
// Nothing to copy.
}
};
//============================================================================
$for(num_params in range(0, max_parameters+1))\

@ -123,13 +123,19 @@ public:
/// Topology map worklets use topology map indices.
///
template<typename T, typename Invocation>
template<typename T, typename OutToInArrayType, typename VisitArrayType, typename InputDomainType>
VTKM_EXEC_EXPORT
vtkm::exec::arg::ThreadIndicesTopologyMap<typename Invocation::InputDomainType>
GetThreadIndices(const T& threadIndex, const Invocation &invocation) const
vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType>
GetThreadIndices(const T& threadIndex,
const OutToInArrayType& outToIn,
const VisitArrayType& visit,
const InputDomainType &connectivity) const
{
return vtkm::exec::arg::ThreadIndicesTopologyMap<typename Invocation::InputDomainType>(
threadIndex, invocation);
return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType>(
threadIndex,
outToIn,
visit,
connectivity);
}
};

@ -282,25 +282,17 @@ public:
/// Worklet types can add additional indices by returning different object
/// types.
///
template<typename Invocation>
template<typename T, typename OutToInArrayType, typename VisitArrayType, typename InputDomainType>
VTKM_EXEC_EXPORT
vtkm::exec::arg::ThreadIndicesBasic
GetThreadIndices(vtkm::Id threadIndex, const Invocation &invocation) const
GetThreadIndices(const T& threadIndex,
const OutToInArrayType& outToIn,
const VisitArrayType& visit,
const InputDomainType &) const
{
return vtkm::exec::arg::ThreadIndicesBasic(threadIndex, invocation);
}
/// \brief Creates a \c ThreadIndices object.
///
/// Worklet types can add additional indices by returning different object
/// types.
///
template<typename T, typename Invocation>
VTKM_EXEC_EXPORT
vtkm::exec::arg::ThreadIndicesBasic
GetThreadIndices(const T& threadIndex, const Invocation &invocation) const
{
return vtkm::exec::arg::ThreadIndicesBasic(threadIndex, invocation);
return vtkm::exec::arg::ThreadIndicesBasic(threadIndex,
outToIn.Get(threadIndex),
visit.Get(threadIndex) );
}
};