Intel software manual says clwb "Writes back to memory the cache line (if modified) that contains the linear address specified with the memory operand from any level of the cache hierarchy in the cache coherence domain. The line may be retained in the cache hierarchy in non-modified state. clwb is ordered with respect to older writes to the cache line being written back"
My question is, in the below pseudo code
write(A)
clwb (A)
Does clwb take care of the write in store buffer? or Do I need to sfence after a write, before using clwb, like
write (A)
sfence
clwb (A)
I want to know whether the "sfence" is actually required or not? Thanks
On Intel processors, the
clwb
instruction is ordered with respect to older writes to the same cache line. On AMD processors, according to Section 7.6.3 of Volume 2 of the AMD manual No. 24593, theclwb
instruction is ordered with respect to older writes to the same cache line if the memory type of the target address is a cacheable memory type (i.e., WB, WT, or WP) at the time of executing theclwb
instruction.This ordering guarantee means that the most recent state of the line or a later state with respect to program order will eventually be written back if necessary to the persistence domain at some point in time after retiring the
clwb
instruction. Note that the persistence domain is defined by the platform.