What is the relationship between the _mm_sfence intrinsic and a SFENCE instruction?

蹲街弑〆低调 提交于 2019-12-11 14:57:09

问题


I am experimenting with non-temporal instructions, and am already familiar with how fences with ordinary load/stores operate.

Intel defines an intrinsic, _mm_sfence, in relation with non-temporal operations, which the manual defines as:

Guarantees that every preceding store is globally visible before any subsequent store.

I have some questions about this operation.

  1. Is this just inserting a SFENCE instruction? If not, what does this translate to?
  2. If this is not just a SFENCE, does a SFENCE instruction also carry the ordering guarantee for non-temporal stores?

回答1:


The _mm_sfence intrinsic does two things:

  • Inserts the SFENCE instruction.
  • Depending on the compiler, it inserts a compiler write barrier so that the compiler will not reorder any memory writes across the intrinsic with respect to program order. This is the case in GCC, MSVC, and ICC. Not sure about Clang though, but most probably it does that too.


来源:https://stackoverflow.com/questions/51251186/what-is-the-relationship-between-the-mm-sfence-intrinsic-and-a-sfence-instructi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!