caching - 显式 openmp 刷新是否会导致缓存行刷新?

标签 caching openmp flush

我一直在尝试了解 openmp 编译指示,openmp 刷新(#pragma omp flash)是否会导致缓存行刷新?

隐式刷新会如何改变?

最佳答案

如果您使用的是具有一致缓存的机器(大多数主流机器),则通常不需要缓存行刷新,并且刷新指令不太可能对缓存执行任何明确的操作。在连贯系统中,写入一个核心缓存的任何内容都会立即对所有其他核心可见。

但是,FLUSH 指令可能充当内存屏障或栅栏,并且它还会强制编译器为可能已存储在寄存器中的值生成存储指令。

对该指令有很好的描述 here ,包括此注释:

Q17: Is the !$omp flush directive necessary on a cache coherent system?

A17: Yes the flush directive is necessary. Look in the OpenMP specifications for examples of its uses. The directive is necessary to instruct the compiler that the variable must be written to/read from the memory system, i.e. that the variable can not be kept in a local CPU register over the flush "statement" in your code.

Cache coherency makes certain that if one CPU executes a read or write instruction from/to memory, then all other CPUs in the system will get the same value from that memory address when they access it. All caches will show a coherent value. However, in the OpenMP standard there must be a way to instruct the compiler to actually insert the read/write machine instruction and not postpone it. Keeping a variable in a register in a loop is very common when producing efficient machine language code for a loop.

如果您使用的计算机具有不一致的缓存,那么您可能正在 super 计算设施中工作,并且应该咨询熟悉您的架构和工具集的本地专家。

关于caching - 显式 openmp 刷新是否会导致缓存行刷新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19480591/

相关文章:

c# - 在 WebControl 中使用响应刷新

Nginx 反复修改后不刷新文件。返回旧的 Last Modified header

caching - 静态文件应该缓存多长时间?

c++ - std::sort 比自定义 OpenMP 并行排序算法快得多

c - 循环中缺少错误(OpenMP with C)

java servlet PrintWriter#flush 停止抛出异常

caching - 在缓存事务中加入 Infinispan 缓存存储?

php - 如何只为后退按钮缓存

c++ - OpenMP 动态与引导式调度

PHP 刷新输出到浏览器