Commit 36fc5958 by Johannes Singler

parallel_mode.xml: Documented the new choices, factoring out common tags.

2008-05-16  Johannes Singler  <singler@ira.uka.de>

         * doc/xml/manual/parallel_mode.xml:
         Documented the new choices, factoring out common tags.
         * include/parallel/multiway_merge.h:
         Place comparison functor at the end, to comply with
         established convention.
         (parallel_multiway_merge) Pass number of threads explicitly.
         Introduce new compile-time variants, make exact splitting the
         default.
         * include/parallel/tags.h:
         Extend exact_tag, introduce sampling_tag.
         * include/parallel/merge.h:
         (parallel_merge_advance) Adapt to changed interface.
         * include/parallel/multiway_mergesort.h: Likewise.

From-SVN: r135411
parent fa9290d3
......@@ -576,23 +576,35 @@ This means that the actual parallelization strategy is chosen at run-time.
</para>
<para>
For the following algorithms in general, we have
<code>__gnu_parallel::parallel_tag</code> and
<code>__gnu_parallel::default_parallel_tag</code>, in addition to
<code>__gnu_parallel::sequential_tag</code>.
<code>__gnu_parallel::default_parallel_tag</code> chooses the default
algorithm at compiletime, as does omitting the tag.
<code>__gnu_parallel::parallel_tag</code> postpones the decision to runtime
(see next section).
For all tags, the number of threads desired for this call can optionally be
passed to the respective tag's constructor.
</para>
<para>
The <code>multiway_merge</code> algorithm comes with the additional choices,
<code>__gnu_parallel::exact_tag</code> and
<code>__gnu_parallel::sampling_tag</code>.
Exact and sampling are the two available splitting strategies.
</para>
<para>
For the <code>sort</code> and <code>stable_sort</code> algorithms, there are
several possible choices,
<code>__gnu_parallel::parallel_tag</code>,
<code>__gnu_parallel::default_parallel_tag</code>,
several additional choices, namely
<code>__gnu_parallel::multiway_mergesort_tag</code>,
<code>__gnu_parallel::multiway_mergesort_exact_tag</code>,
<code>__gnu_parallel::multiway_mergesort_sampling_tag</code>,
<code>__gnu_parallel::quicksort_tag</code>,
<code>__gnu_parallel::quicksort_tag</code>, and
<code>__gnu_parallel::balanced_quicksort_tag</code>.
Multiway mergesort comes with two splitting strategies for merging, therefore
the extra choice. If non is chosen, the default splitting strategy is selected.
<code>__gnu_parallel::default_parallel_tag</code> chooses the default parallel
sorting algorithm at runtime. <code>__gnu_parallel::parallel_tag</code>
postpones the decision to runtime (see next section).
The quicksort options cannot be used for <code>stable_sort</code>.
For all tags, the number of threads desired for this call can optionally be
passed to the tag's constructor.
Multiway mergesort comes with the two splitting strategies for multi-way
merging. The quicksort options cannot be used for <code>stable_sort</code>.
</para>
</sect3>
......
......@@ -254,11 +254,11 @@ namespace __gnu_parallel
RandomAccessIterator3
target_end = parallel_multiway_merge
< /* stable = */ true, /* sentinels = */ false>(
seqs, seqs + 2, target, comp,
seqs, seqs + 2, target,
multiway_merge_exact_splitting
< /* stable = */ true, iterator_pair*,
Comparator, difference_type1>,
max_length);
max_length, comp, omp_get_max_threads());
return target_end;
}
......
......@@ -289,8 +289,8 @@ template<typename SeqRandomAccessIterator, typename RandomAccessIterator,
Comparator& comp,
DiffType length_am) const
{
stable_multiway_merge(seqs_begin, seqs_end, target, comp,
length_am, sequential_tag());
stable_multiway_merge(seqs_begin, seqs_end, target, length_am, comp,
sequential_tag());
}
};
......@@ -306,8 +306,8 @@ template<typename SeqRandomAccessIterator, typename RandomAccessIterator,
Comparator& comp,
DiffType length_am) const
{
multiway_merge(seqs_begin, seqs_end, target, comp,
length_am, sequential_tag());
multiway_merge(seqs_begin, seqs_end, target, length_am, comp,
sequential_tag());
}
};
......
......@@ -47,9 +47,6 @@ namespace __gnu_parallel
/** @brief Forces sequential execution at compile time. */
struct sequential_tag { };
/** @brief Forces exact splitting in multiway merge at compile time. */
struct exact_tag { };
/** @brief Recommends parallel execution at compile time,
* optionally using a user-specified number of threads. */
struct parallel_tag
......@@ -119,6 +116,25 @@ namespace __gnu_parallel
struct find_tag { };
/** @brief Forces parallel merging
* with exact splitting, at compile time. */
struct exact_tag : public parallel_tag
{
exact_tag() { }
exact_tag(thread_index_t num_threads)
: parallel_tag(num_threads) { }
};
/** @brief Forces parallel merging
* with exact splitting, at compile time. */
struct sampling_tag : public parallel_tag
{
sampling_tag() { }
sampling_tag(thread_index_t num_threads)
: parallel_tag(num_threads) { }
};
/** @brief Forces parallel sorting using multiway mergesort
* at compile time. */
struct multiway_mergesort_tag : public parallel_tag
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment