=================================================================== RCS file: /home/cvs/OpenXM_contrib/gmp/mpn/tests/Attic/addmul_1.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -p -r1.1.1.1 -r1.1.1.2 --- OpenXM_contrib/gmp/mpn/tests/Attic/addmul_1.c 2000/01/10 15:35:26 1.1.1.1 +++ OpenXM_contrib/gmp/mpn/tests/Attic/addmul_1.c 2000/09/09 14:12:45 1.1.1.2 @@ -1,37 +1,51 @@ +/* +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. +*/ + #include #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" -#ifndef USG -#include -#include +#if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux) +#include -unsigned long +int cputime () { - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; + if (CLOCKS_PER_SEC < 100000) + return clock () * 1000 / CLOCKS_PER_SEC; + return clock () / (CLOCKS_PER_SEC / 1000); } #else -#include +#include +#include +#include -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long +int cputime () { - return CLOCK_TO_MILLISEC (clock ()); + struct rusage rus; + + getrusage (0, &rus); + return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; } #endif @@ -41,7 +55,7 @@ cputime () #if defined (__m88k__) #define CLOCK 20 M #elif defined (__i386__) -#define CLOCK (16.666667 M) +#define CLOCK (16666667) #elif defined (__m68k__) #define CLOCK (20 M) #elif defined (_IBMR2) @@ -62,7 +76,7 @@ cputime () #endif #ifndef OPS -#define OPS 20000000 +#define OPS (CLOCK/5) #endif #ifndef SIZE #define SIZE 496 @@ -129,57 +143,63 @@ main (argc, argv) for (test = 0; ; test++) { +#if TIMES == 1 && ! defined (PRINT) + if (test % (SIZE > 10000 ? 1 : 10000 / SIZE) == 0) + { + printf ("\r%d", test); + fflush (stdout); + } +#endif + #ifdef RANDOM - size = (random () % SIZE + 1); + size = random () % SIZE + 1; #else size = SIZE; #endif - mpn_random2 (s1, size); - mpn_random2 (dy+1, size); - - if (random () % 0x100 == 0) - xlimb = 0; - else - mpn_random2 (&xlimb, 1); - dy[size+1] = 0x12345678; dy[0] = 0x87654321; -#if defined (PRINT) || defined (XPRINT) - printf ("xlimb=%*lX\n", (int) (2 * sizeof(mp_limb_t)), xlimb); -#endif -#ifdef PRINT - mpn_print (dy+1, size); - mpn_print (s1, size); -#endif + mpn_random2 (&xlimb, 1); +#if TIMES != 1 + mpn_random (s1, size); + mpn_random (dy+1, size); + +#ifndef NOCHECK MPN_COPY (dx, dy, size+2); t0 = cputime(); for (i = 0; i < TIMES; i++) - cyx = refmpn_addmul_1 (dx+1, s1, size, xlimb); + refmpn_addmul_1 (dx+1, s1, size, xlimb); t = cputime() - t0; -#if TIMES != 1 cyc = ((double) t * CLOCK) / (OPS * 1000.0); printf ("refmpn_addmul_1: %5ldms (%.2f cycles/limb) [%.2f Gb/s]\n", - t, - cyc, - CLOCK/cyc*BITS_PER_MP_LIMB*BITS_PER_MP_LIMB); + t, cyc, + CLOCK/cyc*BITS_PER_MP_LIMB*BITS_PER_MP_LIMB/1e9); #endif MPN_COPY (dx, dy, size+2); t0 = cputime(); for (i = 0; i < TIMES; i++) - cyy = mpn_addmul_1 (dx+1, s1, size, xlimb); + mpn_addmul_1 (dx+1, s1, size, xlimb); t = cputime() - t0; -#if TIMES != 1 cyc = ((double) t * CLOCK) / (OPS * 1000.0); printf ("mpn_addmul_1: %5ldms (%.2f cycles/limb) [%.2f Gb/s]\n", - t, - cyc, - CLOCK/cyc*BITS_PER_MP_LIMB*BITS_PER_MP_LIMB); + t, cyc, + CLOCK/cyc*BITS_PER_MP_LIMB*BITS_PER_MP_LIMB/1e9); #endif + mpn_random2 (s1, size); + mpn_random2 (dy+1, size); +#if defined (PRINT) || defined (XPRINT) + printf ("xlimb="); + mpn_print (&xlimb, 1); +#endif +#ifdef PRINT + mpn_print (dy+1, size); + mpn_print (s1, size); +#endif + MPN_COPY (dx, dy, size+2); cyx = refmpn_addmul_1 (dx+1, s1, size, xlimb); cyy = mpn_addmul_1 (dy+1, s1, size, xlimb); @@ -201,6 +221,7 @@ main (argc, argv) printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); mpn_print (dy+1, size); #endif + printf ("TEST NUMBER %d\n", test); abort(); } #endif @@ -213,7 +234,13 @@ mpn_print (mp_ptr p, mp_size_t size) for (i = size - 1; i >= 0; i--) { +#ifdef _LONG_LONG_LIMB + printf ("%0*lX%0*lX", (int) (sizeof(mp_limb_t)), + (unsigned long) (p[i] >> (BITS_PER_MP_LIMB/2)), + (int) (sizeof(mp_limb_t)), (unsigned long) (p[i])); +#else printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); +#endif #ifdef SPACE if (i != 0) printf (" ");