Skip to content

Commit 4e15644

Browse files
committed
P3008R6 Atomic floating-point min/max
1 parent 691ab30 commit 4e15644

File tree

3 files changed

+135
-3
lines changed

3 files changed

+135
-3
lines changed

source/numerics.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9649,6 +9649,11 @@
96499649
constexpr float fminf(float x, float y);
96509650
constexpr long double fminl(long double x, long double y);
96519651

9652+
constexpr @\placeholdernc{floating-point-type}@ fmaximum(@\placeholdernc{floating-point-type}@ x, @\placeholdernc{floating-point-type}@ y);
9653+
constexpr @\placeholdernc{floating-point-type}@ fmaximum_num(@\placeholdernc{floating-point-type}@ x, @\placeholdernc{floating-point-type}@ y);
9654+
constexpr @\placeholdernc{floating-point-type}@ fminimum(@\placeholdernc{floating-point-type}@ x, @\placeholdernc{floating-point-type}@ y);
9655+
constexpr @\placeholdernc{floating-point-type}@ fminimum_num(@\placeholdernc{floating-point-type}@ x, @\placeholdernc{floating-point-type}@ y);
9656+
96529657
constexpr @\placeholdernc{floating-point-type}@ fma(@\placeholdernc{floating-point-type}@ x, @\placeholdernc{floating-point-type}@ y,
96539658
@\placeholdernc{floating-point-type}@ z);
96549659
constexpr float fmaf(float x, float y, float z);

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@
578578
#define @\defnlibxname{cpp_lib_atomic_float}@ 201711L // freestanding, also in \libheader{atomic}
579579
#define @\defnlibxname{cpp_lib_atomic_is_always_lock_free}@ 201603L // freestanding, also in \libheader{atomic}
580580
#define @\defnlibxname{cpp_lib_atomic_lock_free_type_aliases}@ 201907L // also in \libheader{atomic}
581-
#define @\defnlibxname{cpp_lib_atomic_min_max}@ 202403L // freestanding, also in \libheader{atomic}
581+
#define @\defnlibxname{cpp_lib_atomic_min_max}@ 202506L // freestanding, also in \libheader{atomic}
582582
#define @\defnlibxname{cpp_lib_atomic_ref}@ 202411L // freestanding, also in \libheader{atomic}
583583
#define @\defnlibxname{cpp_lib_atomic_shared_ptr}@ 201711L // also in \libheader{memory}
584584
#define @\defnlibxname{cpp_lib_atomic_value_initialization}@ 201911L // freestanding, also in \libheader{atomic}, \libheader{memory}

source/threads.tex

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,6 +3773,19 @@
37733773
constexpr value_type fetch_sub(@\placeholdernc{floating-point-type}@,
37743774
memory_order = memory_order::seq_cst) const noexcept;
37753775

3776+
constexpr @\placeholdernc{floating-point-type}@ fetch_max(@\placeholdernc{floating-point-type}@,
3777+
memory_order = memory_order::seq_cst) const noexcept;
3778+
constexpr @\placeholdernc{floating-point-type}@ fetch_min(@\placeholdernc{floating-point-type}@,
3779+
memory_order = memory_order::seq_cst) const noexcept;
3780+
constexpr @\placeholdernc{floating-point-type}@ fetch_fmaximum(@\placeholdernc{floating-point-type}@,
3781+
memory_order = memory_order::seq_cst) const noexcept;
3782+
constexpr @\placeholdernc{floating-point-type}@ fetch_fminimum(@\placeholdernc{floating-point-type}@,
3783+
memory_order = memory_order::seq_cst) const noexcept;
3784+
constexpr @\placeholdernc{floating-point-type}@ fetch_fmaximum_num(@\placeholdernc{floating-point}@,
3785+
memory_order = memory_order::seq_cst) const noexcept;
3786+
constexpr @\placeholdernc{floating-point-type}@ fetch_fminimum_num(@\placeholdernc{floating-point-type}@,
3787+
memory_order = memory_order::seq_cst) const noexcept;
3788+
37763789
constexpr value_type operator+=(value_type) const noexcept;
37773790
constexpr value_type operator-=(value_type) const noexcept;
37783791

