By: NoSpammer (no.delete@this.spam.com), July 15, 2015 2:44 am
Room: Moderated Discussions
Michael S (already5chosen.delete@this.yahoo.com) on July 15, 2015 1:19 am wrote:
> It seems, in explanation above NoSpammer was taking about situation in which all changes of interest
> are done by one (producer) CPU and observed by another one (consumer) CPU. For such situation x86 ordering
> guarantees are not just strong enough, but stronger than necessary. I think, they are also sufficient
> for slightly more complicated case where consumer acknowledges the consumption of the item to the producer.
> With the help of interlocked primitives it can be extended to a case of single producer feeding multiple
> consumers (probably better described as multiple consumers eating from a single consumer) and you will
> still need no memory barriers except those implied in x86 interlocked operations and still will not
> be impacted at by store forwarding violation of sequential consistency.
Yes, with multiple consumers it can be done non-interlocked in the same way as long as they are not writing to the same memory. Actually it's very easy to do non-interlocked messaging as long as you make sure each thread has only it's own memory region to write and all the others just read it. Then you have only time dependencies to deal with intelligently. Only when threads want to write to the same memory you actually meet the nasty memory ordering details.
> It seems, in explanation above NoSpammer was taking about situation in which all changes of interest
> are done by one (producer) CPU and observed by another one (consumer) CPU. For such situation x86 ordering
> guarantees are not just strong enough, but stronger than necessary. I think, they are also sufficient
> for slightly more complicated case where consumer acknowledges the consumption of the item to the producer.
> With the help of interlocked primitives it can be extended to a case of single producer feeding multiple
> consumers (probably better described as multiple consumers eating from a single consumer) and you will
> still need no memory barriers except those implied in x86 interlocked operations and still will not
> be impacted at by store forwarding violation of sequential consistency.
Yes, with multiple consumers it can be done non-interlocked in the same way as long as they are not writing to the same memory. Actually it's very easy to do non-interlocked messaging as long as you make sure each thread has only it's own memory region to write and all the others just read it. Then you have only time dependencies to deal with intelligently. Only when threads want to write to the same memory you actually meet the nasty memory ordering details.