缓存线乒乓和错误共享是否相同? [英] Are cache-line-ping-pong and false sharing the same?

查看:146
本文介绍了缓存线乒乓和错误共享是否相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的学士论文,我必须评估多核系统上的常见问题.

For my bachelor thesis I have to evaluate common problems on multicore systems.

在某些书籍中,我读到了有关虚假共享的信息,在其他书籍中,我读到了关于缓存线乒乓球的信息.特定的问题听起来非常熟悉,所以这些是相同的问题,但具有其他名称吗? 有人可以给我提供详细讨论这些主题的书籍的名称吗? (我已经有塔里鲍姆(Danenbaum)的达里·格洛夫(Darry Glove)的文献了……)

In some books I have read about false sharing and in other books about cache-line-ping-pong. The specific problems sound very familiar, so are these the same problems but given other names? Can someone give me names of books which discuss these topics in detail? (I already have literature from Darry Glove, Tanenbaum,...)

推荐答案

摘要:

虚假共享缓存行ping-ponging 是相关的,但不是同一回事.错误共享会导致高速缓存行ping-poning,但这不是唯一可能的原因,因为高速缓存行ping-ponging也可能由真正的共享引起.

Summary:

False sharing and cache-line ping-ponging are related but not the same thing. False sharing can cause cache-line ping-ponging, but it is not the only possible cause since cache-line ping-ponging can also be caused by true sharing.

当不同的线程在程序中具有未共享的数据,但此数据被映射到共享的缓存行时,就会发生错误共享.例如,假设一个程序具有一个整数数组,其中一个线程执行读取和写入具有偶数索引的所有数组条目,而另一个线程执行读取和写入具有奇数索引的条目.在这种情况下,线程实际上不会共享数据,但是它们将共享高速缓存行,因为每条高速缓存行都将包含奇数和偶数索引值(假设高速缓存行大于整数,通常是正确的).

False sharing occurs when different threads have data that is not shared in the program, but this data gets mapped to a cache line that is shared. For example imagine a program that had an array of integers where one thread performed reads and writes to all of the array entries with an even index, and the other thread performed reads and writes to entries with an odd index. In this case the threads would not actually be sharing data, but they would share cache lines since each cache line would contain both odd and even indexed values (assuming the cache line was bigger than an integer, which is typically true).

高速缓存线ping-ponging是一种效果,其中高速缓存线在多个CPU(或内核)之间快速连续地传输.这可能是由于 错误或真实共享引起的.本质上,如果多个CPU试图在同一高速缓存行中读取和写入数据,则该高速缓存行可能必须快速连续地在两个线程之间传输,并且这可能会导致性能显着下降(与单个驱动器相比,性能甚至可能更差).线程正在执行).错误共享会使这个问题特别难以发现,因为程序员可能试图编写一个应用程序,以使线程不共享数据,却没有意识到数据已映射到同一缓存行.但是,错误共享不是缓存行ping-ponging的唯一可能原因.这也可能是由真正的共享引起的,其中多个线程试图读取和写入相同的数据.

Cache line ping-ponging is the effect where a cache line is transferred between multiple CPUs (or cores) in rapid succession. This can be cause by either false or true sharing. Essentially if multiple CPUs are trying to read and write data in the same cache line then that cache line might have to be transferred between the two threads in rapid succession, and this can cause a significant performance degradation (possibly even worse performance than if a single thread were executing). False sharing can make this problem particularly difficult to detect, because a programmer might have tried to write an application so that the threads weren't sharing data, without realizing that the data was mapped to the same cache line. But false sharing is not the only possible cause of cache-line ping-ponging. This could also be caused by true sharing where multiple threads are trying to read and write the same data.

这篇关于缓存线乒乓和错误共享是否相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