Skip to content

Commit 08f1315

Browse files
committed
Apply N4275
1 parent e46da70 commit 08f1315

File tree

6 files changed

+534
-19
lines changed

6 files changed

+534
-19
lines changed

algorithms.html

Lines changed: 199 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ <h1>Effect of execution policies on algorithm execution</h1>
3535
<p>
3636
The invocations of element access functions in parallel algorithms invoked with an execution
3737
policy object of type <code>parallel_execution_policy</code> are permitted to execute in an
38-
unordered fashion in unspecified threads, and indeterminately sequenced within each thread.
38+
unordered fashion in <del>unspecified threads</del><ins>either the invoking thread or in a
39+
thread implicitly created by the library to support parallel algorithm execution.</ins>
40+
<del>, and</del> <ins>Any such invocations executing in the same thread are</ins> indeterminately
41+
sequenced <del>within each thread</del><ins>with respect to each other</ins>.
3942

4043
<cxx-note>
4144
It is the caller's responsibility to ensure correctness, for example that the invocation does
@@ -293,16 +296,22 @@ <h1><code>ExecutionPolicy</code> algorithm overloads</h1>
293296
<td><code>transform</code></td>
294297
</tr>
295298
<tr>
299+
<td><code><ins>transform_exclusive_scan</ins></code></td>
300+
<td><code><ins>transform_inclusive_scan</ins></code></td>
301+
<td><code><ins>transform_reduce</ins></code></td>
296302
<td><code>uninitialized_copy</code></td>
303+
</tr>
304+
<tr>
297305
<td><code>uninitialized_copy_n</code></td>
298306
<td><code>uninitialized_fill</code></td>
299307
<td><code>uninitialized_fill_n</code></td>
308+
<td><code>unique</code></td>
300309
</tr>
301310
<tr>
302-
<td><code>unique</code></td>
303311
<td><code>unique_copy</code></td>
304312
<td></td>
305313
<td></td>
314+
<td></td>
306315
</tr>
307316
</table>
308317

@@ -530,6 +539,38 @@ <h1>Header <code>&lt;experimental/numeric&gt;</code> synopsis</h1>
530539
inclusive_scan(InputIterator first, InputIterator last,
531540
OutputIterator result,
532541
BinaryOperation binary_op, T init);
542+
543+
<ins>
544+
template&lt;class InputIterator, class UnaryOperation,
545+
class T, class BinaryOperation&gt;
546+
T transform_reduce(InputIterator first, InputIterator last,
547+
UnaryOperation unary_op,
548+
T init, BinaryOperation binary_op);
549+
550+
template&lt;class InputIterator, class OutputIterator,
551+
class UnaryOperation, class T, class BinaryOperation&gt;
552+
OutputIterator
553+
transform_exclusive_scan(InputIterator first, InputIterator last,
554+
OutputIterator result,
555+
UnaryOperation unary_op,
556+
T init, BinaryOperation binary_op);
557+
558+
template&lt;class InputIterator, class OutputIterator,
559+
class UnaryOperation, class BinaryOperation&gt;
560+
OutputIterator
561+
transform_inclusive_scan(InputIterator first, InputIterator last,
562+
OutputIterator result,
563+
UnaryOperation unary_op,
564+
BinaryOperation binary_op);
565+
566+
template&lt;class InputIterator, class OutputIterator,
567+
class UnaryOperation, class BinaryOperation, class T&gt;
568+
OutputIterator
569+
transform_inclusive_scan(InputIterator first, InputIterator last,
570+
OutputIterator result,
571+
UnaryOperation unary_op,
572+
BinaryOperation binary_op, T init);
573+
</ins>
533574
}
534575
}
535576
}
@@ -695,7 +736,7 @@ <h1>Inclusive scan</h1>
695736
</cxx-requires>
696737

697738
<cxx-complexity>
698-
O(<code>last - first)</code> applications of <code>binary_op</code>.
739+
O(<code>last - first</code>) applications of <code>binary_op</code>.
699740
</cxx-complexity>
700741

