|
17 | 17 |
|
18 | 18 | \begin{libsumtab}{Algorithms library summary}{algorithms.summary}
|
19 | 19 | \ref{algorithms.requirements} & Algorithms requirements & \\
|
20 |
| -\ref{algorithms.parallel} & Parallel algorithms & \\ \rowsep |
21 |
| -\ref{algorithms.results} & Algorithm result types & \tcode{<algorithm>} \\ |
| 20 | +\ref{algorithms.parallel} & Parallel algorithms & \tcode{<execution>} \\ \rowsep |
| 21 | +\ref{algorithms.results} & Algorithm result types & \tcode{<algorithm>} \\ |
22 | 22 | \ref{alg.nonmodifying} & Non-modifying sequence operations & \\
|
23 | 23 | \ref{alg.modifying.operations} & Mutating sequence operations & \\
|
24 | 24 | \ref{alg.sorting} & Sorting and related operations & \\ \rowsep
|
25 |
| -\ref{numeric.ops} & Generalized numeric operations & \tcode{<numeric>} \\ \rowsep |
| 25 | +\ref{numeric.ops} & Generalized numeric operations & \tcode{<numeric>} \\ \rowsep |
26 | 26 | \ref{specialized.algorithms} & Specialized \tcode{<memory>} algorithms & \tcode{<memory>} \\ \rowsep
|
27 | 27 | \ref{alg.rand} & Specialized \tcode{<random>} algorithms & \tcode{<random>} \\ \rowsep
|
28 |
| -\ref{alg.c.library} & C library algorithms & \tcode{<cstdlib>} \\ |
| 28 | +\ref{alg.c.library} & C library algorithms & \tcode{<cstdlib>} \\ |
29 | 29 | \end{libsumtab}
|
30 | 30 |
|
31 | 31 | \rSec1[algorithms.requirements]{Algorithms requirements}
|
|
620 | 620 | Parallel algorithms shall not participate in overload resolution unless
|
621 | 621 | \tcode{is_execution_policy_v<remove_cvref_t<ExecutionPolicy>>} is \tcode{true}.
|
622 | 622 |
|
| 623 | +\rSec2[execpol]{Execution policies} |
| 624 | + |
| 625 | +\rSec3[execpol.general]{General} |
| 626 | + |
| 627 | +\pnum |
| 628 | +Subclause~\ref{execpol} describes classes that are \defn{execution policy} types. An |
| 629 | +object of an execution policy type indicates the kinds of parallelism allowed |
| 630 | +in the execution of an algorithm and expresses the consequent requirements on |
| 631 | +the element access functions. |
| 632 | +Execution policy types are declared in header \libheaderref{execution}. |
| 633 | +\begin{example} |
| 634 | +\begin{codeblock} |
| 635 | +using namespace std; |
| 636 | +vector<int> v = @\commentellip@; |
| 637 | + |
| 638 | +// standard sequential sort |
| 639 | +sort(v.begin(), v.end()); |
| 640 | + |
| 641 | +// explicitly sequential sort |
| 642 | +sort(execution::seq, v.begin(), v.end()); |
| 643 | + |
| 644 | +// permitting parallel execution |
| 645 | +sort(execution::par, v.begin(), v.end()); |
| 646 | + |
| 647 | +// permitting vectorization as well |
| 648 | +sort(execution::par_unseq, v.begin(), v.end()); |
| 649 | +\end{codeblock} |
| 650 | +\end{example} |
| 651 | +\begin{note} |
| 652 | +Implementations can provide additional execution policies |
| 653 | +to those described in this document as extensions |
| 654 | +to address parallel architectures that require idiosyncratic |
| 655 | +parameters for efficient execution. |
| 656 | +\end{note} |
| 657 | + |
| 658 | +\rSec3[execpol.type]{Execution policy type trait} |
| 659 | + |
| 660 | +\indexlibraryglobal{is_execution_policy}% |
| 661 | +\begin{itemdecl} |
| 662 | +template<class T> struct is_execution_policy { @\seebelow@ }; |
| 663 | +\end{itemdecl} |
| 664 | + |
| 665 | +\begin{itemdescr} |
| 666 | +\pnum |
| 667 | +\tcode{is_execution_policy} can be used to detect execution policies for the |
| 668 | +purpose of excluding function signatures from otherwise ambiguous overload |
| 669 | +resolution participation. |
| 670 | + |
| 671 | +\pnum |
| 672 | +\tcode{is_execution_policy<T>} is a \oldconcept{UnaryTypeTrait} with a |
| 673 | +base characteristic of \tcode{true_type} if \tcode{T} is the type of a standard |
| 674 | +or \impldef{additional execution policies supported by parallel algorithms} |
| 675 | +execution policy, otherwise \tcode{false_type}. |
| 676 | + |
| 677 | +\begin{note} |
| 678 | +This provision reserves the privilege of creating non-standard execution |
| 679 | +policies to the library implementation. |
| 680 | +\end{note} |
| 681 | + |
| 682 | +\pnum |
| 683 | +The behavior of a program that adds specializations for |
| 684 | +\tcode{is_execution_policy} is undefined. |
| 685 | +\end{itemdescr} |
| 686 | + |
| 687 | +\rSec3[execpol.seq]{Sequenced execution policy} |
| 688 | + |
| 689 | +\indexlibraryglobal{execution::sequenced_policy}% |
| 690 | +\begin{itemdecl} |
| 691 | +class execution::sequenced_policy { @\unspec@ }; |
| 692 | +\end{itemdecl} |
| 693 | + |
| 694 | +\begin{itemdescr} |
| 695 | +\pnum |
| 696 | +The class \tcode{execution::sequenced_policy} is an execution policy type used |
| 697 | +as a unique type to disambiguate parallel algorithm overloading and require |
| 698 | +that a parallel algorithm's execution may not be parallelized. |
| 699 | + |
| 700 | +\pnum |
| 701 | +During the execution of a parallel algorithm with |
| 702 | +the \tcode{execution::sequenced_policy} policy, |
| 703 | +if the invocation of an element access function exits via an exception, |
| 704 | +\tcode{terminate} is invoked\iref{except.terminate}. |
| 705 | +\end{itemdescr} |
| 706 | + |
| 707 | +\rSec3[execpol.par]{Parallel execution policy} |
| 708 | + |
| 709 | +\indexlibraryglobal{execution::parallel_policy}% |
| 710 | +\begin{itemdecl} |
| 711 | +class execution::parallel_policy { @\unspec@ }; |
| 712 | +\end{itemdecl} |
| 713 | + |
| 714 | +\begin{itemdescr} |
| 715 | +\pnum |
| 716 | +The class \tcode{execution::parallel_policy} is an execution policy type used as |
| 717 | +a unique type to disambiguate parallel algorithm overloading and indicate that |
| 718 | +a parallel algorithm's execution may be parallelized. |
| 719 | + |
| 720 | +\pnum |
| 721 | +During the execution of a parallel algorithm with |
| 722 | +the \tcode{execution::parallel_policy} policy, |
| 723 | +if the invocation of an element access function exits via an exception, |
| 724 | +\tcode{terminate} is invoked\iref{except.terminate}. |
| 725 | +\end{itemdescr} |
| 726 | + |
| 727 | +\rSec3[execpol.parunseq]{Parallel and unsequenced execution policy} |
| 728 | + |
| 729 | +\indexlibraryglobal{execution::parallel_unsequenced_policy}% |
| 730 | +\begin{itemdecl} |
| 731 | +class execution::parallel_unsequenced_policy { @\unspec@ }; |
| 732 | +\end{itemdecl} |
| 733 | + |
| 734 | +\begin{itemdescr} |
| 735 | +\pnum |
| 736 | +The class \tcode{execution::parallel_unsequenced_policy} is an execution policy type |
| 737 | +used as a unique type to disambiguate parallel algorithm overloading and |
| 738 | +indicate that a parallel algorithm's execution may be parallelized and |
| 739 | +vectorized. |
| 740 | + |
| 741 | +\pnum |
| 742 | +During the execution of a parallel algorithm with |
| 743 | +the \tcode{execution::parallel_unsequenced_policy} policy, |
| 744 | +if the invocation of an element access function exits via an exception, |
| 745 | +\tcode{terminate} is invoked\iref{except.terminate}. |
| 746 | +\end{itemdescr} |
| 747 | + |
| 748 | +\rSec3[execpol.unseq]{Unsequenced execution policy} |
| 749 | + |
| 750 | +\indexlibraryglobal{execution::unsequenced_policy}% |
| 751 | +\begin{itemdecl} |
| 752 | +class execution::unsequenced_policy { @\unspec@ }; |
| 753 | +\end{itemdecl} |
| 754 | + |
| 755 | +\begin{itemdescr} |
| 756 | +\pnum |
| 757 | +The class \tcode{unsequenced_policy} is an execution policy type |
| 758 | +used as a unique type to disambiguate parallel algorithm overloading and |
| 759 | +indicate that a parallel algorithm's execution may be vectorized, |
| 760 | +e.g., executed on a single thread using instructions |
| 761 | +that operate on multiple data items. |
| 762 | + |
| 763 | +\pnum |
| 764 | +During the execution of a parallel algorithm with |
| 765 | +the \tcode{execution::unsequenced_policy} policy, |
| 766 | +if the invocation of an element access function exits via an exception, |
| 767 | +\tcode{terminate} is invoked\iref{except.terminate}. |
| 768 | +\end{itemdescr} |
| 769 | + |
| 770 | +\rSec3[execpol.objects]{Execution policy objects} |
| 771 | + |
| 772 | +\indexlibraryglobal{seq}% |
| 773 | +\indexlibraryglobal{par}% |
| 774 | +\indexlibraryglobal{par_unseq}% |
| 775 | +\indexlibrarymember{execution}{seq}% |
| 776 | +\indexlibrarymember{execution}{par}% |
| 777 | +\indexlibrarymember{execution}{par_unseq}% |
| 778 | +\begin{itemdecl} |
| 779 | +inline constexpr execution::sequenced_policy execution::seq{ @\unspec@ }; |
| 780 | +inline constexpr execution::parallel_policy execution::par{ @\unspec@ }; |
| 781 | +inline constexpr execution::parallel_unsequenced_policy execution::par_unseq{ @\unspec@ }; |
| 782 | +inline constexpr execution::unsequenced_policy execution::unseq{ @\unspec@ }; |
| 783 | +\end{itemdecl} |
| 784 | + |
| 785 | +\begin{itemdescr} |
| 786 | +\pnum |
| 787 | +The header \libheaderref{execution} declares global objects associated with each type of execution policy. |
| 788 | +\end{itemdescr} |
| 789 | + |
623 | 790 | \rSec1[algorithm.syn]{Header \tcode{<algorithm>} synopsis}
|
624 | 791 | \indexheader{algorithm}%
|
625 | 792 |
|
|
0 commit comments