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

Add specialized methods for complex-real BLAS multiplication. #6235

Merged
merged 1 commit into from
Apr 10, 2014

Conversation

andreasnoack
Copy link
Member

This implements the method proposed by @stevengj for multiplying a complex matrix with a real matrix or vector. On my computer this gives around a 12x speed up for two 1000x1000 matrices over calling the generic algorithm which is what happens now and it is a double speed up over converting the real array to complex.

The only methods where (I can see that) this is feasible are A_mul_B(Matrix{Complex},MatOrVec{Real}), A_mul_Bt(Matrix{Complex},Matrix}) and by transposing the result also A_mul_Bt(Matrix{Real},Matrix{Complex}) and At_mul_Bt(Matrix{Real},Matrix{Complex}). A_mul_B(Matrix{Real},Vector{Complex}) could be written in terms of two dgemv call with stride=2, but in my benchmarks this is not faster than the generic algorithm.

Finally, I tried to write methods for dot but it was not faster than the Julia version. Not surprisingly, it appears that it is mainly for level 3 operations that BLAS gives big speed gains.

@andreasnoack
Copy link
Member Author

I have removed the two versions that transposed the result. It is probably better just to convert the input matrix to complex for these two. For larger matrices this should be the approach except for A_mul_B(Matrix{Complex},MatOrVec{Real}) and A_mul_Bt(Matrix{Complex},Matrix}) which can use the trick. Related to #3239

@andreasnoack
Copy link
Member Author

I'll merge this tonight if I hear no complains. Note that this pull request also adds exclamation marks to the mutating multiplication functions. This is noted in the commit message, but not in the comments.

… of matmul.jl. This includes some !s in the mutation versions.
@carlobaldassi
Copy link
Member

I'll merge this tonight if I hear no complains.

Bump. (12 days later, no complains were heard :) )

@andreasnoack
Copy link
Member Author

I know, but during that day I realised that @stevengj also worked to matmul.jl and decided to wait for him to merge. I think many of the headers in the file should be AbstractMatrix after the recent development in the type hierarchy for arrays, but that can be in another pull request. I'll merge this now.

andreasnoack added a commit that referenced this pull request Apr 10, 2014
Add specialized methods for complex-real BLAS multiplication.
@andreasnoack andreasnoack merged commit 588b4f8 into master Apr 10, 2014
@andreasnoack andreasnoack deleted the anj/complexreal branch April 10, 2014 08:45
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.

2 participants