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_sort<RandomAccessIterator, Compare> Template Function — Sorts a sequence.

Synopsis

#include "tbb/parallel_sort.h"

template<typename RandomAccessIterator>

  void parallel_sort(RandomAccessIterator begin,

                     RandomAccessIterator end);

template<typename RandomAccessIterator, typename Compare>

  void parallel_sort(RandomAccessIterator begin,

                     RandomAccessIterator end,

                     const Compare& comp );

Description

Performs an unstable sort of the sequence [begin1,end1). The requirements on the iterator and sequence are the same as for std::sort. Specifically, RandomAccessIterator must be a random access iterator, and its value type T must model the requirements in Table 4-2.

Table 4-2. Requirements on value type T of RandomAccessIterator for parallel_sort

Pseudosignature

Semantics

void swap(T&x,T&y)

Swaps x and y.

boolCompare::operator()(constT&x,constT&y)

True if x comes before y; false otherwise.

Complexity

parallel_sort is a comparison sort with an average time complexity of O(nlogn)on a single-processor core, where n is the number of elements in the sequence. Complexity reduces to O(N) as the number of processors increases. When worker threads are available, parallel_sort creates subtasks that may be executed concurrently, leading to improved execution times.

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