Go to the documentation of this file.
63 template <
typename ScanBody>
66 template <
typename NodeImpl>
97 using ScanBody::ScanBody;
102 Node* rootNode =
nullptr;
113 rootNode->
Range = range;
115 ScanBody::InitializeRootNode(rootNode);
117 this->
Scan(rootNode);
121 return rootNode ? ScanBody::GetFinalResult(rootNode)
132 #pragma GCC diagnostic push
133 #pragma GCC diagnostic ignored "-Wunused-value"
141 #pragma GCC diagnostic pop
145 return &this->Nodes[nodeIdx];
158 return (((n / 2) + (np - 1)) / np) * np + range[0];
168 .GetThreads(numThreads);
172 numVals, numThreads, chunksPerThread,
sizeof(
ValueType), numChunks, this->LeafSize);
175 std::size_t numNodes =
static_cast<std::size_t
>(numChunks);
176 while (numChunks > 1)
178 numChunks = (numChunks + 1) / 2;
179 numNodes +=
static_cast<std::size_t
>(numChunks);
181 this->Nodes.resize(numNodes);
201 auto explicitThis =
this;
207 explicitThis->Scan(right);
220 ScanBody::CombineSummaries(node, node->
Left, node->
Right);
234 if (node->
Left !=
nullptr)
236 assert(node->
Right !=
nullptr);
251 auto explicitThis =
this;
257 explicitThis->UpdateOutput(node->
Right);
269 template <
typename InPortalT,
typename OutPortalT,
typename RawFunctorT>
273 using FunctorType = internal::WrappedBinaryOperator<ValueType, RawFunctorT>;
290 const OutPortalT& outPortal,
291 const RawFunctorT& functor,
313 node->
Sum = input[range[0]];
365 output[i] = this->
Functor(carry, input[i]);
368 swap(output[i], carry);
378 template <
typename InPortalT,
typename OutPortalT,
typename RawFunctorT>
382 using FunctorType = internal::WrappedBinaryOperator<ValueType, RawFunctorT>;
398 const OutPortalT& outPortal,
399 const RawFunctorT& functor)
428 node->
Sum = input[range[0]];
468 if (!useCarry && start < end)
470 carry = input[start];
471 output[start] = carry;
477 output[i] = this->
Functor(carry, input[i]);
481 return output[end - 1];
490 template <
typename InPortalT,
typename OutPortalT,
typename FunctorT>
493 template <
typename InPortalT,
typename OutPortalT,
typename FunctorT>
ValueType InitialValue
Definition: ParallelScanOpenMP.h:278
void InitializeRootNode(Node *)
Definition: ParallelScanOpenMP.h:407
ValueType Sum
Definition: ParallelScanOpenMP.h:391
bool LeftEdge
Definition: ParallelScanOpenMP.h:79
viskores::Vec< viskores::Id, 2 > Id2
Id2 corresponds to a 2-dimensional index.
Definition: Types.h:935
ChildType
Definition: ParallelScanOpenMP.h:39
static constexpr size_t DataSize
Definition: ParallelScanOpenMP.h:82
FunctorType Functor
Definition: ParallelScanOpenMP.h:277
ValueType UpdateOutputImpl(const Node *node, const viskores::Id2 &range, bool skip, bool useCarry)
Definition: ParallelScanOpenMP.h:452
OutPortalT OutPortal
Definition: ParallelScanOpenMP.h:276
ScanInclusiveBody(const InPortalT &inPortal, const OutPortalT &outPortal, const RawFunctorT &functor)
Definition: ParallelScanOpenMP.h:397
OutPortalT OutPortal
Definition: ParallelScanOpenMP.h:385
void CombineSummaries(Node *parent, const Node *left, const Node *right)
Definition: ParallelScanOpenMP.h:331
void InitializeRootNode(Node *)
Definition: ParallelScanOpenMP.h:301
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:85
typename InPortalT::ValueType ValueType
Definition: ParallelScanOpenMP.h:272
ValueType UpdateOutputImpl(const Node *node, const viskores::Id2 &range, bool skip, bool useInit)
Definition: ParallelScanOpenMP.h:347
typename InPortalT::ValueType ValueType
Definition: ParallelScanOpenMP.h:381
void Prepare(const viskores::Id2 &range)
Definition: ParallelScanOpenMP.h:161
static constexpr size_t PaddingSize
Definition: ParallelScanOpenMP.h:85
FunctorType Functor
Definition: ParallelScanOpenMP.h:386
void ComputeSummary(Node *node, const viskores::Id2 &range, bool leftEdge)
Definition: ParallelScanOpenMP.h:310
InPortalT InPortal
Definition: ParallelScanOpenMP.h:275
#define VISKORES_OPENMP_DIRECTIVE(directive)
Definition: FunctorsOpenMP.h:45
bool IsLeaf(const viskores::Id2 &range) const
Definition: ParallelScanOpenMP.h:149
Tag for a device adapter that uses OpenMP compiler extensions to run algorithms on multiple threads.
Definition: DeviceAdapterTagOpenMP.h:35
unsigned char Padding[PaddingSize]
Definition: ParallelScanOpenMP.h:86
void UpdateOutput(const Node *node, const viskores::Id2 &range, bool leftEdge)
Definition: ParallelScanOpenMP.h:447
ValueType Carry
Definition: ParallelScanOpenMP.h:286
viskores::Id LeafSize
Definition: ParallelScanOpenMP.h:92
Definition: ParallelScanOpenMP.h:388
ValueType Carry
Definition: ParallelScanOpenMP.h:394
Node * AllocNode()
Definition: ParallelScanOpenMP.h:127
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::Id2 Range
Definition: ParallelScanOpenMP.h:70
void CombineSummaries(Node *parent, const Node *left, const Node *right)
Definition: ParallelScanOpenMP.h:436
Groups connected points that have the same field value.
Definition: Atomic.h:27
InPortalT InPortal
Definition: ParallelScanOpenMP.h:384
viskores::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:189
ScanExclusiveBody(const InPortalT &inPortal, const OutPortalT &outPortal, const RawFunctorT &functor, const ValueType &init)
Definition: ParallelScanOpenMP.h:289
Definition: ParallelScanOpenMP.h:67
void PropagateSummaries(const Node *parent, Node *left, Node *right, bool leftEdge)
Definition: ParallelScanOpenMP.h:336
typename ScanBody::ValueType ValueType
Definition: ParallelScanOpenMP.h:90
void ComputeSummary(Node *node, const viskores::Id2 &range, bool leftEdge)
Definition: ParallelScanOpenMP.h:417
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
std::vector< Node > Nodes
Definition: ParallelScanOpenMP.h:93
Definition: ParallelScanOpenMP.h:379
Definition: ParallelScanOpenMP.h:64
Binary Predicate that takes two arguments argument x, and y and returns sum (addition) of the two val...
Definition: BinaryOperators.h:41
Represent a continuous scalar range of values.
Definition: Range.h:39
viskores::Id ComputeMidpoint(const viskores::Id2 &range) const
Definition: ParallelScanOpenMP.h:153
ValueType GetFinalResult(const Node *node) const
Definition: ParallelScanOpenMP.h:485
static constexpr size_t NumCacheLines
Definition: ParallelScanOpenMP.h:84
NodeWrapper * Parent
Definition: ParallelScanOpenMP.h:73
void InitializeChildNode(Node *, const Node *, ChildType, bool)
Definition: ParallelScanOpenMP.h:303
void UpdateOutput(Node *node)
Definition: ParallelScanOpenMP.h:232
void UpdateOutput(const Node *node, const viskores::Id2 &range, bool leftEdge)
Definition: ParallelScanOpenMP.h:342
NodeWrapper * Right
Definition: ParallelScanOpenMP.h:75
void InitializeChildNode(Node *, const Node *, ChildType, bool)
Definition: ParallelScanOpenMP.h:412
ValueType GetFinalResult(const Node *node) const
Definition: ParallelScanOpenMP.h:375
ValueType Execute(const viskores::Id2 &range)
Definition: ParallelScanOpenMP.h:100
internal::WrappedBinaryOperator< ValueType, RawFunctorT > FunctorType
Definition: ParallelScanOpenMP.h:382
NodeWrapper * Left
Definition: ParallelScanOpenMP.h:74
internal::WrappedBinaryOperator< ValueType, RawFunctorT > FunctorType
Definition: ParallelScanOpenMP.h:273
Definition: ParallelScanOpenMP.h:270
Definition: ParallelScanOpenMP.h:280
ValueType Sum
Definition: ParallelScanOpenMP.h:283
void PropagateSummaries(const Node *parent, Node *left, Node *right, bool leftEdge)
Definition: ParallelScanOpenMP.h:441
size_t NextNode
Definition: ParallelScanOpenMP.h:94
void Scan(Node *node)
Definition: ParallelScanOpenMP.h:186