diff options
Diffstat (limited to 'tuneup.c')
-rw-r--r-- | tuneup.c | 74 |
1 files changed, 37 insertions, 37 deletions
@@ -171,8 +171,8 @@ analyze_data (double *dat, int ndat) { #define THRESHOLD_WINDOW 16 #define THRESHOLD_FINAL_WINDOW 128 static double domeasure (mp_prec_t *threshold, - double (*func) (struct speed_params *), - mp_prec_t p) + double (*func) (struct speed_params *), + mp_prec_t p) { struct speed_params s; mp_size_t size; @@ -223,8 +223,8 @@ static double domeasure (mp_prec_t *threshold, the behaviour of this function is undefined. */ static void tune_simple_func (mp_prec_t *threshold, - double (*func) (struct speed_params *), - mp_prec_t pstart) + double (*func) (struct speed_params *), + mp_prec_t pstart) { double measure[THRESHOLD_FINAL_WINDOW+1]; double d; @@ -238,7 +238,7 @@ tune_simple_func (mp_prec_t *threshold, if (d < 0.0) { if (verbose) printf ("Oups: even for %lu, algo 2 seems to be faster!\n", - (unsigned long) pmin); + (unsigned long) pmin); *threshold = MPFR_PREC_MIN; return; } @@ -246,7 +246,7 @@ tune_simple_func (mp_prec_t *threshold, for (;;) { d = domeasure (threshold, func, pmin); if (d < 1.00) - break; + break; p = pmin; pmin += pmin/2; } @@ -273,29 +273,29 @@ tune_simple_func (mp_prec_t *threshold, { pstep = MAX(MIN(BITS_PER_MP_LIMB/2,(pmax-pmin)/(2*THRESHOLD_WINDOW)),1); if (verbose) - printf ("Pmin = %8lu Pmax = %8lu Pstep=%lu\n", pmin, pmax, pstep); + printf ("Pmin = %8lu Pmax = %8lu Pstep=%lu\n", pmin, pmax, pstep); p = (pmin + pmax) / 2; for (i = numpos = numneg = 0 ; i < THRESHOLD_WINDOW + 1 ; i++) { - measure[i] = domeasure (threshold, func, - p+(i-THRESHOLD_WINDOW/2)*pstep); - if (measure[i] > 0) - numpos ++; - else if (measure[i] < 0) - numneg ++; + measure[i] = domeasure (threshold, func, + p+(i-THRESHOLD_WINDOW/2)*pstep); + if (measure[i] > 0) + numpos ++; + else if (measure[i] < 0) + numneg ++; } if (numpos > numneg) - /* We use more often algo 1 than algo 2 */ - pmin = p - THRESHOLD_WINDOW/2*pstep; + /* We use more often algo 1 than algo 2 */ + pmin = p - THRESHOLD_WINDOW/2*pstep; else if (numpos < numneg) - pmax = p + THRESHOLD_WINDOW/2*pstep; + pmax = p + THRESHOLD_WINDOW/2*pstep; else - /* numpos == numneg ... */ - if (++ try > 2) { - *threshold = p; - if (verbose) - printf ("Quick find: %lu\n", *threshold); - return ; - } + /* numpos == numneg ... */ + if (++ try > 2) { + *threshold = p; + if (verbose) + printf ("Quick find: %lu\n", *threshold); + return ; + } } /* Final tune... */ @@ -383,11 +383,11 @@ tune_mulder (FILE *f) { fprintf (f, "%d", (int) tune_mulder_upto (k)); if (k != MPFR_MULHIGH_TAB_SIZE-1) - fputc (',', f); + fputc (',', f); if ((k+1) % 16 == 0) - fprintf (f, " \\\n "); + fprintf (f, " \\\n "); if (verbose) - putchar ('.'); + putchar ('.'); } fprintf (f, " \n"); if (verbose) @@ -430,7 +430,7 @@ all (const char *filename) time (&start_time); tp = localtime (&start_time); fprintf (f, "/* Generated by MPFR's tuneup.c, %d-%02d-%02d, ", - tp->tm_year+1900, tp->tm_mon+1, tp->tm_mday); + tp->tm_year+1900, tp->tm_mon+1, tp->tm_mday); #ifdef __ICC fprintf (f, "icc %d.%d.%d */\n", __ICC / 100, __ICC / 10 % 10, __ICC % 10); @@ -440,9 +440,9 @@ all (const char *filename) fprintf (f, "Sun C %d.%d */\n", __SUNPRO_C / 0x100, __SUNPRO_C % 0x100); #elif defined (__sgi) && defined (_COMPILER_VERSION) fprintf (f, "MIPSpro C %d.%d.%d */\n", - _COMPILER_VERSION / 100, - _COMPILER_VERSION / 10 % 10, - _COMPILER_VERSION % 10); + _COMPILER_VERSION / 100, + _COMPILER_VERSION / 10 % 10, + _COMPILER_VERSION % 10); #elif defined (__DECC) && defined (__DECC_VER) fprintf (f, "DEC C %d */\n", __DECC_VER); #else @@ -457,31 +457,31 @@ all (const char *filename) if (verbose) printf ("Tuning mpfr_mul...\n"); tune_simple_func (&mpfr_mul_threshold, speed_mpfr_mul, - 2*BITS_PER_MP_LIMB+1); + 2*BITS_PER_MP_LIMB+1); fprintf (f, "#define MPFR_MUL_THRESHOLD %lu\n", - (unsigned long) (mpfr_mul_threshold-1)/BITS_PER_MP_LIMB+1); + (unsigned long) (mpfr_mul_threshold-1)/BITS_PER_MP_LIMB+1); /* Tune mpfr_exp_2 */ if (verbose) printf ("Tuning mpfr_exp_2...\n"); tune_simple_func (&mpfr_exp_2_threshold, speed_mpfr_exp_2, - MPFR_PREC_MIN); + MPFR_PREC_MIN); mpfr_exp_2_threshold = MAX (BITS_PER_MP_LIMB, mpfr_exp_2_threshold); fprintf (f, "#define MPFR_EXP_2_THRESHOLD %lu\n", - (unsigned long) mpfr_exp_2_threshold); + (unsigned long) mpfr_exp_2_threshold); /* Tune mpfr_exp */ if (verbose) printf ("Tuning mpfr_exp...\n"); tune_simple_func (&mpfr_exp_threshold, speed_mpfr_exp, - MPFR_PREC_MIN+3*BITS_PER_MP_LIMB); + MPFR_PREC_MIN+3*BITS_PER_MP_LIMB); fprintf (f, "#define MPFR_EXP_THRESHOLD %lu\n", - (unsigned long) mpfr_exp_threshold); + (unsigned long) mpfr_exp_threshold); /* End of tuning */ time (&end_time); fprintf (f, "/* Tuneup completed successfully, took %ld seconds */\n", - end_time - start_time); + end_time - start_time); if (verbose) printf ("Complete (took %ld seconds).\n", end_time - start_time); |