Skip to content

Commit

Permalink
Closes Bears-R-Us#3367 racy condition in SegHead function (Bears-R-Us…
Browse files Browse the repository at this point in the history
…#3369)

* Closes Bears-R-Us#3367 racy condition in SegHead function

* Replace loop with more performant version

---------

Co-authored-by: Amanda Potts <[email protected]>
  • Loading branch information
ajpotts and ajpotts authored Jun 28, 2024
1 parent e9023c6 commit 5e09a33
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/ReductionMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,12 @@ module ReductionMsg
const dom = makeDistDom(newSize);
var ret = makeDistArray(dom, intype);

forall (oldSegStart, newSegStart, newLength) in zip(segments, newSegs, newSegLengths) with (var agg = newSrcAggregator(intype)){
agg.copy(ret[newSegStart..#newLength], values[oldSegStart..#newLength]);
forall (oldSegStart, newSegStart, newLength) in zip(segments, newSegs, newSegLengths) with (ref values,
var agg = newDstAggregator(intype)){
var v = new lowLevelLocalizingSlice(values, oldSegStart..#newLength);
for i in 0..#newLength {
agg.copy(ret[newSegStart+i], v.ptr[i]);
}
}
return ret;
}
Expand All @@ -978,8 +982,12 @@ module ReductionMsg
const dom = makeDistDom(newSize);
var ret = makeDistArray(dom, intype);

forall (oldSegEnd, newSegEnd, newLength) in zip(oldSegEnds, newSegEnds, newSegLengths) with (var agg = newSrcAggregator(intype)){
agg.copy(ret[(newSegEnd - newLength)..#newLength], values[(oldSegEnd - newLength)..#newLength]);
forall (oldSegEnd, newSegEnd, newLength) in zip(oldSegEnds, newSegEnds, newSegLengths) with (ref values,
var agg = newDstAggregator(intype)){
var v = new lowLevelLocalizingSlice(values, (oldSegEnd - newLength)..#newLength);
for i in 0..#newLength {
agg.copy(ret[(newSegEnd - newLength)+i], v.ptr[i]);
}
}
return ret;
}
Expand Down

0 comments on commit 5e09a33

Please sign in to comment.