diff --git a/test/library/packages/ParallelIO/delimIter.chpl b/test/library/packages/ParallelIO/delimIter.chpl index f815953f035b..cb170779a584 100644 --- a/test/library/packages/ParallelIO/delimIter.chpl +++ b/test/library/packages/ParallelIO/delimIter.chpl @@ -14,6 +14,10 @@ proc main() { with (ref things) do mapAddOrSet(things, t.k, t.v); + // ensure the file was read correctly + for (k, v) in zip(things.keys(), things.values()) do + assert(thingsActual[k] == v, "single-locale mismatch"); + // multi-locale read var things2 = new map(int, int, parSafe=true); forall t in readDelimited(fileName, t=thing, delim=",", nTasks=nTasks, targetLocales=Locales) @@ -21,9 +25,6 @@ proc main() { mapAddOrSet(things2, t.k, t.v); // ensure the file was read correctly - for (k, v) in zip(things.keys(), things.values()) do - assert(thingsActual[k] == v, "single-locale mismatch"); - for (k, v) in zip(things2.keys(), things2.values()) do assert(thingsActual[k] == v, "multi-locale mismatch"); } @@ -62,18 +63,20 @@ proc makeThingsFile(path: string, n: int): map(int, int) { } proc mapAddOrSet(ref m: map(int, int), k: int, v: int) { - record adder { - const val: int; - - proc this(k: int, ref v: int) { - v += this.val; - return none; + on Locales[0] { + record adder { + const val: int; + + proc this(k: int, ref v: int) { + v += this.val; + return none; + } } - } - if m.contains(k) - then m.update(k, new adder(v)); // update 'v' in place - else if !m.add(k, v) // try to add 'k' and 'v' - // another task added 'k' in the meantime, so update it instead - then m.update(k, new adder(v)); + if m.contains(k) + then m.update(k, new adder(v)); // update 'v' in place + else if !m.add(k, v) // try to add 'k' and 'v' + // another task added 'k' in the meantime, so update it instead + then m.update(k, new adder(v)); + } }