By: Wilco (Wilco.Dijkstra.delete@this.ntlworld.com), July 6, 2015 4:35 pm
Room: Moderated Discussions
Linus Torvalds (torvalds.delete@this.linux-foundation.org) on July 6, 2015 3:59 pm wrote:
> x86 doesn't have those insane memory ordering semantics. Loads are done in order (as far as software
> could tell - they do get re-ordered, but the semantics are guaranteed to be the same as if they were done
> in order), so it doesn't matter if the two accessed had a data or control dependency between them.
Wrong - of course it does matter! If there is just a control dependency then the compiler may reorder the loads, lift them, CSE them etc (it can't if there is a data dependency). So if you didn't tell the compiler about the dependency, the code would run incorrectly on any CPU irrespectively of what memory model it supports.
Nobody writes multithreading code in pure assembler - if you did then you might have had a point.
Wilco
> x86 doesn't have those insane memory ordering semantics. Loads are done in order (as far as software
> could tell - they do get re-ordered, but the semantics are guaranteed to be the same as if they were done
> in order), so it doesn't matter if the two accessed had a data or control dependency between them.
Wrong - of course it does matter! If there is just a control dependency then the compiler may reorder the loads, lift them, CSE them etc (it can't if there is a data dependency). So if you didn't tell the compiler about the dependency, the code would run incorrectly on any CPU irrespectively of what memory model it supports.
Nobody writes multithreading code in pure assembler - if you did then you might have had a point.
Wilco