summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2016-12-06 17:12:59 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2016-12-06 17:12:59 +0000
commit0e47befcda2ab36c9eedc565966ace5f7a8c17f5 (patch)
tree99b6fd3badf6c16db58e660923cb95446542bdba
parentaba659c1a6a83000542d4c7537a9568ef780defc (diff)
downloadmpfr-0e47befcda2ab36c9eedc565966ace5f7a8c17f5.tar.gz
[mfv5] added option -e, for example use -e1 to avoid over/underflow in mpfr_pow
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@10973 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tools/mbench/mfv5.cc10
-rw-r--r--tools/mbench/mfv5.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/tools/mbench/mfv5.cc b/tools/mbench/mfv5.cc
index b3588426a..753993727 100644
--- a/tools/mbench/mfv5.cc
+++ b/tools/mbench/mfv5.cc
@@ -28,7 +28,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#define USAGE \
"Bench functions for Pentium (V5++).\n" \
__FILE__ " " __DATE__ " " __TIME__ " GCC " __VERSION__ "\n" \
- "Usage: mfv5 [-pPREC] [-sSEED] [-mSIZE] [-iPRIO] [-lLIST] [-xEXPORT_BASE] [-XIMPORT_BASE] [-rROUNDING_MODE] tests ...\n"
+ "Usage: mfv5 [-pPREC] [-sSEED] [-mSIZE] [-iPRIO] [-lLIST] [-xEXPORT_BASE] [-XIMPORT_BASE] [-rROUNDING_MODE] [-eEXP] tests ...\n"
using namespace std;
@@ -81,7 +81,7 @@ build_base (vector<string> &base, const option_test &opt)
for (i = 0 ; i < n ; i++) {
mpfr_urandomb (x, state);
- mpfr_mul_2si (x, x, (rand()%GMP_NUMB_BITS)-(GMP_NUMB_BITS/2), MPFR_RNDN);
+ mpfr_mul_2si (x, x, (rand() % opt.max_exp) - (opt.max_exp / 2), MPFR_RNDN);
str = mpfr_get_str (NULL, &e, 10, 0, x, MPFR_RNDN);
if (str == 0)
abort ();
@@ -125,6 +125,8 @@ int main (int argc, const char *argv[])
vector<string> base;
int i, j, cont, prio;
+ options.max_exp = GMP_NUMB_BITS; /* default value */
+
/* Parse option */
prio = 19;
for(i = 1 ; i < argc ; i++)
@@ -152,6 +154,10 @@ int main (int argc, const char *argv[])
case 'i':
prio = atol (argv[i]+2);
break;
+ case 'e':
+ options.max_exp = atol (argv[i]+2);
+ assert (options.max_exp > 0);
+ break;
case 'r':
{
switch (argv[i][2])
diff --git a/tools/mbench/mfv5.h b/tools/mbench/mfv5.h
index 237ce1f5d..b47c5a735 100644
--- a/tools/mbench/mfv5.h
+++ b/tools/mbench/mfv5.h
@@ -33,6 +33,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#include <string>
#include <fstream>
+#include <assert.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -42,6 +43,7 @@ struct option_test {
unsigned long prec;
unsigned long seed;
unsigned long stat;
+ long max_exp;
bool verbose;
mpfr_rnd_t rnd;
std::string export_base;