1 #ifndef _SM_PARALLEL_MERGE_SORT_H_
2 #define _SM_PARALLEL_MERGE_SORT_H_
4 #include <SharedTaskSequencer.h>
8 namespace helios{
namespace hpc {
24 template <
typename RandomAccessIterator,
typename Comparator>
105 RandomAccessIterator begin,
106 RandomAccessIterator end,
107 Comparator comparator
116 RandomAccessIterator begin,
117 RandomAccessIterator end,
118 Comparator comparator
120 trySort(begin, end, comparator);
172 #include <hpc/SM_ParallelMergeSort.tpp>
Class providing a shared memory sorting algorithm based on merge sort.
Definition: SM_ParallelMergeSort.h:25
SM_ParallelMergeSort(size_t const numThreads)
Build a shared memory parallel merge sort instance with given number of threads. The number of minimu...
Definition: SM_ParallelMergeSort.h:73
virtual void setMinElements(size_t const minElements)
Set the minimum number of elements for parallel execution.
Definition: SM_ParallelMergeSort.h:165
virtual size_t getNumThreads() const
Get the number of threads.
Definition: SM_ParallelMergeSort.h:146
virtual void init()
Common initialization for all constructors.
virtual size_t getMinElements() const
Get the minimum number of elements for parallel execution.
Definition: SM_ParallelMergeSort.h:159
size_t minElements
If the number of elements to be sorted is less than minElements, then a sequential sort will be appli...
Definition: SM_ParallelMergeSort.h:45
size_t numThreads
How many threads can be used to compute parallel sorting.
Definition: SM_ParallelMergeSort.h:36
virtual void join()
Force caller thread to wait until current sort has been finished.
virtual void sort(RandomAccessIterator begin, RandomAccessIterator end, Comparator comparator)
Like SM_ParallelMergeSort::trySort function but it returns only after sorting has been finished....
Definition: SM_ParallelMergeSort.h:115
std::shared_ptr< SharedTaskSequencer > stSequencer
The shared task sequencer to handle concurrent execution of multiple threads.
Definition: SM_ParallelMergeSort.h:62
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 num...
Definition: SM_ParallelMergeSort.h:83
int maxDepth
The maximum depth that the tree of splits must reach considering number of threads.
Definition: SM_ParallelMergeSort.h:56
virtual void setNumThreads(size_t const numThreads)
Set the number of threads.
Definition: SM_ParallelMergeSort.h:152
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 retur...