PeekPoke

Usage

use PeekPoke;

or

import PeekPoke;

Support for directly accessing an ‘atomic’ variable’s value.

Warning

This module is unstable and the API is likely to change over time.

This module provides peek() and poke() operations on atomics. peek() and poke() are non-atomic read and write operations. They can provide a performance improvement when local reads/writes are performed and atomicity is not required. For example they can be used to initialize an array of atomics or perform a reduction when no concurrent updates are occurring.

use BlockDist, PeekPoke;

const space = {1..1000};
const D = space dmapped blockDist(space);
var A: [D] atomic int;

forall i in D do
  A[i].poke(i);

const sum = + reduce A.peek();
writeln(sum); // 500500
proc AtomicBool.peek(): bool

Non-atomically reads the stored value.

proc ref AtomicBool.poke(val: bool): void

Non-atomically writes val.

proc AtomicT.peek(): valType

Non-atomically reads the stored value.

proc ref AtomicT.poke(val: valType): void

Non-atomically writes val.