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

Parsing to wrap Level 3 BLAS routines syr2k/her2k #4950

Closed
jiahao opened this issue Nov 26, 2013 · 13 comments
Closed

Parsing to wrap Level 3 BLAS routines syr2k/her2k #4950

jiahao opened this issue Nov 26, 2013 · 13 comments
Labels
linear algebra Linear algebra speculative Whether the change will be implemented is speculative

Comments

@jiahao
Copy link
Member

jiahao commented Nov 26, 2013

PR #4813 provides a BLAS wrapper to the symmetric rank 2k update function syr2k, which provides the updates:

C := alpha*A*B' + alpha*B*A' + beta*C,
C := alpha*A'*B + alpha*B'*A + beta*C,

Is it worth parsing Julia expressions of this form and turning them into calls to syr2k/her2k?

@StefanKarpinski
Copy link
Sponsor Member

Doing this in the parser is not really the direction we should be heading here, IMO, but it's not entirely clear how else to approach it.

@kmsquire
Copy link
Member

kmsquire commented Nov 27, 2013

It would be nice if, at some point, the parser provided hooks to allow user code to analyze and rewrite expressions like this.

Kevin

@StefanKarpinski
Copy link
Sponsor Member

Yes. We've discussed this forever and haven't come up with anything satisfactory yet. It's really hard to make something like this not super brittle.

@JeffBezanson
Copy link
Sponsor Member

The only thing that comes to mind is something like Haskell rewrite rules.

@StefanKarpinski
Copy link
Sponsor Member

Honestly, I'm not even sure we should do this. It's getting into "sufficiently clever compiler" territory. Having the syr2k routines there for those who know about them and want to call them is already pretty good. This fits with our whole philosophy of doing something simple, understandable and reasonably fast by default but allowing experts to easily tune their codes to get even more performance with a bit of work. Looking for opportunities to use calls like syr2k and her2k seems like the kind of things human experts are best cut out for.

@JeffBezanson
Copy link
Sponsor Member

Yeah, it leaves me a bit cold too.

@ViralBShah
Copy link
Member

I wouldn't mind trying out rewrite rules and it would be better if they can be expressed in julia rather than being part of the parser. Rewrite rules combined with type inference could make it possible for us to efficiently deal with a lot of array expressions.

rewrite
   C::Matrix = A::Matrix'*A::Matrix
as
   someblascall(A,C)
end

The other big thing is reusing memory in something like eigs or anything iterative, where repeated matrix-vector products happen.

@JeffBezanson
Copy link
Sponsor Member

That approach is certainly better than mucking with the parser.

@jiahao
Copy link
Member Author

jiahao commented Nov 27, 2013

@ViralBShah's idea was sort of what I had in mind. I take it that this is implemented on top of the base Julia parser?

@JeffBezanson
Copy link
Sponsor Member

Yes, there would be no parser changes. These would be patterns that the compiler can match and apply if it is able to. They are advisory and for performance only.

@jiahao
Copy link
Member Author

jiahao commented Nov 27, 2013

Yeah, that's the clearly the way to go then.

@andreasnoack
Copy link
Member

@JeffBezanson do you think anything like #4950 (comment) will ever happen? If not, we should probably close this issue.

@KristofferC
Copy link
Sponsor Member

Adding this to the parser seems quite unlikely due to how dynamic Julia has become.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra speculative Whether the change will be implemented is speculative
Projects
None yet
Development

No branches or pull requests

7 participants