Why is there huge performance hit in 2048x2048 versus 2047x2047 array multiplication?

前端 未结 10 1512
不思量自难忘°
不思量自难忘° 2020-11-29 17:06

I am making some matrix multiplication benchmarking, as previously mentioned in Why is MATLAB so fast in matrix multiplication?

Now I\'ve got another issue, when mu

10条回答
  •  青春惊慌失措
    2020-11-29 18:02

    As you are accessing the matice2 array vertically, it will be swapped in and out of the cache a lot more. If you mirror the array diagonally, so that you can access it using [k,m] instead of [m,k], the code will run a lot faster.

    I tested this for 1024x1024 matrices, and it is about twice as fast. For 2048x2048 matrices it's about ten times faster.

提交回复
热议问题