Go to the documentation of this file.
55 template <
typename ScanBody>
58 template <
typename NodeImpl>
89 using ScanBody::ScanBody;
94 Node* rootNode =
nullptr;
105 rootNode->
Range = range;
107 ScanBody::InitializeRootNode(rootNode);
109 this->
Scan(rootNode);
113 return rootNode ? ScanBody::GetFinalResult(rootNode)
124 #pragma GCC diagnostic push
125 #pragma GCC diagnostic ignored "-Wunused-value"
133 #pragma GCC diagnostic pop
137 return &this->Nodes[nodeIdx];
147 const vtkm::Id n = range[1] - range[0];
150 return (((n / 2) + (np - 1)) / np) * np + range[0];
156 vtkm::Id numVals = range[1] - range[0];
160 .GetThreads(numThreads);
164 numVals, numThreads, chunksPerThread,
sizeof(
ValueType), numChunks, this->LeafSize);
167 std::size_t numNodes =
static_cast<std::size_t
>(numChunks);
168 while (numChunks > 1)
170 numChunks = (numChunks + 1) / 2;
171 numNodes +=
static_cast<std::size_t
>(numChunks);
173 this->Nodes.resize(numNodes);
193 auto explicitThis =
this;
209 ScanBody::CombineSummaries(node, node->
Left, node->
Right);
223 if (node->
Left !=
nullptr)
225 assert(node->
Right !=
nullptr);
240 auto explicitThis =
this;
255 template <
typename InPortalT,
typename OutPortalT,
typename RawFunctorT>
259 using FunctorType = internal::WrappedBinaryOperator<ValueType, RawFunctorT>;
276 const OutPortalT& outPortal,
277 const RawFunctorT& functor,
299 node->
Sum = input[range[0]];
310 for (
vtkm::Id i = range[0] + 1; i < range[1]; ++i)
349 for (
vtkm::Id i = range[0]; i < end; ++i)
351 output[i] = this->
Functor(carry, input[i]);
354 swap(output[i], carry);
364 template <
typename InPortalT,
typename OutPortalT,
typename RawFunctorT>
368 using FunctorType = internal::WrappedBinaryOperator<ValueType, RawFunctorT>;
384 const OutPortalT& outPortal,
385 const RawFunctorT& functor)
414 node->
Sum = input[range[0]];
415 for (
vtkm::Id i = range[0] + 1; i < range[1]; ++i)
454 if (!useCarry && start < end)
456 carry = input[start];
457 output[start] = carry;
461 for (
vtkm::Id i = start; i < end; ++i)
463 output[i] = this->
Functor(carry, input[i]);
467 return output[end - 1];
476 template <
typename InPortalT,
typename OutPortalT,
typename FunctorT>
479 template <
typename InPortalT,
typename OutPortalT,
typename FunctorT>
void UpdateOutput(const Node *node, const vtkm::Id2 &range, bool leftEdge)
Definition: ParallelScanOpenMP.h:433
void CombineSummaries(Node *parent, const Node *left, const Node *right)
Definition: ParallelScanOpenMP.h:317
void ComputeSummary(Node *node, const vtkm::Id2 &range, bool leftEdge)
Definition: ParallelScanOpenMP.h:296
Groups connected points that have the same field value.
Definition: Atomic.h:19
Tag for a device adapter that uses OpenMP compiler extensions to run algorithms on multiple threads.
Definition: DeviceAdapterTagOpenMP.h:25
Definition: ParallelScanOpenMP.h:365
typename InPortalT::ValueType ValueType
Definition: ParallelScanOpenMP.h:258
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
ValueType GetFinalResult(const Node *node) const
Definition: ParallelScanOpenMP.h:471
ValueType Carry
Definition: ParallelScanOpenMP.h:272
vtkm::Id ComputeMidpoint(const vtkm::Id2 &range) const
Definition: ParallelScanOpenMP.h:145
void InitializeChildNode(Node *, const Node *, ChildType, bool)
Definition: ParallelScanOpenMP.h:289
vtkm::Id2 Range
Definition: ParallelScanOpenMP.h:62
void InitializeRootNode(Node *)
Definition: ParallelScanOpenMP.h:393
static constexpr size_t NumCacheLines
Definition: ParallelScanOpenMP.h:76
unsigned char Padding[PaddingSize]
Definition: ParallelScanOpenMP.h:78
FunctorType Functor
Definition: ParallelScanOpenMP.h:263
Node * AllocNode()
Definition: ParallelScanOpenMP.h:119
size_t NextNode
Definition: ParallelScanOpenMP.h:86
void InitializeRootNode(Node *)
Definition: ParallelScanOpenMP.h:287
NodeWrapper * Right
Definition: ParallelScanOpenMP.h:67
bool IsLeaf(const vtkm::Id2 &range) const
Definition: ParallelScanOpenMP.h:141
bool LeftEdge
Definition: ParallelScanOpenMP.h:71
Definition: ParallelScanOpenMP.h:266
OutPortalT OutPortal
Definition: ParallelScanOpenMP.h:371
Definition: ParallelScanOpenMP.h:56
Binary Predicate that takes two arguments argument x, and y and returns sum (addition) of the two val...
Definition: BinaryOperators.h:33
void Scan(Node *node)
Definition: ParallelScanOpenMP.h:178
NodeWrapper * Parent
Definition: ParallelScanOpenMP.h:65
ValueType Carry
Definition: ParallelScanOpenMP.h:380
ValueType Sum
Definition: ParallelScanOpenMP.h:269
void PropagateSummaries(const Node *parent, Node *left, Node *right, bool leftEdge)
Definition: ParallelScanOpenMP.h:427
ScanInclusiveBody(const InPortalT &inPortal, const OutPortalT &outPortal, const RawFunctorT &functor)
Definition: ParallelScanOpenMP.h:383
ValueType UpdateOutputImpl(const Node *node, const vtkm::Id2 &range, bool skip, bool useInit)
Definition: ParallelScanOpenMP.h:333
void CombineSummaries(Node *parent, const Node *left, const Node *right)
Definition: ParallelScanOpenMP.h:422
NodeWrapper * Left
Definition: ParallelScanOpenMP.h:66
void UpdateOutput(const Node *node, const vtkm::Id2 &range, bool leftEdge)
Definition: ParallelScanOpenMP.h:328
ValueType UpdateOutputImpl(const Node *node, const vtkm::Id2 &range, bool skip, bool useCarry)
Definition: ParallelScanOpenMP.h:438
Definition: ParallelScanOpenMP.h:59
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
Definition: ParallelScanOpenMP.h:374
#define VTKM_OPENMP_DIRECTIVE(directive)
Definition: FunctorsOpenMP.h:37
internal::WrappedBinaryOperator< ValueType, RawFunctorT > FunctorType
Definition: ParallelScanOpenMP.h:368
ValueType GetFinalResult(const Node *node) const
Definition: ParallelScanOpenMP.h:361
std::vector< Node > Nodes
Definition: ParallelScanOpenMP.h:85
typename InPortalT::ValueType ValueType
Definition: ParallelScanOpenMP.h:367
InPortalT InPortal
Definition: ParallelScanOpenMP.h:261
ValueType Sum
Definition: ParallelScanOpenMP.h:377
void PropagateSummaries(const Node *parent, Node *left, Node *right, bool leftEdge)
Definition: ParallelScanOpenMP.h:322
OutPortalT OutPortal
Definition: ParallelScanOpenMP.h:262
static constexpr size_t PaddingSize
Definition: ParallelScanOpenMP.h:77
static constexpr size_t DataSize
Definition: ParallelScanOpenMP.h:74
ScanExclusiveBody(const InPortalT &inPortal, const OutPortalT &outPortal, const RawFunctorT &functor, const ValueType &init)
Definition: ParallelScanOpenMP.h:275
void ComputeSummary(Node *node, const vtkm::Id2 &range, bool leftEdge)
Definition: ParallelScanOpenMP.h:403
ValueType Execute(const vtkm::Id2 &range)
Definition: ParallelScanOpenMP.h:92
vtkm::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:178
ValueType InitialValue
Definition: ParallelScanOpenMP.h:264
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:77
InPortalT InPortal
Definition: ParallelScanOpenMP.h:370
Definition: ParallelScanOpenMP.h:256
FunctorType Functor
Definition: ParallelScanOpenMP.h:372
internal::WrappedBinaryOperator< ValueType, RawFunctorT > FunctorType
Definition: ParallelScanOpenMP.h:259
ChildType
Definition: ParallelScanOpenMP.h:31
vtkm::Id LeafSize
Definition: ParallelScanOpenMP.h:84
void Prepare(const vtkm::Id2 &range)
Definition: ParallelScanOpenMP.h:153
void InitializeChildNode(Node *, const Node *, ChildType, bool)
Definition: ParallelScanOpenMP.h:398
void UpdateOutput(Node *node)
Definition: ParallelScanOpenMP.h:221
vtkm::Vec< vtkm::Id, 2 > Id2
Id2 corresponds to a 2-dimensional index.
Definition: Types.h:923
typename ScanBody::ValueType ValueType
Definition: ParallelScanOpenMP.h:82
Represent a continuous scalar range of values.
Definition: Range.h:31