VTK-m  2.2
Invocation.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_internal_Invocation_h
11 #define vtk_m_internal_Invocation_h
12 
13 #include <vtkm/Types.h>
15 
16 namespace vtkm
17 {
18 namespace internal
19 {
20 
27 template <typename ParameterInterface_,
28  typename ControlInterface_,
29  typename ExecutionInterface_,
30  vtkm::IdComponent InputDomainIndex_,
31  typename OutputToInputMapType_ = vtkm::internal::NullType,
32  typename VisitArrayType_ = vtkm::internal::NullType,
33  typename ThreadToOutputMapType_ = vtkm::internal::NullType,
34  typename DeviceAdapterTag_ = vtkm::internal::NullType>
35 struct Invocation
36 {
42  using ParameterInterface = ParameterInterface_;
43 
50  using ControlInterface = ControlInterface_;
51 
58  using ExecutionInterface = ExecutionInterface_;
59 
66  static constexpr vtkm::IdComponent InputDomainIndex = InputDomainIndex_;
67 
75  using OutputToInputMapType = OutputToInputMapType_;
76 
84  using VisitArrayType = VisitArrayType_;
85 
92  using ThreadToOutputMapType = ThreadToOutputMapType_;
93 
99  using DeviceAdapterTag = DeviceAdapterTag_;
100 
103  VTKM_CONT
104  Invocation(const ParameterInterface& parameters,
105  OutputToInputMapType outputToInputMap = OutputToInputMapType(),
106  VisitArrayType visitArray = VisitArrayType(),
107  ThreadToOutputMapType threadToOutputMap = ThreadToOutputMapType())
108  : Parameters(parameters)
109  , OutputToInputMap(outputToInputMap)
110  , VisitArray(visitArray)
111  , ThreadToOutputMap(threadToOutputMap)
112  {
113  }
114 
115  Invocation(const Invocation&) = default;
116 
120  template <typename NewParameterInterface>
121  struct ChangeParametersType
122  {
123  using type = Invocation<NewParameterInterface,
124  ControlInterface,
125  ExecutionInterface,
126  InputDomainIndex,
127  OutputToInputMapType,
128  VisitArrayType,
129  ThreadToOutputMapType,
130  DeviceAdapterTag>;
131  };
132 
136  template <typename NewParameterInterface>
137  VTKM_CONT typename ChangeParametersType<NewParameterInterface>::type ChangeParameters(
138  const NewParameterInterface& newParameters) const
139  {
140  return typename ChangeParametersType<NewParameterInterface>::type(
141  newParameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
142  }
143 
147  template <typename NewControlInterface>
148  struct ChangeControlInterfaceType
149  {
150  using type = Invocation<ParameterInterface,
151  NewControlInterface,
152  ExecutionInterface,
153  InputDomainIndex,
154  OutputToInputMapType,
155  VisitArrayType,
156  ThreadToOutputMapType,
157  DeviceAdapterTag>;
158  };
159 
163  template <typename NewControlInterface>
164  typename ChangeControlInterfaceType<NewControlInterface>::type ChangeControlInterface(
165  NewControlInterface) const
166  {
167  return typename ChangeControlInterfaceType<NewControlInterface>::type(
168  this->Parameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
169  }
170 
174  template <typename NewExecutionInterface>
175  struct ChangeExecutionInterfaceType
176  {
177  using type = Invocation<ParameterInterface,
178  NewExecutionInterface,
179  ExecutionInterface,
180  InputDomainIndex,
181  OutputToInputMapType,
182  VisitArrayType,
183  ThreadToOutputMapType,
184  DeviceAdapterTag>;
185  };
186 
190  template <typename NewExecutionInterface>
191  typename ChangeExecutionInterfaceType<NewExecutionInterface>::type ChangeExecutionInterface(
192  NewExecutionInterface) const
193  {
194  return typename ChangeExecutionInterfaceType<NewExecutionInterface>::type(
195  this->Parameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
196  }
197 
201  template <vtkm::IdComponent NewInputDomainIndex>
202  struct ChangeInputDomainIndexType
203  {
204  using type = Invocation<ParameterInterface,
205  ControlInterface,
206  ExecutionInterface,
207  NewInputDomainIndex,
208  OutputToInputMapType,
209  VisitArrayType,
210  ThreadToOutputMapType,
211  DeviceAdapterTag>;
212  };
213 
217  template <vtkm::IdComponent NewInputDomainIndex>
218  VTKM_EXEC_CONT typename ChangeInputDomainIndexType<NewInputDomainIndex>::type
219  ChangeInputDomainIndex() const
220  {
221  return typename ChangeInputDomainIndexType<NewInputDomainIndex>::type(
222  this->Parameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
223  }
224 
228  template <typename NewOutputToInputMapType>
229  struct ChangeOutputToInputMapType
230  {
231  using type = Invocation<ParameterInterface,
232  ControlInterface,
233  ExecutionInterface,
234  InputDomainIndex,
235  NewOutputToInputMapType,
236  VisitArrayType,
237  ThreadToOutputMapType,
238  DeviceAdapterTag>;
239  };
240 
244  template <typename NewOutputToInputMapType>
245  VTKM_CONT typename ChangeOutputToInputMapType<NewOutputToInputMapType>::type
246  ChangeOutputToInputMap(NewOutputToInputMapType newOutputToInputMap) const
247  {
248  return typename ChangeOutputToInputMapType<NewOutputToInputMapType>::type(
249  this->Parameters, newOutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
250  }
251 
255  template <typename NewVisitArrayType>
256  struct ChangeVisitArrayType
257  {
258  using type = Invocation<ParameterInterface,
259  ControlInterface,
260  ExecutionInterface,
261  InputDomainIndex,
262  OutputToInputMapType,
263  NewVisitArrayType,
264  ThreadToOutputMapType,
265  DeviceAdapterTag>;
266  };
267 
271  template <typename NewVisitArrayType>
272  VTKM_CONT typename ChangeVisitArrayType<NewVisitArrayType>::type ChangeVisitArray(
273  NewVisitArrayType newVisitArray) const
274  {
275  return typename ChangeVisitArrayType<NewVisitArrayType>::type(
276  this->Parameters, this->OutputToInputMap, newVisitArray, this->ThreadToOutputMap);
277  }
278 
282  template <typename NewThreadToOutputMapType>
283  struct ChangeThreadToOutputMapType
284  {
285  using type = Invocation<ParameterInterface,
286  ControlInterface,
287  ExecutionInterface,
288  InputDomainIndex,
289  OutputToInputMapType,
290  VisitArrayType,
291  NewThreadToOutputMapType,
292  DeviceAdapterTag>;
293  };
294 
298  template <typename NewThreadToOutputMapType>
299  VTKM_CONT typename ChangeThreadToOutputMapType<NewThreadToOutputMapType>::type
300  ChangeThreadToOutputMap(NewThreadToOutputMapType newThreadToOutputMap) const
301  {
302  return typename ChangeThreadToOutputMapType<NewThreadToOutputMapType>::type(
303  this->Parameters, this->OutputToInputMap, this->VisitArray, newThreadToOutputMap);
304  }
305 
309  template <typename NewDeviceAdapterTag>
310  struct ChangeDeviceAdapterTagType
311  {
312  using type = Invocation<ParameterInterface,
313  ControlInterface,
314  ExecutionInterface,
315  InputDomainIndex,
316  OutputToInputMapType,
317  VisitArrayType,
318  ThreadToOutputMapType,
319  NewDeviceAdapterTag>;
320  };
321 
325  template <typename NewDeviceAdapterTag>
326  VTKM_CONT typename ChangeDeviceAdapterTagType<NewDeviceAdapterTag>::type ChangeDeviceAdapterTag(
327  NewDeviceAdapterTag) const
328  {
329  return typename ChangeDeviceAdapterTagType<NewDeviceAdapterTag>::type(
330  this->Parameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
331  }
332 
335  using InputDomainType =
336  typename ParameterInterface::template ParameterType<InputDomainIndex>::type;
337 
340  using InputDomainTag = typename ControlInterface::template ParameterType<InputDomainIndex>::type;
341 
346  const InputDomainType& GetInputDomain() const
347  {
348  return vtkm::internal::ParameterGet<InputDomainIndex>(this->Parameters);
349  }
350 
358  ParameterInterface Parameters;
359  OutputToInputMapType OutputToInputMap;
360  VisitArrayType VisitArray;
361  ThreadToOutputMapType ThreadToOutputMap;
362 
363 private:
364  // Do not allow assignment of one Invocation to another. It is too expensive.
365  void operator=(const Invocation<ParameterInterface,
366  ControlInterface,
367  ExecutionInterface,
368  InputDomainIndex,
369  OutputToInputMapType,
370  VisitArrayType,
371  ThreadToOutputMapType,
372  DeviceAdapterTag>&) = delete;
373 };
374 
377 template <vtkm::IdComponent InputDomainIndex,
378  typename ControlInterface,
379  typename ExecutionInterface,
380  typename ParameterInterface,
381  typename OutputToInputMapType,
382  typename VisitArrayType,
383  typename ThreadToOutputMapType>
384 VTKM_CONT vtkm::internal::Invocation<ParameterInterface,
385  ControlInterface,
386  ExecutionInterface,
387  InputDomainIndex,
388  OutputToInputMapType,
389  VisitArrayType,
390  ThreadToOutputMapType>
391 make_Invocation(const ParameterInterface& params,
392  ControlInterface,
393  ExecutionInterface,
394  OutputToInputMapType outputToInputMap,
395  VisitArrayType visitArray,
396  ThreadToOutputMapType threadToOutputMap)
397 {
398  return vtkm::internal::Invocation<ParameterInterface,
399  ControlInterface,
400  ExecutionInterface,
401  InputDomainIndex,
402  OutputToInputMapType,
403  VisitArrayType,
404  ThreadToOutputMapType>(
405  params, outputToInputMap, visitArray, threadToOutputMap);
406 }
407 template <vtkm::IdComponent InputDomainIndex,
408  typename ControlInterface,
409  typename ExecutionInterface,
410  typename ParameterInterface>
411 VTKM_CONT vtkm::internal::
412  Invocation<ParameterInterface, ControlInterface, ExecutionInterface, InputDomainIndex>
413  make_Invocation(const ParameterInterface& params,
414  ControlInterface = ControlInterface(),
415  ExecutionInterface = ExecutionInterface())
416 {
417  return vtkm::internal::make_Invocation<InputDomainIndex>(params,
418  ControlInterface(),
419  ExecutionInterface(),
420  vtkm::internal::NullType(),
421  vtkm::internal::NullType(),
422  vtkm::internal::NullType());
423 }
424 }
425 } // namespace vtkm::internal
426 
427 #endif //vtk_m_internal_Invocation_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
FunctionInterface.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
VTKM_SUPPRESS_EXEC_WARNINGS
#define VTKM_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:53