News for hackers. Stuff that matters.
Re:A 100x speedup with unsafe Python by planede on Tuesday May 07, 2024 @07:45AM (#40284405)
Your reasoning starts out nicely with y=Ax, but you get the wrong conclusion. The layout of x and y are not affected at all by row or column order, they are just consecutive numbers in either case. So you have to look at the layout of A.

For the row-major layout the multiplication Ax ends up being more cache-efficient than for the column major layout, as for calculating each component of y you need to scan x and a row of A.

Re:A 100x speedup with unsafe Python by bee_rider on Tuesday May 07, 2024 @10:11AM (#40285664)
I’m pretty sure BLAS will tile out the matrix multiplication internally anyway, so it doesn’t matter. At least for matmat would, is matvec special?
Re:A 100x speedup with unsafe Python by planede on Tuesday May 07, 2024 @11:43AM (#40287137)
However matmat is done, row-major vs column-major for both matrices shouldn't make a difference (for square matrices at least).

I don't know if tiling is done for matvec. I don't think it makes sense there, but I didn't think about it too hard.