Helios++
Helios software for LiDAR simulations
|
Class providing a shared memory sorting algorithm based on merge sort. More...
#include <SM_ParallelMergeSort.h>
Public Member Functions | |
SM_ParallelMergeSort (size_t const numThreads) | |
Build a shared memory parallel merge sort instance with given number of threads. The number of minimum elements will be twice the number of threads. More... | |
SM_ParallelMergeSort (size_t const numThreads, size_t const minElements) | |
Build a shared memory parallel merge sort instance with given number of threads and given minimum number of elements. More... | |
virtual void | init () |
Common initialization for all constructors. | |
virtual void | trySort (RandomAccessIterator begin, RandomAccessIterator end, Comparator comparator) |
Sort given sequence using given comparator in a non-blocking fashion. It is, the function might return before the sequence has been sorted. More... | |
virtual void | sort (RandomAccessIterator begin, RandomAccessIterator end, Comparator comparator) |
Like SM_ParallelMergeSort::trySort function but it returns only after sorting has been finished. It can be considered as the blocking counterpart of trySort. More... | |
virtual void | join () |
Force caller thread to wait until current sort has been finished. More... | |
virtual size_t | getNumThreads () const |
Get the number of threads. More... | |
virtual void | setNumThreads (size_t const numThreads) |
Set the number of threads. More... | |
virtual size_t | getMinElements () const |
Get the minimum number of elements for parallel execution. More... | |
virtual void | setMinElements (size_t const minElements) |
Set the minimum number of elements for parallel execution. More... | |
Protected Attributes | |
size_t | numThreads |
How many threads can be used to compute parallel sorting. More... | |
size_t | minElements |
If the number of elements to be sorted is less than minElements, then a sequential sort will be applied. More... | |
int | maxDepth |
The maximum depth that the tree of splits must reach considering number of threads. More... | |
std::shared_ptr< SharedTaskSequencer > | stSequencer |
The shared task sequencer to handle concurrent execution of multiple threads. More... | |
Class providing a shared memory sorting algorithm based on merge sort.
Sort \(m\) elements using \(n\) threads.
RandomAccessIterator | Type of iterator specifying start and end for sequence to be sorted |
Comparator | Type of comparator to be used to compare elements from a sequence |
|
inline |
Build a shared memory parallel merge sort instance with given number of threads. The number of minimum elements will be twice the number of threads.
|
inline |
Build a shared memory parallel merge sort instance with given number of threads and given minimum number of elements.
|
inlinevirtual |
Get the minimum number of elements for parallel execution.
|
inlinevirtual |
|
virtual |
Force caller thread to wait until current sort has been finished.
Usage example
|
inlinevirtual |
Set the minimum number of elements for parallel execution.
minElements | New minimum number of elements for parallel execution |
|
inlinevirtual |
Set the number of threads.
numThreads | New number of threads |
|
inlinevirtual |
Like SM_ParallelMergeSort::trySort function but it returns only after sorting has been finished. It can be considered as the blocking counterpart of trySort.
|
virtual |
Sort given sequence using given comparator in a non-blocking fashion. It is, the function might return before the sequence has been sorted.
begin | Start of sequence to be sorted |
end | End of sequence to be sorted |
comparator | Comparator defining sorting criteria |
|
protected |
The maximum depth that the tree of splits must reach considering number of threads.
\[ d^* \]
|
protected |
If the number of elements to be sorted is less than minElements, then a sequential sort will be applied.
\[ m_* \]
|
protected |
How many threads can be used to compute parallel sorting.
\[ n \]
|
protected |
The shared task sequencer to handle concurrent execution of multiple threads.