On 26-ott-10, at 05:13, Sean Kelly wrote:
Don Wrote:
Wait a minute. x86 has no read-modify-write instructions for x87,
or for
SSE. So I don't think it's possible to implement atomic floating-
point
ops, apart from assignment.
(Of course, you can fake it with a mass of casts and a CAS, but that
doesn't seem helpful).
It should just be prevented, except possibly for assignment. (Is an
80-bit float assignment atomic? Maybe not, since it would need
special
logic).
atomicOp does most of its RMW operations using a CAS loop, so I
think it should work. The redo occurs when the memory location
being written to changed since it was read, and that shouldn't be
any different for floating point values vs. integers.
I use atomic op casting pointers as integer pointers ( http://github.com/fawzi/blip/blob/master/blip/sync/Atomic.d
which is also tango one), and I haven't encountered any problem yet,
but I haven't checked in detail if some x87 or SSE load/store might
potentially give problems, but as sean says they should not (as the
value should be transferred from register to register, not going
through the memory, and memory accesses are controlled by CAS, and
memory barriers (if used to separate subsequent "normal" ops) should
be valid also for x87/SEE.
Fawzi