To: J3 12-xxx From: Bill Long Subject: Atomic compare-and-swap Date: 2012 June 27 Discussion: --------- N1930 requirement 4 adds five new atomic subroutines to the Coarray TS. This paper provides semantics and edits for the Atomic Compare and Swap routine. Semantics: ---------- The operation of the compare and swap intrinsic: atomic_cas (atom, old, compare, new) is to perform atomically: old = atom if (old == compare) atom = new Edits: --------- In the TS Clause for new intrinsic procedures, add this subsubclause in the subclause on Atomic Subroutines alphabetically by routine name. " 4.x.y ATOMIC_CAS (ATOM, OLD, COMPARE, NEW) Description. Conditionally swap values atomically. Class. Atomic subroutine. Arguments. ATOM shall be scalar and of type integer with kind ATOMIC_INT_KIND or of type logical with kind ATOMIC_LOGICAL_KIND, where ATOMIC_INT_KIND and ATOMIC_LOGICAL_KIND are the named constants in the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If the value of ATOM is equal to the value of COMPARE, ATOM becomes defined with the value of INT (NEW, ATOMIC_INT_KIND) if it is of type integer, and with the value of NEW if it of type logical. OLD shall be scalar and of the same type as ATOM. It is an INTENT (OUT) argument. It becomes defined with the value of INT (ATOMC, KIND (OLD)) if ATOM is of type integer, and the value of ATOMC if ATOM is of type logical, where ATOMC has the same type and KIND as ATOM and has the value of ATOM used for the compare operation. COMPARE shall be scalar and of the same type and kind as ATOM. It is an INTENT(IN) argument. NEW shall be scalar and of the same type as ATOM. It is an INTENT(IN) argument. Example. CALL ATOMIC_CAS(I[3], OLD, Z, 1) causes I on image 3 to become defined with the value 1 if its value is that of Z, and OLD to become defined with the value of I on image 3 prior to the comparison." In the Edits clause of the TS, in the subclause for edits to Clause 13, add --------------------------- '[323:Table13.1] In Table 13.1 Standard generic intrinsic procedure summary, add a new entry "ATOMIC_CAS (ATOM, OLD, COMPARE, NEW) A Conditionally swap values atomically."' --------------------------- In the Edits clause of the TS, in the subclause for edits to Clause 13, add "Move the description of ATOMIC_CAS from 4.x.y in this Technical Specification to Clause 13 of \Fortranstandard{} in order alphabetically." ---------------------------