amo

Date:

08-03-2026

NAME

amo_aadd, amo_aaddf, amo_afadd, amo_aax, amo_afax, amo_aandf, amo_afand, amo_anandf, amo_afnand, amo_aorf, amo_afor, amo_axorf, amo_afxor, amo_acswap, amo_aswap, amo_aflush - Perform various atomic memory operations

SYNOPSIS

Fortran Synopsis

call amo_aadd( var, value)
  integer (kind=8) var, value

integer function amo_aaddf( var, value)
  integer (kind=8) var, value

integer function amo_afadd( var, value)
  integer (kind=8) var, value

call amo_aax( var, andMask, xorMask )
  integer (kind=8) var, andMask, xorMask

integer function amo_afax( var, andMask, xorMask )
  integer (kind=8) var, andMask, xorMask

integer function amo_aandf( var, value)
  integer (kind=8) var, value

integer function amo_afand( var, value)
  integer (kind=8) var, value

integer function amo_anandf( var, value)
  integer (kind=8) var, value

integer function amo_afnand( var, value)
  integer (kind=8) var, value

integer function amo_aorf( var, value)
  integer (kind=8) var, value

integer function amo_afor( var, value)
  integer (kind=8) var, value

integer function amo_axorf( var, value)
  integer (kind=8) var, value

integer function amo_afxor( var, value)
  integer (kind=8) var, value

integer function amo_acswap( var, compareValue, replacementValue )
  integer (kind=8) var, compareValue, replacementValue

integer function amo_aswap( var, replacementValue )
  integer (kind=8) var, replacementValue

call amo_aflush( var )
  integer (kind=8) var

DESCRIPTION

Atomic memory operations (AMOs), unlike other functions, cannot be interrupted by the system and can allow multiple threads to safely modify the same variable under certain conditions. The AMO intrinsics allow you to add, subtract, AND, NAND, OR, and XOR values together, or compare and swap values.

It is possible to safely modify a variable using both atomic and non-atomic operations within a single thread; however, if a thread modifies a variable with an atomic operation and a different thread concurrently modifies the same variable with a non-atomic operation, the result is indeterminate.

Global AMOs use the network interface to access variables in memory. The variables may or may not be in the processor’s local cache domain. Global AMOs are atomic with respect to each other. Global AMOs are used to modify a Fortran coarray and are available only when compiling coarray Fortran (-hcaf).

These are the Fortran Global AMO intrinsics:

  • The amo_aadd subroutine (atomic add) adds value to the var object.

  • The amo_aaddf function (atomic add and fetch) adds value to the var object and returns the new value.

  • The amo_afadd function (atomic fetch and add) adds value to the var object and returns the old value.

  • The amo_aax subroutine (atomic AND and XOR) ANDs var with andMask, XORs the result with xorMask, and places the result into var.

  • The amo_afax function (atomic fetch and AND and XOR) ANDs var with andMask, XORs the result with xorMask, places the result into var, and returns the old value of var.

  • The amo_aandf function (atomic AND and fetch) ANDs value with var, places the result into the var object, and returns the new value of var.

  • The amo_afand function (atomic fetch and AND) ANDs value with var, places the result into the var object, and returns the old value of var.

  • The amo_anandf function (atomic NAND and fetch) NANDs value with var, places the result into the var object, and returns the new value of var.

  • The amo_afnand function (atomic fetch and NAND) NANDs value with var, places the result into the var object, and returns the old value of var.

  • The amo_aorf function (atomic OR and fetch) ORs value with var, places the result into the var object, and returns the new value of var.

  • The amo_afor function (atomic fetch and OR) ORs value with var, places the result into the var object, and returns the old value of var.

  • The amo_axorf function (atomic XOR and fetch) XORs value with var, places the result into the var object, and returns the new value of var.

  • The amo_afxor function (atomic fetch and XOR) XORs value with var, places the result into the var object, and returns the old value of var.

  • The amo_acswap function (atomic compare and swap) compares and swaps a value by replacing var with replacementValue if compareValue is equal to var. This function always returns the old value.

  • The amo_aswap function (atomic swap) swaps a value by replacing var with replacementValue. This function always returns the old value.

  • The amo_aflush subroutine (atomic flush) forces var to be written to memory.

SEE ALSO

Cray Fortran Reference Manual