flat assembler
Message board for the users of flat assembler.
Index
> Main > multicore load/store ordering pitfalls |
Author |
|
revolution 04 Nov 2022, 13:51
All the magic for cache coherency is done by the MESI protocol.
You don't have to worry about it. You have no control over it anyway. And it works just fine. |
|||
04 Nov 2022, 13:51 |
|
sylware 04 Nov 2022, 20:36
Interesting.
I had a look at this wikipedia article, and there is a store buffer section. But there, they say that a memory barrier will flush the store buffer up to the cache only, but I recall reading amd datasheet about memory ordering, memory barriers would flush stores to the dram. Am I delusional? Unable to read a datasheet? |
|||
04 Nov 2022, 20:36 |
|
revolution 04 Nov 2022, 22:30
Depending upon the CPU and system configuration a memory barrier instruction might force all data to be coherent all the way to the DRAM (very slow), or just to the highest level cache (less slow). It really doesn't matter though as long as the CPU delivers a consistent state to all the cores.
Using a memory barrier in user code is very rare, and not needed usually. Most usage is to synchronise and order data for external peripherals. |
|||
04 Nov 2022, 22:30 |
|
Furs 05 Nov 2022, 15:01
Note that this is mostly true for x86 CPUs since they have strong memory ordering. It's not the same on other CPU architectures where you need to add barriers in a lot of cases with multi-threading.
|
|||
05 Nov 2022, 15:01 |
|
sylware 05 Nov 2022, 17:14
RISC-V is one of those architectures, where you have to program like this as far as I know.
That said, iret on x86_64 is a synchronizing instruction, "locked xchg" instruction too, so it sort of happens all the time on x86_64. |
|||
05 Nov 2022, 17:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.