[Gmp-commit] /var/hg/gmp: 5 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Wed Feb 20 22:11:44 CET 2013


details:   /var/hg/gmp/rev/16c3d1a275b4
changeset: 15469:16c3d1a275b4
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Feb 20 21:55:23 2013 +0100
description:
(TESTS_REPS): Keep count >= 10.

details:   /var/hg/gmp/rev/4c7371d844e4
changeset: 15470:4c7371d844e4
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Feb 20 22:06:00 2013 +0100
description:
Support coreibwl.  Use proper name for ADX extension.

details:   /var/hg/gmp/rev/c8f61f840be8
changeset: 15471:c8f61f840be8
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Feb 20 22:09:23 2013 +0100
description:
New file.

details:   /var/hg/gmp/rev/449b10fbd69d
changeset: 15472:449b10fbd69d
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Feb 20 22:09:41 2013 +0100
description:
ChangeLog

details:   /var/hg/gmp/rev/4a3e45618e3d
changeset: 15473:4a3e45618e3d
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Feb 20 22:11:39 2013 +0100
description:
Trivial merge.

diffstat:

 ChangeLog                                |  15 +++++
 acinclude.m4                             |  12 ++--
 configure.ac                             |  10 +++-
 mpn/x86_64/haswell/mulx/adx/addmul_1.asm |  85 ++++++++++++++++++++++++++++++++
 tests/mpq/t-get_d.c                      |  43 +++++++++++----
 tests/tests.h                            |   3 +-
 6 files changed, 146 insertions(+), 22 deletions(-)

diffs (263 lines):

diff -r 693ac3cb4f8d -r 4a3e45618e3d ChangeLog
--- a/ChangeLog	Tue Feb 19 16:29:41 2013 +0100
+++ b/ChangeLog	Wed Feb 20 22:11:39 2013 +0100
@@ -1,3 +1,18 @@
+2013-02-20  Niels Möller  <nisse at lysator.liu.se>
+
+	* tests/mpq/t-get_d.c (check_random): Rewrote to make test less
+	dependent on float operations. Fixes problem with m68k-linux and
+	extended float precision.
+
+2013-02-20  Torbjorn Granlund  <tege at gmplib.org>
+
+	* mpn/x86_64/haswell/mulx/adx/addmul_1.asm: New file.
+
+	* configure.ac: Support coreibwl.  Use proper name for ADX extension.
+	* acinclude.m4 (GMP_ASM_X86_ADX): Rename from GMP_ASM_X86_ADOX.
+
+	* tests/tests.h (TESTS_REPS): Keep count >= 10.
+
 2013-02-19 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
         * mini-gmp/mini-gmp.c: Move asserts to work-around a compiler bug.
diff -r 693ac3cb4f8d -r 4a3e45618e3d acinclude.m4
--- a/acinclude.m4	Tue Feb 19 16:29:41 2013 +0100
+++ b/acinclude.m4	Wed Feb 20 22:11:39 2013 +0100
@@ -2643,7 +2643,7 @@
 ])
 
 
-dnl  GMP_ASM_X86_ADOX([ACTION-IF-YES][,ACTION-IF-NO])
+dnl  GMP_ASM_X86_ADX([ACTION-IF-YES][,ACTION-IF-NO])
 dnl  ------------------------------------------------
 dnl  Determine whether the assembler supports the adcx and adox instructions
 dnl  which debut with the Haswell shrink Broadwell.
@@ -2653,17 +2653,17 @@
 dnl  it's all GMP_ASM_TEXT gives currently.  Actually ".text" probably isn't
 dnl  needed at all, at least for just checking instruction syntax.
 
