summaryrefslogtreecommitdiff
path: root/tune
diff options
context:
space:
mode:
authorTorbjorn Granlund <tg@gmplib.org>2019-09-23 22:23:20 +0200
committerTorbjorn Granlund <tg@gmplib.org>2019-09-23 22:23:20 +0200
commit546ba0036914ffe1da1732f41d56e9830a4a2b68 (patch)
tree7b27419a302129a014e35ea1998cb2f21d753ba9 /tune
parent5149e9a3ff21e81edcf59825c3e31d2dbbef6a0a (diff)
downloadgmp-546ba0036914ffe1da1732f41d56e9830a4a2b68.tar.gz
Measure variant 4 and 5 of HGCD2_DIV1_METHOD.
Diffstat (limited to 'tune')
-rw-r--r--tune/Makefile.am2
-rw-r--r--tune/common.c10
-rw-r--r--tune/hgcd2-4.c39
-rw-r--r--tune/hgcd2-5.c39
-rw-r--r--tune/speed.h13
-rw-r--r--tune/tuneup.c18
6 files changed, 109 insertions, 12 deletions
diff --git a/tune/Makefile.am b/tune/Makefile.am
index 7a8f04ac7..9e382567c 100644
--- a/tune/Makefile.am
+++ b/tune/Makefile.am
@@ -58,7 +58,7 @@ libspeed_la_SOURCES = \
gcdext_single.c gcdext_double.c gcdextod.c gcdextos.c \
hgcd_lehmer.c hgcd_appr_lehmer.c hgcd_reduce_1.c hgcd_reduce_2.c \
jacbase1.c jacbase2.c jacbase3.c jacbase4.c \
- hgcd2-1.c hgcd2-2.c hgcd2-3.c \
+ hgcd2-1.c hgcd2-2.c hgcd2-3.c hgcd2-4.c hgcd2-5.c \
mod_1_div.c mod_1_inv.c mod_1_1-1.c mod_1_1-2.c modlinv.c \
noop.c powm_mod.c powm_redc.c pre_divrem_1.c \
set_strb.c set_strs.c set_strp.c time.c
diff --git a/tune/common.c b/tune/common.c
index ec7168175..6f4332700 100644
--- a/tune/common.c
+++ b/tune/common.c
@@ -1653,6 +1653,16 @@ speed_mpn_hgcd2_3 (struct speed_params *s)
{
SPEED_ROUTINE_MPN_HGCD2 (mpn_hgcd2_3);
}
+double
+speed_mpn_hgcd2_4 (struct speed_params *s)
+{
+ SPEED_ROUTINE_MPN_HGCD2 (mpn_hgcd2_4);
+}
+double
+speed_mpn_hgcd2_5 (struct speed_params *s)
+{
+ SPEED_ROUTINE_MPN_HGCD2 (mpn_hgcd2_5);
+}
double
speed_mpn_hgcd (struct speed_params *s)
diff --git a/tune/hgcd2-4.c b/tune/hgcd2-4.c
new file mode 100644
index 000000000..ec7f92753
--- /dev/null
+++ b/tune/hgcd2-4.c
@@ -0,0 +1,39 @@
+/* mpn/generic/hgcd2.c method 4.
+
+Copyright 2019 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 either:
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+or
+
+ * the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any
+ later version.
+
+or both in parallel, as here.
+
+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 General Public License
+for more details.
+
+You should have received copies of the GNU General Public License and the
+GNU Lesser General Public License along with the GNU MP Library. If not,
+see https://www.gnu.org/licenses/. */
+
+#include "gmp-impl.h"
+
+#undef HGCD2_DIV1_METHOD
+#define HGCD2_DIV1_METHOD 4
+#define __gmpn_hgcd2 mpn_hgcd2_4
+/* Not used, but renamed to not get duplicate definitions */
+#define __gmpn_hgcd_mul_matrix1_vector mpn_hgcd_mul_matrix1_vector_4
+
+#include "mpn/generic/hgcd2.c"
diff --git a/tune/hgcd2-5.c b/tune/hgcd2-5.c
new file mode 100644
index 000000000..ed661716e
--- /dev/null
+++ b/tune/hgcd2-5.c
@@ -0,0 +1,39 @@
+/* mpn/generic/hgcd2.c method 5.
+
+Copyright 2019 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 either:
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+or
+
+ * the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any
+ later version.
+
+or both in parallel, as here.
+
+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 General Public License
+for more details.
+
+You should have received copies of the GNU General Public License and the
+GNU Lesser General Public License along with the GNU MP Library. If not,
+see https://www.gnu.org/licenses/. */
+
+#include "gmp-impl.h"
+
+#undef HGCD2_DIV1_METHOD
+#define HGCD2_DIV1_METHOD 5
+#define __gmpn_hgcd2 mpn_hgcd2_5
+/* Not used, but renamed to not get duplicate definitions */
+#define __gmpn_hgcd_mul_matrix1_vector mpn_hgcd_mul_matrix1_vector_5
+
+#include "mpn/generic/hgcd2.c"
diff --git a/tune/speed.h b/tune/speed.h
index 5df155841..18f54600a 100644
--- a/tune/speed.h
+++ b/tune/speed.h
@@ -218,6 +218,8 @@ double speed_mpn_hgcd2 (struct speed_params *);
double speed_mpn_hgcd2_1 (struct speed_params *);
double speed_mpn_hgcd2_2 (struct speed_params *);
double speed_mpn_hgcd2_3 (struct speed_params *);
+double speed_mpn_hgcd2_4 (struct speed_params *);
+double speed_mpn_hgcd2_5 (struct speed_params *);
double speed_mpn_hgcd (struct speed_params *);
double speed_mpn_hgcd_lehmer (struct speed_params *);
double speed_mpn_hgcd_appr (struct speed_params *);
@@ -484,12 +486,11 @@ int mpn_jacobi_base_2 (mp_limb_t, mp_limb_t, int);
int mpn_jacobi_base_3 (mp_limb_t, mp_limb_t, int);
int mpn_jacobi_base_4 (mp_limb_t, mp_limb_t, int);
-int mpn_hgcd2_1 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl,
- struct hgcd_matrix1 *M);
-int mpn_hgcd2_2 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl,
- struct hgcd_matrix1 *M);
-int mpn_hgcd2_3 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl,
- struct hgcd_matrix1 *M);
+int mpn_hgcd2_1 (mp_limb_t, mp_limb_t, mp_limb_t, mp_limb_t, struct hgcd_matrix1*);
+int mpn_hgcd2_2 (mp_limb_t, mp_limb_t, mp_limb_t, mp_limb_t, struct hgcd_matrix1*);
+int mpn_hgcd2_3 (mp_limb_t, mp_limb_t, mp_limb_t, mp_limb_t, struct hgcd_matrix1*);
+int mpn_hgcd2_4 (mp_limb_t, mp_limb_t, mp_limb_t, mp_limb_t, struct hgcd_matrix1*);
+int mpn_hgcd2_5 (mp_limb_t, mp_limb_t, mp_limb_t, mp_limb_t, struct hgcd_matrix1*);
mp_limb_t mpn_mod_1_div (mp_srcptr, mp_size_t, mp_limb_t);
mp_limb_t mpn_mod_1_inv (mp_srcptr, mp_size_t, mp_limb_t);
diff --git a/tune/tuneup.c b/tune/tuneup.c
index 94926d653..86ba5edf6 100644
--- a/tune/tuneup.c
+++ b/tune/tuneup.c
@@ -1962,14 +1962,22 @@ void
tune_hgcd2 (void)
{
static struct param_t param;
- 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 };
+ hgcd2_func_t *f[5] =
+ { mpn_hgcd2_1,
+ mpn_hgcd2_2,
+ mpn_hgcd2_3,
+ mpn_hgcd2_4,
+ mpn_hgcd2_5 };
+ speed_function_t speed_f[5] =
+ { speed_mpn_hgcd2_1,
+ speed_mpn_hgcd2_2,
+ speed_mpn_hgcd2_3,
+ speed_mpn_hgcd2_4,
+ speed_mpn_hgcd2_5 };
int best;
s.size = 1;
- best = one_method (3, speed_f, "mpn_hgcd2", "HGCD2_DIV1_METHOD", &param);
+ best = one_method (5, speed_f, "mpn_hgcd2", "HGCD2_DIV1_METHOD", &param);
/* Use selected function when tuning hgcd and gcd */
hgcd2_func = f[best];