[hashcash] cpu detection, disabling mmx code on non mmx cpu (Re: Re: status of hashcash version 1?)

  • From: Adam Back <adam@xxxxxxxxxxxxxxx>
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Tue, 3 Aug 2004 15:14:31 -0400

To be sure I understood correctly: the MMX detection and "switching
out of circuit" of the MMX instruction using assembler code you wrote
are both done by you right?

Ie the compiler by itself a) does not produce MMX code, and b) does
not help you dumping out with SIGILL on non MMX capable CPUs if you do
write MMX code.

But for your libfastmint you have done this work (eg the assembler
code in minter_mmx_compact_1_test) so one could just go ahead and
compile with MMX enabled and the code adapts to the presence or
absence of MMX on the processor (modulo the level of testing given
time frame before release).

Adam

On Tue, Aug 03, 2004 at 07:45:55PM +0100, Jonathan Morton wrote:
> 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.)

Other related posts: