2
votes

I am trying to find out whether, on Ivy Bridge, its possible to write a 256-bit object which consists of various data types (int, double, float etc)?

I have had a look at the Intel Manual and ctrl+f for "32-byte" but the results were all discussing 256-bits of the same data type (so 4x doubles or 8x floats etc).

I am doing this as part of a lock-free design to ensure data consistency- load all 256 bits of data together, then extract each of the various components separately.

1
You can do large atomic operations on some versions of Haswell, if the chip has the TSX en.wikipedia.org/wiki/Transactional_Synchronization_Extensions support.Zan Lynx
@ZanLynx As the Wikipedia article notes, there is a bug in Haswell's implementation of TSX. Its recommended use is now limited to development.Paul A. Clayton

1 Answers

3
votes

I did a Web search, and it appears that Intel does not guarantee that a 32 byte write is atomic. I found this which suggests that not even regular 8 byte writes are guaranteed atomic.

Intel provides the compare and exchange 8 byte instruction which is atomic.

Bottom line is that I think you will need to take another approach.

EDIT: I forgot about the x86 lock prefix. Looking at this, it says that byte memory operations are guaranteed atomic, while larger operations are not unless the LOCK prefix is used on the read/write instruction.