@@ -3792,7 +3805,15 @@
37923805
\pnum
37933806
The following operations perform arithmetic computations.
37943807
The correspondence among key, operator, and computation is specified
3795-
in \tref{atomic.types.int.comp}.
3808+
in \tref{atomic.types.int.comp},
3809+
except for the keys
3810+
\tcode{max},
3811+
\tcode{min},
3812+
\tcode{fmaximum},
3813+
\tcode{fminimum},
3814+
\tcode{fmaximum_num}, and
3815+
\tcode{fminimum_num},
3816+
which are specified below.
37963817

37973818
\indexlibrarymember{fetch_add}{atomic_ref<\placeholder{floating-point-type}>}%
37983819
\indexlibrarymember{fetch_sub}{atomic_ref<\placeholder{floating-point-type}>}%
@@ -3830,6 +3851,41 @@
38303851
The floating-point environment\iref{cfenv}
38313852
for atomic arithmetic operations on \tcode{\placeholder{floating-\newline point-type}}
38323853
may be different than the calling thread's floating-point environment.
3854+
3855+
\pnum
3856+
\begin{itemize}
3857+
\item
3858+
For \tcode{fetch_fmaximum} and \tcode{fetch_fminimum},
3859+
the maximum and minimum computation is performed
3860+
as if by \tcode{fmaximum} and \tcode{fminimum}, respectively,
3861+
with \tcode{*ptr} and the first parameter as the arguments.
3862+
\item
3863+
For \tcode{fetch_fmaximum_num} and \tcode{fetch_fminimum_num},
3864+
the maximum and minimum computation is performed
3865+
as if by \tcode{fmaximum_num} and \tcode{fminimum_num}, respectively,
3866+
with \tcode{*ptr} and the first parameter as the arguments.
3867+
\item
3868+
For \tcode{fetch_max} and \tcode{fetch_min},
3869+
the maximum and minimum computation is performed
3870+
as if by \tcode{fmaximum_num} and \tcode{fminimum_num}, respectively,
3871+
with \tcode{*ptr} and the first parameter as the arguments, except that:
3872+
\begin{itemize}
3873+
\item
3874+
If both arguments are NaN, an unspecified NaN value is stored at \tcode{*ptr}.
3875+
\item
3876+
If exactly one argument is a NaN,
3877+
either the other argument or an unspecified NaN value is stored at \tcode{*ptr};
3878+
it is unspecified which.
3879+
\item
3880+
If the arguments are differently signed zeros,
3881+
which of these values is stored at \tcode{*ptr} is unspecified.
3882+
\end{itemize}
3883+
\end{itemize}
3884+
3885+
\pnum
3886+
\recommended
3887+
The implementation of \tcode{fetch_max} and \tcode{fetch_min}
3888+
should treat negative zero as smaller than positive zero.
38333889
\end{itemdescr}
38343890

38353891
\indexlibrarymember{operator+=}{atomic_ref<\placeholder{floating-point-type}>}%
@@ -4965,6 +5021,30 @@
49655021
memory_order = memory_order::seq_cst) volatile noexcept;
49665022
constexpr @\placeholdernc{floating-point-type}@ fetch_sub(@\placeholdernc{floating-point-type}@,
49675023
memory_order = memory_order::seq_cst) noexcept;
5024+
@\placeholdernc{floating-point-type}@ fetch_max(@\placeholdernc{floating-point-type}@,
5025+
memory_order = memory_order::seq_cst) volatile noexcept;
5026+
constexpr @\placeholdernc{floating-point-type}@ fetch_max(@\placeholdernc{floating-point-type}@,
5027+
memory_order = memory_order::seq_cst) noexcept;
5028+
@\placeholdernc{floating-point-type}@ fetch_min(@\placeholdernc{floating-point-type}@,
5029+
memory_order = memory_order::seq_cst) volatile noexcept;
5030+
constexpr @\placeholdernc{floating-poin-type}@t fetch_min(@\placeholdernc{floating-point-type}@,
5031+
memory_order = memory_order::seq_cst) noexcept;
5032+
@\placeholdernc{floating-point-type}@ fetch_fmaximum(@\placeholdernc{floating-point-type}@,
5033+
memory_order = memory_order::seq_cst) volatile noexcept;
5034+
constexpr @\placeholdernc{floating-point-type}@ fetch_fmaximum(@\placeholdernc{floating-point-type}@,
5035+
memory_order = memory_order::seq_cst) noexcept;
5036+
@\placeholdernc{floating-point-type}@ fetch_fminimum(@\placeholdernc{floating-point-type}@,
5037+
memory_order = memory_order::seq_cst) volatile noexcept;
5038+
constexpr @\placeholdernc{floating-point-type}@ fetch_fminimum(@\placeholdernc{floating-point-type}@,
5039+
memory_order = memory_order::seq_cst) noexcept;
5040+
@\placeholdernc{floating-point-type}@ fetch_fmaximum_num(@\placeholdernc{floating-point-type}@,
5041+
memory_order = memory_order::seq_cst) volatile noexcept;
5042+
constexpr @\placeholdernc{floating-point-type}@ fetch_fmaximum_num(@\placeholdernc{floating-point-type}@,
5043+
memory_order = memory_order::seq_cst) noexcept;
5044+
@\placeholdernc{floating-point-type}@ fetch_fminimum_num(@\placeholdernc{floating-point-type}@,
5045+
memory_order = memory_order::seq_cst) volatile noexcept;
5046+
constexpr @\placeholdernc{floating-point-type}@ fetch_fminimum_num(f@\placeholdernc{loating-point-type}@,
5047+
memory_order = memory_order::seq_cst) noexcept;
49685048

