Remove unnecessary template parameters from DispatcherMapField

DispatcherMapField was templated on the device adapter but it
actually doesn't need to be, only BasicInvoke and subsequent
methods need to be templated on the device.
This commit is contained in:
Robert Maynard 2015-10-21 17:20:27 -04:00
parent 160f0099e5
commit 05d397cbf7
3 changed files with 55 additions and 41 deletions

@ -35,14 +35,12 @@ class DispatcherMapField :
public vtkm::worklet::internal::DispatcherBase< public vtkm::worklet::internal::DispatcherBase<
DispatcherMapField<WorkletType,Device>, DispatcherMapField<WorkletType,Device>,
WorkletType, WorkletType,
vtkm::worklet::WorkletMapField, vtkm::worklet::WorkletMapField>
Device>
{ {
typedef vtkm::worklet::internal::DispatcherBase< typedef vtkm::worklet::internal::DispatcherBase<
DispatcherMapField<WorkletType,Device>, DispatcherMapField<WorkletType,Device>,
WorkletType, WorkletType,
vtkm::worklet::WorkletMapField, vtkm::worklet::WorkletMapField> Superclass;
Device> Superclass;
public: public:
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
@ -68,7 +66,7 @@ public:
// A MapField is a pretty straightforward dispatch. Once we know the number // A MapField is a pretty straightforward dispatch. Once we know the number
// of invocations, the superclass can take care of the rest. // of invocations, the superclass can take care of the rest.
this->BasicInvoke(invocation, numInstances); this->BasicInvoke(invocation, numInstances, Device());
} }
}; };

@ -36,14 +36,14 @@ class DispatcherMapTopology :
public vtkm::worklet::internal::DispatcherBase< public vtkm::worklet::internal::DispatcherBase<
DispatcherMapTopology<WorkletType,Device>, DispatcherMapTopology<WorkletType,Device>,
WorkletType, WorkletType,
vtkm::worklet::template WorkletMapTopology<typename WorkletType::FromTopologyType, typename WorkletType::ToTopologyType>, vtkm::worklet::template WorkletMapTopology<typename WorkletType::FromTopologyType, typename WorkletType::ToTopologyType>
Device> >
{ {
typedef vtkm::worklet::internal::DispatcherBase< typedef vtkm::worklet::internal::DispatcherBase<
DispatcherMapTopology<WorkletType,Device>, DispatcherMapTopology<WorkletType,Device>,
WorkletType, WorkletType,
vtkm::worklet::template WorkletMapTopology<typename WorkletType::FromTopologyType, typename WorkletType::ToTopologyType>, vtkm::worklet::template WorkletMapTopology<typename WorkletType::FromTopologyType, typename WorkletType::ToTopologyType>
Device> Superclass; > Superclass;
public: public:
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
@ -70,7 +70,8 @@ public:
// scheduling and call BadicInvoke. // scheduling and call BadicInvoke.
this->BasicInvoke(invocation, this->BasicInvoke(invocation,
inputDomain.GetSchedulingRange( inputDomain.GetSchedulingRange(
typename WorkletType::ToTopologyType())); typename WorkletType::ToTopologyType()),
Device());
} }
}; };

@ -179,6 +179,17 @@ struct DispatcherBaseDynamicTransformHelper
} }
}; };
// A look up helper used by DispatcherBaseTransportFunctor to determine
//the types independent of the device we are templated on.
template<typename ControlInterface, vtkm::IdComponent Index>
struct DispatcherBaseTransportInvokeTypes
{
//Moved out of DispatcherBaseTransportFunctor to reduce code generation
typedef typename ControlInterface::template ParameterType<Index>::type
ControlSignatureTag;
typedef typename ControlSignatureTag::TransportTag TransportTag;
};
// A functor used in a StaticCast of a FunctionInterface to transport arguments // A functor used in a StaticCast of a FunctionInterface to transport arguments
// from the control environment to the execution environment. // from the control environment to the execution environment.
template<typename ControlInterface, typename Device> template<typename ControlInterface, typename Device>
@ -198,27 +209,22 @@ struct DispatcherBaseTransportFunctor
DispatcherBaseTransportFunctor(vtkm::Id3 dimensions) DispatcherBaseTransportFunctor(vtkm::Id3 dimensions)
: NumInstances(dimensions[0]*dimensions[1]*dimensions[2]) { } : NumInstances(dimensions[0]*dimensions[1]*dimensions[2]) { }
template<typename ControlParameter, vtkm::IdComponent Index>
struct InvokeTypes {
typedef typename ControlInterface::template ParameterType<Index>::type
ControlSignatureTag;
typedef typename ControlSignatureTag::TransportTag TransportTag;
typedef vtkm::cont::arg::Transport<TransportTag,ControlParameter,Device>
TransportType;
};
template<typename ControlParameter, vtkm::IdComponent Index> template<typename ControlParameter, vtkm::IdComponent Index>
struct ReturnType { struct ReturnType {
typedef typename InvokeTypes<ControlParameter, Index>:: typedef typename DispatcherBaseTransportInvokeTypes<ControlInterface, Index>::TransportTag TransportTag;
TransportType::ExecObjectType type; typedef typename vtkm::cont::arg::Transport<TransportTag,ControlParameter,Device> TransportType;
typedef typename TransportType::ExecObjectType type;
}; };
template<typename ControlParameter, vtkm::IdComponent Index> template<typename ControlParameter, vtkm::IdComponent Index>
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
typename ReturnType<ControlParameter, Index>::type typename ReturnType<ControlParameter, Index>::type
operator()(const ControlParameter &invokeData, operator()(const ControlParameter &invokeData,
vtkm::internal::IndexTag<Index>) const { vtkm::internal::IndexTag<Index>) const
typename InvokeTypes<ControlParameter, Index>::TransportType transport; {
typedef typename DispatcherBaseTransportInvokeTypes<ControlInterface, Index>::TransportTag TransportTag;
vtkm::cont::arg::Transport<TransportTag,ControlParameter,Device> transport;
return transport(invokeData, this->NumInstances); return transport(invokeData, this->NumInstances);
} }
}; };
@ -230,12 +236,11 @@ struct DispatcherBaseTransportFunctor
/// ///
template<typename DerivedClass, template<typename DerivedClass,
typename WorkletType, typename WorkletType,
typename BaseWorkletType, typename BaseWorkletType>
typename Device>
class DispatcherBase class DispatcherBase
{ {
private: private:
typedef DispatcherBase<DerivedClass,WorkletType,BaseWorkletType,Device> MyType; typedef DispatcherBase<DerivedClass,WorkletType,BaseWorkletType> MyType;
friend struct detail::DispatcherBaseDynamicTransformHelper<MyType>; friend struct detail::DispatcherBaseDynamicTransformHelper<MyType>;
@ -305,27 +310,33 @@ protected:
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
DispatcherBase(const WorkletType &worklet) : Worklet(worklet) { } DispatcherBase(const WorkletType &worklet) : Worklet(worklet) { }
template<typename Invocation> template<typename Invocation, typename DeviceAdapter>
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
void BasicInvoke(const Invocation &invocation, vtkm::Id numInstances) const void BasicInvoke(const Invocation &invocation,
vtkm::Id numInstances,
DeviceAdapter tag) const
{ {
this->InvokeTransportParameters(invocation, numInstances); this->InvokeTransportParameters(invocation, numInstances, tag);
} }
template<typename Invocation> template<typename Invocation, typename DeviceAdapter>
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
void BasicInvoke(const Invocation &invocation, vtkm::Id2 dimensions) const void BasicInvoke(const Invocation &invocation,
vtkm::Id2 dimensions,
DeviceAdapter tag) const
{ {
vtkm::Id3 dim3d(dimensions[0], dimensions[1], 1); vtkm::Id3 dim3d(dimensions[0], dimensions[1], 1);
this->InvokeTransportParameters(invocation, dim3d); this->InvokeTransportParameters(invocation, dim3d, tag);
} }
template<typename Invocation> template<typename Invocation, typename DeviceAdapter>
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
void BasicInvoke(const Invocation &invocation, vtkm::Id3 dimensions) const void BasicInvoke(const Invocation &invocation,
vtkm::Id3 dimensions,
DeviceAdapter tag) const
{ {
this->InvokeTransportParameters(invocation, dimensions); this->InvokeTransportParameters(invocation, dimensions, tag);
} }
WorkletType Worklet; WorkletType Worklet;
@ -335,10 +346,11 @@ private:
DispatcherBase(const MyType &); DispatcherBase(const MyType &);
void operator=(const MyType &); void operator=(const MyType &);
template<typename Invocation, typename RangeType> template<typename Invocation, typename RangeType, typename DeviceAdapter>
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
void InvokeTransportParameters(const Invocation &invocation, void InvokeTransportParameters(const Invocation &invocation,
RangeType range) const RangeType range,
DeviceAdapter tag) const
{ {
// The first step in invoking a worklet is to transport the arguments to // The first step in invoking a worklet is to transport the arguments to
// the execution environment. The invocation object passed to this function // the execution environment. The invocation object passed to this function
@ -353,7 +365,7 @@ private:
const ParameterInterfaceType &parameters = invocation.Parameters; const ParameterInterfaceType &parameters = invocation.Parameters;
typedef detail::DispatcherBaseTransportFunctor< typedef detail::DispatcherBaseTransportFunctor<
typename Invocation::ControlInterface, Device> TransportFunctorType; typename Invocation::ControlInterface, DeviceAdapter> TransportFunctorType;
typedef typename ParameterInterfaceType::template StaticTransformType< typedef typename ParameterInterfaceType::template StaticTransformType<
TransportFunctorType>::type ExecObjectParameters; TransportFunctorType>::type ExecObjectParameters;
@ -363,12 +375,15 @@ private:
// Replace the parameters in the invocation with the execution object and // Replace the parameters in the invocation with the execution object and
// pass to next step of Invoke. // pass to next step of Invoke.
this->InvokeSchedule(invocation.ChangeParameters(execObjectParameters), this->InvokeSchedule(invocation.ChangeParameters(execObjectParameters),
range); range,
tag);
} }
template<typename Invocation, typename RangeType> template<typename Invocation, typename RangeType, typename DeviceAdapter>
VTKM_CONT_EXPORT VTKM_CONT_EXPORT
void InvokeSchedule(const Invocation &invocation, RangeType range) const void InvokeSchedule(const Invocation &invocation,
RangeType range,
DeviceAdapter) const
{ {
// The WorkletInvokeFunctor class handles the magic of fetching values // The WorkletInvokeFunctor class handles the magic of fetching values
// for each instance and calling the worklet's function. So just create // for each instance and calling the worklet's function. So just create
@ -378,7 +393,7 @@ private:
WorkletInvokeFunctorType workletFunctor = WorkletInvokeFunctorType workletFunctor =
WorkletInvokeFunctorType(this->Worklet, invocation); WorkletInvokeFunctorType(this->Worklet, invocation);
typedef vtkm::cont::DeviceAdapterAlgorithm<Device> Algorithm; typedef vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter> Algorithm;
Algorithm::Schedule(workletFunctor, range); Algorithm::Schedule(workletFunctor, range);
} }