Impact of cpu cache lines验证

本文通过两个示例探讨了CPU缓存行对内存访问和性能的影响。Example 1表明,尽管第二个循环只完成了第一个循环约6%的工作量,但它们在现代机器上的运行时间相近,因为运行时间主要受内存访问而非乘法运算影响。Example 2深入解释了当步长超过数组中16个整数的倍数时,循环时间会因缓存行的利用而显著减少。了解缓存行对于某些程序优化至关重要。
摘要由CSDN通过智能技术生成

http://igoro.com/archive/gallery-of-processor-cache-effects/


此文提到

Example 1: Memory accesses and performance

How much faster do you expect Loop 2 to run, compared Loop 1?

int[] arr = new int[64 * 1024 * 1024];

// Loop 1
for (int i = 0; i < arr.Length; i++) arr[i] *= 3;

// Loop 2
for (int i = 0; i < arr.Length; i += 16) arr[i] *= 3;

The first loop multiplies every value in the array by 3, and the second loop multiplies only every 16-th. The second loop only does about 6% of the work of the first loop, but on modern machines, the two for-loops t

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure! The Viking Age had a significant impact on Europe and beyond. Here are some of the key ways: 1. Exploration and Trade: The Vikings were skilled seafarers who traveled vast distances, discovering new lands and establishing trade routes. They traded in goods such as furs, timber, and fish, and also brought back luxury goods like silk, spices, and precious metals from their travels. 2. Military Conquest: The Vikings were also known for their military prowess and raided many parts of Europe, leaving a trail of destruction in their wake. They conquered and settled in many areas, including England, Scotland, Ireland, and parts of Russia. 3. Language and Culture: The Vikings had a distinct culture and language that influenced the areas they conquered and settled in. Old Norse words and phrases can still be found in many modern European languages, and traditional Viking art and mythology continue to fascinate people today. 4. Technology and Innovation: The Vikings were skilled at shipbuilding and navigation, and they also developed new weapons and tools. The longship, a type of Viking ship, was particularly innovative and allowed them to travel long distances quickly. 5. Social and Political Changes: The Viking Age also brought about significant social and political changes, with new forms of government and social hierarchy emerging in the areas they conquered and settled in. Overall, the Viking Age had a lasting impact on Europe and the world, shaping language, culture, technology, and politics for centuries to come.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值