[hashcash] Re: status of hashcash version 1?

  • From: Jonathan Morton <chromi@xxxxxxxxxxxxxxxxxxxxx>
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Tue, 3 Aug 2004 19:45:55 +0100

I think I found when trying this kind of thing earlier that you get a
core dump if it runs on hardware that does not have feature you are
asking for.

There is a difference between optimize for pentium (but still run on
486), and use SSE instructions; if the instructions are not there,
unlike floating point there is no emulation / alternate code managed
by compiler and it just bombs!

To answer both questions, yes you just use '-mmmx', regardless of whether the code will eventually run on an MMX-capable CPU or not. The flag only turns on the availability of the MMX compiler extensions - it doesn't generate any MMX code by itself. (The same goes for '-msse'.) The specially optimised code *does* add MMX instructions, but it's switched out of circuit when it isn't running on an MMX-capable CPU.


(NB: I haven't rigourously tested the MMX detection code. It might fail nastily on old CPUs, but should be fine on a Pentium Classic at least. If it does turn out to fail nastily, compile a special package with -march=i{3,4}86 and without -mmmx - this will cut the MMX detection code and cores right out of the binary.)

For Altivec, the situation is more weird. On MacOS X, a special version of GCC is used - for this, use '-faltivec'. For other UNIXes, use '-maltivec -mabi=altivec' instead. However, the behaviour is the same as for MMX - the flag doesn't add Altivec code by itself, it just allows Altivec code to be included in the code. The code is also switched out of circuit when the CPU can't support it - and this code is more robust than the MMX detection.

By contrast, if you use -march=pentium and try to run on a 486 (or, indeed, a Cyrix 6x86, which is an "i586 class" but not a full Pentium compatible), you'll find the compiler will automatically use instructions that aren't available on the 486, such as CMOV. That *will* cause a SIGILL and core dump. It's a completely different situation to the SIMD instruction sets.

--------------------------------------------------------------
from:     Jonathan "Chromatix" Morton
mail:     chromi@xxxxxxxxxxxxxxxxxxxxx
website:  http://www.chromatix.uklinux.net/
tagline:  The key to knowledge is not to rely on people to teach you it.


Other related posts: