11

The cmpxchg16b instruction for doing atomic 128 bit memory exchanges is not supported on old versions of the x64 processor but it seems like this has been supported by newer versions of the processor for several years now. How likely am I to encounter a 64-bit machine with an old processor that lacks this instruction?

2
  • 13
    Your most important customer certainly have one of those in one of their critical production server thats used only for important tasks run on Christmas Eve, but nowhere else, and absolutely not in the test environment...
    – KarlP
    Sep 9, 2010 at 20:06
  • 8
    I don't think question this should have been migrated to superuser. It just ensures that fewer people who know the answer will ever see this question. Sep 21, 2010 at 19:09

3 Answers 3

8

You are looking at early AMD 64-bit processors, before Rev F (which is when they moved to DDR2 memory). There is some early stepping D Intel Noconas too that did not support it, I think, but these are rarer.

6

I have no data regarding the prevalence of certain types of CPUs, so I can't directly answer your question. However, you can find out whether the CPU supports CMPXCHG16B by checking whether CPUID.01h.ECX.bit13 is 1 (available) or 0 (not available).

Also note that Intel's manuals suggest that for this instruction to be carried out atomically, you need to combine it with the LOCK prefix.

3
  • 1
    Yes, I know how to check the cpuid result. The issue is what to do if it is not supported. I would rather not waste time working around a missing instruction if I am never going to see that case in practice. Sep 9, 2010 at 20:37
  • @Christopher Barber - CPUID has been supported since late 486 processors, which also implies that every 64-bit capable x86 processor will support CPUID.
    – PhiS
    Sep 10, 2010 at 6:49
  • 3
    @PhiS: I'm pretty sure Christopher was talking about the lack of support for the cmpxchg16b. What to do if that is missing
    – Bahbar
    Sep 10, 2010 at 8:01
4

Support in the CPU may not actually be enough as some Core 2 users found out on the launch of Windows 8.1, particularly those having an Intel DP35DP motherboard. I'm not yet sure what in the motherboard could prevent CMPXCHG16B from working. Probably the feature detection bits can be disabled by BIOS. To summarize what Yuhong Bao's blog says on this, there was a processor errata in early Core 2 chips (E0/R0 steppings of the 45nm Core 2) that caused their features to be misreported via CPUID. It was possible to work around this via BIOS/microcode update, as far as I can tell.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .