Viskores  1.0
Invocation.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_internal_Invocation_h
19 #define viskores_internal_Invocation_h
20 
21 #include <viskores/Types.h>
23 
24 namespace viskores
25 {
26 namespace internal
27 {
28 
35 template <typename ParameterInterface_,
36  typename ControlInterface_,
37  typename ExecutionInterface_,
38  viskores::IdComponent InputDomainIndex_,
39  typename OutputToInputMapType_ = viskores::internal::NullType,
40  typename VisitArrayType_ = viskores::internal::NullType,
41  typename ThreadToOutputMapType_ = viskores::internal::NullType,
42  typename DeviceAdapterTag_ = viskores::internal::NullType>
43 struct Invocation
44 {
50  using ParameterInterface = ParameterInterface_;
51 
58  using ControlInterface = ControlInterface_;
59 
66  using ExecutionInterface = ExecutionInterface_;
67 
74  static constexpr viskores::IdComponent InputDomainIndex = InputDomainIndex_;
75 
83  using OutputToInputMapType = OutputToInputMapType_;
84 
92  using VisitArrayType = VisitArrayType_;
93 
100  using ThreadToOutputMapType = ThreadToOutputMapType_;
101 
107  using DeviceAdapterTag = DeviceAdapterTag_;
108 
112  Invocation(const ParameterInterface& parameters,
113  OutputToInputMapType outputToInputMap = OutputToInputMapType(),
114  VisitArrayType visitArray = VisitArrayType(),
115  ThreadToOutputMapType threadToOutputMap = ThreadToOutputMapType())
116  : Parameters(parameters)
117  , OutputToInputMap(outputToInputMap)
118  , VisitArray(visitArray)
119  , ThreadToOutputMap(threadToOutputMap)
120  {
121  }
122 
123  Invocation(const Invocation&) = default;
124 
128  template <typename NewParameterInterface>
129  struct ChangeParametersType
130  {
131  using type = Invocation<NewParameterInterface,
132  ControlInterface,
133  ExecutionInterface,
134  InputDomainIndex,
135  OutputToInputMapType,
136  VisitArrayType,
137  ThreadToOutputMapType,
138  DeviceAdapterTag>;
139  };
140 
144  template <typename NewParameterInterface>
145  VISKORES_CONT typename ChangeParametersType<NewParameterInterface>::type ChangeParameters(
146  const NewParameterInterface& newParameters) const
147  {
148  return typename ChangeParametersType<NewParameterInterface>::type(
149  newParameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
150  }
151 
155  template <typename NewControlInterface>
156  struct ChangeControlInterfaceType
157  {
158  using type = Invocation<ParameterInterface,
159  NewControlInterface,
160  ExecutionInterface,
161  InputDomainIndex,
162  OutputToInputMapType,
163  VisitArrayType,
164  ThreadToOutputMapType,
165  DeviceAdapterTag>;
166  };
167 
171  template <typename NewControlInterface>
172  typename ChangeControlInterfaceType<NewControlInterface>::type ChangeControlInterface(
173  NewControlInterface) const
174  {
175  return typename ChangeControlInterfaceType<NewControlInterface>::type(
176  this->Parameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
177  }
178 
182  template <typename NewExecutionInterface>
183  struct ChangeExecutionInterfaceType
184  {
185  using type = Invocation<ParameterInterface,
186  NewExecutionInterface,
187  ExecutionInterface,
188  InputDomainIndex,
189  OutputToInputMapType,
190  VisitArrayType,
191  ThreadToOutputMapType,
192  DeviceAdapterTag>;
193  };
194 
198  template <typename NewExecutionInterface>
199  typename ChangeExecutionInterfaceType<NewExecutionInterface>::type ChangeExecutionInterface(
200  NewExecutionInterface) const
201  {
202  return typename ChangeExecutionInterfaceType<NewExecutionInterface>::type(
203  this->Parameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
204  }
205 
209  template <viskores::IdComponent NewInputDomainIndex>
210  struct ChangeInputDomainIndexType
211  {
212  using type = Invocation<ParameterInterface,
213  ControlInterface,
214  ExecutionInterface,
215  NewInputDomainIndex,
216  OutputToInputMapType,
217  VisitArrayType,
218  ThreadToOutputMapType,
219  DeviceAdapterTag>;
220  };
221 
225  template <viskores::IdComponent NewInputDomainIndex>
226  VISKORES_EXEC_CONT typename ChangeInputDomainIndexType<NewInputDomainIndex>::type
227  ChangeInputDomainIndex() const
228  {
229  return typename ChangeInputDomainIndexType<NewInputDomainIndex>::type(
230  this->Parameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
231  }
232 
236  template <typename NewOutputToInputMapType>
237  struct ChangeOutputToInputMapType
238  {
239  using type = Invocation<ParameterInterface,
240  ControlInterface,
241  ExecutionInterface,
242  InputDomainIndex,
243  NewOutputToInputMapType,
244  VisitArrayType,
245  ThreadToOutputMapType,
246  DeviceAdapterTag>;
247  };
248 
252  template <typename NewOutputToInputMapType>
253  VISKORES_CONT typename ChangeOutputToInputMapType<NewOutputToInputMapType>::type
254  ChangeOutputToInputMap(NewOutputToInputMapType newOutputToInputMap) const
255  {
256  return typename ChangeOutputToInputMapType<NewOutputToInputMapType>::type(
257  this->Parameters, newOutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
258  }
259 
263  template <typename NewVisitArrayType>
264  struct ChangeVisitArrayType
265  {
266  using type = Invocation<ParameterInterface,
267  ControlInterface,
268  ExecutionInterface,
269  InputDomainIndex,
270  OutputToInputMapType,
271  NewVisitArrayType,
272  ThreadToOutputMapType,
273  DeviceAdapterTag>;
274  };
275 
279  template <typename NewVisitArrayType>
280  VISKORES_CONT typename ChangeVisitArrayType<NewVisitArrayType>::type ChangeVisitArray(
281  NewVisitArrayType newVisitArray) const
282  {
283  return typename ChangeVisitArrayType<NewVisitArrayType>::type(
284  this->Parameters, this->OutputToInputMap, newVisitArray, this->ThreadToOutputMap);
285  }
286 
290  template <typename NewThreadToOutputMapType>
291  struct ChangeThreadToOutputMapType
292  {
293  using type = Invocation<ParameterInterface,
294  ControlInterface,
295  ExecutionInterface,
296  InputDomainIndex,
297  OutputToInputMapType,
298  VisitArrayType,
299  NewThreadToOutputMapType,
300  DeviceAdapterTag>;
301  };
302 
306  template <typename NewThreadToOutputMapType>
307  VISKORES_CONT typename ChangeThreadToOutputMapType<NewThreadToOutputMapType>::type
308  ChangeThreadToOutputMap(NewThreadToOutputMapType newThreadToOutputMap) const
309  {
310  return typename ChangeThreadToOutputMapType<NewThreadToOutputMapType>::type(
311  this->Parameters, this->OutputToInputMap, this->VisitArray, newThreadToOutputMap);
312  }
313 
317  template <typename NewDeviceAdapterTag>
318  struct ChangeDeviceAdapterTagType
319  {
320  using type = Invocation<ParameterInterface,
321  ControlInterface,
322  ExecutionInterface,
323  InputDomainIndex,
324  OutputToInputMapType,
325  VisitArrayType,
326  ThreadToOutputMapType,
327  NewDeviceAdapterTag>;
328  };
329 
333  template <typename NewDeviceAdapterTag>
334  VISKORES_CONT typename ChangeDeviceAdapterTagType<NewDeviceAdapterTag>::type
335  ChangeDeviceAdapterTag(NewDeviceAdapterTag) const
336  {
337  return typename ChangeDeviceAdapterTagType<NewDeviceAdapterTag>::type(
338  this->Parameters, this->OutputToInputMap, this->VisitArray, this->ThreadToOutputMap);
339  }
340 
343  using InputDomainType =
344  typename ParameterInterface::template ParameterType<InputDomainIndex>::type;
345 
348  using InputDomainTag = typename ControlInterface::template ParameterType<InputDomainIndex>::type;
349 
354  const InputDomainType& GetInputDomain() const
355  {
356  return viskores::internal::ParameterGet<InputDomainIndex>(this->Parameters);
357  }
358 
366  ParameterInterface Parameters;
367  OutputToInputMapType OutputToInputMap;
368  VisitArrayType VisitArray;
369  ThreadToOutputMapType ThreadToOutputMap;
370 
371 private:
372  // Do not allow assignment of one Invocation to another. It is too expensive.
373  void operator=(const Invocation<ParameterInterface,
374  ControlInterface,
375  ExecutionInterface,
376  InputDomainIndex,
377  OutputToInputMapType,
378  VisitArrayType,
379  ThreadToOutputMapType,
380  DeviceAdapterTag>&) = delete;
381 };
382 
385 template <viskores::IdComponent InputDomainIndex,
386  typename ControlInterface,
387  typename ExecutionInterface,
388  typename ParameterInterface,
389  typename OutputToInputMapType,
390  typename VisitArrayType,
391  typename ThreadToOutputMapType>
392 VISKORES_CONT viskores::internal::Invocation<ParameterInterface,
393  ControlInterface,
394  ExecutionInterface,
395  InputDomainIndex,
396  OutputToInputMapType,
397  VisitArrayType,
398  ThreadToOutputMapType>
399 make_Invocation(const ParameterInterface& params,
400  ControlInterface,
401  ExecutionInterface,
402  OutputToInputMapType outputToInputMap,
403  VisitArrayType visitArray,
404  ThreadToOutputMapType threadToOutputMap)
405 {
406  return viskores::internal::Invocation<ParameterInterface,
407  ControlInterface,
408  ExecutionInterface,
409  InputDomainIndex,
410  OutputToInputMapType,
411  VisitArrayType,
412  ThreadToOutputMapType>(
413  params, outputToInputMap, visitArray, threadToOutputMap);
414 }
415 template <viskores::IdComponent InputDomainIndex,
416  typename ControlInterface,
417  typename ExecutionInterface,
418  typename ParameterInterface>
419 VISKORES_CONT viskores::internal::
420  Invocation<ParameterInterface, ControlInterface, ExecutionInterface, InputDomainIndex>
421  make_Invocation(const ParameterInterface& params,
422  ControlInterface = ControlInterface(),
423  ExecutionInterface = ExecutionInterface())
424 {
425  return viskores::internal::make_Invocation<InputDomainIndex>(params,
426  ControlInterface(),
427  ExecutionInterface(),
428  viskores::internal::NullType(),
429  viskores::internal::NullType(),
430  viskores::internal::NullType());
431 }
432 }
433 } // namespace viskores::internal
434 
435 #endif //viskores_internal_Invocation_h
Types.h
VISKORES_SUPPRESS_EXEC_WARNINGS
#define VISKORES_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:61
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
VISKORES_EXEC_CONT
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
FunctionInterface.h