VTK-m  2.0
TaskSingular.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_exec_internal_TaskSingular_h
11 #define vtk_m_exec_internal_TaskSingular_h
12 
14 
15 #include <vtkm/exec/TaskBase.h>
16 
17 #include <vtkm/exec/arg/Fetch.h>
18 
19 //Todo: rename this header to TaskSingularDetail.h
21 
22 namespace vtkm
23 {
24 namespace exec
25 {
26 namespace internal
27 {
28 
29 // TaskSingular represents an execution pattern for a worklet
30 // that is best expressed in terms of single dimension iteration space. Inside
31 // this single dimension no order is preferred.
32 //
33 //
34 template <typename WorkletType, typename InvocationType>
35 class TaskSingular : public vtkm::exec::TaskBase
36 {
37 public:
38  VTKM_CONT
39  TaskSingular(const WorkletType& worklet, const InvocationType& invocation)
40  : Worklet(worklet)
41  , Invocation(invocation)
42  {
43  }
44 
45  VTKM_CONT
46  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
47  {
48  this->Worklet.SetErrorMessageBuffer(buffer);
49  }
51  template <typename T>
52  VTKM_EXEC void operator()(T index) const
53  {
54  //Todo: rename this function to DoTaskSingular
55  detail::DoWorkletInvokeFunctor(
56  this->Worklet,
57  this->Invocation,
58  this->Worklet.GetThreadIndices(index,
59  this->Invocation.OutputToInputMap,
60  this->Invocation.VisitArray,
61  this->Invocation.ThreadToOutputMap,
62  this->Invocation.GetInputDomain()));
63  }
64 
65 private:
66  typename std::remove_const<WorkletType>::type Worklet;
67  // This is held by by value so that when we transfer the invocation object
68  // over to CUDA it gets properly copied to the device. While we want to
69  // hold by reference to reduce the number of copies, it is not possible
70  // currently.
71  const InvocationType Invocation;
72 };
73 }
74 }
75 } // vtkm::exec::internal
76 
77 #endif //vtk_m_exec_internal_TaskSingular_h
WorkletInvokeFunctorDetail.h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::exec::TaskBase
Base class for all classes that are used to marshal data from the invocation parameters to the user w...
Definition: TaskBase.h:24
Fetch.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
Invocation.h
TaskBase.h
VTKM_SUPPRESS_EXEC_WARNINGS
#define VTKM_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:53