-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use broadcast for array operators #17313
Conversation
Cool. How is performance? I think that's the main (only?) concern here. |
@inbounds F[iF] = ($f)(A[iA], B[iB]) | ||
end | ||
return F | ||
promote_shape(A,B) # check size compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't broadcast
handle that check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite, broadcast
is more liberal: broadcast(+, rand(3,3), rand(3))
works while rand(3,3) + rand(3)
throws a DimensionMismatch
.
I'm not sure this PR makes sense at this juncture. I'm worried that it is too late for this to be worthwhile in 0.5, whereas for 0.6 there will be a completely different mechanism: dot operators will be converted by the parser to broadcast calls, so no method should be defined at all. |
I didn't do any thorough benchmarks, just checked adding a 1000×1000 to itself, and that was even slightly faster. Maybe some greater power could ask nanosoldier. Anyway, if this presents a performance penalty, we probably should improve @stevengj I was hoping this could make it into 0.5 (and, yes, be obsoleted in 0.6) to not have people complaining as in #17254 for a whole release cycle. And the change to un-dotted |
|
3ad148a
to
8a6ea6f
Compare
Rebased. |
@nanosoldier |
Fair enough, let's see how the performance looks. |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
Bummer. Interestingly, the regressions are less severe for the larger problem sizes, so probably some constant overhead kicking in. But |
If you're interested in fixing the performance challenges, https://github.com/JuliaCI/BaseBenchmarks.jl#recipe-for-testing-a-julia-pr-locally has some good tips. I often start out lazily and eventually (e.g., #17137) discover I have to run locally. I find that having two julia builds on the same machine, one master and one PR, helps make this a lot more efficient. |
8a6ea6f
to
b7c1bd9
Compare
Changed the non-dot operators to use the old implementation if I've also tried to short-circuit into Broadcast._broadcast!(op, F, (map(i->true, size(A)), map(i->true, size(B))), (A, B), Val{2}) instead of the Considering the original intention - having a fix for #17254 ready for 0.5 - I guess the current solution is reasonable: Only if |
I'll be ignored if I ask |
@nanosoldier |
Err... is there a way to see more of the error message? Is this my (this PR's) fault or nanosoldier's? cc @jrevels |
Removal of UTF16String broke JLD which broke BaseBenchmarks which broke nanosoldier. As of a few hours ago everything is fixed in the source code, but I bet something needs to do a |
^ This. ref JuliaCI/BenchmarkTools.jl#15. I've just updated JLD on nanosoldier. Let's see if it worked: @nanosoldier |
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. cc @jrevels |
LGTM. Any objections to merging? |
This is causing test failures on the buildbots (edit: locally too), likely due to an interaction with something else that was merged since travis last ran here: https://build.julialang.org/builders/build_centos7.1-x64/builds/1435/steps/shell_2/logs/stdio edit2: bandaid in #17394 |
Ref #17254: Motivation is to have the machinery for figuring out the result type available. For the dot-operators, this can be seen as temporary until they are lowered to
op.()
syntax anyway (if that is still the plan).Note that this does not fix the issue for other
AbstractArray
classes providing their own operator implementations.