-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12547 from bradcray/reduce-atomics-future
Add future requesting the ability to + reduce atomics [trivial, not reviewed] It seems that we should be able to simply do reductions across arrays of atomics, yet this seems not to work without providing some additional helper functions yourself... This may relate somewhat to issue #8847.
- Loading branch information
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
reduceAtomics.chpl:12: error: Cannot directly add atomic variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var A: [1..10] atomic int; | ||
|
||
forall i in 1..10 do | ||
A[i].write(i); | ||
|
||
var AofA: [1..3] [1..10] atomic int; | ||
|
||
forall i in 1..3 do | ||
forall j in 1..10 do | ||
AofA[i][j].write(i*10 + j); | ||
|
||
var B = + reduce A; | ||
var C = + reduce AofA; | ||
|
||
writeln(B); | ||
writeln(C); | ||
|
||
|
||
// It's annoying that I have to define these in order to run a + | ||
// reduction over an array of atomic ints, but that seems to be | ||
// the case at present... | ||
/* | ||
proc +(x: atomic int, y: atomic int) { | ||
return x.read() + y.read(); | ||
} | ||
proc +=(ref x: int, y: atomic int) { | ||
x += y.read(); | ||
} | ||
proc +=(X: [?D] int, Y: [D] atomic int) { | ||
forall i in D do | ||
X[i] += Y[i].read(); | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
feature request: Support reductions on arrays of atomics | ||
|
||
It seems that we should support reductions on arrays of atomics, yet | ||
today we don't. Here, I focus on + reductions and atomic ints, but I | ||
think we should have a general solution for all cases. The commented | ||
out code demonstrates overloads that will make this program work as | ||
intended if I uncomment it. But I don't think I should have to write | ||
it and wouldn't expect most users to figure out how to do it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
55 | ||
63 66 69 72 75 78 81 84 87 90 |