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

Improving performance through matrix operations (?) #11

Open
gadamico opened this issue Apr 26, 2016 · 1 comment
Open

Improving performance through matrix operations (?) #11

gadamico opened this issue Apr 26, 2016 · 1 comment

Comments

@gadamico
Copy link

The trouble with the naive version of matrix multiplication was that there was unnecessary latency since we were accessing the second matrix factor ("B") by its columns rather than its rows. It occurred to me that one way of improving the performance would therefore be to transpose B and then to multiply the rows of A by the rows of B^T....

... But I suppose the cost of doing the transposing work would make this a worse option? And perhaps even worse than just cranking through the naive version?

@quantheory
Copy link
Member

It seems unlikely that this would help for a single matrix multiplication. Think about how the transpose has to be implemented. You have to have the matrix B, and a matrix that's the transpose (call it BT). When you're doing the copying, either you have to access the matrix B row-wise and the matrix BT column-wise, or vice-versa, so that operation is not any more cache-friendly, and also not vectorizable with SIMD.

However, if you know that you will want to access B column-wise many times, it may make sense to take the transpose right away and reuse that copy.

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

No branches or pull requests

2 participants