-AC_DEFUN([GMP_ASM_X86_ADOX],
+AC_DEFUN([GMP_ASM_X86_ADX],
 [AC_CACHE_CHECK([if the assembler knows about the adox instruction],
-		gmp_cv_asm_x86_adox,
+		gmp_cv_asm_x86_adx,
 [GMP_TRY_ASSEMBLE(
 [	.text
 	adox	%r8, %r9
 	adcx	%r8, %r9],
-  [gmp_cv_asm_x86_adox=yes],
-  [gmp_cv_asm_x86_adox=no])
+  [gmp_cv_asm_x86_adx=yes],
+  [gmp_cv_asm_x86_adx=no])
 ])
-case $gmp_cv_asm_x86_adox in
+case $gmp_cv_asm_x86_adx in
 yes)
   ifelse([$1],,:,[$1])
   ;;
diff -r 693ac3cb4f8d -r 4a3e45618e3d configure.ac
--- a/configure.ac	Tue Feb 19 16:29:41 2013 +0100
+++ b/configure.ac	Wed Feb 20 22:11:39 2013 +0100
@@ -1651,6 +1651,12 @@
 	path="x86/haswell x86/coreisbr x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86"
 	path_64="x86_64/haswell/mulx x86_64/haswell x86_64/coreisbr x86_64/coreinhm x86_64/core2 x86_64"
 	;;
+      coreibwl)
+	gcc_cflags_cpu="-mtune=corei7 -mtune=core2 -mtune=k8"
+	gcc_cflags_arch="-march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
+	path="x86/haswell x86/coreisbr x86/p6/sse2 x86/p6/p3mmx x86/p6/mmx x86/p6 x86"
+	path_64="x86_64/haswell/mulx/adx x86_64/haswell/mulx x86_64/haswell x86_64/coreisbr x86_64/coreinhm x86_64/core2 x86_64"
+	;;
       atom)
 	gcc_cflags_cpu="-mtune=atom -mtune=pentium3"
 	gcc_cflags_arch="-march=atom -march=pentium3"
@@ -2302,8 +2308,8 @@
       *mulx*)  GMP_ASM_X86_MULX( , [GMP_STRIP_PATH(mulx)]) ;;
     esac
     case "$path $fat_path" in
-      *adox*)  GMP_ASM_X86_MULX( , [GMP_STRIP_PATH(adox)])
-	       GMP_ASM_X86_ADOX( , [GMP_STRIP_PATH(adox)]) ;;
+      *adx*)   GMP_ASM_X86_MULX( , [GMP_STRIP_PATH(adx)])
+	       GMP_ASM_X86_ADX( , [GMP_STRIP_PATH(adx)]) ;;
     esac
     ;;
 esac
