summaryrefslogtreecommitdiff
path: root/tune/tuneup.c
diff options
context:
space:
mode:
authorNiels M?ller <nisse@lysator.liu.se>2019-09-23 17:26:46 +0200
committerNiels M?ller <nisse@lysator.liu.se>2019-09-23 17:26:46 +0200
commit5149e9a3ff21e81edcf59825c3e31d2dbbef6a0a (patch)
tree944487c77dcfb17466fd11ff689f8897faaef978 /tune/tuneup.c
parentb4b615920b330e37aa4b806674bbeb7a5a284195 (diff)
downloadgmp-5149e9a3ff21e81edcf59825c3e31d2dbbef6a0a.tar.gz
Make tuning of hgcd and gcd take hgcd2 choice into account
* gmp-impl.h (hgcd2_func_t) [TUNE_PROGRAM_BUILD]: New typedef. (hgcd2_func) [TUNE_PROGRAM_BUILD]: New function pointer. * tune/hgcd2.c (mpn_hgcd2): New file, with a redefined function to invoke an implementation via the hgcd2_func function pointer. Initially points to the default implementation in mpn/generic/hgcd2.c. * tune/Makefile.am (tuneup_SOURCES): Add hgcd2.c. * tune/tuneup.c (one_method): Return index of selected function. (tune_hgcd2): Set hgcd2_func to point to selected function. So that the later tuning of mpn_hgcd and mpn_gcd uses the right implementation of hgcd2.
Diffstat (limited to 'tune/tuneup.c')
-rw-r--r--tune/tuneup.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/tune/tuneup.c b/tune/tuneup.c
index fd7ecbac9..94926d653 100644
--- a/tune/tuneup.c
+++ b/tune/tuneup.c
@@ -716,8 +716,11 @@ one (mp_size_t *threshold, struct param_t *param)
select the fastest. Since *_METHOD defines start numbering from
one, if functions[i] is fastest, the value of the define is i+1.
Also output a comment with speedup compared to the next fastest
- function. The NAME argument is used only for trace output.*/
-void
+ function. The NAME argument is used only for trace output.
+
+ Returns the index of the fastest function.
+*/
+int
one_method (int n, speed_function_t *functions,
const char *name, const char *define,
const struct param_t *param)
@@ -757,6 +760,7 @@ one_method (int n, speed_function_t *functions,
t[method_runner_up] / t[method]);
TMP_FREE;
+ return method;
}
@@ -1958,15 +1962,17 @@ void
tune_hgcd2 (void)
{
static struct param_t param;
- speed_function_t f[3] =
- {
- speed_mpn_hgcd2_1,
- speed_mpn_hgcd2_2,
- speed_mpn_hgcd2_3,
- };
+ hgcd2_func_t *f[3] =
+ { mpn_hgcd2_1, mpn_hgcd2_2, mpn_hgcd2_3 };
+ speed_function_t speed_f[3] =
+ { speed_mpn_hgcd2_1, speed_mpn_hgcd2_2, speed_mpn_hgcd2_3 };
+ int best;
s.size = 1;
- one_method (3, f, "mpn_hgcd2", "HGCD2_DIV1_METHOD", &param);
+ best = one_method (3, speed_f, "mpn_hgcd2", "HGCD2_DIV1_METHOD", &param);
+
+ /* Use selected function when tuning hgcd and gcd */
+ hgcd2_func = f[best];
}
void
@@ -2236,9 +2242,6 @@ tune_divrem_1 (void)
void
tune_div_qr_1 (void)
{
- static struct param_t param;
- double t1, t2;
-
if (!HAVE_NATIVE_mpn_div_qr_1n_pi1)
{
static struct param_t param;