summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2014-01-20 18:17:47 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2014-01-20 18:17:47 +0000
commit7a74507866b0130177c6f3554896e5b1bdd8e666 (patch)
tree11efa12216dc1055c9a0dc101714248bda1ce518 /tools
parent89a887e765284637514e6a96f01e5f1e7e7eb4a3 (diff)
downloadmpfr-7a74507866b0130177c6f3554896e5b1bdd8e666.tar.gz
[tools/mbench] Patch by Patrick PĂ©lissier: import base support,
corei7 support, build fix (with MPFR 3.1+). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8816 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tools')
-rw-r--r--tools/mbench/Makefile10
-rw-r--r--tools/mbench/mfv5.cc29
-rw-r--r--tools/mbench/mfv5.h2
-rw-r--r--tools/mbench/timp.h31
4 files changed, 64 insertions, 8 deletions
diff --git a/tools/mbench/Makefile b/tools/mbench/Makefile
index a6c8fb0d3..94dcc9314 100644
--- a/tools/mbench/Makefile
+++ b/tools/mbench/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2005-2010 Free Software Foundation, Inc.
+# Copyright 2005-2010, 2014 Free Software Foundation, Inc.
# Contributed by Patrick Pelissier, INRIA.
#
# This file is part of the MPFR Library.
@@ -17,7 +17,7 @@
# along with the MPFR Library; see the file COPYING.LESSER. If not, write to
# the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
-
+
AR=ar
CC=gcc
CXX=g++
@@ -42,7 +42,7 @@ MPFR_INCLUDE=$(MPFR)/include
MPFR_LIB=$(MPFR)/lib
########################################################
-VERSION=0.6.1
+VERSION=0.6.2
NAME=mbench
#########################################################
@@ -54,13 +54,13 @@ NAME=mbench
# is ignored in such a case.
# [*] http://austingroupbugs.net/view.php?id=187
ifeq ($(CC),gcc)
-INCLUDES=`test -f $(GMP_INCLUDE)/gmp.h && echo "-include $(GMP_INCLUDE)/gmp.h"` `test -f $(GMP)/gmp.h && echo "-include $(GMP)/gmp.h"` `test -f $(MPFR_INCLUDE)/mpfr.h && echo "-include $(MPFR_INCLUDE)/mpfr.h"` `test -f $(MPFR)/mpfr.h && echo "-include $(MPFR)/mpfr.h"` -I. -I$(MPFR_INCLUDE) -I$(MPFR) -I$(GMP)/include/ -I$(GMP)
+INCLUDES=`test -f $(GMP_INCLUDE)/gmp.h && echo "-include $(GMP_INCLUDE)/gmp.h"` `test -f $(GMP)/gmp.h && echo "-include $(GMP)/gmp.h"` `test -f $(MPFR_INCLUDE)/mpfr.h && echo "-include $(MPFR_INCLUDE)/mpfr.h"` `test -f $(MPFR)/mpfr.h && echo "-include $(MPFR)/mpfr.h"` `test -f $(MPFR)/src/mpfr.h && echo "-include $(MPFR)/src/mpfr.h"` -I. -I$(MPFR_INCLUDE) -I$(MPFR) -I$(GMP)/include/ -I$(GMP)
else
INCLUDES=-I. -I$(MPFR_INCLUDE) -I$(MPFR) -I$(GMP)/include/ -I$(GMP)
endif
# search first for real install, then for build directory
-LIBS=`(test -f $(MPFR_LIB)/libmpfr.a && echo $(MPFR_LIB)/libmpfr.a)` `(test -f $(MPFR)/src/.libs/libmpfr.a && echo $(MPFR)/src/.libs/libmpfr.a)` `(test -f $(GMP)/lib/libgmp.a && echo $(GMP)/lib/libgmp.a)` `(test -f $(GMP)/.libs/libgmp.a && echo $(GMP)/.libs/libgmp.a)`
+LIBS=`(test -f $(MPFR_LIB)/libmpfr.a && echo $(MPFR_LIB)/libmpfr.a)` `(test -f $(MPFR)/.libs/libmpfr.a && echo $(MPFR)/.libs/libmpfr.a)` `(test -f $(MPFR)/src/.libs/libmpfr.a && echo $(MPFR)/src/.libs/libmpfr.a)` `(test -f $(GMP)/lib/libgmp.a && echo $(GMP)/lib/libgmp.a)` `(test -f $(GMP)/.libs/libgmp.a && echo $(GMP)/.libs/libgmp.a)`
XLIBS=`test -f $(PARI)/lib/libpari.a && echo $(PARI)/lib/libpari.a` \
`test -f $(NTL)/lib/libntl.a && echo $(NTL)/lib/libntl.a` \
diff --git a/tools/mbench/mfv5.cc b/tools/mbench/mfv5.cc
index 7dfeb582a..060aa98d2 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] tests ...\n"
+ "Usage: mfv5 [-pPREC] [-sSEED] [-mSIZE] [-iPRIO] [-lLIST] [-xEXPORT_BASE] [-XIMPORT_BASE] tests ...\n"
using namespace std;
@@ -104,6 +104,20 @@ build_base (vector<string> &base, const option_test &opt)
mpfr_clear (x);
}
+void
+read_base (vector<string> &base, const option_test &opt)
+{
+ unsigned long i, n = opt.stat;
+ std::string x;
+ std::ifstream f(opt.import_base.c_str());
+ std::cout << "Read data from " << opt.import_base << std::endl;
+
+ for (i = 0 ; i < n ; i++) {
+ getline(f, x);
+ base.push_back (x.c_str());
+ }
+}
+
int main (int argc, const char *argv[])
{
@@ -145,6 +159,9 @@ int main (int argc, const char *argv[])
case 'x':
options.export_base = (argv[i]+2);
break;
+ case 'X':
+ options.import_base = (argv[i]+2);
+ break;
default:
cerr << "Unkwown option:" << argv[i] << endl;
exit (1);
@@ -163,7 +180,15 @@ int main (int argc, const char *argv[])
if (options.verbose)
cout << "Building DATA Base\n";
mp_set_memory_functions (NULL, NULL, NULL);
- build_base (base, options);
+
+
+ cout << "GMP VERSION HEADER= " << __GNU_MP_VERSION << "." << __GNU_MP_VERSION_MINOR << "." << __GNU_MP_VERSION_PATCHLEVEL << " LIB=" << gmp_version << endl;
+ cout << "MPFR VERSION HEADER= " << MPFR_VERSION_STRING << " LIB=" << mpfr_get_version() << endl;
+
+ if (options.import_base != "")
+ read_base(base, options);
+ else
+ build_base (base, options);
/* Do test */
for (j = 1, cont = 5 ; cont ; j++, cont--) {
diff --git a/tools/mbench/mfv5.h b/tools/mbench/mfv5.h
index 45c81b0d9..7e029158b 100644
--- a/tools/mbench/mfv5.h
+++ b/tools/mbench/mfv5.h
@@ -31,6 +31,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#include <cstddef>
#include <vector>
#include <string>
+#include <fstream>
#include <sys/time.h>
#include <sys/resource.h>
@@ -41,6 +42,7 @@ struct option_test {
unsigned long stat;
bool verbose;
std::string export_base;
+ std::string import_base;
option_test () : prec (53), seed (14528596), stat (100), verbose (false), export_base("") {}
};
diff --git a/tools/mbench/timp.h b/tools/mbench/timp.h
index a91073c85..250297f1f 100644
--- a/tools/mbench/timp.h
+++ b/tools/mbench/timp.h
@@ -28,7 +28,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
* to measure the # of cycles taken by the call to f(x).
*/
-#define TIMP_VERSION 1*100+0*10+0
+#define TIMP_VERSION 1*100+1*10+0
#ifndef __GNUC__
# error CC != GCC
@@ -51,6 +51,8 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#elif defined (__i386__) || defined(__amd64__)
+#if !defined(corei7)
+
#define timp_rdtsc_before(time) \
__asm__ __volatile__( \
".align 64\n\t" \
@@ -77,6 +79,33 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
: /* no output */ \
: "S"(&time) \
: "eax", "ebx", "ecx", "edx", "memory")
+#else
+
+/* corei7 offers newer instruction rdtscp wich should be better */
+#define timp_rdtsc_before(time) \
+ __asm__ __volatile__( \
+ ".align 64\n\t" \
+ "xorl %%eax,%%eax\n\t" \
+ "cpuid\n\t" \
+ "rdtsc\n\t" \
+ "movl %%eax,(%0)\n\t" \
+ "movl %%edx,4(%0)\n\t" \
+ : /* no output */ \
+ : "S"(&time) \
+ : "eax", "ebx", "ecx", "edx", "memory")
+
+#define timp_rdtsc_after(time) \
+ __asm__ __volatile__( \
+ "rdtscp\n\t" \
+ "movl %%eax,(%0)\n\t" \
+ "movl %%edx,4(%0)\n\t" \
+ "xorl %%eax,%%eax\n\t" \
+ "cpuid\n\t" \
+ : /* no output */ \
+ : "S"(&time) \
+ : "eax", "ebx", "ecx", "edx", "memory")
+
+#endif
#elif defined (__ia64)