Project: | ISO JTC1/SC22/WG21: Programming Language C++ |
---|---|

Number: | P0020r3 |

Date: | 2016-10-14 |

Reply-to: | hcedwar@sandia.gov |

Author: | H. Carter Edwards |

Contact: | hcedwar@sandia.gov |

Author: | Hans Boehm |

Contact: | hboehm@google.com |

Author: | Olivier Giroux |

Contact: | ogiroux@nvidia.com |

Author: | JF Bastien |

Contact: | jfbastien@apple.com |

Author: | James Reus |

Contact: | reus1@llnl.gov |

Audience: | SG1 Concurrency, Library Evolution |

URL: | https://github.com/kokkos/ISO-CPP-Papers/blob/master/P0020.rst |

- Align proposal with content of corresponding sections in N5131, 2016-07-15.

This paper proposes an extension to the atomic operations library [atomics]
for atomic addition on an object conforming to the atomic<T> where T is
a *floating-point* type (N5131 3.9.1p8).

This paper **does not** include proposed extension
of the named atomic type (N5131 Tables 134 and 135),
or by implication extension of the C _Atomic qualification
for floating point types.

The capability for atomic addition on floating point types
critical for high performance computing (HPC) applications.
The need is for extension of *atomic* and
*atomic_view* (P0019) for floating point types.

namespace std {template<> stuct atomic<floating-point>;// In the following declarations,atomic-floatingis atomic<T>.floating-pointatomic_fetch_add( volatileatomic-floating-point*,floating-point) noexcept ;floating-pointatomic_fetch_add(atomic-floating-point*,floating-point) noexcept ;floating-pointatomic_fetch_add_explicit( volatileatomic-floating-point*,floating-point, memory_order ) noexcept ;floating-pointatomic_fetch_add_explicit(atomic-floating-point*,floating-point, memory_order ) noexcept ;floating-pointatomic_fetch_sub( volatileatomic-floating-point*,floating-point) noexcept ;floating-pointatomic_fetch_sub(atomic-floating-point*,floating-point) noexcept ;floating-pointatomic_fetch_sub_explicit( volatileatomic-floating-point*,floating-point, memory_order ) noexcept ;floating-pointatomic_fetch_sub_explicit(atomic-floating-point*,floating-point, memory_order ) noexcept ;}

template<> struct atomic<floating-point> {static constexpr bool is_always_lock_free =implementation-defined;bool is_lock_free() const volatile noexcept;bool is_lock_free() const noexcept;void store(floating-point, memory_order = memory_order_seq_cst ) volatile noexcept;void store(floating-point, memory_order = memory_order_seq_cst ) noexcept;floating-pointload( memory_order = memory_order_seq_cst ) volatile noexcept;floating-pointload( memory_order = memory_order_seq_cst ) noexcept;operatorfloating-point() volatile noexcept ;operatorfloating-point() noexcept ;floating-pointexchange(floating-point, memory_order = memory_order_seq_cst ) volatile noexcept;floating-pointexchange(floating-point, memory_order = memory_order_seq_cst ) noexcept;bool compare_exchange_weak(floating-point& ,floating-point, memory_order , memory_order ) volatile noexcept;bool compare_exchange_weak(floating-point& ,floating-point, memory_order , memory_order ) noexcept;bool compare_exchange_strong(floating-point& ,floating-point, memory_order , memory_order ) volatile noexcept;bool compare_exchange_strong(floating-point& ,floating-point, memory_order , memory_order ) noexcept;bool compare_exchange_weak(floating-point& ,floating-point, memory_order = memory_order_seq_cst ) volatile noexcept;bool compare_exchange_weak(floating-point& ,floating-point, memory_order = memory_order_seq_cst ) noexcept;bool compare_exchange_strong(floating-point&,floating-point, memory_order = memory_order_seq_cst ) volatile noexcept;bool compare_exchange_strong(floating-point&,floating-point, memory_order = memory_order_seq_cst ) noexcept;floating-pointfetch_add(floating-point, memory_order = memory_order_seq_cst) volatile noexcept;floating-pointfetch_add(floating-point, memory_order = memory_order_seq_cst) noexcept;floating-pointfetch_sub(floating-point, memory_order = memory_order_seq_cst) volatile noexcept;floating-pointfetch_sub(floating-point, memory_order = memory_order_seq_cst) noexcept;atomic() noexcept = default ;constexpr atomic(floating-point) noexcept ;atomic( const atomic & ) = delete ;atomic & operator = ( const atomic & ) = delete ;atomic & operator = ( const atomic & ) volatile = delete ;floating-pointoperator=(floating-point) volatile noexcept ;floating-pointoperator=(floating-point) noexcept ;floating-pointoperator+=(floating-point) volatile noexcept;floating-pointoperator+=(floating-point) noexcept;floating-pointoperator-=(floating-point) volatile noexcept;floating-pointoperator-=(floating-point) noexcept;};

In the declarations of these functions and function template specializations,
the name *floating-point* refers to a floating point type and the name
*atomic-floating-point* refers to **atomic<***floating-point***>**.

*regarding arithmetic operations*

*update 29.6.5p31 Remark*

Remark:For signed integer types, arithmetic is defined to use two’s complement representation~~. There~~and thereare no undefined results.For floating point types, if the result is not mathematically defined or not in the range of representable values for its type (5p4) the result is unspecified. [Note: Atomic arithmetic operations onFor address types, the result may be an undefined address, but the operations otherwise have no undefined behavior.floating-pointshould conform tostd::numeric_limits<floating-point>traits associated with the floating point type (18.3.2). The floating point environment (26.4) for atomic arithmetic operations onfloating-pointmay be different than the calling thread's floating point environment. - end note]