diff -r 693ac3cb4f8d -r 4a3e45618e3d mpn/x86_64/haswell/mulx/adx/addmul_1.asm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpn/x86_64/haswell/mulx/adx/addmul_1.asm	Wed Feb 20 22:11:39 2013 +0100
@@ -0,0 +1,85 @@
+dnl  AMD64 mpn_mul_1 for Intel Broadwell.
+
+dnl  Copyright 2012, 2013 Free Software Foundation, Inc.
+
+dnl  This file is part of the GNU MP Library.
+
+dnl  The GNU MP Library is free software; you can redistribute it and/or modify
+dnl  it under the terms of the GNU Lesser General Public License as published
+dnl  by the Free Software Foundation; either version 3 of the License, or (at
+dnl  your option) any later version.
+
+dnl  The GNU MP Library is distributed in the hope that it will be useful, but
+dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+dnl  License for more details.
+
+dnl  You should have received a copy of the GNU Lesser General Public License
+dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
+
+include(`../config.m4')
+
+C	     cycles/limb
+C AMD K8,K9
+C AMD K10
+C AMD bd1
+C AMD bobcat
+C Intel P4
+C Intel PNR
+C Intel NHM
+C Intel SBR
+C Intel HWL
+C Intel BWL
+C Intel atom
+C VIA nano
+
+define(`rp',      `%rdi')   C rcx
+define(`up',      `%rsi')   C rdx
+define(`n_param', `%rdx')   C r8
+define(`v0_param',`%rcx')   C r9
+
+define(`n',       `%rcx')
+define(`v0',      `%rdx')
+
+IFDOS(`	define(`up', ``%rsi'')	') dnl
+IFDOS(`	define(`rp', ``%rcx'')	') dnl
+IFDOS(`	define(`v0', ``%r9'')	') dnl
+IFDOS(`	define(`r9', ``rdi'')	') dnl
+IFDOS(`	define(`n',  ``%r8'')	') dnl
+IFDOS(`	define(`r8', ``r11'')	') dnl
+
+ASM_START()
+	TEXT
+	ALIGN(16)
+PROLOGUE(mpn_addmul_1)
+	xor	%rax, %rax
+L(ent):	mov	v0_param, %r8
+	mov	n_param, n
+	mov	%r8, v0
+	lea	(rp,n,8), rp
+	lea	(up,n,8), up
+	neg	n
+	test	$1, R8(n)
+	jne	L(odd)
+
+L(top):	jrcxz	L(end)
+	mulx	(up,n,8), %r9, %r8
+	adcx	%rax, %r9
+	adox	(rp,n,8), %r9
+	mov	%r9, (rp,n,8)
+L(mid):	mulx	8(up,n,8), %r11, %rax
+	adcx	%r8, %r11
+	adox	8(rp,n,8), %r11
+	mov	%r11, 8(rp,n,8)
+	lea	2(n), n
+	jmp	L(top)
+
+L(end):	adcx	%rcx, %rax
+	adox	%rcx, %rax
+	ret
+
+L(odd):	dec	n
+	mov	%rax, %r8
+	jmp	L(mid)
+EPILOGUE()
+ASM_END()
diff -r 693ac3cb4f8d -r 4a3e45618e3d tests/mpq/t-get_d.c
--- a/tests/mpq/t-get_d.c	Tue Feb 19 16:29:41 2013 +0100
+++ b/tests/mpq/t-get_d.c	Wed Feb 20 22:11:39 2013 +0100
@@ -163,9 +163,13 @@
 void
 check_random (int argc, char **argv)
 {
-  double d, d2, nd, dd;
+  gmp_randstate_ptr rands = RANDS;
+  
+  double d;
   mpq_t q;
-  mp_limb_t rp[LIMBS_PER_DOUBLE + 1];
+  mpz_t a, t;
+  int exp;
+
   int test, reps = 100000;
   int i;
 
@@ -173,27 +177,40 @@
      reps = 100 * atoi (argv[1]);
 
   mpq_init (q);
-
+  mpz_init (a);
+  mpz_init (t);
+  
   for (test = 0; test < reps; test++)
     {
-      mpn_random2 (rp, LIMBS_PER_DOUBLE + 1);
-      d = 0.0;
-      for (i = LIMBS_PER_DOUBLE - 1; i >= 0; i--)
-	d = d * MP_BASE_AS_DOUBLE + rp[i];
-      d = my_ldexp (d, (int) (rp[LIMBS_PER_DOUBLE] % (2 * MAXEXP)) - MAXEXP);
+      mpz_rrandomb (a, rands, 53);
+      mpz_urandomb (t, rands, 32);
+      exp = mpz_get_ui (t) % (2*MAXEXP) - MAXEXP;
+
+      d = my_ldexp (mpz_get_d (a), exp);
       mpq_set_d (q, d);
-      nd = mpz_get_d (mpq_numref (q));
-      dd = mpz_get_d (mpq_denref (q));
-      d2 = nd / dd;
-      if (d != d2)
+      /* Check that n/d = a * 2^exp, or
+	 d*a 2^{exp} = n */
+      mpz_mul (t, a, mpq_denref (q));
+      if (exp > 0)
+	mpz_mul_2exp (t, t, exp);
+      else
 	{
+	  if (!mpz_divisible_2exp_p (t, -exp))
+	    goto fail;
+	  mpz_div_2exp (t, t, -exp);
+	}
+      if (mpz_cmp (t, mpq_numref (q)) != 0)
+	{
+	fail:
 	  printf ("ERROR (check_random test %d): bad mpq_set_d results\n", test);
 	  printf ("%.16g\n", d);
-	  printf ("%.16g\n", d2);
+	  gmp_printf ("%Qd\n", q);
 	  abort ();
 	}
     }
   mpq_clear (q);
+  mpz_clear (t);
+  mpz_clear (a);
 }
 
 void
diff -r 693ac3cb4f8d -r 4a3e45618e3d tests/tests.h
--- a/tests/tests.h	Tue Feb 19 16:29:41 2013 +0100
+++ b/tests/tests.h	Wed Feb 20 22:11:39 2013 +0100
@@ -1,6 +1,6 @@
 /* Tests support prototypes etc.
 
-Copyright 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010, 2011, 2012 Free
+Copyright 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010, 2011, 2012, 2013 Free
 Software Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
@@ -431,6 +431,7 @@
 	  exit (1);							\
 	}								\
       count *= repfactor;						\
+      count = MAX (count, 10);						\
       reps_nondefault = 1;						\
     }									\
   if (reps_nondefault)							\


More information about the gmp-commit mailing list