Skip to content

P0493 R5 Atomic maximum/minimum #866

Closed
cplusplus/draft
#6918
@wg21bot

Description

@wg21bot
Collaborator

P0493R1 Atomic maximum/minimum (Al Grant, Bronek Kozicki)

Activity

added this to the 2020-telecon milestone on May 21, 2020
ogiroux

ogiroux commented on Jul 7, 2020

@ogiroux
Collaborator

Continue the discussion of early bail offline (idempotent operations being said to be non-synchronizing while allowing strengthening as well).

Want an atomic min/max operation.
Yay 9 Nay 1

We want this operation (with the semantics we determine are right) to be called fetch_min/max.
No objections.

added
B3 - additionBucket 3 as described by P0592: material that is not mentioned in P0592
ISShip vehicle: IS
on Aug 25, 2020
removed this from the 2020-telecon milestone on Dec 27, 2020
wg21bot

wg21bot commented on May 21, 2021

@wg21bot
CollaboratorAuthor

P0493R2 Atomic maximum/minimum (Al Grant, Bronek Kozicki)

added this to the 2021-telecon milestone on May 21, 2021
inbal2l

inbal2l commented on Sep 11, 2021

@inbal2l
Member

The paper was seen by LEWG ML review. summary:

  • A request for benchmarks demonstrating the facility is better then the CAS + loop
    Authors: The performance benefit is that a non-CAS implementation would instead rely on an existing CPU-level implementation which, as the paper explains, is already available on many platforms (Editor's note: this is standardization of existing practice).

  • A request for a "Tony table" of code with and without the proposed functions
    Authors: Example of CAS exists in N2396. Example of 'atomic_fetch_max':

T atomic_fetch_max(T value)
{
    unsigned long read = this->load();
    while (value > read) {
      if (this->compare_exchange_weak(read, value))
        return read;
    }
    return read;
}
  • Regarding the write barrier macro - Is it possible that code built for an architecture that doesn’t need the barrier could run on an architecture that does, or vice versa? Point is to avoid making things compile-time constants when they might more correctly be decided at run time.
    Authors: This is a very good question. One platform made its behaviour in the past subject to environment flags.
    I hope that if such a macro was provided, it wouldn't need to be used often and in cases when it would make a difference, an alternative algorithm could be found.
    Perhaps by NOT defining such a macro, we will encourage that all algorithms should be written this way and end up with better lockfree designs.

  • Strong support in the proposal: 

    • Functionality proposed on this papier, will eliminate 99% of the CAS loop usages in the code I have written, and by doing so improve its usability.
    • Many implementations already provide intrinsics for these operations, and they are both widely used and work well.

I didn't recognize objections to the proposal.
I recommend that the authors will add the examples requested, and that we'll move fixed revision directly to electronic polls.

105 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B3 - additionBucket 3 as described by P0592: material that is not mentioned in P0592C++26Targeted at C++26ISShip vehicle: ISLWGLibraryconcurrencyplenary-approvedPapers approved for inclusion in their target vehicle by plenary vote.size - mediumpaper size estimate

    Type

    No type

    Projects

    Status

    Tentatively Ready

    Relationships

    None yet

      Development

      Participants

      @brycelelbach@FabioFracassi@jwakely@cor3ntin@JeffGarland

      Issue actions

        P0493 R5 Atomic maximum/minimum · Issue #866 · cplusplus/papers