How to copy variables across multiple locales in the Chapel
1 answer
You can use to get a copy of a variable for each locale. To make it easier to use, there is a module . ReplicatedDist
UtilReplicatedVar
use UtilReplicatedVar;
var regularInt = 42;
// rcDomain is declared in UtilReplicatedVar. It maps
// one int value to each locale
var repInt: [rcDomain] int;
// Other types can be replicated as well. Here a
// heterogeneous tuple containing an integer,
// real, and complex is replicated
var repTuple: [rcDomain] (int, real, complex);
// Assign 42 to the replicated int on all locales
rcReplicate(repVar, regularInt);
// Access the local copy of the replicated var.
// The first form must use 1 as the index.
repVar[1] = 0;
writeln(rcLocal(repVar));
// Access the local complex component of the tuple
writeln(repTuple[1](3));
// Access a remote copy.
rcRemote(repVar, remoteLocale);
+3
source to share