49695049
@\placeholdernc{floating-point-type}@ operator+=(@\placeholder{floating-point-type}@) volatile noexcept;
49705050
constexpr @\placeholdernc{floating-point-type}@ operator+=(@\placeholder{floating-point-type}@) noexcept;
@@ -4994,7 +5074,15 @@
49945074
\pnum
49955075
The following operations perform arithmetic addition and subtraction computations.
49965076
The correspondence among key, operator, and computation is specified
4997-
in \tref{atomic.types.int.comp}.
5077+
in \tref{atomic.types.int.comp},
5078+
except for the keys
5079+
\tcode{max},
5080+
\tcode{min},
5081+
\tcode{fmaximum},
5082+
\tcode{fminimum},
5083+
\tcode{fmaximum_num}, and
5084+
\tcode{fminimum_num},
5085+
which are specified below.
49985086

49995087
\indexlibraryglobal{atomic_fetch_add}%
50005088
\indexlibraryglobal{atomic_fetch_sub}%
@@ -5035,6 +5123,45 @@
50355123
The floating-point environment\iref{cfenv} for atomic arithmetic operations
50365124
on \tcode{\placeholder{floating-point-type}} may be different than the
50375125
calling thread's floating-point environment.
5126+
5127+
\pnum
5128+
\begin{itemize}
5129+
\item
5130+
For \tcode{fetch_fmaximum} and \tcode{fetch_fminimum},
5131+
the maximum and minimum computation is performed
5132+
as if by \tcode{fmaximum} and \tcode{fminimum}, respectively,
5133+
with the value pointed to by \tcode{this} and the first parameter
5134+
as the arguments.
5135+
\item
5136+
For \tcode{fetch_fmaximum}_num and \tcode{fetch_fminimum_num},
5137+
the maximum and minimum computation is performed
5138+
as if by \tcode{fmaximum_num} and \tcode{fminimum_num}, respectively,
5139+
with the value pointed to by \tcode{this} and the first parameter
5140+
as the arguments.
5141+
\item
5142+
For \tcode{fetch_max} and \tcode{fetch_min},
5143+
the maximum and minimum computation is performed
5144+
as if by \tcode{fmaximum_num} and \tcode{fminimum_num}, respectively,
5145+
with the value pointed to by \tcode{this} and the first parameter
5146+
as the arguments, except that:
5147+
\begin{itemize}
5148+
\item
5149+
If both arguments are NaN,
5150+
an unspecified NaN value replaces the value pointed to by \tcode{this}.
5151+
\item
5152+
If exactly one argument is a NaN,
5153+
either the other argument or an unspecified NaN value
5154+
replaces the value pointed to by \tcode{this}; it is unspecified which.
5155+
\item
5156+
If the arguments are differently signed zeros,
5157+
which of these values replaces the value pointed to by this is unspecified.
5158+
\end{itemize}
5159+
\end{itemize}
5160+
5161+
\pnum
5162+
\recommended
5163+
The implementation of \tcode{fetch_max} and \tcode{fetch_min}
5164+
should treat negative zero as smaller than positive zero.
50385165
\end{itemdescr}
50395166

50405167
\indexlibrarymember{operator+=}{atomic<T*>}%

0 commit comments

Comments
 (0)