Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust + reduce on atomics for Chapel POI change #453

Merged
merged 1 commit into from
Aug 13, 2020

Conversation

vasslitvinov
Copy link
Contributor

@vasslitvinov vasslitvinov commented Aug 12, 2020

Arkouda runs + reduce on arrays of atomic ints. For that, it redefines + and += on atomics in user code to read() from each atomic int. Starting with chapel-lang/chapel#16158 this does not work any longer.

Instead, implement this reduction using a forall loop with a reduce intent, reading the atomics within the loop. This works with both Chapel 1.22 release and Chapel master.

Testing: make test-python test-chapel with 1.22 homebrew and with Chapel master under gasnet.

Minor performance improvement left as future work: specialize the pattern:

var hist = makeDistArray(bins,int);
hist = lHist;
return hist;

for the case when MyDmap == Dmap.defaultRectangular, by returning lHist (or gHist) directly.

Arkouda runs `+ reduce` on arrays of atomic ints. For that, it redefines `+` and `+=` on atomics in user code to read() from each atomic int. Starting with chapel-lang/chapel#16158 this does not work any longer.

Instead, implement this reduction using a forall loop with a reduce intent, reading the atomics within the loop. This works with both Chapel 1.22 release and Chapel master.

Testing: `make test-python test-chapel` with 1.22 homebrew and with Chapel master under gasnet.

Minor performance improvement left as future work: specialize the pattern:
```chpl
var hist = makeDistArray(bins,int);
hist = lHist;
return hist;
```
fot the case when `MyDmap` == `Dmap.defaultRectangular`, by returning `lHist` (or `gHist`) directly.
@bradcray
Copy link
Contributor

Hi @mhmerrill — Arkouda has been breaking in testing against our master branch this week due to changes to how point of instantiation is handled for generic functions to prevent surprises and hijacking. This change will fix it, so would be nice to merge if you're open to it. The reason POI comes into play is that the code implementing the reduction doesn't necessarily have access to the scope where the Arkouda-overloaded + operations are defined. This is a question we're continuing to wrestle with ("How should visibility of operators be handled?") and relates to a question I asked you a month or so ago about whether you had preferences between expressing operator overloads as standalone functions or methods. Bottom line: I don't think the design questions here are fully resolved yet, but it would be helpful to us to merge this PR to keep our testing working and on-track if you're OK with it.

Copy link
Contributor

@mhmerrill mhmerrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good change. Thanks.

@mhmerrill mhmerrill merged commit a1c64e5 into Bears-R-Us:master Aug 13, 2020
@bradcray
Copy link
Contributor

In discussing this, Mike asked "Should the language just have support for + and + reduce on atomics?" which led me to file chapel-lang/chapel#16239 on the Chapel repo

@vasslitvinov vasslitvinov deleted the histogram-fix branch August 13, 2020 20:22
@vasslitvinov
Copy link
Contributor Author

Mike, thank you for reviewing my two PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants