Viskores  1.0
DispatcherMapField.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_worklet_Dispatcher_MapField_h
19 #define viskores_worklet_Dispatcher_MapField_h
20 
22 
23 namespace viskores
24 {
25 namespace worklet
26 {
27 
28 class WorkletMapField;
29 
32 template <typename WorkletType>
34  : public viskores::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType>,
35  WorkletType,
36  viskores::worklet::WorkletMapField>
37 {
38  using Superclass =
39  viskores::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType>,
40  WorkletType,
42  using ScatterType = typename Superclass::ScatterType;
43 
44 public:
45  template <typename... T>
47  : Superclass(std::forward<T>(args)...)
48  {
49  }
50 
51  template <typename Invocation>
52  VISKORES_CONT void DoInvoke(Invocation& invocation) const
53  {
54  using namespace viskores::worklet::internal;
55 
56  // This is the type for the input domain
57  using InputDomainType = typename Invocation::InputDomainType;
58 
59  // We can pull the input domain parameter (the data specifying the input
60  // domain) from the invocation object.
61  const InputDomainType& inputDomain = invocation.GetInputDomain();
62 
63  // For a DispatcherMapField, the inputDomain must be an ArrayHandle (or
64  // an UnknownArrayHandle that gets cast to one). The size of the domain
65  // (number of threads/worklet instances) is equal to the size of the
66  // array.
67  auto numInstances = SchedulingRange(inputDomain);
68 
69  // A MapField is a pretty straightforward dispatch. Once we know the number
70  // of invocations, the superclass can take care of the rest.
71  this->BasicInvoke(invocation, numInstances);
72  }
73 };
74 }
75 } // namespace viskores::worklet
76 
77 #endif //viskores_worklet_Dispatcher_MapField_h
viskores::worklet::DispatcherMapField::Superclass
viskores::worklet::internal::DispatcherBase< DispatcherMapField< WorkletType >, WorkletType, viskores::worklet::WorkletMapField > Superclass
Definition: DispatcherMapField.h:41
DispatcherBase.h
viskores::worklet::DispatcherMapField::ScatterType
typename Superclass::ScatterType ScatterType
Definition: DispatcherMapField.h:42
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::worklet::DispatcherMapField
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:33
viskores::worklet::DispatcherMapField::DispatcherMapField
DispatcherMapField(T &&... args)
Definition: DispatcherMapField.h:46
viskores::worklet::DispatcherMapField::DoInvoke
void DoInvoke(Invocation &invocation) const
Definition: DispatcherMapField.h:52
viskores::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:47