Why are elementwise additions much faster in separate loops than in a combined loop?

后端 未结 10 710
旧巷少年郎
旧巷少年郎 2020-11-22 09:49

Suppose a1, b1, c1, and d1 point to heap memory and my numerical code has the following core loop.

const i         


        
10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 09:56

    The second loop involves a lot less cache activity, so it's easier for the processor to keep up with the memory demands.

提交回复
热议问题