Skip to content

Commit

Permalink
Fix failing readDelmited test (#25850)
Browse files Browse the repository at this point in the history
Following, #25730,
`/test/library/packages/ParallelIO/delimIter.chpl` was failing
intermittently due to the test containing remote updates to a parallel
map (which `map` does not support). This PR fixes the failure by adding
an on-clause around the map updates.

- [x] test passing w/ gasnet for 100's of trials

[ trivial - not reviewed ]
  • Loading branch information
jeremiah-corrado authored Aug 30, 2024
2 parents 789e150 + 60b3b28 commit 998a5a0
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions test/library/packages/ParallelIO/delimIter.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ 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)
with (ref things2) do
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");
}
Expand Down Expand Up @@ -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));
}
}

0 comments on commit 998a5a0

Please sign in to comment.