tuning fo hgcd

This commit is contained in:
jasonmoxham 2011-10-13 07:01:55 +00:00
parent 34d3495f4b
commit 2ba892e9d1
4 changed files with 66 additions and 3 deletions

View File

@ -4059,6 +4059,10 @@ extern mp_size_t mod_1_3_threshold;
#define GCD_DC_THRESHOLD gcd_dc_threshold
extern mp_size_t gcd_dc_threshold;
#undef HGCD_THRESHOLD
#define HGCD_THRESHOLD hgcd_threshold
extern mp_size_t hgcd_threshold;
#undef GCDEXT_DC_THRESHOLD
#define GCDEXT_DC_THRESHOLD gcdext_dc_threshold
extern mp_size_t gcdext_dc_threshold;

View File

@ -1259,6 +1259,51 @@ speed_mpn_gcd (struct speed_params *s)
{
SPEED_ROUTINE_MPN_GCD (mpn_gcd);
}
double
speed_mpn_hgcd (struct speed_params *s)
{
mp_ptr wp;
mp_size_t hgcd_init_scratch = MPN_HGCD_MATRIX_INIT_ITCH (s->size);
mp_size_t hgcd_scratch = mpn_hgcd_itch (s->size);
mp_ptr ap;
mp_ptr bp;
mp_ptr tmp1;
struct hgcd_matrix hgcd;
int res;
unsigned i;
double t;
TMP_DECL;
if (s->size < 2)
return -1;
TMP_MARK;
SPEED_TMP_ALLOC_LIMBS (ap, s->size + 1, s->align_xp);
SPEED_TMP_ALLOC_LIMBS (bp, s->size + 1, s->align_yp);
s->xp[s->size - 1] |= 1;
s->yp[s->size - 1] |= 1;
SPEED_TMP_ALLOC_LIMBS (tmp1, hgcd_init_scratch, s->align_wp);
SPEED_TMP_ALLOC_LIMBS (wp, hgcd_scratch, s->align_wp);
speed_starttime ();
i = s->reps;
do
{
MPN_COPY (ap, s->xp, s->size);
MPN_COPY (bp, s->yp, s->size);
mpn_hgcd_matrix_init (&hgcd, s->size, tmp1);
res = mpn_hgcd (ap, bp, s->size, &hgcd, wp);
}
while (--i != 0);
t = speed_endtime ();
TMP_FREE;
return t;
}
double
speed_mpn_gcdext (struct speed_params *s)

View File

@ -303,7 +303,7 @@ const struct routine_t {
{ "mpn_gcd_1", speed_mpn_gcd_1, FLAG_R_OPTIONAL },
{ "mpn_gcd_1N", speed_mpn_gcd_1N, FLAG_R_OPTIONAL },
{ "mpn_hgcd", speed_mpn_hgcd },
{ "mpn_gcd", speed_mpn_gcd },
{ "mpn_gcdext", speed_mpn_gcdext },

View File

@ -215,6 +215,7 @@ mp_size_t dc_bdiv_q_threshold = MP_SIZE_T_MAX;
mp_size_t powm_threshold = MP_SIZE_T_MAX;
mp_size_t fac_ui_threshold = MP_SIZE_T_MAX;
mp_size_t gcd_dc_threshold = MP_SIZE_T_MAX;
mp_size_t hgcd_threshold = MP_SIZE_T_MAX;
mp_size_t gcdext_dc_threshold = MP_SIZE_T_MAX;
mp_size_t divrem_1_norm_threshold = MP_SIZE_T_MAX;
mp_size_t divrem_1_unnorm_threshold = MP_SIZE_T_MAX;
@ -1282,17 +1283,29 @@ tune_gcd (gmp_randstate_t rands)
static struct param_t param;
param.name = "GCD_DC_THRESHOLD";
param.function = speed_mpn_gcd;
param.min_size = 7;
param.min_size = hgcd_threshold;
param.max_size = 3000;
one (&gcd_dc_threshold, rands, &param);
}
void
tune_hgcd (gmp_randstate_t rands)
{
static struct param_t param;
param.name = "HGCD_THRESHOLD";
param.function = speed_mpn_hgcd;
param.min_size = 30;
one (&hgcd_threshold,rands, &param);
}
void
tune_gcdext (gmp_randstate_t rands)
{
static struct param_t param;
param.name = "GCDEXT_DC_THRESHOLD";
param.function = speed_mpn_gcdext;
param.min_size = 7;
param.min_size = hgcd_threshold;
param.max_size = 3000;
one (&gcdext_dc_threshold, rands, &param);
}
@ -2011,6 +2024,7 @@ all (gmp_randstate_t rands)
tune_powm (rands);
printf("\n");
tune_hgcd(rands);
tune_gcd (rands);
tune_gcdext (rands);
tune_jacobi_base (rands);