broot vs brootinv performancs

Niels Möller nisse at lysator.liu.se
Wed Oct 31 21:56:35 CET 2012


Torbjorn Granlund <tg at gmplib.org> writes:

> I sometimes write silly little programs when faced with such issues.
> Such as (untested):

The below program seems to work. Took me some time before I realized
that I needed __GMP_NO_ATTRIBUTE_CONST_PURE. The listed numbers are
primes, and they all reach mpn_brootinv (at least in my configuration).
I haven't found any argument smaller than 28 bits which reaches
mpn_brootinv, but I haven't tried very hard.

Regards,
/Niels

/* Compile using

   gcc -I ~/build/gmp -L ~/build/gmp/.libs -L ~/build/gmp/tune/.libs bench-ppower.c -lspeed  -lgmp -lrt -lm -o bench-ppower

   Some suitable small size inputs (all primes):

     139623167
     740924501
     20284049413
     249683975857
     30402462495947
     602345481169867
     28743278983960397
     588897820651224031
 */
#include <stdio.h>

#define __GMP_NO_ATTRIBUTE_CONST_PURE

#include "gmp.h"
#include "gmp-impl.h"
#include "tune/speed.h"

int
main (int argc, char **argv)
{
  mpz_t a;
  int i;
  double t;
  mpz_init_set_str (a, argv[1], 0);
#ifdef __linux__
  speed_option_cycles_broken = 1;
#endif
  for (i = 0; i < 20; i++)
    {
      speed_starttime ();
      mpn_perfect_power_p (PTR(a), SIZ(a));
      t = speed_endtime ();
      printf ("%.8f\n", t);
    }
  return 0;
}

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list