Skip to content

Commit 94a71c1

Browse files
committed
Apply D4070
1 parent b0ef447 commit 94a71c1

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

algorithms.html

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,46 @@ <h1>Effect of execution policies on algorithm execution</h1>
9292
in parallel algorithms invoked with an execution policy of type
9393
<code><del2>vector_execution_policy</del2><ins2>parallel_vector_execution_policy</ins2></code>
9494
are permitted to execute in an unordered fashion in unspecified threads, and unsequenced
95-
within each thread.
95+
<ins3>with respect to one another</ins3> within each thread.
9696
<ins2>
9797
<cxx-note>
9898
This means that multiple function object invocations may be interleaved on a single thread.
9999
</cxx-note>
100-
</ins2>
100+
</ins2><pre>
101+
</pre>
102+
103+
<del3>
101104
<cxx-note>
102105
As a consequence, function objects governed by the <code><del2>vector_execution_policy</del2><ins2>parallel_vector_execution_policy</ins2></code>
103106
policy must not synchronize with each other. Specifically, they must not acquire locks.
104107
</cxx-note>
108+
</del3>
109+
110+
<ins3>
111+
<cxx-note>
112+
This overrides the usual guarantee from the C++ standard, Section 1.9 [intro.execution] that
113+
function executions do not interleave with one another.
114+
</cxx-note>
115+
</ins3><pre>
116+
</pre>
117+
118+
<ins3>
119+
Since <code>parallel_vector_execution_policy</code> allows the execution of element access functions to be
120+
interleaved on a single thread, synchronization, including the use of mutexes, risks deadlock. Thus the
121+
synchronization with <code>parallel_vector_execution_policy</code> is restricted as follows:<pre>
122+
</pre>
123+
124+
A standard library function is <em>vectorization-unsafe</em> if it is specified to synchronize with
125+
another function invocation, or another function invocation is specified to synchronize with it, and if
126+
it is not a memory allocation or deallocation function. Vectorization-unsafe standard library functions
127+
may not be invoked by user code called from <code>parallel_vector_execution_policy</code> algorithms.<pre>
128+
</pre>
129+
130+
<cxx-note>
131+
Implementations must ensure that internal synchronization inside standard library routines does not
132+
induce deadlock.
133+
</cxx-note>
134+
</ins3>
105135
</p>
106136

107137
<cxx-example><pre>

0 commit comments

Comments
 (0)