4

bigintChapel を使用しており、マルチロケール設定で配列 に対して計算を実行しようとしています。1 行に 1 つの整数を含むファイルが読み取られます。各行はbigintレコードに変換され、単一の配列に挿入されます。4 つのロケールがあるため、各ロケールに入力ファイルの 1/4 のみを読み取り、その部分のみを処理するように依頼します。

問題を次の最小限の例に減らしましたが、これも影響を受けます。

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() {
                    // i in [startI;endI[
                    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 {
                // perform some computation
                elem = elem ** power;
            }
            dwriteln("Computed.");
        }
    }


}


}

ロケールが操作を並行して実行することを期待していますが、そうではありません。

ただし、コードを実行すると、各ロケールが順番に処理を行っているように見えます。つまり、ロケール 0 がファイルを読み取り、その処理を行い、次にロケール 1 がファイルを読み取り、その処理を行う、というように続きます。これの原因は何ですか?

4

1 に答える 1