701742
<cxx-notes>
@@ -706,5 +747,160 @@ <h1>Inclusive scan</h1>
706747
</cxx-notes>
707748
</cxx-function>
708749
</cxx-section>
750+
751+
<cxx-section id="parallel.alg.transform.reduce">
752+
<h1>Transform reduce</h1>
753+
754+
<cxx-function>
755+
<cxx-signature>
756+
<ins>
757+
template&lt;class InputIterator, class UnaryFunction, class T, class BinaryOperation&gt;
758+
T transform_reduce(InputIterator first, InputIterator last,
759+
UnaryOperation unary_op, T init, BinaryOperation binary_op);
760+
</ins>
761+
</cxx-signature>
762+
763+
<cxx-returns>
764+
<ins>
765+
<code><em>GENERALIZED_SUM</em>(binary_op, init, unary_op(*first), ..., unary_op(*(first + (last - first) - 1)))</code>.
766+
</ins>
767+
</cxx-returns>
768+
769+
<cxx-requires>
770+
<ins>
771+
Neither <code>unary_op</code> nor <code>binary_op</code> shall invalidate subranges, or modify elements in the range <code>[first,last)</code>
772+
</ins>
773+
</cxx-requires>
774+
775+
<cxx-complexity>
776+
<ins>
777+
O(<code>last - first</code>) applications each of <code>unary_op</code> and <code>binary_op</code>.
778+
</ins>
779+
</cxx-complexity>
780+
781+
<cxx-notes>
782+
<ins>
783+
<code>transform_reduce</code> does not apply <code>unary_op</code> to <code>init</code>.
784+
</ins>
785+
</cxx-notes>
786+
</cxx-function>
787+
</cxx-section>
788+
789+
<cxx-section id="parallel.alg.transform.exclusive.scan">
790+
<h1>Transform exclusive scan</h1>
791+
792+
<cxx-function>
793+
<cxx-signature>
794+
<ins>
795+
template&lt;class InputIterator, class OutputIterator,
796+
class UnaryOperation,
797+
class T, class BinaryOperation&gt;
798+
OutputIterator
799+
transform_exclusive_scan(InputIterator first, InputIterator last,
800+
OutputIterator result,
801+
UnaryOperation unary_op,
802+
T init, BinaryOperation binary_op);
803+
</ins>
804+
</cxx-signature>
805+
806+
<cxx-effects>
807+
<ins>
808+
Assigns through each iterator <code>i</code> in <code>[result,result + (last - first))</code> the value of
809+
<code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, init, unary_op(*first), ..., unary_op(*(first + (i - result) - 1)))</code>.
810+
</ins>
811+
</cxx-effects>
812+
813+
<cxx-returns>
814+
<ins>
815+
The end of the resulting range beginning at <code>result</code>.
816+
</ins>
817+
</cxx-returns>
818+
819+
<cxx-requires>
820+
<ins>
821+
Neither <code>unary_op</code> nor <code>binary_op</code> shall invalidate iterators or subranges, or modify elements in the
822+
ranges <code>[first,last)</code> or <code>[result,result + (last - first))</code>.
823+
</ins>
824+
</cxx-requires>
825+
826+
<cxx-complexity>
827+
<ins>
828+
O(<code>last - first</code>) applications each of <code>unary_op</code> and <code>binary_op</code>.
829+
</ins>
830+
</cxx-complexity>
831+
832+
<cxx-notes>
833+
<ins>
834+
The difference between <code>transform_exclusive_scan</code> and <code>transform_inclusive_scan</code> is that <code>transform_exclusive_scan</code>
835+
excludes the ith input element from the ith sum. If <code>binary_op</code> is not mathematically associative, the behavior of
836+
<code>transform_exclusive_scan</code> may be non-deterministic. <code>transform_exclusive_scan</code> does not apply <code>unary_op</code> to <code>init</code>.
837+
</ins>
838+
</cxx-notes>
839+
</cxx-function>
840+
</cxx-section>
841+
842+
<cxx-section id="parallel.alg.transform.inclusive.scan">
843+
<h1>Transform inclusive scan</h1>
844+
845+
<cxx-function>
846+
<cxx-signature>
847+
<ins>
848+
template&lt;class InputIterator, class OutputIterator,
849+
class UnaryOperation,
850+
class BinaryOperation&gt;
851+
OutputIterator
852+
transform_inclusive_scan(InputIterator first, InputIterator last,
853+
OutputIterator result,
854+
UnaryOperation unary_op,
855+
BinaryOperation binary_op);
856+
857+
template&lt;class InputIterator, class OutputIterator,
858+
class UnaryOperation,
859+
class BinaryOperation, class T&gt;
860+
OutputIterator
861+
transform_inclusive_scan(InputIterator first, InputIterator last,
862+
OutputIterator result,
863+
UnaryOperation unary_op,
864+
BinaryOperation binary_op, T init);
865+
</ins>
866+
</cxx-signature>
867+
868+
<cxx-effects>
869+
<ins>
870+
Assigns through each iterator <code>i</code> in <code>[result,result + (last - first))</code> the value of
871+
<code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, unary_op(*first), ..., unary_op(*(first + (i - result))))</code> or
872+
<code><em>GENERALIZED_NONCOMMUTATIVE_SUM</em>(binary_op, init, unary_op(*first), ..., unary_op(*(first + (i - result))))</code>
873+
if <code>init</code> is provided.
874+
</ins>
875+
</cxx-effects>
876+
877+
<cxx-returns>
878+
<ins>
879+
The end of the resulting range beginning at <code>result</code>.
880+
</ins>
881+
</cxx-returns>
882+
883+
<cxx-requires>
884+
<ins>
885+
Neither <code>unary_op</code> nor <code>binary_op</code> shall invalidate iterators or subranges, or modify elements in the ranges <code>[first,last)</code>
886+
or <code>[result,result + (last - first))</code>.
887+
</ins>
888+
</cxx-requires>
889+
890+
<cxx-complexity>
891+
<ins>
892+
O(<code>last - first</code>) applications each of <code>unary_op</code> and <code>binary_op</code>.
893+
</ins>
894+
</cxx-complexity>
895+
896+
<cxx-notes>
897+
<ins>
898+
The difference between <code>transform_exclusive_scan</code> and <code>transform_inclusive_scan</code> is that <code>transform_inclusive_scan</code>
899+
includes the ith input element from the ith sum. If <code>binary_op</code> is not mathematically associative, the behavior of
900+
<code>transform_inclusive_scan</code> may be non-deterministic. <code>transform_inclusive_scan</code> does not apply <code>unary_op</code> to <code>init</code>.
901+
</ins>
902+
</cxx-notes>
903+
</cxx-function>
904+
</cxx-section>
709905
</cxx-section>
710906
</cxx-clause>

