UnorderedCopy

Usage

use UnorderedCopy;

Warning

This module represents work in progress. The API is unstable and likely to change over time.

This module provides an unordered version of copy/assign for numeric types. The results from this function are not visible until task or forall termination or an explicit unorderedCopyFence(), but it can provide a significant speedup for bulk assignment operations that do not require ordering of operations:

use BlockDist, UnorderedCopy;

const size = 10000;
const space = {0..size};
const D = space dmapped Block(space);
var A, reversedA: [D] int = D;

forall i in D do
  unorderedCopy(reversedA[i], A[size-i]);

// no fence required, fenced at task/forall termination

forall (rA, i) in zip(reversedA, D) do
  assert(rA == size-i);

It's important to be aware that unordered operations are not consistent with regular operations and updates may not be visible until the task or forall that issued them terminates or an explicit unorderedCopyFence().

var a = 0;
on Locales[1] {
  var b = 1;
  unorderedCopy(b, a);
  writeln(b);        // can print 0 or 1
  unorderedCopyFence();
  writeln(b);        // must print 0
}

Generally speaking they are useful for when you have a large batch of remote assignments to perform and the order of those operations doesn't matter.

Note

Currently, this is only optimized for CHPL_COMM=ugni. Other communication layers fall back to regular operations. Under ugni, GETs are internally buffered. When the buffers are flushed, the operations are performed all at once. Cray Linux Environment (CLE) 5.2.UP04 or newer is required for best performance. In our experience, buffered gets can achieve up to a 5X performance improvement over non-buffered gets for CLE 5.2UP04 or newer.

proc unorderedCopy(ref dst, ref src): void

Unordered copy. Only supported for numeric types.

proc unorderedCopyFence(): void

Fence any pending unordered copies. Note that this is a global fence across all locales.