在openmp中读取数据时会发生错误共享吗

在openmp中读取数据时会发生错误共享吗

本文介绍了在openmp中读取数据时会发生错误共享吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个具有OpenMP并行化功能的C ++程序,其中不同的线程不断地仅使用一些小型共享数组来从中读取数据,因此是否会发生错误共享?换句话说,错误共享仅与内存写入操作有关,或者在内存读取操作中也可能发生.

If I have a C++ program with OpenMP parallelization, where different threads constantly use some small shared array only for reading data from it, does false sharing occur in this case? in other words, is false sharing related only to memory write operations, or it can also happen with memory read operations.

推荐答案

通常使用的缓存一致性协议,例如 MESI (已修改,互斥,共享,无效)具有用于缓存行的特定状态,称为共享".如果高速缓存行被多个处理器读取,则处于此状态.然后,每个处理器都有一个高速缓存行的副本,可以安全地从中读取内容而不会进行错误共享.写入时,将通知所有处理器使高速缓存行无效,这是导致错误共享的主要原因

Typically used cache coherence protocols, such as MESI (modified, exclusive, shared, invalid), have a specific state for cache lines called "shared". Cache lines are in this state if they are read by multiple processors. Each processor then has a copy of the cache line and can safely read from it without false-sharing. On a write, all processors are informed to invalidate the cache line which is the main cause for false-sharing

这篇关于在openmp中读取数据时会发生错误共享吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 12:54