News for hackers. Stuff that matters.
Re:Switching to Mojo gave a 14% improvement over CUDA by londons_explore on Friday June 06, 2025 @07:33PM (#44206104)
Why do we ever need to transpose a matrix?

Isn't it better to simply combine the transposition with whatever next operation one wishes to do with the matrix?

Re:Switching to Mojo gave a 14% improvement over CUDA by throwawayabcdef on Friday June 06, 2025 @08:20PM (#44206349)
The next operation might need the data in column major order to read it fast. So you might have to transpose first. And these maybe be concurrent stages of a processing pipeline.
Re:Switching to Mojo gave a 14% improvement over CUDA by viraptor on Friday June 06, 2025 @09:27PM (#44206655)
Now I'm curious, how many times do you have to fully read the matrix in GPU for the total impact of reading columns to be higher than one-off actual transpose and then sequential row reads? I know it depends on lots of things, I'm after a rough estimate.
Re:Switching to Mojo gave a 14% improvement over CUDA by saagarjha on Saturday June 07, 2025 @05:59AM (#44208611)
It's quite rare. Usually problems are tiled anyway and you can amortize the cost of having data in the "wrong" layout by loading coalesced in whatever is the best layout for your data and then transposing inside your tile, which gives you access to much faster memory.
Re:Switching to Mojo gave a 14% improvement over CUDA by stephencanon on Saturday June 07, 2025 @11:50AM (#44210433)
The one pure transpose case that does come up occasionally is an in-place non-square transpose, where there is a rich literature of very fussy algorithms. If someone managed to make any headway with compiler optimization there, I'd be interested.
Re:Switching to Mojo gave a 14% improvement over CUDA by hogepodge on Friday June 06, 2025 @08:25PM (#44206373)
You're right that a good graph compiler will do this for you. There still may be times, like if you're interfacing with another library, where you'll need to switch a matrix between row major or column major layouts.
Re:Switching to Mojo gave a 14% improvement over CUDA by meindnoch on Saturday June 07, 2025 @08:33AM (#44209227)
Serious linear algebra libraries expect a flag that tells if elements are column-major or row-major.
Re:Switching to Mojo gave a 14% improvement over CUDA by fulafel on Saturday June 07, 2025 @02:14AM (#44207772)
This could make Mojo look even better as it would ld be more compute heavy and the last step thread reduction would be less relevant.