Re: Suggested tune/tuneup.c patch

2021-11-01 Thread Marco Bodrato

Ciao,

Il 2021-11-01 01:04 Torbjörn Granlund ha scritto:

Marco Bodrato  writes:



  fac_ui... and I find an empty page if I look at
  https://gmplib.org/devel/thres/2021-10-30/FAC_ODD_THRESHOLD

Still there, but for some reason nginx had stopped serving gz pages, 
and

there were no non-gzip pages on the server.  I made a quick workaround.


And the workaround works. Thanks!

Ĝis,
m
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Suggested tune/tuneup.c patch

2021-10-31 Thread Torbjörn Granlund
Marco Bodrato  writes:

  Is this still active?
  I can access https://gmplib.org/devel/thres/2021-10-30/ , but I'd like
  to check how FAC_ODD_THRESHOLD evolves after my last commit to
  fac_ui... and I find an empty page if I look at
  https://gmplib.org/devel/thres/2021-10-30/FAC_ODD_THRESHOLD

Still there, but for some reason nginx had stopped serving gz pages, and
there were no non-gzip pages on the server.  I made a quick workaround.

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Suggested tune/tuneup.c patch

2021-10-31 Thread Marco Bodrato

Ciao,

Il 2019-09-11 19:37 t...@gmplib.org ha scritto:
I added a history preservation feature to the .../devel/thres/ pages.  
At

23:59 each night, all pages are copied to .../devel/thres/-MM-DD.

(There is no index, one needs to type in the wanted date manually.)


Is this still active?
I can access https://gmplib.org/devel/thres/2021-10-30/ , but I'd like 
to check how FAC_ODD_THRESHOLD evolves after my last commit to fac_ui... 
and I find an empty page if I look at

https://gmplib.org/devel/thres/2021-10-30/FAC_ODD_THRESHOLD

Ĝis,
m
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Suggested tune/tuneup.c patch

2019-09-13 Thread Niels Möller
t...@gmplib.org (Torbjörn Granlund) writes:

> ni...@lysator.liu.se (Niels Möller) writes:
>
>   Below patch adds a helper function for tuning *_METHOD values,
>   evaluated at some fix size. What do you think?
>
> It helps with some function comments, outlining what a function does,
> and what its arguments mean.
>
> Please consider adding that before committing.

Done and pushed.

> And please take a screenshot of the affected parameters before and
> after this change, as a sanity check.

Looks reasonable to me:

Before:

size=1, mpn_hgcd2_1 0.01154
size=1, mpn_hgcd2_2 0.01552
size=1, mpn_hgcd2_3 0.01138
#define HGCD2_METHOD ...
#define HGCD2_METHOD 3  /* 1.38% faster than 1 */

After: 

size=1, mpn_hgcd2, method 1 0.01160
size=1, mpn_hgcd2, method 2 0.01548
size=1, mpn_hgcd2, method 3 0.01146
#define HGCD2_METHOD ...
#define HGCD2_METHOD 3  /* 1.20% faster than 1 */

I only get this _METHOD and JACOBI_BASE_METHOD on my machine, though.
DIV_QR_1N_PI1_METHOD and MOD_1_1P_METHOD which also use the new helper
are both skipped.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Suggested tune/tuneup.c patch

2019-09-11 Thread Torbjörn Granlund
  And please take a screenshot of the affected parameters before and
  after this change, as a sanity check.

I added a history preservation feature to the .../devel/thres/ pages.  At
23:59 each night, all pages are copied to .../devel/thres/-MM-DD.

(There is no index, one needs to type in the wanted date manually.)

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Suggested tune/tuneup.c patch

2019-09-11 Thread Torbjörn Granlund
ni...@lysator.liu.se (Niels Möller) writes:

  Below patch adds a helper function for tuning *_METHOD values,
  evaluated at some fix size. What do you think?

It helps with some function comments, outlining what a function does,
and what its arguments mean.

Please consider adding that before committing.  And please take a
screenshot of the affected parameters before and after this change, as a
sanity check.


-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Suggested tune/tuneup.c patch

2019-09-10 Thread Niels Möller
Below patch adds a helper function for tuning *_METHOD values,
evaluated at some fix size. What do you think?

Regards,
/Niels

diff -r ed6ddbb7a15b tune/tuneup.c
--- a/tune/tuneup.c Tue Sep 10 00:00:35 2019 +0200
+++ b/tune/tuneup.c Tue Sep 10 21:29:34 2019 +0200
@@ -519,8 +519,8 @@
 }
 
 void
