Does x86-SSE-instructions have an automatic release-acquire order?

前端 未结 2 1209
天命终不由人
天命终不由人 2020-12-20 14:38

As we know from from C11-memory_order: http://en.cppreference.com/w/c/atomic/memory_order

And the same from C++11-std::memory_order: http://en.cppreference.com/w/cpp

2条回答
  •  离开以前
    2020-12-20 15:16

    Here is an excerpt from Intel's Software Developers Manual, volume 3, section 8.2.2 (the edition 325384-052US of September 2014):

    • Reads are not reordered with other reads.
    • Writes are not reordered with older reads.
    • Writes to memory are not reordered with other writes, with the following exceptions:
      • writes executed with the CLFLUSH instruction;
      • streaming stores (writes) executed with the non-temporal move instructions (MOVNTI, MOVNTQ, MOVNTDQ, MOVNTPS, and MOVNTPD); and
      • string operations (see Section 8.2.4.1).
    • Reads may be reordered with older writes to different locations but not with older writes to the same location.
    • Reads or writes cannot be reordered with I/O instructions, locked instructions, or serializing instructions.
    • Reads cannot pass earlier LFENCE and MFENCE instructions.
    • Writes cannot pass earlier LFENCE, SFENCE, and MFENCE instructions.
    • LFENCE instructions cannot pass earlier reads.
    • SFENCE instructions cannot pass earlier writes.
    • MFENCE instructions cannot pass earlier reads or writes.

    The first three bullets describe the release-acquire ordering, and the exceptions are explicitly listed there. As you might see, only cacheability control instructions (MOVNT*) are in the exception list, while the rest of SSE/SSE2 and other vector instructions obey to the general memory ordering rules, and do not require use of [LSM]FENCE.

提交回复
热议问题