new directory and target make bench
This commit is contained in:
parent
5a048dae03
commit
8f15821fc7
@ -92,7 +92,7 @@ if BUILD_YASM
|
||||
SUBDIRS += yasm
|
||||
endif
|
||||
|
||||
SUBDIRS += mpn mpz mpq mpf printf scanf cxx mpbsd demos tune doc
|
||||
SUBDIRS += mpn mpz mpq mpf printf scanf cxx mpbsd demos tune doc bench
|
||||
|
||||
EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf
|
||||
|
||||
|
@ -156,7 +156,7 @@ RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = tests yasm mpn mpz mpq mpf printf scanf cxx mpbsd demos \
|
||||
tune doc
|
||||
tune doc bench
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
@ -379,7 +379,7 @@ LIBMP_LT_CURRENT = 4
|
||||
LIBMP_LT_REVISION = 10
|
||||
LIBMP_LT_AGE = 1
|
||||
SUBDIRS = tests $(am__append_1) mpn mpz mpq mpf printf scanf cxx mpbsd \
|
||||
demos tune doc
|
||||
demos tune doc bench
|
||||
|
||||
# The ansi2knr setups for the build programs are the same as the normal
|
||||
# automake ansi2knr rules, but using $(CC_FOR_BUILD) instead of $(CC).
|
||||
|
67
bench/Makefile.am
Normal file
67
bench/Makefile.am
Normal file
@ -0,0 +1,67 @@
|
||||
## Process this file with automake to generate Makefile.in
|
||||
|
||||
# Copyright 2000, 2001, 2002, 2003, 2005 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 the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# 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 Lesser General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/tests
|
||||
|
||||
EXTRA_DIST = README divide.c gexpr.c mpirbench.sln mpirver.c multiply.c rsa.c runbench runbench.py timing.h version
|
||||
noinst_HEADERS = timing.h
|
||||
|
||||
# Prefer -static on the speed and tune programs, since that can avoid
|
||||
# overheads of shared library linkages on some systems. Libtool tends to
|
||||
# botch -static if configured with --disable-static, perhaps reasonably
|
||||
# enough. In any event under --disable-static the only choice is a dynamic
|
||||
# link so there's no point in -static.
|
||||
#
|
||||
if ENABLE_STATIC
|
||||
STATIC = -static
|
||||
else
|
||||
STATIC =
|
||||
endif
|
||||
|
||||
DEPENDENCIES = $(top_builddir)/libmpir.la -lm
|
||||
LIBADD = $(libspeed_la_DEPENDENCIES) $(LIBM)
|
||||
AM_LDFLAGS = $(STATIC)
|
||||
|
||||
$(top_builddir)/tests/libtests.la:
|
||||
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
|
||||
|
||||
EXTRA_PROGRAMS = gexpr rsa multiply divide mpirver
|
||||
|
||||
LDADD = $(DEPENDENCIES)
|
||||
|
||||
bench: bench
|
||||
./runbench ..
|
||||
|
||||
allprogs: $(EXTRA_PROGRAMS)
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(STATIC)
|
||||
|
||||
CLEANFILES = $(EXTRA_PROGRAMS) \
|
||||
RES-divide-8192,128 RES-divide-8388608,4194304 RES-multiply-8192,8192 \
|
||||
RES-divide-8192,32 RES-multiply-128,128 RES-rsa-1024 RES-rsa-512 \
|
||||
RES-divide-8192,4096 RES-multiply-131072,131072 RES-rsa-2048 \
|
||||
RES-divide-131072,65536 RES-divide-8192,64 RES-multiply-2097152,2097152 \
|
||||
RES-divide-131072,8192 RES-divide-8192,8064 RES-multiply-512,512
|
||||
DISTCLEANFILES = $(EXTRA_PROGRAMS) \
|
||||
RES-divide-8192,128 RES-divide-8388608,4194304 RES-multiply-8192,8192 \
|
||||
RES-divide-8192,32 RES-multiply-128,128 RES-rsa-1024 RES-rsa-512 \
|
||||
RES-divide-8192,4096 RES-multiply-131072,131072 RES-rsa-2048 \
|
||||
RES-divide-131072,65536 RES-divide-8192,64 RES-multiply-2097152,2097152 \
|
||||
RES-divide-131072,8192 RES-divide-8192,8064 RES-multiply-512,512
|
563
bench/Makefile.in
Normal file
563
bench/Makefile.in
Normal file
@ -0,0 +1,563 @@
|
||||
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
# Copyright 2000, 2001, 2002, 2003, 2005 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 the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# 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 Lesser General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
ANSI2KNR = $(top_builddir)/ansi2knr
|
||||
EXTRA_PROGRAMS = gexpr$(EXEEXT) rsa$(EXEEXT) multiply$(EXEEXT) \
|
||||
divide$(EXEEXT) mpirver$(EXEEXT)
|
||||
subdir = bench
|
||||
DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
divide_SOURCES = divide.c
|
||||
divide_OBJECTS = divide$U.$(OBJEXT)
|
||||
divide_LDADD = $(LDADD)
|
||||
am__DEPENDENCIES_1 = $(top_builddir)/libmpir.la
|
||||
divide_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
gexpr_SOURCES = gexpr.c
|
||||
gexpr_OBJECTS = gexpr$U.$(OBJEXT)
|
||||
gexpr_LDADD = $(LDADD)
|
||||
gexpr_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
mpirver_SOURCES = mpirver.c
|
||||
mpirver_OBJECTS = mpirver$U.$(OBJEXT)
|
||||
mpirver_LDADD = $(LDADD)
|
||||
mpirver_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
multiply_SOURCES = multiply.c
|
||||
multiply_OBJECTS = multiply$U.$(OBJEXT)
|
||||
multiply_LDADD = $(LDADD)
|
||||
multiply_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
rsa_SOURCES = rsa.c
|
||||
rsa_OBJECTS = rsa$U.$(OBJEXT)
|
||||
rsa_LDADD = $(LDADD)
|
||||
rsa_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
||||
depcomp =
|
||||
am__depfiles_maybe =
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
SOURCES = divide.c gexpr.c mpirver.c multiply.c rsa.c
|
||||
DIST_SOURCES = divide.c gexpr.c mpirver.c multiply.c rsa.c
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ABI = @ABI@
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BITS_PER_MP_LIMB = @BITS_PER_MP_LIMB@
|
||||
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
|
||||
CC = @CC@
|
||||
CCAS = @CCAS@
|
||||
CC_FOR_BUILD = @CC_FOR_BUILD@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPP_FOR_BUILD = @CPP_FOR_BUILD@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@
|
||||
DEFS = @DEFS@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
|
||||
GMP_LDFLAGS = @GMP_LDFLAGS@
|
||||
GMP_NAIL_BITS = @GMP_NAIL_BITS@
|
||||
GREP = @GREP@
|
||||
GSYM_FLAG = @GSYM_FLAG@
|
||||
HAVE_CLOCK_01 = @HAVE_CLOCK_01@
|
||||
HAVE_CPUTIME_01 = @HAVE_CPUTIME_01@
|
||||
HAVE_GETRUSAGE_01 = @HAVE_GETRUSAGE_01@
|
||||
HAVE_GETTIMEOFDAY_01 = @HAVE_GETTIMEOFDAY_01@
|
||||
HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@
|
||||
HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@
|
||||
HAVE_SIGACTION_01 = @HAVE_SIGACTION_01@
|
||||
HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@
|
||||
HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@
|
||||
HAVE_STACK_T_01 = @HAVE_STACK_T_01@
|
||||
HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LEX = @LEX@
|
||||
LEXLIB = @LEXLIB@
|
||||
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
|
||||
LIBCURSES = @LIBCURSES@
|
||||
LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@
|
||||
LIBGMP_DLL = @LIBGMP_DLL@
|
||||
LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@
|
||||
LIBM = @LIBM@
|
||||
LIBM_FOR_BUILD = @LIBM_FOR_BUILD@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBREADLINE = @LIBREADLINE@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
M4 = @M4@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
MPIR_AS = @MPIR_AS@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJECT_FORMAT = @OBJECT_FORMAT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@
|
||||
STRIP = @STRIP@
|
||||
TAL_OBJECT = @TAL_OBJECT@
|
||||
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
|
||||
U = @U@
|
||||
U_FOR_BUILD = @U_FOR_BUILD@
|
||||
VERSION = @VERSION@
|
||||
WITH_READLINE_01 = @WITH_READLINE_01@
|
||||
YACC = @YACC@
|
||||
YFLAGS = @YFLAGS@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
gmp_srclinks = @gmp_srclinks@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
mpn_objects = @mpn_objects@
|
||||
mpn_objs_in_libgmp = @mpn_objs_in_libgmp@
|
||||
mpn_objs_in_libmp = @mpn_objs_in_libmp@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
subdirs = @subdirs@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/tests
|
||||
EXTRA_DIST = README divide.c gexpr.c mpirbench.sln mpirver.c multiply.c rsa.c runbench runbench.py timing.h version
|
||||
noinst_HEADERS = timing.h
|
||||
@ENABLE_STATIC_FALSE@STATIC =
|
||||
|
||||
# Prefer -static on the speed and tune programs, since that can avoid
|
||||
# overheads of shared library linkages on some systems. Libtool tends to
|
||||
# botch -static if configured with --disable-static, perhaps reasonably
|
||||
# enough. In any event under --disable-static the only choice is a dynamic
|
||||
# link so there's no point in -static.
|
||||
#
|
||||
@ENABLE_STATIC_TRUE@STATIC = -static
|
||||
DEPENDENCIES = $(top_builddir)/libmpir.la -lm
|
||||
LIBADD = $(libspeed_la_DEPENDENCIES) $(LIBM)
|
||||
AM_LDFLAGS = $(STATIC)
|
||||
LDADD = $(DEPENDENCIES)
|
||||
CLEANFILES = $(EXTRA_PROGRAMS) \
|
||||
RES-divide-8192,128 RES-divide-8388608,4194304 RES-multiply-8192,8192 \
|
||||
RES-divide-8192,32 RES-multiply-128,128 RES-rsa-1024 RES-rsa-512 \
|
||||
RES-divide-8192,4096 RES-multiply-131072,131072 RES-rsa-2048 \
|
||||
RES-divide-131072,65536 RES-divide-8192,64 RES-multiply-2097152,2097152 \
|
||||
RES-divide-131072,8192 RES-divide-8192,8064 RES-multiply-512,512
|
||||
|
||||
DISTCLEANFILES = $(EXTRA_PROGRAMS) \
|
||||
RES-divide-8192,128 RES-divide-8388608,4194304 RES-multiply-8192,8192 \
|
||||
RES-divide-8192,32 RES-multiply-128,128 RES-rsa-1024 RES-rsa-512 \
|
||||
RES-divide-8192,4096 RES-multiply-131072,131072 RES-rsa-2048 \
|
||||
RES-divide-131072,65536 RES-divide-8192,64 RES-multiply-2097152,2097152 \
|
||||
RES-divide-131072,8192 RES-divide-8192,8064 RES-multiply-512,512
|
||||
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps bench/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu --ignore-deps bench/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
divide$(EXEEXT): $(divide_OBJECTS) $(divide_DEPENDENCIES)
|
||||
@rm -f divide$(EXEEXT)
|
||||
$(LINK) $(divide_OBJECTS) $(divide_LDADD) $(LIBS)
|
||||
gexpr$(EXEEXT): $(gexpr_OBJECTS) $(gexpr_DEPENDENCIES)
|
||||
@rm -f gexpr$(EXEEXT)
|
||||
$(LINK) $(gexpr_OBJECTS) $(gexpr_LDADD) $(LIBS)
|
||||
mpirver$(EXEEXT): $(mpirver_OBJECTS) $(mpirver_DEPENDENCIES)
|
||||
@rm -f mpirver$(EXEEXT)
|
||||
$(LINK) $(mpirver_OBJECTS) $(mpirver_LDADD) $(LIBS)
|
||||
multiply$(EXEEXT): $(multiply_OBJECTS) $(multiply_DEPENDENCIES)
|
||||
@rm -f multiply$(EXEEXT)
|
||||
$(LINK) $(multiply_OBJECTS) $(multiply_LDADD) $(LIBS)
|
||||
rsa$(EXEEXT): $(rsa_OBJECTS) $(rsa_DEPENDENCIES)
|
||||
@rm -f rsa$(EXEEXT)
|
||||
$(LINK) $(rsa_OBJECTS) $(rsa_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
$(top_builddir)/ansi2knr:
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ./ansi2knr
|
||||
|
||||
mostlyclean-kr:
|
||||
-test "$U" = "" || rm -f *_.c
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
$(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
$(LTCOMPILE) -c -o $@ $<
|
||||
divide_.c: divide.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/divide.c; then echo $(srcdir)/divide.c; else echo divide.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
gexpr_.c: gexpr.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/gexpr.c; then echo $(srcdir)/gexpr.c; else echo gexpr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
mpirver_.c: mpirver.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mpirver.c; then echo $(srcdir)/mpirver.c; else echo mpirver.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
multiply_.c: multiply.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/multiply.c; then echo $(srcdir)/multiply.c; else echo multiply.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
rsa_.c: rsa.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/rsa.c; then echo $(srcdir)/rsa.c; else echo rsa.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
divide_.$(OBJEXT) divide_.lo gexpr_.$(OBJEXT) gexpr_.lo \
|
||||
mpirver_.$(OBJEXT) mpirver_.lo multiply_.$(OBJEXT) multiply_.lo \
|
||||
rsa_.$(OBJEXT) rsa_.lo : $(ANSI2KNR)
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(HEADERS)
|
||||
installdirs:
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool ctags distclean distclean-compile \
|
||||
distclean-generic distclean-libtool distclean-tags distdir dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-kr mostlyclean-libtool pdf \
|
||||
pdf-am ps ps-am tags uninstall uninstall-am
|
||||
|
||||
|
||||
$(top_builddir)/tests/libtests.la:
|
||||
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
|
||||
|
||||
bench: bench
|
||||
./runbench ..
|
||||
|
||||
allprogs: $(EXTRA_PROGRAMS)
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(STATIC)
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
54
bench/README
Normal file
54
bench/README
Normal file
@ -0,0 +1,54 @@
|
||||
MPIRbench 0.1
|
||||
|
||||
Copyright 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of MPIRbench.
|
||||
|
||||
MPIRbench is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2.1 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
The MPIRbench 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 a copy of the GNU General Public License along with
|
||||
the MPIRbench; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
The idea is to have a hierarchy of benchmarks, with benchmark results
|
||||
computed for the entire "MPIRbench", and for "MPIRbench.app.mersenne",
|
||||
"MPIRbench.app.RSA", "MPIRbench.app.RSA.encrypt", etc, separately.
|
||||
|
||||
For MPIRbench 0.1, there are just three parts:
|
||||
|
||||
[Multiply large numbers]
|
||||
base.multiply 128
|
||||
512
|
||||
8192
|
||||
131072
|
||||
2097152
|
||||
|
||||
[Divide numbers of different sizes by small primes]
|
||||
base.divide 8192/32 preinv
|
||||
8192/64 preinv
|
||||
8192/128
|
||||
8192/4096
|
||||
8192/8064 clever
|
||||
131072/8192 barrett repeat
|
||||
131072/65536
|
||||
8388608/4194304 newton+barrett
|
||||
|
||||
[Run the RSA encryption algorithm]
|
||||
app.RSA encrypt/verify 512
|
||||
1024
|
||||
2048
|
||||
decrypt/sign 512
|
||||
1024
|
||||
2048
|
||||
|
||||
|
||||
Result scores are computed as a geometric mean. Please use the included
|
||||
script runbench for running the benchmarks and computing benchmark scores.
|
109
bench/divide.c
Normal file
109
bench/divide.c
Normal file
@ -0,0 +1,109 @@
|
||||
/* divide.c -- benchmark plain integer division.
|
||||
|
||||
Copyright 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of MPIRbench.
|
||||
|
||||
MPIRbench is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2.1 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
The MPIRbench 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 a copy of the GNU General Public License along with
|
||||
the MPIRbench; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "mpir.h"
|
||||
#include "timing.h"
|
||||
|
||||
int cputime (void);
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gmp_randstate_t rs;
|
||||
mpz_t x, y, z;
|
||||
unsigned long int m, n, i, niter, t0, ti;
|
||||
double t, f, ops_per_sec;
|
||||
int decimals;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
fprintf (stderr, "usage: %s m n\n", argv[0]);
|
||||
fprintf (stderr, " where m is number of dividend bits\n");
|
||||
fprintf (stderr, " and n is number of divisor bits\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
m = atoi (argv[1]);
|
||||
n = atoi (argv[2]);
|
||||
|
||||
gmp_randinit_default (rs);
|
||||
|
||||
mpz_init (x);
|
||||
mpz_init (y);
|
||||
mpz_init (z);
|
||||
mpz_urandomb (x, rs, m);
|
||||
mpz_urandomb (y, rs, n);
|
||||
|
||||
printf ("Calibrating CPU speed..."); fflush (stdout);
|
||||
TIME (t, mpz_tdiv_q (z, x, y));
|
||||
printf ("done\n");
|
||||
|
||||
niter = 1 + (unsigned long) (1e4 / t);
|
||||
printf ("Dividing an %lu-bit number by an %lu-bit number %lu times...",
|
||||
m, n, niter);
|
||||
fflush (stdout);
|
||||
t0 = cputime ();
|
||||
for (i = niter; i > 0; i--)
|
||||
{
|
||||
mpz_tdiv_q (z, x, y);
|
||||
}
|
||||
ti = cputime () - t0;
|
||||
printf ("done!\n");
|
||||
|
||||
ops_per_sec = 1000.0 * niter / ti;
|
||||
f = 100.0;
|
||||
for (decimals = 0;; decimals++)
|
||||
{
|
||||
if (ops_per_sec > f)
|
||||
break;
|
||||
f = f * 0.1;
|
||||
}
|
||||
|
||||
printf ("RESULT: %.*f operations per second\n", decimals, ops_per_sec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return user CPU time measured in milliseconds. */
|
||||
#if !defined (__sun) \
|
||||
&& (defined (USG) || defined (__SVR4) || defined (_UNICOS) \
|
||||
|| defined (__hpux))
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
cputime ()
|
||||
{
|
||||
return (int) ((double) clock () * 1000 / CLOCKS_PER_SEC);
|
||||
}
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
int
|
||||
cputime ()
|
||||
{
|
||||
struct rusage rus;
|
||||
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
|
||||
}
|
||||
#endif
|
359
bench/gexpr.c
Normal file
359
bench/gexpr.c
Normal file
@ -0,0 +1,359 @@
|
||||
/* Expression evaluation using plain floating-point arithmetic.
|
||||
Copyright 1999, 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2, or (at your option) any later version.
|
||||
|
||||
This program 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 a copy of the GNU General Public License along with
|
||||
this program; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
jmp_buf top;
|
||||
|
||||
static char *bp, *expr_start_p, *expr_end_p;
|
||||
static int ch;
|
||||
static int previous_result_valid_flag;
|
||||
double previous_result;
|
||||
|
||||
double term (void), expo (void), factor (void), number (void);
|
||||
|
||||
#define next skip ()
|
||||
|
||||
void
|
||||
skip (void)
|
||||
{
|
||||
do
|
||||
ch = *bp++;
|
||||
while (ch == ' ' || ch == '\n');
|
||||
}
|
||||
|
||||
void
|
||||
error (void)
|
||||
{
|
||||
fprintf (stderr, "%s\n", expr_start_p);
|
||||
fprintf (stderr, "%*s^ syntax error\n", (int) (bp - expr_start_p) - 1, "");
|
||||
longjmp (top, 1);
|
||||
}
|
||||
|
||||
double
|
||||
expr (void)
|
||||
{
|
||||
double e;
|
||||
if (ch == '+')
|
||||
{
|
||||
next;
|
||||
e = term ();
|
||||
}
|
||||
else if (ch == '-')
|
||||
{
|
||||
next;
|
||||
e = - term ();
|
||||
}
|
||||
else
|
||||
e = term ();
|
||||
while (ch == '+' || ch == '-')
|
||||
{ char op;
|
||||
op = ch;
|
||||
next;
|
||||
if (op == '-')
|
||||
e -= term ();
|
||||
else
|
||||
e += term ();
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
double
|
||||
term (void)
|
||||
{
|
||||
double t;
|
||||
t = expo ();
|
||||
for (;;)
|
||||
switch (ch)
|
||||
{
|
||||
case '*':
|
||||
next;
|
||||
t *= expo ();
|
||||
break;
|
||||
case '/':
|
||||
next;
|
||||
t /= expo ();
|
||||
break;
|
||||
case '%':
|
||||
next;
|
||||
t = fmod (t, expo ());
|
||||
break;
|
||||
default:
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
expo (void)
|
||||
{
|
||||
double e;
|
||||
e = factor ();
|
||||
if (ch == '^')
|
||||
{
|
||||
next;
|
||||
e = pow (e, expo ());
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
struct functions
|
||||
{
|
||||
char *spelling;
|
||||
double (* evalfn) ();
|
||||
};
|
||||
|
||||
double
|
||||
my_log2 (double x)
|
||||
{
|
||||
return log (x) * 1.4426950408889634073599246810019;
|
||||
}
|
||||
|
||||
struct functions fns[] =
|
||||
{
|
||||
{"log2", my_log2},
|
||||
{"log10", log10},
|
||||
{"log", log},
|
||||
{"exp", exp},
|
||||
{"sqrt", sqrt},
|
||||
{"floor", floor},
|
||||
{"ceil", ceil},
|
||||
{"sin", sin},
|
||||
{"cos", cos},
|
||||
{"tan", tan},
|
||||
{"asin", asin},
|
||||
{"acos", acos},
|
||||
{"atan", atan},
|
||||
{"sinh", sinh},
|
||||
{"cosh", cosh},
|
||||
{"tanh", tanh},
|
||||
{"asinh", asinh},
|
||||
{"acosh", acosh},
|
||||
{"atanh", atanh},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
||||
double
|
||||
factor (void)
|
||||
{
|
||||
double f;
|
||||
int i;
|
||||
|
||||
for (i = 0; fns[i].spelling != 0; i++)
|
||||
{
|
||||
char *spelling = fns[i].spelling;
|
||||
int len = strlen (spelling);
|
||||
if (strncmp (spelling, bp - 1, len) == 0 && ! isalnum (bp[-1 + len]))
|
||||
{
|
||||
bp += len - 1;
|
||||
next;
|
||||
if (ch != '(')
|
||||
error ();
|
||||
next;
|
||||
f = expr ();
|
||||
if (ch != ')')
|
||||
error ();
|
||||
next;
|
||||
return (fns[i].evalfn) (f);
|
||||
}
|
||||
}
|
||||
|
||||
if (ch == '(')
|
||||
{
|
||||
next;
|
||||
f = expr ();
|
||||
if (ch == ')')
|
||||
next;
|
||||
else
|
||||
error ();
|
||||
}
|
||||
else
|
||||
f = number ();
|
||||
if (ch == '!')
|
||||
{
|
||||
unsigned long n;
|
||||
if (floor (f) != f)
|
||||
error ();
|
||||
for (n = f, f = 1; n > 1; n--)
|
||||
f *= n;
|
||||
next;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
double
|
||||
number (void)
|
||||
{
|
||||
double n;
|
||||
char *endp;
|
||||
|
||||
if (strncmp ("pi", bp - 1, 2) == 0 && ! isalnum (bp[1]))
|
||||
{
|
||||
bp += 2 - 1;
|
||||
next;
|
||||
return 3.1415926535897932384626433832795;
|
||||
}
|
||||
if (ch == '$')
|
||||
{
|
||||
if (! previous_result_valid_flag)
|
||||
error ();
|
||||
next;
|
||||
return previous_result;
|
||||
}
|
||||
if (ch != '.' && (ch < '0' || ch > '9'))
|
||||
error ();
|
||||
n = strtod (bp - 1, &endp);
|
||||
if (endp == bp - 1)
|
||||
error ();
|
||||
bp = endp;
|
||||
next;
|
||||
return n;
|
||||
}
|
||||
|
||||
int nl_flag = 1;
|
||||
int hhmm_flag = 0;
|
||||
int dhhmm_flag = 0;
|
||||
int round_flag = 0;
|
||||
int prec = 5;
|
||||
|
||||
void
|
||||
output (double exp)
|
||||
{
|
||||
int h, m;
|
||||
if (hhmm_flag)
|
||||
{
|
||||
m = exp * 60;
|
||||
h = m / 60;
|
||||
m -= h * 60;
|
||||
printf ("%02d:%02d", h, m);
|
||||
}
|
||||
else if (dhhmm_flag)
|
||||
{
|
||||
int d;
|
||||
m = exp * (24 * 60);
|
||||
d = m / (24 * 60);
|
||||
m -= d * (24 * 60);
|
||||
h = m / 60;
|
||||
m -= h * 60;
|
||||
printf ("%dd %02d:%02d", d, h, m);
|
||||
}
|
||||
else
|
||||
printf ("%.*g", prec, exp);
|
||||
if (nl_flag)
|
||||
puts ("");
|
||||
previous_result = exp;
|
||||
previous_result_valid_flag = 1;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
while (argc >= 2)
|
||||
{
|
||||
if (!strcmp (argv[1], "-n"))
|
||||
{
|
||||
nl_flag = 0;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
else if (!strcmp (argv[1], "-hhmm"))
|
||||
{
|
||||
hhmm_flag = 1;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
else if (!strcmp (argv[1], "-dhhmm"))
|
||||
{
|
||||
dhhmm_flag = 1;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
else if (!strcmp (argv[1], "-round"))
|
||||
{
|
||||
round_flag = 1;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
else if (!strcmp (argv[1], "-prec"))
|
||||
{
|
||||
prec = atoi (argv[2]);
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
}
|
||||
else if (!strcmp (argv[1], "-help") || !strcmp (argv[1], "-h"))
|
||||
{
|
||||
printf ("usage: %s [options] expr [expr ... ]\n", argv[0]);
|
||||
printf (" options: -n -- suppress newline\n");
|
||||
printf (" -prec n -- print n digits\n");
|
||||
printf (" -round -- round to nearest integer\n");
|
||||
printf (" -hhmm -- print in base 60 (time format)\n");
|
||||
printf (" -dhhmm -- print in base 24,60,60 (time format)\n");
|
||||
printf (" -help -- you've figured out that one\n");
|
||||
exit (0);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
int i;
|
||||
double exp;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
expr_start_p = argv[i];
|
||||
expr_end_p = expr_end_p + strlen (expr_start_p);
|
||||
bp = expr_start_p;
|
||||
next;
|
||||
if (setjmp (top) == 0)
|
||||
{
|
||||
exp = expr ();
|
||||
if (round_flag)
|
||||
exp = floor (exp + 0.5);
|
||||
output (exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#define BUFSIZE 1024
|
||||
char buf[BUFSIZE];
|
||||
double exp;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
fputs ("eval> ", stdout);
|
||||
bp = fgets (buf, BUFSIZE, stdin);
|
||||
if (bp == NULL)
|
||||
break;
|
||||
next;
|
||||
if (setjmp (top) == 0)
|
||||
{
|
||||
exp = expr ();
|
||||
if (round_flag)
|
||||
exp = floor (exp + 0.5);
|
||||
output (exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
56
bench/mpirbench.sln
Normal file
56
bench/mpirbench.sln
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "divide", "divide\divide.vcproj", "{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multiply", "multiply\multiply.vcproj", "{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rsa", "rsa\rsa.vcproj", "{0A7502E9-9286-444A-BB7F-71EEF26506B3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpirver", "mpirver\mpirver.vcproj", "{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}.Debug|x64.Build.0 = Debug|x64
|
||||
{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}.Release|Win32.Build.0 = Release|Win32
|
||||
{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}.Release|x64.ActiveCfg = Release|x64
|
||||
{DBCBBCDF-1124-48A9-8D3D-BEFF6439DECA}.Release|x64.Build.0 = Release|x64
|
||||
{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}.Debug|x64.Build.0 = Debug|x64
|
||||
{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}.Release|Win32.Build.0 = Release|Win32
|
||||
{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}.Release|x64.ActiveCfg = Release|x64
|
||||
{2D065F50-8DDF-4BA5-A913-550E6D6F9ED9}.Release|x64.Build.0 = Release|x64
|
||||
{0A7502E9-9286-444A-BB7F-71EEF26506B3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{0A7502E9-9286-444A-BB7F-71EEF26506B3}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0A7502E9-9286-444A-BB7F-71EEF26506B3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0A7502E9-9286-444A-BB7F-71EEF26506B3}.Debug|x64.Build.0 = Debug|x64
|
||||
{0A7502E9-9286-444A-BB7F-71EEF26506B3}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0A7502E9-9286-444A-BB7F-71EEF26506B3}.Release|Win32.Build.0 = Release|Win32
|
||||
{0A7502E9-9286-444A-BB7F-71EEF26506B3}.Release|x64.ActiveCfg = Release|x64
|
||||
{0A7502E9-9286-444A-BB7F-71EEF26506B3}.Release|x64.Build.0 = Release|x64
|
||||
{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}.Debug|x64.Build.0 = Debug|x64
|
||||
{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}.Release|Win32.Build.0 = Release|Win32
|
||||
{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}.Release|x64.ActiveCfg = Release|x64
|
||||
{351E3DF9-4E47-4BE9-8F71-3C1BBD164F47}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
9
bench/mpirver.c
Normal file
9
bench/mpirver.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include "mpir.h"
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
printf ("mpir version: %s\n", mpir_version);
|
||||
return 0;
|
||||
}
|
113
bench/multiply.c
Normal file
113
bench/multiply.c
Normal file
@ -0,0 +1,113 @@
|
||||
/* multiply.c -- benchmark plain integer multiplication.
|
||||
|
||||
Copyright 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of MPIRbench.
|
||||
|
||||
MPIRbench is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2.1 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
The MPIRbench 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 a copy of the GNU General Public License along with
|
||||
the MPIRbench; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "mpir.h"
|
||||
#include "timing.h"
|
||||
int cputime (void);
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gmp_randstate_t rs;
|
||||
mpz_t x, y, z;
|
||||
unsigned long int m, n, i, j, niter, t0, ti;
|
||||
double t, f, ops_per_sec;
|
||||
int decimals;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
fprintf (stderr, "usage: %s m n\n", argv[0]);
|
||||
fprintf (stderr, " where m and n are number of bits in numbers tested\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
m = atoi (argv[1]);
|
||||
n = atoi (argv[2]);
|
||||
|
||||
gmp_randinit_default (rs);
|
||||
|
||||
mpz_init (x);
|
||||
mpz_init (y);
|
||||
mpz_init (z);
|
||||
mpz_urandomb (x, rs, m);
|
||||
mpz_urandomb (y, rs, n);
|
||||
// gmp_printf("%Zd\n", x);
|
||||
// gmp_printf("%Zd\n", y);
|
||||
|
||||
printf ("Calibrating CPU speed..."); fflush (stdout);
|
||||
TIME (t, mpz_mul (z, x, y));
|
||||
printf ("done\n");
|
||||
|
||||
niter = 1 + (unsigned long) (1e4 / t);
|
||||
printf ("Multiplying %lu-bit number with %lu-bit number %lu times...",
|
||||
m, n, niter);
|
||||
fflush (stdout);
|
||||
t0 = cputime ();
|
||||
|
||||
mpz_urandomb (x, rs, m);
|
||||
mpz_urandomb (y, rs, n);
|
||||
for (i = niter; i > 0; i--)
|
||||
{
|
||||
mpz_mul (z, x, y);
|
||||
}
|
||||
|
||||
ti = cputime () - t0;
|
||||
printf ("done!\n");
|
||||
|
||||
ops_per_sec = 1000.0 * niter / ti;
|
||||
f = 100.0;
|
||||
for (decimals = 0;; decimals++)
|
||||
{
|
||||
if (ops_per_sec > f)
|
||||
break;
|
||||
f = f * 0.1;
|
||||
}
|
||||
|
||||
printf ("RESULT: %.*f operations per second\n", decimals, ops_per_sec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return user CPU time measured in milliseconds. */
|
||||
#if !defined (__sun) \
|
||||
&& (defined (USG) || defined (__SVR4) || defined (_UNICOS) \
|
||||
|| defined (__hpux))
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
cputime ()
|
||||
{
|
||||
return (int) ((double) clock () * 1000 / CLOCKS_PER_SEC);
|
||||
}
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
int
|
||||
cputime ()
|
||||
{
|
||||
struct rusage rus;
|
||||
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
|
||||
}
|
||||
#endif
|
186
bench/rsa.c
Normal file
186
bench/rsa.c
Normal file
@ -0,0 +1,186 @@
|
||||
/* rsa.c -- benchmark signing with the RSA algorithm.
|
||||
|
||||
Copyright 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the MPIRbench.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of 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.
|
||||
|
||||
This program 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 a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "mpir.h"
|
||||
#include "timing.h"
|
||||
|
||||
#define RSA_EXP 0x10001
|
||||
|
||||
int cputime (void);
|
||||
void rsa_sign (mpz_t, mpz_t, mpz_t, mpz_t, mpz_t, mpz_t, mpz_t, mpz_t);
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gmp_randstate_t rs;
|
||||
mpz_t p, q, pq, pm1, qm1, phi, e, d, p_i_q, dp, dq, msg[1024], smsg;
|
||||
unsigned long int n, i, niter, t0, ti;
|
||||
double t, f, ops_per_sec;
|
||||
int decimals;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf (stderr, "usage: %s n\n", argv[0]);
|
||||
fprintf (stderr, " where n is number of bits in numbers tested\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (argc == 2)
|
||||
n = atoi (argv[1]);
|
||||
|
||||
gmp_randinit_default (rs);
|
||||
mpz_init (p);
|
||||
mpz_init (q);
|
||||
mpz_init (pq);
|
||||
|
||||
printf ("Generating p, q, d..."); fflush (stdout);
|
||||
|
||||
mpz_urandomb (p, rs, n/2);
|
||||
mpz_setbit (p, n / 2 - 1);
|
||||
mpz_setbit (p, n / 2 - 2);
|
||||
mpz_nextprime (p, p);
|
||||
|
||||
mpz_urandomb (q, rs, n/2);
|
||||
mpz_setbit (q, n / 2 - 1);
|
||||
mpz_setbit (q, n / 2 - 2);
|
||||
mpz_nextprime (q, q);
|
||||
|
||||
mpz_mul (pq, p, q);
|
||||
|
||||
mpz_init_set_ui (e, RSA_EXP);
|
||||
mpz_init (d);
|
||||
mpz_init (pm1);
|
||||
mpz_init (qm1);
|
||||
mpz_init (phi);
|
||||
|
||||
mpz_sub_ui (pm1, p, 1);
|
||||
mpz_sub_ui (qm1, q, 1);
|
||||
mpz_mul (phi, pm1, qm1);
|
||||
if (mpz_invert (d, e, phi) == 0)
|
||||
abort ();
|
||||
|
||||
printf ("done; pq is %d bits\n", (int) mpz_sizeinbase (pq, 2));
|
||||
|
||||
printf ("Precomputing CRT constants\n");
|
||||
|
||||
mpz_init (p_i_q);
|
||||
if (mpz_invert (p_i_q, p, q) == 0)
|
||||
abort ();
|
||||
|
||||
mpz_init (dp);
|
||||
mpz_init (dq);
|
||||
mpz_mod (dp, d, pm1);
|
||||
mpz_mod (dq, d, qm1);
|
||||
|
||||
printf ("Generating random messages\n");
|
||||
|
||||
for (i = 0; i < 1024; i++)
|
||||
{
|
||||
mpz_init (msg[i]);
|
||||
mpz_urandomb (msg[i], rs, n);
|
||||
}
|
||||
mpz_init (smsg);
|
||||
|
||||
printf ("Calibrating CPU speed..."); fflush (stdout);
|
||||
TIME (t, rsa_sign (smsg, msg[0], p, q, pq, p_i_q, dp, dq));
|
||||
printf ("done\n");
|
||||
|
||||
niter = (unsigned long) (1e4 / t);
|
||||
printf ("Signing random messages %lu times...", niter); fflush (stdout);
|
||||
t0 = cputime ();
|
||||
for (i = niter; i > 0; i--)
|
||||
{
|
||||
rsa_sign (smsg, msg[i % 1024], p, q, pq, p_i_q, dp, dq);
|
||||
}
|
||||
ti = cputime () - t0;
|
||||
printf ("done!\n");
|
||||
|
||||
ops_per_sec = 1000.0 * niter / ti;
|
||||
f = 100.0;
|
||||
for (decimals = 0;; decimals++)
|
||||
{
|
||||
if (ops_per_sec > f)
|
||||
break;
|
||||
f = f * 0.1;
|
||||
}
|
||||
|
||||
printf ("RESULT: %.*f operations per second\n", decimals, ops_per_sec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rsa_sign (mpz_t smsg,
|
||||
mpz_t msg, mpz_t p, mpz_t q, mpz_t pq,
|
||||
mpz_t p_i_q, mpz_t dp, mpz_t dq)
|
||||
{
|
||||
mpz_t t, o, pr, qr, qr_m_pr;
|
||||
|
||||
mpz_init (pr);
|
||||
mpz_init (qr);
|
||||
mpz_init (qr_m_pr);
|
||||
mpz_init (t);
|
||||
mpz_init (o);
|
||||
|
||||
mpz_powm (pr, msg, dp, p);
|
||||
mpz_powm (qr, msg, dq, q);
|
||||
|
||||
mpz_sub (qr_m_pr, qr, pr);
|
||||
|
||||
mpz_mul (t, qr_m_pr, p_i_q);
|
||||
mpz_mod (o, t, q); /* slow mod */
|
||||
|
||||
mpz_mul (t, o, p);
|
||||
mpz_add (smsg, pr, t);
|
||||
mpz_mod (smsg, smsg, pq); /* fast mod */
|
||||
|
||||
mpz_clear (o);
|
||||
mpz_clear (t);
|
||||
mpz_clear (qr_m_pr);
|
||||
mpz_clear (qr);
|
||||
mpz_clear (pr);
|
||||
}
|
||||
|
||||
/* Return user CPU time measured in milliseconds. */
|
||||
#if !defined (__sun) \
|
||||
&& (defined (USG) || defined (__SVR4) || defined (_UNICOS) \
|
||||
|| defined (__hpux))
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
cputime ()
|
||||
{
|
||||
return (int) ((double) clock () * 1000 / CLOCKS_PER_SEC);
|
||||
}
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
int
|
||||
cputime ()
|
||||
{
|
||||
struct rusage rus;
|
||||
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
|
||||
}
|
||||
#endif
|
153
bench/runbench
Normal file
153
bench/runbench
Normal file
@ -0,0 +1,153 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
# Copyright 2009 William Hart
|
||||
# Copyright 2009 Gonzalo Tornaria
|
||||
|
||||
# This file is part of the MPIRbench.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of 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.
|
||||
|
||||
# This program 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 a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
die() {
|
||||
echo "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "***** MPIRbench version `cat version` *****"
|
||||
|
||||
if [ "$1" == "clean" ]
|
||||
then
|
||||
echo rm RES-*
|
||||
rm RES-*
|
||||
echo rm mpirver gexpr multiply divide rsa
|
||||
rm mpirver gexpr multiply divide rsa
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
MPIR_DIR="$1"
|
||||
[ -d "$MPIR_DIR" ] || die "Usage: $0 <path-to-mpir-compile-dir>"
|
||||
|
||||
if [ -r "$MPIR_DIR"/mpir.h ]
|
||||
then
|
||||
MPIR_NAME=mpir
|
||||
elif [ -r "$MPIR_DIR"/gmp.h ]
|
||||
then
|
||||
MPIR_NAME=gmp
|
||||
fi
|
||||
|
||||
[ -r "$MPIR_DIR"/${MPIR_NAME}.h ] || die "${MPIR_NAME}.h not found"
|
||||
[ -r "$MPIR_DIR"/.libs/lib${MPIR_NAME}.a ] || die "lib${MPIR_NAME}.a not found"
|
||||
|
||||
default=false
|
||||
|
||||
if [ -z "$CFLAGS" ]
|
||||
then
|
||||
CFLAGS="-O2 -fomit-frame-pointer -I$MPIR_DIR -include ${MPIR_NAME}.h"
|
||||
echo "Using default CFLAGS = \"$CFLAGS\""
|
||||
default=true
|
||||
else
|
||||
echo "Using CFLAGS = \"$CFLAGS\" from your environment"
|
||||
fi
|
||||
if [ -z "$CC" ]
|
||||
then
|
||||
CC="gcc"
|
||||
echo "Using default CC = \"$CC\""
|
||||
default=true
|
||||
else
|
||||
echo "Using CC = \"$CC\" from your environment"
|
||||
fi
|
||||
if [ -z "$LIBS" ]
|
||||
then
|
||||
LIBS="-static -L$MPIR_DIR/.libs/ -l$MPIR_NAME"
|
||||
echo "Using default LIBS = \"$LIBS\""
|
||||
default=true
|
||||
else
|
||||
echo "Using LIBS = \"$LIBS\" from your environment"
|
||||
fi
|
||||
|
||||
echo "Using compilation command: $CC $CFLAGS foo.c -o foo $LIBS"
|
||||
|
||||
if $default
|
||||
then
|
||||
echo "You may want to override CC, CFLAGS, and LIBS"
|
||||
fi
|
||||
|
||||
$CC $CFLAGS mpirver.c -o mpirver $LIBS || die "error compling mpirver"
|
||||
echo "Using `./mpirver`"
|
||||
$CC --version | head -1
|
||||
|
||||
echo "Compiling benchmarks"
|
||||
$CC $CFLAGS gexpr.c -o gexpr $LIBS -lm || die "error compiling gexpr"
|
||||
$CC $CFLAGS multiply.c -o multiply $LIBS || die "error compiling multiply"
|
||||
$CC $CFLAGS divide.c -o divide $LIBS || die "error compiling divide"
|
||||
$CC $CFLAGS rsa.c -o rsa $LIBS || die "error compiling rsa"
|
||||
|
||||
|
||||
multiply_args="128,128 512,512 8192,8192 131072,131072 2097152,2097152"
|
||||
divide_args="8192,32 8192,64 8192,128 8192,4096 8192,8064 131072,8192 131072,65536 8388608,4194304"
|
||||
rsa_args="512 1024 2048"
|
||||
|
||||
base_tests="multiply divide"
|
||||
app_tests="rsa"
|
||||
|
||||
tests="base app"
|
||||
|
||||
echo "Running benchmarks"
|
||||
|
||||
acc2=1
|
||||
n2=0
|
||||
for cat in $tests
|
||||
do
|
||||
echo " Category $cat"
|
||||
eval tests=\$${cat}_tests
|
||||
|
||||
acc1=1
|
||||
n1=0
|
||||
for t in $tests
|
||||
do
|
||||
echo " Program $t"
|
||||
eval args=\$${t}_args
|
||||
|
||||
acc=1
|
||||
n=0
|
||||
for a in $args
|
||||
do
|
||||
ta=`echo $a | sed 's;,; ;g'`
|
||||
echo " $t $ta"
|
||||
./$t $ta >RES-$t-$a
|
||||
res=`grep "^RESULT" RES-$t-$a | sed 's;^RESULT: \([0-9.]*\).*$;\1;'`
|
||||
echo " MPIRbench.$cat.$t.$a result: $res"
|
||||
acc=`./gexpr -prec 10 "$acc*$res"`
|
||||
n=`./gexpr $n+1`
|
||||
done
|
||||
|
||||
out=`./gexpr "$acc^(1/$n)"`
|
||||
echo " MPIRbench.$cat.$t result: $out"
|
||||
acc1=`./gexpr -prec 10 "$acc1*$acc^(1/$n)"`
|
||||
n1=`./gexpr $n1+1`
|
||||
done
|
||||
|
||||
out=`./gexpr "$acc1^(1/$n1)"`
|
||||
echo " MPIRbench.$cat result: $out"
|
||||
acc2=`./gexpr -prec 10 "$acc2*$acc1^(1/$n1)"`
|
||||
n2=`./gexpr $n2+1`
|
||||
done
|
||||
|
||||
|
||||
out=`./gexpr "$acc2^(1/$n2)"`
|
||||
echo "MPIRbench result: $out"
|
||||
|
||||
exit 0
|
102
bench/runbench.py
Normal file
102
bench/runbench.py
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
# A Python equivalent to gmpbench script 'runbench' for MPIR
|
||||
#
|
||||
# Copyright (c) 1998-2008, Brian Gladman, Worcester, UK.
|
||||
#
|
||||
# Support for Linux added with help from Case Van Horsen.
|
||||
#
|
||||
# This file is part of the MPIR Library. The MPIR Library is free
|
||||
# software; you can redistribute it and/or modify it under the terms
|
||||
# of the GNU Lesser General Public License version 2.1 as published
|
||||
# by the Free Software Foundation.
|
||||
#
|
||||
# The MPIR 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
|
||||
# Lesser General Public License for more details. You should have
|
||||
# received a copy of the GNU Lesser General Public License along
|
||||
# with the MPIR Library; see the file COPYING.LIB. If not, write to
|
||||
# the Free Software Foundation, Inc., 51Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# To compile the test applications:
|
||||
#
|
||||
# Windows:
|
||||
#
|
||||
# Use the VC++ mpirbench project
|
||||
#
|
||||
# Linux:
|
||||
#
|
||||
# mkdir bin
|
||||
# gcc multiply.c -lmpir -o bin/multiply
|
||||
# gcc divide.c -lmpir -o bin/divide
|
||||
# gcc rsa.c -lmpir -o bin/rsa
|
||||
# gcc mpirver.c -lmpir -o bin/mpirver
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import string
|
||||
import platform
|
||||
from re import match
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
|
||||
if sys.platform.startswith('win') :
|
||||
dir = 'x64\\release\\'
|
||||
else:
|
||||
dir = 'bin'
|
||||
|
||||
def run_exe(exe, args, inp) :
|
||||
al = {'stdin' : PIPE, 'stdout' : PIPE, 'stderr' : STDOUT }
|
||||
if sys.platform.startswith('win') :
|
||||
al['creationflags'] = 0x08000000
|
||||
p = Popen([exe] + args, **al)
|
||||
res = p.communicate(inp.encode())[0].decode()
|
||||
ret = p.poll()
|
||||
return (ret, res)
|
||||
|
||||
multiply_args = [(128,128),(512,512),(8192,8192),(131072,131072),\
|
||||
(2097152,2097152)]
|
||||
divide_args = [(8192,32),(8192,64),(8192,128),(8192,4096),(8192,8064),\
|
||||
(131072,8192),(131072,65536),(8388608,4194304)]
|
||||
rsa_args = [[512],[1024],[2048]]
|
||||
|
||||
base_tests = ['multiply', 'divide']
|
||||
app_tests = ["rsa"]
|
||||
tests = ['base', 'app']
|
||||
|
||||
print('Machine:', platform.processor())
|
||||
print('Running:', platform.platform())
|
||||
print('Running benchmarks')
|
||||
acc2 = 1.0
|
||||
n2 = 0.0
|
||||
for c in tests :
|
||||
print(' Category {0:s}'.format(c))
|
||||
acc1 = 1.0
|
||||
n1 = 0.0
|
||||
for t in globals()[c + '_tests'] :
|
||||
print(' Program {0:s}'.format(t))
|
||||
acc = 1.0
|
||||
n = 0.0
|
||||
for pars in globals()[t + '_args'] :
|
||||
params = list(map(str,pars))
|
||||
print(' {0:s} {1:s}'.format(t, ' '.join(params)))
|
||||
ss = (run_exe(os.path.join(dir, t), params, '')[1]).split('\n')
|
||||
for s in ss :
|
||||
if match('RESULT: [0-9]*', s) :
|
||||
res = s.split(' ')[1]
|
||||
print(' MPIRbench.{0:s}.{1:s}.{2:s} result: {3:s}' \
|
||||
.format(c, t, '.'.join(params), res))
|
||||
acc *= eval(res)
|
||||
n += 1.0
|
||||
v = acc ** (1.0 / n)
|
||||
acc1 *= v
|
||||
print(' MPIRbench.{0:s}.{1:s} result: {2:.2f}'.format(c, t, v))
|
||||
n1 += 1.0
|
||||
v = acc1 ** (1.0 / n1)
|
||||
acc2 *= v
|
||||
print(' MPIRbench.{0:s} result {1:.2f}'.format(c, v))
|
||||
n2 += 1.0
|
||||
print('MPIRbench result: {0:.2f}'.format(acc2 ** (1.0 / n2)))
|
||||
input(".. completed - press ENTER")
|
35
bench/timing.h
Normal file
35
bench/timing.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* timing.h
|
||||
|
||||
Copyright 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of MPIRbench.
|
||||
|
||||
MPIRbench is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2.1 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
The MPIRbench 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 a copy of the GNU General Public License along with
|
||||
the MPIRbench; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#define TIME(t,func) \
|
||||
do { long int __t0, __times, __t, __tmp; \
|
||||
__times = 1; \
|
||||
{func;} \
|
||||
do \
|
||||
{ \
|
||||
__times <<= 1; \
|
||||
__t0 = cputime (); \
|
||||
for (__t = 0; __t < __times; __t++) \
|
||||
{func;} \
|
||||
__tmp = cputime () - __t0; \
|
||||
} \
|
||||
while (__tmp < 250); \
|
||||
(t) = (double) __tmp / __times; \
|
||||
} while (0)
|
1
bench/version
Normal file
1
bench/version
Normal file
@ -0,0 +1 @@
|
||||
0.1
|
3
configure
vendored
3
configure
vendored
@ -35197,7 +35197,7 @@ fi
|
||||
ac_config_links="$ac_config_links yasm_mac.inc:$YASM_MAC_INC"
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile tests/cxx/Makefile doc/Makefile tune/Makefile demos/Makefile demos/calc/Makefile demos/expr/Makefile mpir.h:gmp-h.in mp.h:mp-h.in"
|
||||
ac_config_files="$ac_config_files Makefile mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile tests/cxx/Makefile doc/Makefile tune/Makefile bench/Makefile demos/Makefile demos/calc/Makefile demos/expr/Makefile mpir.h:gmp-h.in mp.h:mp-h.in"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
@ -35869,6 +35869,7 @@ do
|
||||
"tests/cxx/Makefile") CONFIG_FILES="$CONFIG_FILES tests/cxx/Makefile" ;;
|
||||
"doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
|
||||
"tune/Makefile") CONFIG_FILES="$CONFIG_FILES tune/Makefile" ;;
|
||||
"bench/Makefile") CONFIG_FILES="$CONFIG_FILES bench/Makefile" ;;
|
||||
"demos/Makefile") CONFIG_FILES="$CONFIG_FILES demos/Makefile" ;;
|
||||
"demos/calc/Makefile") CONFIG_FILES="$CONFIG_FILES demos/calc/Makefile" ;;
|
||||
"demos/expr/Makefile") CONFIG_FILES="$CONFIG_FILES demos/expr/Makefile" ;;
|
||||
|
@ -3324,4 +3324,4 @@ YASM_MAC_INC=yasm_mac.inc.nofat
|
||||
fi
|
||||
AC_CONFIG_LINKS(yasm_mac.inc:$YASM_MAC_INC)
|
||||
|
||||
AC_OUTPUT(Makefile mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile tests/cxx/Makefile doc/Makefile tune/Makefile demos/Makefile demos/calc/Makefile demos/expr/Makefile mpir.h:gmp-h.in mp.h:mp-h.in)
|
||||
AC_OUTPUT(Makefile mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile tests/cxx/Makefile doc/Makefile tune/Makefile bench/Makefile demos/Makefile demos/calc/Makefile demos/expr/Makefile mpir.h:gmp-h.in mp.h:mp-h.in)
|
||||
|
Loading…
Reference in New Issue
Block a user