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

前端 未结 10 1517
不思量自难忘°
不思量自难忘° 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 17:52

    Effectively utilizing the cache hierarchy is very important. You need to make sure that multidimensional arrays have data in a nice arrangement, which can be accomplished by tiling. To do this you'll need to store the 2D array as a 1D array together with an indexing mechanism. The problem with the traditional method is that although two adjacent array elements that are in the same row are next to each other in memory, two adjacent elements in the same column will be separated by W elements in memory, where W is the number of columns. Tiling can make as much as a factor-of-ten performance difference.

提交回复
热议问题