-print_define_with_margin (const char *name, mp_size_t value,
- mp_size_t runner_up, double speedup)
+print_define_with_speedup (const char *name, mp_size_t value,
+  mp_size_t runner_up, double speedup)
 {
   char buf[100];
   snprintf (buf, sizeof(buf), "%.2f%% faster than %ld",
@@ -712,6 +712,48 @@
 print_define_end (param->name, *threshold);
 }
 
+void
+one_method (int n, speed_function_t *functions,
+   const char *name, const char *define,
+   const struct param_t *param)
+{
+  double *t;
+  int i;
+  int method;
+  int method_runner_up;
+
+  TMP_DECL;
+  TMP_MARK;
+  t = TMP_ALLOC (n * sizeof (*t));
+
+  for (i = 0; i < n; i++)
+{
+  t[i] = tuneup_measure (functions[i], param, );
+  if (option_trace >= 1)
+   printf ("size=%ld, %s, method %d %.9f\n",
+   (long) s.size, name, i + 1, t[i]);
+  if (t[i] == -1.0)
+   {
+ printf ("Oops, can't measure all %s methods\n", name);
+ abort ();
+   }
+}
+  method = 0;
+  for (i = 1; i < n; i++)
+if (t[i] < t[method])
+  method = i;
+
+  method_runner_up = (method == 0);
+  for (i = 0; i < n; i++)
+if (i != method && t[i] < t[method_runner_up])
+  method_runner_up = i;
+
+  print_define_with_speedup (define, method + 1, method_runner_up + 1,
+t[method_runner_up] / t[method]);
+
+  TMP_FREE;
+}
+
 
 /* Special probing for the fft thresholds.  The size restrictions on the
FFTs mean the graph of time vs size has a step effect.  See this for
@@ -1911,47 +1953,15 @@
 tune_hgcd2 (void)
 {
   static struct param_t  param;
-  double   t[3+1];
-  int  method;
-  int  runner_up_method;
-  double   runner_up_ratio;
+  speed_function_t f[3] =
+{
+ speed_mpn_hgcd2_1,
+ speed_mpn_hgcd2_2,
+ speed_mpn_hgcd2_3,
+};
 
   s.size = 1;
-  t[1] = tuneup_measure (speed_mpn_hgcd2_1, , );
-  if (option_trace >= 1)
-printf ("size=%ld, mpn_hgcd2_1 %.9f\n", (long) s.size, t[1]);
-
-  t[2] = tuneup_measure (speed_mpn_hgcd2_2, , );
-  if (option_trace >= 1)
-printf ("size=%ld, mpn_hgcd2_2 %.9f\n", (long) s.size, t[2]);
-
-  t[3] = tuneup_measure (speed_mpn_hgcd2_3, , );
-  if (option_trace >= 1)
-printf ("size=%ld, mpn_hgcd2_3 %.9f\n", (long) s.size, t[3]);
-
-  if (t[1] == -1.0 || t[2] == -1.0 || t[3] == -1.0)
-{
-  printf ("Oops, can't measure all mpn_hgcd2 methods\n");
-  abort ();
-}
-
-  if (t[1] < t[2] && t[1] < t[3])
-{
-  method = 1;
-  runner_up_method = (t[2] < t[3]) ? 2 : 3;
-}
-  else if (t[2] < t[3])
-{
-  method = 2;
-  runner_up_method = (t[1] < t[3]) ? 1 : 3;
-}
-  else
-{
-  method = 3;
-  runner_up_method = (t[1] < t[2]) ? 1 : 2;
-}
-  print_define_with_margin ("HGCD2_METHOD", method, runner_up_method,
-   t[runner_up_method] / t[method]);
+  one_method (3, f, "mpn_hgcd2", "HGCD2_METHOD", );
 }
 
 void
@@ -2227,22 +2237,16 @@
   if (!HAVE_NATIVE_mpn_div_qr_1n_pi1)
 {
   static struct param_t  param;
-  double   t1, t2;
+  speed_function_t f[2] =
+   {
+speed_mpn_div_qr_1n_pi1_1,
+speed_mpn_div_qr_1n_pi1_2,
+   };
 
   s.size = 10;
   s.r = randlimb_norm ();
 
-  t1 = tuneup_measure (speed_mpn_div_qr_1n_pi1_1, , );
-  t2 = tuneup_measure (speed_mpn_div_qr_1n_pi1_2, , );
-
-  if (t1 == -1.0 || t2 == -1.0)
-   {
- printf ("Oops, can't measure all mpn_div_qr_1n_pi1 methods at %ld\n",
- (long) s.size);
- abort ();
-   }
-  div_qr_1n_pi1_method = (t1 < t2) ? 1 : 2;
-  print_define ("DIV_QR_1N_PI1_METHOD", div_qr_1n_pi1_method);
+  one_method (2, f, "mpn_div_qr_1n_pi1", "DIV_QR_1N_PI1_METHOD", );
 }
 
   {
@@ -2289,22 +2293,15 @@
   if (!HAVE_NATIVE_mpn_mod_1_1p)
 {
   static struct param_t  param;
-  double   t1, t2;
+  speed_function_t f[2] =
+   {
+speed_mpn_mod_1_1_1,
+speed_mpn_mod_1_1_2,
+   };
 
   s.size = 10;
   s.r = randlimb_half ();
-
-  t1 = tuneup_measure (speed_mpn_mod_1_1_1, , );
-  t2 = tuneup_measure (speed_mpn_mod_1_1_2, , );
-
-  if (t1 == -1.0 || t2 == -1.0)
-   {
- printf ("Oops, can't measure all mpn_mod_1_1 methods at %ld\n",
- (long) s.size);
- abort ();
-   }
-  mod_1_1p_method = (t1 < t2) ? 1 : 2;
-  print_define ("MOD_1_1P_METHOD", mod_1_1p_method);
+  one_method (2, f, "mpn_mod_1_1", "MOD_1_1P_METHOD", );
 }
 
   if (UDIV_PREINV_ALWAYS)
@@ -2680,44 +2677,17 @@
 tune_jacobi_base (void)
 {
   static struct param_t  param;
-