<html>

<head>
  <meta name="description" content="Proposal for C++ Standard">
  <meta name="keywords" content="C++,cplusplus,wg21,C++20,parallism, wavefront">
  <meta name="author" content="Alisdair Meredith">

  <title>Target Vectorization Policies from Parallelism V2 TS to C++20</title>

  <style type="text/css">
    ins {background-color:#A0FFA0}
    del {background-color:#FFA0A0}
    li {text-align:justify}
    blockquote.note
    {
      background-color:#E0E0E0;
      padding-left: 15px;
      padding-right: 15px;
      padding-top: 1px;
      padding-bottom: 1px;
    }
  </style>
</head>

<body>
<table>
<tr>
  <td align="left">Doc. no.</td>
  <td align="left">P10010R0</td>
</tr>
<tr>
  <td align="left">Date:</td>
  <td align="left">2018-03-14</td>
</tr>
<tr>
  <td align="left">Project:</td>
  <td align="left">Programming Language C++</td>
</tr>
<tr>
  <td align="left">Audience:</td>
  <td align="left">SG1 Parallelism and Concurrency</td>
</tr>
<tr>
  <td align="left"> </td>
  <td align="left">Library Evolution Working Group</td>
</tr>
<tr>
  <td align="left">Reply to:</td>
  <td align="left">Alisdair Meredith &lt;<a href="mailto:ameredith1@bloomberg.net">ameredith1@bloomberg.net</a>&gt;</td>
</tr>
</table>

<h1>Target Vectorization Policies from Parallelism V2 TS to C++20</h1>

<h2>Table of Contents</h2>
<ol>
<li><a href="#rev.hist">Revision History</a></li>
  <ul>
  <li><a href="#rev.0">Revision 0</a></li>
  </ul>
<li><a href="#1.0">1 Introduction</a></li>
<li><a href="#2.0">2 Stating the problem</a></li>
<li><a href="#3.0">3 Propose Solution</a></li>
<li><a href="#4.0">4 Other Directions</a></li>
<li><a href="#5.0">5 Formal Wording</a></li>
<li><a href="#6.0">6 Acknowledgements</a></li>
<li><a href="#7.0">7 References</a></li>
</ol>


<h2><a name="rev.hist">Revision History</a></h2>

<h3><a name="rev.0">Revision 0</a></h3>
<p>
Original version of the paper for the 2018 Jacksonville meeting.
</p>


<h2><a name="1.0">1 Introduction</a></h2>
<p>
The Parallelism v2 working draft has new vector policies for the parallel
algorithms that might better target C++20 directly.
</p>


<h2><a name="2.0">2 Stating the problem</a></h2>
<p>
We plan to send the Parallelism V2 working paper to PDTS ballot at the
Jacksonville meeting.  It seems reasonable to conclude that if we want feedback
from the TS process, then anything in that TS vehicle will miss the merge
deadline for C++20.
</p>
<p>
Of the (expected) three components to that TS, the Task Blocks feature depends
on the <tt>exception_list</tt> class that is still underspecified for general
use, and waiting feedback from such a TS process.
<p>
</p>
The <tt>simd</tt> library type has been going through rapid evolution and been
subject to much change in the review process, so seems appropriate to seek
feedback through the TS process.
</p>
<p>
Finally, there are two new vectorization policies for the parallel
algorithms, which rely on the main <tt>&lt;algorithm&gt;</tt> header providing
overloads for the new policies in the non-experimental <tt>std</tt> namespace
in order to be usable.  The algorithms can safely be implemented as reverting
to serial or any other lesser parallel behavior without using the freedoms
granted by the wavefront policies, so implementability is much less of a
concern than QoI.  There is no room in the design space for how we dispatch to
the algorithms to be seeking TS feedback, so it is seems reasonable to suggest
that if we want this feature, it would be more appropriate to target the C++20
standard directly, avoiding the awkward interaction with the <tt>std</tt> and
<tt>experimental</tt> namespaces.  We are still early enough in the C++20 cycle
to respond to unexpected implementer feedback, and the current state of the
C++17 parallel algorithms is that most standard library vendors are still
starting or in the middle of their first implementation of the parallel
algorithms, so it would be easier to tackle these extra policies now along with
the rest of that work.
</p>


<h2><a name="3.0">3 Propose Solution</a></h2>
<p>
Propose directly merging the contents of section 5 and 7 of the current working
draft of the Parallelism V2 TS into the C++20 Working paper, and then striking
those sections, and the corresponing rows of the feature macros table from section
4 of the Parallelism TS.
</p>


<h2><a name="4.0">4 Other Directions</a></h2>
<p>
Considered suggesting a merge of the wavefront policies into C++20 without striking
the content from the Parallism TS V2.  However, it does not seem useful to have two
duplicate copies of the same wording, with either a burden to maintain both, or
seeing the two diverge over time.  The benefit of maintaining both copies is that
it removes the urgency of answering this question immediately at the Jacksoville
meeting.
</p>


<h2><a name="5.0">5 Formal Wording</a></h2>
<p>
Merge the contents of section 5 and 7 of 
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4725">N4725</a>
into the C++ Working paper, and then strike those sections from the
Parallelism V2 TS Working Paper.
</p>
<p>
When merging, all references to the inline namespace <tt>std::experimental::parallism_v2</tt>
should be replaced with simply namespace <tt>std</tt>.  Any reference to an
<tt>&lt;experimental/*&gt;</tt> header should be replaced (or merged into) the
corresponding standard (non-experimental) header.
</p>
<p>
For guidance to the editors on merging, clauses 5.2-5.4 should be added as new
subclauses under 23.19 <b>[execpol]</b>.  Section 7 already had the stable tag
<b>[parallel.alg]</b>, so should readily merge into the same top level tag in
the main standard.
</p>
<p>
Strike the following rows from Table 1 - Feature Test Macro(s) in the Parallism V2
TS:
<blockquote><pre>
__cpp_lib_experimental_execution_vector_policy
__cpp_lib_experimental_parallel_for_loop
</pre></blockquote>
</p>
<p>
Corresponding rows should be added to the feature detection macros standing
document (prior to any merging with the C++ Working Paper) with the
</tt>_experimental</tt> term redacted.
</p>


<h2><a name="6.0">6 Acknowledgements</h2>
<p>
Thanks to all the troublemakers in Jacksonville who persuaded me there was time
to write this late paper!
</p>


<h2><a name="7.0">7 References</h2>
<ul>
  <li><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4725">N4725</a> Working Draft, Technical Specification for C++ Extensions for Parallelism Version 2, Jared Hoberock</li>
  <li><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0075r2">P0075R2</a> Template Library for Parallel For Loops, Pablo Halpern, Clark Nelson, Arch D. Robison, Robert Geva</li>
  <li><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0076r4">P0076R4</a> Vector and Wavefront Policies, Arch Robison, Pablo Halpern, Robert Geva, Clark Nelson, Jens Maurer</li>
</ul>


</body>
</html>
