On Sat, 03 Oct 2015 09:56:23 -0400
Wayne Sallee <wa...@waynesallee.com> wrote:

>     0x00007fe021043dde <__gmpn_mul_1+94>:    mulx   (%rsi),%rbx,%rax


  Wayne,

That's it! That's the offender -> mulx

It's a new instruction for Intel's Haswell processors:

http://www.intel.com/content/www/us/en/intelligent-systems/intel-technology/ia-large-integer-arithmetic-paper.html
https://en.wikipedia.org/wiki/Haswell_%28microarchitecture%29

But, not every Intel CPU that may be thought of as being of "Haswell"
class actually supports it.

Which CPU are you running here?

Do a

cat /proc/cpuinfo

To support mulx, the CPU must list bmi2 in the cpuinfo flags section:

http://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean

(see under "Intel-defined CPU features, CPUID level 0x00000007:0 (ebx)")

There was a bug in the detection code of gmp before 6.0.0a which affected
Intel G3420 CPUs:

https://gmplib.org/list-archives/gmp-devel/2014-February/003696.html

In that thread, take note that the correct patch (which is already in
the latest gmp, 6.0.0a) is here:

https://gmplib.org/list-archives/gmp-devel/attachments/20140227/db077071/attachment.obj

(which is a text/diff file)

You should be able to recompile and reinstall gmp 6.0.0a without having to
redo all of gcc.

http://www.linuxfromscratch.org/lfs/view/development/chapter06/gmp.html
http://ftp.gnu.org/gnu/gmp/

If the CPU BMI detection problem persists on your machine even with
gmp 6.0.0a (not withstanding the problem of compiling on one machine and
moving the result to another, of course), it should be reported to the
gmp maintainers. Although there isn't a configure option to lockout the
use of bmi2 instructions in gmp, you can force their lockout with with
a code change to config.guess where around line 815 where:

          if (strcmp (modelstr, "coreihwl") == 0)
            {
              /* Some Haswells lack BMI2.  Let them appear as Sandybridges for
                 now.  */
              CPUID (dummy_string, 7);
              if ((dummy_string[0 + 8 / 8] & (1 << (8 % 8))) == 0)
                modelstr = "coreisbr";
            }

can be changed simply to

modelstr = "coreisbr";

and also in 

mpn/x86_64/fat/fat.c around line 293 delete

              if ((dummy_string[0 + 8 / 8] & (1 << (8 % 8))) != 0)
                CPUVEC_SETUP_coreihwl;


The idea here being is to force the use of coreisbr (which does not use
the bmi2 instructions) rather than coreihwl.


   Cheers,

   Mike


-- 
http://lists.linuxfromscratch.org/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to