vtk-m/vtkm/worklet/DispatcherMapField.h

67 lines
2.2 KiB
C
Raw Normal View History

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_worklet_Dispatcher_MapField_h
#define vtk_m_worklet_Dispatcher_MapField_h
#include <vtkm/worklet/internal/DispatcherBase.h>
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace worklet
{
class WorkletMapField;
/// \brief Dispatcher for worklets that inherit from \c WorkletMapField.
///
template <typename WorkletType>
2017-05-18 14:29:41 +00:00
class DispatcherMapField
: public vtkm::worklet::internal::
DispatcherBase<DispatcherMapField<WorkletType>, WorkletType, vtkm::worklet::WorkletMapField>
{
using Superclass = vtkm::worklet::internal::
DispatcherBase<DispatcherMapField<WorkletType>, WorkletType, vtkm::worklet::WorkletMapField>;
using ScatterType = typename Superclass::ScatterType;
public:
template <typename... T>
VTKM_CONT DispatcherMapField(T&&... args)
: Superclass(std::forward<T>(args)...)
2017-05-18 14:29:41 +00:00
{
}
2017-05-18 14:29:41 +00:00
template <typename Invocation>
VTKM_CONT void DoInvoke(Invocation& invocation) const
{
using namespace vtkm::worklet::internal;
// This is the type for the input domain
2018-02-22 13:29:13 +00:00
using InputDomainType = typename Invocation::InputDomainType;
// We can pull the input domain parameter (the data specifying the input
// domain) from the invocation object.
2017-05-18 14:29:41 +00:00
const InputDomainType& inputDomain = invocation.GetInputDomain();
// For a DispatcherMapField, the inputDomain must be an ArrayHandle (or
// an UnknownArrayHandle that gets cast to one). The size of the domain
// (number of threads/worklet instances) is equal to the size of the
// array.
auto numInstances = SchedulingRange(inputDomain);
// A MapField is a pretty straightforward dispatch. Once we know the number
// of invocations, the superclass can take care of the rest.
this->BasicInvoke(invocation, numInstances);
}
};
}
} // namespace vtkm::worklet
#endif //vtk_m_worklet_Dispatcher_MapField_h