1. Background
The Standard was simplified in [P0394r4]: exceptions leaving parallel algorithms lead to
being called. This matches the behavior of exceptions leaving
as well as
.
The following National Body comments from [P0488R0] were discussed in SG1 at Issaquah, along with [p0451r0]:
-
US 15, US 167: Don’t
when a parallel algorithm exits via uncaught exception and either re-addterminate ()
, addexception_list
policies + re-addnoexcept
, make it UB or throw an unspecified exception (revert [P0394r4]).exception_list -
US 17, US 169: Don’t
when a parallel algorithm exits via uncaught exception and re-addterminate ()
(revert [P0394r4]).exception_list -
US 16, US 168: Clarify which exception is thrown when a parallel algorithm exits via uncaught exception.
-
US 170: Add a customization point for
s which defines their exception handling behavior (don’t re-addExecutionPolicy
).exception_list -
CA 17: Preserve the
-on-uncaught-exception behavior in the parallel algorithms (keep [P0394r4]).terminate ()
1.1. Straw Polls
The following straw polls were taken:
Straw Poll A: In 25.2.4 ❡2, have uncaught exception behavior be defined by
. In 20.19 define the behavior for the three standard policies in C++17 (
,
,
) as
.
SF | F | N | A | SA |
---|---|---|---|---|
Many | 7 | 1 | 1 | 0 |
⟹ Consensus to write a paper for this before the end of the week. Bryce, JF, and Carter will write it.
Straw Poll B: Do we want to rename the policies to reflect the fact that they call
instead of throwing exceptions.
SF | F | N | A | SA |
---|---|---|---|---|
1 | 7 | 9 | 6 | 7 |
⟹ No consensus for change.
Straw Poll C: Beyond the changes from the first straw poll, additional changes are required.
SF | F | N | A | SA |
---|---|---|---|---|
2 | 0 | 10 | 11 | 6 |
⟹ No consensus for change.
1.2. Action
This paper follows the guidance from straw poll A: there is no behavior change, but the behavior is specified to allow future execution policies which exhibit different behavior.
2. Proposed Wording
Apply the following edits to section 15.5.1 ❡1 note, bullet 1.13:
15.5.1 The
function [except.terminate]
std :: terminate ()
In some situations exception handling must be abandoned for less subtle error handling techniques. [ Note: These situations are:
[…]
(1.13) — for parallel algorithms whose
specify such behavior (20.19.4, 20.19.5, 20.19.6), when execution of an element access function (25.2.1) of a parallel algorithm exits via an exception (25.2.4), or
ExecutionPolicy […]
— end note ]
Apply the following edits to section 20.19:
20.19.4 Sequential execution policy [execpol.seq]
class execution :: sequenced_policy { unspecified };
The class
is an execution policy type used as a unique type to disambiguate parallel algorithm overloading and require that a parallel algorithm’s execution may not be parallelized.
execution :: sequenced_policy - During the execution of a parallel algorithm with the
policy, if the invocation of an element access function exits via an uncaught exception,
execution :: sequenced_policy shall be called.
terminate () 20.19.5 Parallel execution policy [execpol.par]
class execution :: parallel_policy { unspecified };
The class
is an execution policy type used as a unique type to disambiguate parallel algorithm overloading and indicate that a parallel algorithm’s execution may be parallelized.
execution :: parallel_policy - During the execution of a parallel algorithm with the
policy, if the invocation of an element access function exits via an uncaught exception,
execution :: parallel_policy shall be called.
terminate () 20.19.6 Parallel+Vector execution policy [execpol.vec]
class execution :: parallel_unsequenced_policy { unspecified };
The class
is an execution policy type used as a unique type to disambiguate parallel algorithm overloading and indicate that a parallel algorithm’s execution may be parallelized and vectorized.
execution :: parallel_unsequenced_policy - During the execution of a parallel algorithm with the
policy, if the invocation of an element access function exits via an uncaught exception,
execution :: parallel_unsequenced_policy shall be called.
terminate ()
Apply the following edits to section 25.2.4 [algorithms.parallel.exceptions] ❡2:
During the execution of a parallel algorithm, if the invocation of an element access function exits via an uncaught exception, the behavior is determined by the
.
ExecutionPolicy is called.
terminate ()
3. Acknowledgement
Thank you to all SG1 participants: David Sankel, Alisdair Meredith, Hartmut Kaiser, Pablo Halpern, Jared Hoberock, Michael Wong, Pete Becker. Special thanks to the scribe Paul McKenney.