algorithms_list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ stable_partition
6666
stable_sort
6767
swap_ranges
6868
transform
69+
transform_exclusive_scan
70+
transform_inclusive_scan
71+
transform_reduce
6972
uninitialized_copy
7073
uninitialized_copy_n
7174
uninitialized_fill

execution_policies.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ <h1>Execution policies</h1>
44
<h1>In general</h1>
55
<p>
66
This clause describes classes that are <dfn>execution policy</dfn> types. An object
7-
of an execution policy type indicates to an algorithm whether it is allowed to execute
8-
in parallel and expresses the requirements on the element access functions.
7+
of an execution policy type indicates <ins>the kinds of parallelism allowed in the execution
8+
of</ins> <del>to</del> an algorithm <del>whether it is allowed to execute
9+
in parallel</del> and expresses the <ins>consequent</ins> requirements on the element
10+
access functions.
911
</p>
1012

1113
<cxx-example>
1214
<pre>std::vector&lt;int&gt; v = ...
1315

1416
// standard sequential sort
15-
std::sort(vec.begin(), vec.end());
17+
std::sort(v<del>ec</del>.begin(), v<del>ec</del>.end());
1618

1719
using namespace std::experimental::parallel;
1820

@@ -83,6 +85,15 @@ <h1>Execution policy type trait</h1>
8385
<p><code>is_execution_policy</code> can be used to detect parallel execution policies for the purpose of excluding function signatures from otherwise ambiguous overload resolution participation.</p>
8486

8587
<p><code>is_execution_policy&lt;T&gt;</code> shall be a UnaryTypeTrait with a BaseCharacteristic of <code>true_type</code> if <code>T</code> is the type of a standard or implementation-defined execution policy, otherwise <code>false_type</code>.
88+
89+
<pre>
90+
</pre>
91+
92+
<ins>
93+
<cxx-note>
94+
This provision reserves the privilege of creating non-standard execution policies to the library implementation.
95+
</cxx-note>
96+
</ins>
8697

8798
<p>The behavior of a program that adds specializations for <code>is_execution_policy</code> is undefined.</p>
8899
</cxx-section>

front_matter.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<cxx-titlepage stage="draft">
2-
<cxx-docnum>NXXXX</cxx-docnum>
3-
<time pubdate="">2014-11-12</time>
2+
<cxx-docnum>N4310</cxx-docnum>
3+
<time pubdate="">2014-11-21</time>
44
<cxx-revises><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4104.html">N4104</a></cxx-revises>
55
<cxx-editor>
66
Jared Hoberock<br/>

general.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h1>Normative references</h1>
4848
<cxx-section id="parallel.general.namespaces">
4949
<h1>Namespaces and headers</h1>
5050

51-
<p>Since the the extensions described in this Technical Specification are
51+
<p>Since the <del>the</del> extensions described in this Technical Specification are
5252
experimental and not part of the C++ Standard Library, they should not be
5353
declared directly within namespace <code>std</code>. Unless otherwise specified, all
5454
components described in this Technical Specification are declared in namespace

0 commit comments

Comments
 (0)