Skip to Main Content
Intel Threading Building Blocks
book

Intel Threading Building Blocks

by James Reinders
July 2007
Intermediate to advanced content levelIntermediate to advanced
332 pages
10h 4m
English
O'Reilly Media, Inc.
Content preview from Intel Threading Building Blocks

Name

parallel_scan<Range,Body> Template Function — Template function that computes parallel prefix.

Synopsis

#include "tbb/parallel_scan.h"

template<typename Range, typename Body>

  void parallel_scan( const Range& range, Body& body );

template<typename Range, typename Body, typename Partitioner>

    void parallel_scan( const Range& range, Body& body,

                            Partitioner &partitioner );

Description

A parallel_scan<Range,Body> computes a parallel prefix, also known as a parallel scan. This can be useful in scenarios that appear to have inherently serial dependencies. Given an associative operation ⊕ with left-identity element id, the parallel prefix of ⊕ over a sequence x0, x1 , … xn − 1 is a sequence y0, y1, y2 , … yn − 1 , where y0 = id ⊕x0 and yi = yi − 1 ⊕ xi .

The template parallel_scan<Range,Body> implements a parallel prefix generically. The body must model the requirements in Table 3-8.

Table 3-8. parallel_scan requirements

Pseudosignature

Semantics

void Body::operator()( constRange&r, pre_scan_tag )

Preprocess iterations for range r.

void Body::operator()( constRange&r, final_scan_tag )

Do final processing for iterations of range r.

Body::Body( Body&b, split )

Split bso that this and bcan accumulate separately.

VoidBody::reverse_join( Body&a )

Merge preprocessing state of ainto this, where awas created earlier from bby b’s splitting constructor.

VoidBody::assign( Body&b )

Assign state of bto this.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Rezaur Rahman

Publisher Resources

ISBN: 9780596514808Errata Page