memory barrier and cache flush

后端 未结 2 415
不思量自难忘°
不思量自难忘° 2020-12-09 05:53

Is there any archs where a memory barrier is implemented even with a cache flush? I read that memory barrier affects only CPU reordering but I read statements related to the

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 06:19

    The exact impact of a memory barrier depends on the specific architecture

    CPUs employ performance optimizations that can result in out-of-order execution. The reordering of memory operations (loads and stores) normally goes unnoticed within a single thread of execution, but causes unpredictable behaviour in concurrent programs and device drivers unless carefully controlled. The exact nature of an ordering constraint is hardware dependent, and defined by the architecture's memory ordering model. Some architectures provide multiple barriers for enforcing different ordering constraints.

    http://en.wikipedia.org/wiki/Memory_barrier

    Current Intel architectures ensure automatic cache consistency across all CPU's, without explicit use of memory barrier or a cache flush instructions.

    In symmetric multiprocessor (SMP) systems, each processor has a local cache. The memory system must guarantee cache coherence. False sharing occurs when threads on different processors modify variables that reside on the same cache line. This invalidates the cache line and forces an update, which hurts performance.

    http://software.intel.com/en-us/articles/avoiding-and-identifying-false-sharing-among-threads/

提交回复
热议问题