I am using Chapel and I am trying to do the calculation in an array bigint
in a tiered setup. Read a file containing one integer per line. Each row is converted to a record bigint
, which is then inserted into a single array. I have 4 locales, and so I ask each locale to read only 1/4 of the input file and process only this part.
I reduced my problem to the following minimal example, which is also affected:
module Hello {
use BigInteger;
use Math;
use Time;
config const inputPath = "/path/to/file";
config const inputSize = 10000000;
config const power = 2000;
proc dwriteln(args ...?n) {
var curr = getCurrentTime(unit=TimeUnits.seconds);
writeln("[ ", here.id, ": ", here.name, " ] [ ", curr, " ] ", (...args));
}
proc main() throws {
writeln("Input path: ", inputPath);
writeln("numLocales: ", numLocales);
var elementsPerLocale = divceil(inputSize, numLocales);
writeln("elementsPerLocale: ", elementsPerLocale);
coforall loc in Locales {
on loc {
dwriteln("hello");
var inputFile = open(inputPath, iomode.r, hints=IOHINT_CACHED);
var reader = inputFile.reader();
var startI = here.id * elementsPerLocale;
var endI = startI+elementsPerLocale;
dwriteln("startI = ", startI, " endI= ", endI);
var a: [1..0] bigint;
var i = 0;
for line in reader.lines() {
if i >= startI && i < endI {
a.push_back(new bigint(line, 16));
}
i +=1;
}
reader.close();
inputFile.close();
dwriteln("created array of size: ", a.size);
forall elem in a {
elem = elem ** power;
}
dwriteln("Computed.");
}
}
}
}
I expect locales to perform operations in parallel, but this is not the case.
, . , locale 0 , , 1 . ?