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

Implement +(as...) etc. for Array #3223

Closed
ViralBShah opened this issue May 28, 2013 · 6 comments
Closed

Implement +(as...) etc. for Array #3223

ViralBShah opened this issue May 28, 2013 · 6 comments
Labels
performance Must go faster

Comments

@ViralBShah
Copy link
Member

There may be some gains to implementing +(as...) and other similar cases for arrays. This should be faster and also allocate fewer temporaries.

@JeffBezanson
Copy link
Sponsor Member

It would probably help a bit, but it seems to me A + B + C is actually less common than A + s*B. Also, currently we can only do this efficiently for specific numbers of arrays, e.g. +(A,B,C), +(A,B,C,D) etc.

@toivoh
Copy link
Contributor

toivoh commented May 28, 2013

For the array types that it supports, + could call .+ after checking type compatibility. Or I could provide another entry point to the broadcast machinery that it could use. Even though this is not actually broadcasting, a lot of the optimizations are the same, especially for strided arrays. My plan is that the broadcast machinery should eventually be efficient for diverse kinds of arrays, and also in cases where you don't actually need broadcasting. But that will probably take some time yet.

Anyways, the broadcast machinery does include a limited form of staged functions so that this can be done once for any number of arguments. It shouldn't be so hard to hack together something similar (and simpler) for this case.

@ViralBShah
Copy link
Member Author

The general case is the kinds of things that @lindahua does in Devectorize.jl. My guess is that every such little optimization over time will add up to significant gains overall.

@lindahua
Copy link
Contributor

I agree with Jeff that x += a * y is probably more common in practice.

A fundamental way to boost these things is lazy evaluation, that is, actual codes are generated only when it sees the entire expression.

I think Devectorize.jl can be designed in a better way. I will revisit this when I get time in the summer.

@stevengj
Copy link
Member

stevengj commented Aug 2, 2016

This should be closed by #17623, since x .+ y .+ z .+ ... will fuse into a single broadcast loop.

@stevengj
Copy link
Member

Closed by #17623.

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

No branches or pull requests

5 participants