Add Chromium-only Blender WebEngine parity work

This commit is contained in:
mes123456
2026-08-12 04:47:48 -04:00
commit 9fd26010f6
18225 changed files with 11622124 additions and 0 deletions

View File

@@ -0,0 +1,187 @@
## Process this file with automake to generate Makefile.in
# Copyright 2000-2003, 2005-2011 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * 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.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
AM_LDFLAGS = -no-install
EXTRA_DIST = alpha.asm pentium.asm sparcv9.asm hppa.asm hppa2.asm hppa2w.asm \
ia64.asm powerpc.asm powerpc64.asm x86_64.asm many.pl
noinst_HEADERS = speed.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
EXTRA_LTLIBRARIES = libspeed.la
libspeed_la_SOURCES = \
common.c divrem1div.c divrem1inv.c divrem2div.c divrem2inv.c \
div_qr_1n_pi1_1.c div_qr_1n_pi1_2.c div_qr_1n_pi1_3.c \
div_qr_1n_pi1_4.c div_qr_1_tune.c \
freq.c \
gcdext_single.c gcdext_double.c gcdextod.c gcdextos.c \
hgcd_lehmer.c hgcd_appr_lehmer.c hgcd_reduce_1.c hgcd_reduce_2.c \
jacbase1.c jacbase2.c jacbase3.c jacbase4.c \
hgcd2-1.c hgcd2-2.c hgcd2-3.c hgcd2-4.c hgcd2-5.c \
mod_1_div.c mod_1_inv.c mod_1_1-1.c mod_1_1-2.c modlinv.c \
noop.c powm_mod.c powm_redc.c pre_divrem_1.c \
set_strb.c set_strs.c set_strp.c time.c
libspeed_la_DEPENDENCIES = $(SPEED_CYCLECOUNTER_OBJ) \
$(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
libspeed_la_LIBADD = $(libspeed_la_DEPENDENCIES) $(LIBM)
libspeed_la_LDFLAGS = $(STATIC)
$(top_builddir)/tests/libtests.la:
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
# The library code is faster static than shared on some systems, so do
# tuning and measuring with static, since users who care about maximizing
# speed will be using that. speed-dynamic exists to show the difference.
#
# On Solaris 8, gcc 2.95.2 -static is somehow broken (it creates executables
# that immediately seg fault), so -all-static is not used. The only thing
# -all-static does is make libc static linked as well as libgmp, and that
# makes a difference only when measuring malloc and friends in the speed
# program. This can always be forced with "make speed_LDFLAGS=-all-static
# ..." if desired, see tune/README.
EXTRA_PROGRAMS = speed speed-dynamic speed-ext tuneup tune-gcd-p
DEPENDENCIES = libspeed.la
LDADD = $(DEPENDENCIES) $(TUNE_LIBS)
speed_SOURCES = speed.c
speed_LDFLAGS = $(STATIC)
speed_dynamic_SOURCES = speed.c
speed_ext_SOURCES = speed-ext.c
speed_ext_LDFLAGS = $(STATIC)
tuneup_SOURCES = tuneup.c hgcd2.c
nodist_tuneup_SOURCES = sqr_basecase.c fac_ui.c $(TUNE_MPN_SRCS)
tuneup_DEPENDENCIES = $(TUNE_SQR_OBJ) libspeed.la
tuneup_LDADD = $(tuneup_DEPENDENCIES) $(TUNE_LIBS)
tuneup_LDFLAGS = $(STATIC)
tune_gcd_p_SOURCES = tune-gcd-p.c
tune_gcd_p_DEPENDENCIES = ../mpn/gcd.c
tune_gcd_p_LDFLAGS = $(STATIC)
tune:
$(MAKE) $(AM_MAKEFLAGS) tuneup$(EXEEXT)
./tuneup
allprogs: $(EXTRA_PROGRAMS)
# $(MANY_CLEAN) and $(MANY_DISTCLEAN) are hooks for many.pl
CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LTLIBRARIES) \
$(TUNE_MPN_SRCS) fac_ui.c sqr_asm.asm \
stg.gnuplot stg.data \
mtg.gnuplot mtg.data \
fibg.gnuplot fibg.data \
graph.gnuplot graph.data \
$(MANY_CLEAN)
DISTCLEANFILES = sqr_basecase.c $(MANY_DISTCLEAN)
# Generating these little files at build time seems better than including
# them in the distribution, since the list can be changed more easily.
#
# mpn/generic/tdiv_qr.c uses mpn_divrem_1 and mpn_divrem_2, but only for 1
# and 2 limb divisors, which are never used during tuning, so it doesn't
# matter whether it picks up a tuned or untuned version of those.
#
# divrem_1 and mod_1 are recompiled renamed to "_tune" to avoid a linking
# problem. If a native divrem_1 provides an mpn_divrem_1c entrypoint then
# common.c will want that, but the generic divrem_1 doesn't provide it,
# likewise for mod_1. The simplest way around this is to have the tune
# build versions renamed suitably.
#
# FIXME: Would like say mul_n.c to depend on $(top_builddir)/mul_n.c so the
# recompiled object will be rebuilt if that file changes.
TUNE_MPN_SRCS = $(TUNE_MPN_SRCS_BASIC) divrem_1.c mod_1.c
TUNE_MPN_SRCS_BASIC = div_qr_2.c bdiv_q.c bdiv_qr.c \
dcpi1_div_qr.c dcpi1_divappr_q.c dcpi1_bdiv_qr.c dcpi1_bdiv_q.c \
invertappr.c invert.c binvert.c divrem_2.c gcd.c gcdext.c \
get_str.c set_str.c matrix22_mul.c \
hgcd.c hgcd_appr.c hgcd_reduce.c \
mul_n.c sqr.c sec_powm.c \
mullo_n.c mul_fft.c mul.c tdiv_qr.c mulmod_bnm1.c sqrmod_bnm1.c \
mulmid.c mulmid_n.c toom42_mulmid.c sqrlo.c sqrlo_basecase.c \
nussbaumer_mul.c toom6h_mul.c toom8h_mul.c toom6_sqr.c toom8_sqr.c \
toom22_mul.c toom2_sqr.c toom33_mul.c toom3_sqr.c toom44_mul.c toom4_sqr.c
$(TUNE_MPN_SRCS_BASIC):
for i in $(TUNE_MPN_SRCS_BASIC); do \
echo "#define TUNE_PROGRAM_BUILD 1" >$$i; \
echo "#include \"mpn/generic/$$i\"" >>$$i; \
done
divrem_1.c:
echo "#define TUNE_PROGRAM_BUILD 1" >divrem_1.c
echo "#define __gmpn_divrem_1 mpn_divrem_1_tune" >>divrem_1.c
echo "#include \"mpn/generic/divrem_1.c\"" >>divrem_1.c
mod_1.c:
echo "#define TUNE_PROGRAM_BUILD 1" >mod_1.c
echo "#define __gmpn_mod_1 mpn_mod_1_tune" >>mod_1.c
echo "#include \"mpn/generic/mod_1.c\"" >>mod_1.c
sqr_asm.asm: $(top_builddir)/mpn/sqr_basecase.asm
echo 'define(SQR_TOOM2_THRESHOLD_OVERRIDE,SQR_TOOM2_THRESHOLD_MAX)' >sqr_asm.asm
echo 'include(../mpn/sqr_basecase.asm)' >>sqr_asm.asm
# FIXME: Should it depend on $(top_builddir)/fac_ui.h too?
fac_ui.c: $(top_builddir)/mpz/fac_ui.c
echo "#define TUNE_PROGRAM_BUILD 1" >fac_ui.c
echo "#define __gmpz_fac_ui mpz_fac_ui_tune" >>fac_ui.c
echo "#define __gmpz_oddfac_1 mpz_oddfac_1_tune" >>fac_ui.c
echo "#include \"mpz/oddfac_1.c\"" >>fac_ui.c
echo "#include \"mpz/fac_ui.c\"" >>fac_ui.c
include ../mpn/Makeasm.am
.NOTPARALLEL:

View File

@@ -0,0 +1,957 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 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-2003, 2005-2011 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * 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.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
# Copyright 1996, 1998-2002 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * 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.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@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@
EXTRA_PROGRAMS = speed$(EXEEXT) speed-dynamic$(EXEEXT) \
speed-ext$(EXEEXT) tuneup$(EXEEXT) tune-gcd-p$(EXEEXT)
subdir = tune
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
$(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) \
$(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
am_libspeed_la_OBJECTS = common.lo divrem1div.lo divrem1inv.lo \
divrem2div.lo divrem2inv.lo div_qr_1n_pi1_1.lo \
div_qr_1n_pi1_2.lo div_qr_1n_pi1_3.lo div_qr_1n_pi1_4.lo \
div_qr_1_tune.lo freq.lo gcdext_single.lo gcdext_double.lo \
gcdextod.lo gcdextos.lo hgcd_lehmer.lo hgcd_appr_lehmer.lo \
hgcd_reduce_1.lo hgcd_reduce_2.lo jacbase1.lo jacbase2.lo \
jacbase3.lo jacbase4.lo hgcd2-1.lo hgcd2-2.lo hgcd2-3.lo \
hgcd2-4.lo hgcd2-5.lo mod_1_div.lo mod_1_inv.lo mod_1_1-1.lo \
mod_1_1-2.lo modlinv.lo noop.lo powm_mod.lo powm_redc.lo \
pre_divrem_1.lo set_strb.lo set_strs.lo set_strp.lo time.lo
libspeed_la_OBJECTS = $(am_libspeed_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
libspeed_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libspeed_la_LDFLAGS) $(LDFLAGS) -o $@
am_speed_OBJECTS = speed.$(OBJEXT)
speed_OBJECTS = $(am_speed_OBJECTS)
speed_LDADD = $(LDADD)
speed_DEPENDENCIES = $(DEPENDENCIES) $(am__DEPENDENCIES_1)
speed_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(speed_LDFLAGS) $(LDFLAGS) -o $@
am_speed_dynamic_OBJECTS = speed.$(OBJEXT)
speed_dynamic_OBJECTS = $(am_speed_dynamic_OBJECTS)
speed_dynamic_LDADD = $(LDADD)
speed_dynamic_DEPENDENCIES = $(DEPENDENCIES) $(am__DEPENDENCIES_1)
am_speed_ext_OBJECTS = speed-ext.$(OBJEXT)
speed_ext_OBJECTS = $(am_speed_ext_OBJECTS)
speed_ext_LDADD = $(LDADD)
speed_ext_DEPENDENCIES = $(DEPENDENCIES) $(am__DEPENDENCIES_1)
speed_ext_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(speed_ext_LDFLAGS) $(LDFLAGS) -o $@
am_tune_gcd_p_OBJECTS = tune-gcd-p.$(OBJEXT)
tune_gcd_p_OBJECTS = $(am_tune_gcd_p_OBJECTS)
tune_gcd_p_LDADD = $(LDADD)
tune_gcd_p_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(tune_gcd_p_LDFLAGS) $(LDFLAGS) -o $@
am_tuneup_OBJECTS = tuneup.$(OBJEXT) hgcd2.$(OBJEXT)
am__objects_1 = div_qr_2.$(OBJEXT) bdiv_q.$(OBJEXT) bdiv_qr.$(OBJEXT) \
dcpi1_div_qr.$(OBJEXT) dcpi1_divappr_q.$(OBJEXT) \
dcpi1_bdiv_qr.$(OBJEXT) dcpi1_bdiv_q.$(OBJEXT) \
invertappr.$(OBJEXT) invert.$(OBJEXT) binvert.$(OBJEXT) \
divrem_2.$(OBJEXT) gcd.$(OBJEXT) gcdext.$(OBJEXT) \
get_str.$(OBJEXT) set_str.$(OBJEXT) matrix22_mul.$(OBJEXT) \
hgcd.$(OBJEXT) hgcd_appr.$(OBJEXT) hgcd_reduce.$(OBJEXT) \
mul_n.$(OBJEXT) sqr.$(OBJEXT) sec_powm.$(OBJEXT) \
mullo_n.$(OBJEXT) mul_fft.$(OBJEXT) mul.$(OBJEXT) \
tdiv_qr.$(OBJEXT) mulmod_bnm1.$(OBJEXT) sqrmod_bnm1.$(OBJEXT) \
mulmid.$(OBJEXT) mulmid_n.$(OBJEXT) toom42_mulmid.$(OBJEXT) \
sqrlo.$(OBJEXT) sqrlo_basecase.$(OBJEXT) \
nussbaumer_mul.$(OBJEXT) toom6h_mul.$(OBJEXT) \
toom8h_mul.$(OBJEXT) toom6_sqr.$(OBJEXT) toom8_sqr.$(OBJEXT) \
toom22_mul.$(OBJEXT) toom2_sqr.$(OBJEXT) toom33_mul.$(OBJEXT) \
toom3_sqr.$(OBJEXT) toom44_mul.$(OBJEXT) toom4_sqr.$(OBJEXT)
am__objects_2 = $(am__objects_1) divrem_1.$(OBJEXT) mod_1.$(OBJEXT)
nodist_tuneup_OBJECTS = sqr_basecase.$(OBJEXT) fac_ui.$(OBJEXT) \
$(am__objects_2)
tuneup_OBJECTS = $(am_tuneup_OBJECTS) $(nodist_tuneup_OBJECTS)
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) libspeed.la
tuneup_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(tuneup_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_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) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libspeed_la_SOURCES) $(speed_SOURCES) \
$(speed_dynamic_SOURCES) $(speed_ext_SOURCES) \
$(tune_gcd_p_SOURCES) $(tuneup_SOURCES) \
$(nodist_tuneup_SOURCES)
DIST_SOURCES = $(libspeed_la_SOURCES) $(speed_SOURCES) \
$(speed_dynamic_SOURCES) $(speed_ext_SOURCES) \
$(tune_gcd_p_SOURCES) $(tuneup_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
HEADERS = $(noinst_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/../mpn/Makeasm.am $(srcdir)/Makefile.in \
README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ABI = @ABI@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
ASMFLAGS = @ASMFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
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@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
FGREP = @FGREP@
GMP_LDFLAGS = @GMP_LDFLAGS@
GMP_LIMB_BITS = @GMP_LIMB_BITS@
GMP_NAIL_BITS = @GMP_NAIL_BITS@
GREP = @GREP@
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@
LD = @LD@
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@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
M4 = @M4@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
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_LIBS = @TUNE_LIBS@
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
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_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
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@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
AM_LDFLAGS = -no-install
EXTRA_DIST = alpha.asm pentium.asm sparcv9.asm hppa.asm hppa2.asm hppa2w.asm \
ia64.asm powerpc.asm powerpc64.asm x86_64.asm many.pl
noinst_HEADERS = speed.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
EXTRA_LTLIBRARIES = libspeed.la
libspeed_la_SOURCES = \
common.c divrem1div.c divrem1inv.c divrem2div.c divrem2inv.c \
div_qr_1n_pi1_1.c div_qr_1n_pi1_2.c div_qr_1n_pi1_3.c \
div_qr_1n_pi1_4.c div_qr_1_tune.c \
freq.c \
gcdext_single.c gcdext_double.c gcdextod.c gcdextos.c \
hgcd_lehmer.c hgcd_appr_lehmer.c hgcd_reduce_1.c hgcd_reduce_2.c \
jacbase1.c jacbase2.c jacbase3.c jacbase4.c \
hgcd2-1.c hgcd2-2.c hgcd2-3.c hgcd2-4.c hgcd2-5.c \
mod_1_div.c mod_1_inv.c mod_1_1-1.c mod_1_1-2.c modlinv.c \
noop.c powm_mod.c powm_redc.c pre_divrem_1.c \
set_strb.c set_strs.c set_strp.c time.c
libspeed_la_DEPENDENCIES = $(SPEED_CYCLECOUNTER_OBJ) \
$(top_builddir)/tests/libtests.la $(top_builddir)/libgmp.la
libspeed_la_LIBADD = $(libspeed_la_DEPENDENCIES) $(LIBM)
libspeed_la_LDFLAGS = $(STATIC)
DEPENDENCIES = libspeed.la
LDADD = $(DEPENDENCIES) $(TUNE_LIBS)
speed_SOURCES = speed.c
speed_LDFLAGS = $(STATIC)
speed_dynamic_SOURCES = speed.c
speed_ext_SOURCES = speed-ext.c
speed_ext_LDFLAGS = $(STATIC)
tuneup_SOURCES = tuneup.c hgcd2.c
nodist_tuneup_SOURCES = sqr_basecase.c fac_ui.c $(TUNE_MPN_SRCS)
tuneup_DEPENDENCIES = $(TUNE_SQR_OBJ) libspeed.la
tuneup_LDADD = $(tuneup_DEPENDENCIES) $(TUNE_LIBS)
tuneup_LDFLAGS = $(STATIC)
tune_gcd_p_SOURCES = tune-gcd-p.c
tune_gcd_p_DEPENDENCIES = ../mpn/gcd.c
tune_gcd_p_LDFLAGS = $(STATIC)
# $(MANY_CLEAN) and $(MANY_DISTCLEAN) are hooks for many.pl
CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LTLIBRARIES) \
$(TUNE_MPN_SRCS) fac_ui.c sqr_asm.asm \
stg.gnuplot stg.data \
mtg.gnuplot mtg.data \
fibg.gnuplot fibg.data \
graph.gnuplot graph.data \
$(MANY_CLEAN)
DISTCLEANFILES = sqr_basecase.c $(MANY_DISTCLEAN)
# Generating these little files at build time seems better than including
# them in the distribution, since the list can be changed more easily.
#
# mpn/generic/tdiv_qr.c uses mpn_divrem_1 and mpn_divrem_2, but only for 1
# and 2 limb divisors, which are never used during tuning, so it doesn't
# matter whether it picks up a tuned or untuned version of those.
#
# divrem_1 and mod_1 are recompiled renamed to "_tune" to avoid a linking
# problem. If a native divrem_1 provides an mpn_divrem_1c entrypoint then
# common.c will want that, but the generic divrem_1 doesn't provide it,
# likewise for mod_1. The simplest way around this is to have the tune
# build versions renamed suitably.
#
# FIXME: Would like say mul_n.c to depend on $(top_builddir)/mul_n.c so the
# recompiled object will be rebuilt if that file changes.
TUNE_MPN_SRCS = $(TUNE_MPN_SRCS_BASIC) divrem_1.c mod_1.c
TUNE_MPN_SRCS_BASIC = div_qr_2.c bdiv_q.c bdiv_qr.c \
dcpi1_div_qr.c dcpi1_divappr_q.c dcpi1_bdiv_qr.c dcpi1_bdiv_q.c \
invertappr.c invert.c binvert.c divrem_2.c gcd.c gcdext.c \
get_str.c set_str.c matrix22_mul.c \
hgcd.c hgcd_appr.c hgcd_reduce.c \
mul_n.c sqr.c sec_powm.c \
mullo_n.c mul_fft.c mul.c tdiv_qr.c mulmod_bnm1.c sqrmod_bnm1.c \
mulmid.c mulmid_n.c toom42_mulmid.c sqrlo.c sqrlo_basecase.c \
nussbaumer_mul.c toom6h_mul.c toom8h_mul.c toom6_sqr.c toom8_sqr.c \
toom22_mul.c toom2_sqr.c toom33_mul.c toom3_sqr.c toom44_mul.c toom4_sqr.c
# COMPILE minus CC.
#
COMPILE_FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ASMFLAGS)
# Flags used for preprocessing (in ansi2knr rules).
#
PREPROCESS_FLAGS = $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS)
# Recent versions of automake (1.5 and up for instance) append automake
# generated suffixes to this $(SUFFIXES) list. This is essential for us,
# since .c must come after .s, .S and .asm. If .c is before .s, for
# instance, then in the mpn directory "make" will see add_n.c mentioned in
# an explicit rule (the ansi2knr stuff) and decide it must have add_n.c,
# even if add_n.c doesn't exist but add_n.s does. See GNU make
# documentation "(make)Implicit Rule Search", part 5c.
#
# On IRIX 6 native make this doesn't work properly though. Somehow .c
# remains ahead of .s, perhaps because .c.s is a builtin rule. .asm works
# fine though, and mpn/mips3 uses this.
#
SUFFIXES = .s .S .asm
# can be overridden during development, eg. "make RM_TMP=: mul_1.lo"
RM_TMP = rm -f
all: all-am
.SUFFIXES:
.SUFFIXES: .s .S .asm .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../mpn/Makeasm.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps tune/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu --ignore-deps tune/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;
$(srcdir)/../mpn/Makeasm.am $(am__empty):
$(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
$(am__aclocal_m4_deps):
libspeed.la: $(libspeed_la_OBJECTS) $(libspeed_la_DEPENDENCIES) $(EXTRA_libspeed_la_DEPENDENCIES)
$(AM_V_CCLD)$(libspeed_la_LINK) $(libspeed_la_OBJECTS) $(libspeed_la_LIBADD) $(LIBS)
speed$(EXEEXT): $(speed_OBJECTS) $(speed_DEPENDENCIES) $(EXTRA_speed_DEPENDENCIES)
@rm -f speed$(EXEEXT)
$(AM_V_CCLD)$(speed_LINK) $(speed_OBJECTS) $(speed_LDADD) $(LIBS)
speed-dynamic$(EXEEXT): $(speed_dynamic_OBJECTS) $(speed_dynamic_DEPENDENCIES) $(EXTRA_speed_dynamic_DEPENDENCIES)
@rm -f speed-dynamic$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(speed_dynamic_OBJECTS) $(speed_dynamic_LDADD) $(LIBS)
speed-ext$(EXEEXT): $(speed_ext_OBJECTS) $(speed_ext_DEPENDENCIES) $(EXTRA_speed_ext_DEPENDENCIES)
@rm -f speed-ext$(EXEEXT)
$(AM_V_CCLD)$(speed_ext_LINK) $(speed_ext_OBJECTS) $(speed_ext_LDADD) $(LIBS)
tune-gcd-p$(EXEEXT): $(tune_gcd_p_OBJECTS) $(tune_gcd_p_DEPENDENCIES) $(EXTRA_tune_gcd_p_DEPENDENCIES)
@rm -f tune-gcd-p$(EXEEXT)
$(AM_V_CCLD)$(tune_gcd_p_LINK) $(tune_gcd_p_OBJECTS) $(tune_gcd_p_LDADD) $(LIBS)
tuneup$(EXEEXT): $(tuneup_OBJECTS) $(tuneup_DEPENDENCIES) $(EXTRA_tuneup_DEPENDENCIES)
@rm -f tuneup$(EXEEXT)
$(AM_V_CCLD)$(tuneup_LINK) $(tuneup_OBJECTS) $(tuneup_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.c.o:
$(AM_V_CC)$(COMPILE) -c -o $@ $<
.c.obj:
$(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
$(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
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 "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$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:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_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
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
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-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool cscopelist-am ctags ctags-am 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-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
$(top_builddir)/tests/libtests.la:
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
tune:
$(MAKE) $(AM_MAKEFLAGS) tuneup$(EXEEXT)
./tuneup
allprogs: $(EXTRA_PROGRAMS)
$(TUNE_MPN_SRCS_BASIC):
for i in $(TUNE_MPN_SRCS_BASIC); do \
echo "#define TUNE_PROGRAM_BUILD 1" >$$i; \
echo "#include \"mpn/generic/$$i\"" >>$$i; \
done
divrem_1.c:
echo "#define TUNE_PROGRAM_BUILD 1" >divrem_1.c
echo "#define __gmpn_divrem_1 mpn_divrem_1_tune" >>divrem_1.c
echo "#include \"mpn/generic/divrem_1.c\"" >>divrem_1.c
mod_1.c:
echo "#define TUNE_PROGRAM_BUILD 1" >mod_1.c
echo "#define __gmpn_mod_1 mpn_mod_1_tune" >>mod_1.c
echo "#include \"mpn/generic/mod_1.c\"" >>mod_1.c
sqr_asm.asm: $(top_builddir)/mpn/sqr_basecase.asm
echo 'define(SQR_TOOM2_THRESHOLD_OVERRIDE,SQR_TOOM2_THRESHOLD_MAX)' >sqr_asm.asm
echo 'include(../mpn/sqr_basecase.asm)' >>sqr_asm.asm
# FIXME: Should it depend on $(top_builddir)/fac_ui.h too?
fac_ui.c: $(top_builddir)/mpz/fac_ui.c
echo "#define TUNE_PROGRAM_BUILD 1" >fac_ui.c
echo "#define __gmpz_fac_ui mpz_fac_ui_tune" >>fac_ui.c
echo "#define __gmpz_oddfac_1 mpz_oddfac_1_tune" >>fac_ui.c
echo "#include \"mpz/oddfac_1.c\"" >>fac_ui.c
echo "#include \"mpz/fac_ui.c\"" >>fac_ui.c
# .s assembler, no preprocessing.
#
.s.o:
$(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<
.s.obj:
$(CCAS) $(COMPILE_FLAGS) `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
.s.lo:
$(LIBTOOL) --mode=compile --tag=CC $(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<
# .S assembler, preprocessed with cpp.
#
# It's necessary to run $(CPP) separately, since it seems not all compilers
# recognise .S files, in particular "cc" on HP-UX 10 and 11 doesn't (and
# will silently do nothing if given a .S).
#
# For .lo we need a helper script, as described below for .asm.lo.
#
.S.o:
$(CPP) $(PREPROCESS_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$< | grep -v '^#' >tmp-$*.s
$(CCAS) $(COMPILE_FLAGS) tmp-$*.s -o $@
$(RM_TMP) tmp-$*.s
.S.obj:
$(CPP) $(PREPROCESS_FLAGS) `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` | grep -v '^#' >tmp-$*.s
$(CCAS) $(COMPILE_FLAGS) tmp-$*.s -o $@
$(RM_TMP) tmp-$*.s
.S.lo:
$(LIBTOOL) --mode=compile --tag=CC $(top_srcdir)/mpn/cpp-ccas --cpp="$(CPP) $(PREPROCESS_FLAGS)" $(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<
# .asm assembler, preprocessed with m4.
#
# .o and .obj are non-PIC and just need m4 followed by a compile.
#
# .lo is a bit tricky. Libtool (as of version 1.5) has foo.lo as a little
# text file, and .libs/foo.o and foo.o as the PIC and non-PIC objects,
# respectively. It'd be asking for lots of trouble to try to create foo.lo
# ourselves, so instead arrange to invoke libtool like a --mode=compile, but
# with a special m4-ccas script which first m4 preprocesses, then compiles.
# --tag=CC is necessary since foo.asm is otherwise unknown to libtool.
#
# Libtool adds -DPIC when building a shared object and the .asm files look
# for that. But it should be noted that the other PIC flags are on occasion
# important too, in particular FreeBSD 2.2.8 gas 1.92.3 requires -k before
# it accepts PIC constructs like @GOT, and gcc adds that flag only under
# -fPIC. (Later versions of gas are happy to accept PIC stuff any time.)
#
.asm.o:
$(M4) -DOPERATION_$* `test -f '$<' || echo '$(srcdir)/'`$< >tmp-$*.s
$(CCAS) $(COMPILE_FLAGS) tmp-$*.s -o $@
$(RM_TMP) tmp-$*.s
.asm.obj:
$(M4) -DOPERATION_$* `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` >tmp-$*.s
$(CCAS) $(COMPILE_FLAGS) tmp-$*.s -o $@
$(RM_TMP) tmp-$*.s
.asm.lo:
$(LIBTOOL) --mode=compile --tag=CC $(top_srcdir)/mpn/m4-ccas --m4="$(M4)" $(CCAS) $(COMPILE_FLAGS) `test -f '$<' || echo '$(srcdir)/'`$<
.NOTPARALLEL:
# 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:

View File

@@ -0,0 +1,501 @@
Copyright 2000-2002, 2004 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/.
GMP SPEED MEASURING AND PARAMETER TUNING
The programs in this directory are for knowledgeable users who want to
measure GMP routines on their machine, and perhaps tweak some settings or
identify things that can be improved.
The programs here are tools, not ready to run solutions. Nothing is built
in a normal "make all", but various Makefile targets described below exist.
Relatively few systems and CPUs have been tested, so be sure to verify that
results are sensible before relying on them.
MISCELLANEOUS NOTES
--enable-assert
Don't configure with --enable-assert, since the extra code added by
assertion checking may influence measurements.
Direct mapped caches
Some effort has been made to accommodate CPUs with direct mapped caches,
by putting data blocks more or less contiguously on the stack. But this
will depend on TMP_ALLOC using alloca, and even then it may or may not
be enough.
FreeBSD 4.2 i486 getrusage
This getrusage seems to be a bit doubtful, it looks like it's
microsecond accurate, but sometimes ru_utime remains unchanged after a
time of many microseconds has elapsed. It'd be good to detect this in
the time.c initializations, but for now the suggestion is to pretend it
doesn't exist.
./configure ac_cv_func_getrusage=no
NetBSD 1.4.1 m68k macintosh time base
On this system it's been found getrusage often goes backwards, making it
unusable (time.c getrusage_backwards_p detects this). gettimeofday
sometimes doesn't update atomically when it crosses a 1 second boundary.
Not sure what to do about this. Expect possible intermittent failures.
SCO OpenUNIX 8 /etc/hw
/etc/hw takes about a second to return the cpu frequency, which suggests
perhaps it's measuring each time it runs. If this is annoying when
running the speed program repeatedly then set a GMP_CPU_FREQUENCY
environment variable (see TIME BASE section below).
Timing on GNU/Linux
On Linux, timing currently uses the cycle counter. This is unreliable,
since the counter is not saved and restored at context switches (unlike
FreeBSD and Solaris where the cycle counter is "virtualized").
Using the clock_gettime method with CLOCK_PROCESS_CPUTIME_ID (posix) or
CLOCK_VIRTUAL (BSD) should be more reliable. To get clock_gettime
with glibc, one has to link with -lrt (which also drags in the pthreads
threading library). configure.in must be hacked to detect this and
arrange proper linking. Something like
old_LIBS="$LIBS"
AC_SEARCH_LIBS(clock_gettime, rt, [AC_DEFINE(HAVE_CLOCK_GETTIME)])
TUNE_LIBS="$LIBS"
LIBS="$old_LIBS"
AC_SUBST(TUNE_LIBS)
might work.
Low resolution timebase
Parameter tuning can be very time consuming if the only timebase
available is a 10 millisecond clock tick, to the point of being
unusable. This is currently the case on VAX and ARM systems.
PARAMETER TUNING
The "tuneup" program runs some tests designed to find the best settings for
various thresholds, like MUL_TOOM22_THRESHOLD. Its output can be put
into gmp-mparam.h. The program is built and run with
make tune
If the thresholds indicated are grossly different from the values in the
selected gmp-mparam.h then there may be a performance boost in applicable
size ranges by changing gmp-mparam.h accordingly.
Be sure to do a full reconfigure and rebuild to get any newly set thresholds
to take effect. A partial rebuild is enough sometimes, but a fresh
configure and make is certain to be correct.
If a CPU has specific tuned parameters coming from a gmp-mparam.h in one of
the mpn subdirectories then the values from "make tune" should be similar.
But check that the configured CPU is right and there are no machine specific
effects causing a difference.
It's hoped the compiler and options used won't have too much effect on
thresholds, since for most CPUs they ultimately come down to comparisons
between assembler subroutines. Missing out on the longlong.h macros by not
using gcc will probably have an effect.
Some thresholds produced by the tune program are merely single values chosen
from what's a range of sizes where two algorithms are pretty much the same
speed. When this happens the program is likely to give somewhat different
values on successive runs. This is noticeable on the toom3 thresholds for
instance.
SPEED PROGRAM
The "speed" program can be used for measuring and comparing various
routines, and producing tables of data or gnuplot graphs. Compile it with
make speed
(Or on DOS systems "make speed.exe".)
Here are some examples of how to use it. Check the code for all the
options.
Draw a graph of mpn_mul_n, stepping through sizes by 10 or a factor of 1.05
(whichever is greater).
./speed -s 10-5000 -t 10 -f 1.05 -P foo mpn_mul_n
gnuplot foo.gnuplot
Compare mpn_add_n and an mpn_lshift by 1, showing times in cycles and
showing under mpn_lshift the difference between it and mpn_add_n.
./speed -s 1-40 -c -d mpn_add_n mpn_lshift.1
Using option -c for times in cycles is interesting but normally only
necessary when looking carefully at assembler subroutines. You might think
it would always give an integer value, but this doesn't happen in practice,
probably due to overheads in the time measurements.
In the free-form output the "#" symbol against a measurement means the
corresponding routine is fastest at that size. This is a convenient visual
cue when comparing different routines. The graph data files <name>.data
don't get this since it would upset gnuplot or other data viewers.
TIME BASE
The time measuring method is determined in time.c, based on what the
configured host has available. A cycle counter is preferred, possibly
supplemented by another method if the counter has a limited range. A
microsecond accurate getrusage() or gettimeofday() will work quite well too.
The cycle counters (except possibly on alpha) and gettimeofday() will depend
on the machine being otherwise idle, or rather on other jobs not stealing
CPU time from the measuring program. Short routines (those that complete
within a timeslice) should work even on a busy machine.
Some trouble is taken by speed_measure() in common.c to avoid ill effects
from sporadic interrupts, or other intermittent things (like cron waking up
every minute). But generally an idle machine will be necessary to be
certain of consistent results.
The CPU frequency is needed to convert between cycles and seconds, or for
when a cycle counter is supplemented by getrusage() etc. The speed program
will convert as necessary according to the output format requested. The
tune program will work with either cycles or seconds.
freq.c knows how to get the frequency on some systems, or can measure a
cycle counter against gettimeofday() or getrusage(), but when that fails, or
needs to be overridden, an environment variable GMP_CPU_FREQUENCY can be
used (in Hertz). For example in "bash" on a 650 MHz machine,
export GMP_CPU_FREQUENCY=650e6
A high precision time base makes it possible to get accurate measurements in
a shorter time.
EXAMPLE COMPARISONS - VARIOUS
Here are some ideas for things that can be done with the speed program.
There's always going to be a certain amount of overhead in the time
measurements, due to reading the time base, and in the loop that runs a
routine enough times to get a reading of the desired precision. Noop
functions taking various arguments are available to measure this. The
"overhead" printed by the speed program each time in its intro is the "noop"
routine, but note that this is just for information, it isn't deducted from
the times printed or anything.
./speed -s 1 noop noop_wxs noop_wxys
To see how many cycles per limb a routine is taking, look at the time
increase when the size increments, using option -D. This avoids fixed
overheads in the measuring. Also, remember many of the assembler routines
have unrolled loops, so it might be necessary to compare times at, say, 16,
32, 48, 64 etc to see what the unrolled part is taking, as opposed to any
finishing off.
./speed -s 16-64 -t 16 -C -D mpn_add_n
The -C option on its own gives cycles per limb, but is really only useful at
big sizes where fixed overheads are small compared to the code doing the
real work. Remember of course memory caching and/or page swapping will
affect results at large sizes.
./speed -s 500000 -C mpn_add_n
Once a calculation stops fitting in the CPU data cache, it's going to start
taking longer. Exactly where this happens depends on the cache priming in
the measuring routines, and on what sort of "least recently used" the
hardware does. Here's an example for a CPU with a 16kbyte L1 data cache and
32-bit limb, showing a suddenly steeper curve for mpn_add_n at about 2000
limbs.
./speed -s 1-4000 -t 5 -f 1.02 -P foo mpn_add_n
gnuplot foo.gnuplot
When a routine has an unrolled loop for, say, multiples of 8 limbs and then
an ordinary loop for the remainder, it can happen that it's actually faster
to do an operation on, say, 8 limbs than it is on 7 limbs. The following
draws a graph of mpn_sub_n, to see whether times smoothly increase with
size.
./speed -s 1-100 -c -P foo mpn_sub_n
gnuplot foo.gnuplot
If mpn_lshift and mpn_rshift have special case code for shifts by 1, it
ought to be faster (or at least not slower) than shifting by, say, 2 bits.
./speed -s 1-200 -c mpn_rshift.1 mpn_rshift.2
An mpn_lshift by 1 can be done by mpn_add_n adding a number to itself, and
if the lshift isn't faster there's an obvious improvement that's possible.
./speed -s 1-200 -c mpn_lshift.1 mpn_add_n_self
On some CPUs (AMD K6 for example) an "in-place" mpn_add_n where the
destination is one of the sources is faster than a separate destination.
Here's an example to see this. ".1" selects dst==src1 for mpn_add_n (and
mpn_sub_n), for other values see speed.h SPEED_ROUTINE_MPN_BINARY_N_CALL.
./speed -s 1-200 -c mpn_add_n mpn_add_n.1
The gmp manual points out that divisions by powers of two should be done
using a right shift because it'll be significantly faster than an actual
division. The following shows by what factor mpn_rshift is faster than
mpn_divrem_1, using division by 32 as an example.
./speed -s 10-20 -r mpn_rshift.5 mpn_divrem_1.32
EXAMPLE COMPARISONS - MULTIPLICATION
mul_basecase takes a ".<r>" parameter. If positive, it gives the second
(smaller) operand size. For example to show speeds for 3x3 up to 20x3 in
cycles,
./speed -s 3-20 -c mpn_mul_basecase.3
A negative ".<-r>" parameter fixes the size of the product to the absolute
value r. For example to show speeds for 10x10 up to 19x1 in cycles,
./speed -s 10-19 -c mpn_mul_basecase.-20
mul_basecase with no parameter does an NxN multiply, so for example to show
speeds in cycles for 1x1, 2x2, 3x3, etc, up to 20x20, in cycles,
./speed -s 1-20 -c mpn_mul_basecase
sqr_basecase is implemented by a "triangular" method on most CPUs, making it
up to twice as fast as mul_basecase. In practice loop overheads and the
products on the diagonal mean it falls short of this. Here's an example
running the two and showing by what factor an NxN mul_basecase is slower
than an NxN sqr_basecase. (Some versions of sqr_basecase only allow sizes
below SQR_TOOM2_THRESHOLD, so if it crashes at that point don't worry.)
./speed -s 1-20 -r mpn_sqr_basecase mpn_mul_basecase
The technique described above with -CD for showing the time difference in
cycles per limb between two size operations can be done on an NxN
mul_basecase using -E to change the basis for the size increment to N*N.
For instance a 20x20 operation is taken to be doing 400 limbs, and a 16x16
doing 256 limbs. The following therefore shows the per crossproduct speed
of mul_basecase and sqr_basecase at around 20x20 limbs.
./speed -s 16-20 -t 4 -CDE mpn_mul_basecase mpn_sqr_basecase
Of course sqr_basecase isn't really doing NxN crossproducts, but it can be
interesting to compare it to mul_basecase as if it was. For sqr_basecase
the -F option can be used to base the deltas on N*(N+1)/2 operations, which
is the triangular products sqr_basecase does. For example,
./speed -s 16-20 -t 4 -CDF mpn_sqr_basecase
Both -E and -F are preliminary and might change. A consistent approach to
using them when claiming certain per crossproduct or per triangularproduct
speeds hasn't really been established, but the increment between speeds in
the range karatsuba will call seems sensible, that being k to k/2. For
instance, if the karatsuba threshold was 20 for the multiply and 30 for the
square,
./speed -s 10-20 -t 10 -CDE mpn_mul_basecase
./speed -s 15-30 -t 15 -CDF mpn_sqr_basecase
EXAMPLE COMPARISONS - MALLOC
The gmp manual recommends application programs avoid excessive initializing
and clearing of mpz_t variables (and mpq_t and mpf_t too). Every new
variable will at a minimum go through an init, a realloc for its first
store, and finally a clear. Quite how long that takes depends on the C
library. The following compares an mpz_init/realloc/clear to a 10 limb
mpz_add. Don't be surprised if the mallocing is quite slow.
./speed -s 10 -c mpz_init_realloc_clear mpz_add
On some systems malloc and free are much slower when dynamic linked. The
speed-dynamic program can be used to see this. For example the following
measures malloc/free, first static then dynamic.
./speed -s 10 -c malloc_free
./speed-dynamic -s 10 -c malloc_free
Of course a real world program has big problems if it's doing so many
mallocs and frees that it gets slowed down by a dynamic linked malloc.
EXAMPLE COMPARISONS - STRING CONVERSIONS
mpn_get_str does a binary to string conversion. The base is specified with
a ".<r>" parameter, or decimal by default. Power of 2 bases are much faster
than general bases. The following compares decimal and hex for instance.
./speed -s 1-20 -c mpn_get_str mpn_get_str.16
Smaller bases need more divisions to split a given size number, and so are
slower. The following compares base 3 and base 9. On small operands 9 will
be nearly twice as fast, though at bigger sizes this reduces since in the
current implementation both divide repeatedly by 3^20 (or 3^40 for 64 bit
limbs) and those divisions come to dominate.
./speed -s 1-20 -cr mpn_get_str.3 mpn_get_str.9
mpn_set_str does a string to binary conversion. The base is specified with
a ".<r>" parameter, or decimal by default. Power of 2 bases are faster than
general bases on large conversions.
./speed -s 1-512 -f 2 -c mpn_set_str.8 mpn_set_str.10
mpn_set_str also has some special case code for decimal which is a bit
faster than the general case, basically by giving the compiler a chance to
optimize some multiplications by 10.
./speed -s 20-40 -c mpn_set_str.9 mpn_set_str.10 mpn_set_str.11
EXAMPLE COMPARISONS - GCDs
mpn_gcd_1 has a threshold for when to reduce using an initial x%y when both
x and y are single limbs. This isn't tuned currently, but a value can be
established by a measurement like
./speed -s 10-32 mpn_gcd_1.10
This runs src[0] from 10 to 32 bits, and y fixed at 10 bits. If the div
threshold is high, say 31 so it's effectively disabled then a 32x10 bit gcd
is done by nibbling away at the 32-bit operands bit-by-bit. When the
threshold is small, say 1 bit, then an initial x%y is done to reduce it to a
10x10 bit operation.
The threshold in mpn/generic/gcd_1.c or the various assembler
implementations can be tweaked up or down until there's no more speedups on
interesting combinations of sizes. Note that this affects only a 1x1 limb
operation and so isn't very important. (An Nx1 limb operation always does
an initial modular reduction, using mpn_mod_1 or mpn_modexact_1_odd.)
SPEED PROGRAM EXTENSIONS
Potentially lots of things could be made available in the program, but it's
been left at only the things that have actually been wanted and are likely
to be reasonably useful in the future.
Extensions should be fairly easy to make though. speed-ext.c is an example,
in a style that should suit one-off tests, or new code fragments under
development.
many.pl is a script for generating a new speed program supplemented with
alternate versions of the standard routines. It can be used for measuring
experimental code, or for comparing different implementations that exist
within a CPU family.
THRESHOLD EXAMINING
The speed program can be used to examine the speeds of different algorithms
to check the tune program has done the right thing. For example to examine
the karatsuba multiply threshold,
./speed -s 5-40 mpn_mul_basecase mpn_kara_mul_n
When examining the toom3 threshold, remember it depends on the karatsuba
threshold, so the right karatsuba threshold needs to be compiled into the
library first. The tune program uses specially recompiled versions of
mpn/mul_n.c etc for this reason, but the speed program simply uses the
normal libgmp.la.
Note further that the various routines may recurse into themselves on sizes
far enough above applicable thresholds. For example, mpn_kara_mul_n will
recurse into itself on sizes greater than twice the compiled-in
MUL_TOOM22_THRESHOLD.
When doing the above comparison between mul_basecase and kara_mul_n what's
probably of interest is mul_basecase versus a kara_mul_n that does one level
of Karatsuba then calls to mul_basecase, but this only happens on sizes less
than twice the compiled MUL_TOOM22_THRESHOLD. A larger value for that
setting can be compiled-in to avoid the problem if necessary. The same
applies to toom3 and DC, though in a trickier fashion.
There are some upper limits on some of the thresholds, arising from arrays
dimensioned according to a threshold (mpn_mul_n), or asm code with certain
sized displacements (some x86 versions of sqr_basecase). So putting huge
values for the thresholds, even just for testing, may fail.
FUTURE
Make a program to check the time base is working properly, for small and
large measurements. Make it able to test each available method, including
perhaps the apparent resolution of each.
Make a general mechanism for specifying operand overlap, and a syntax like
maybe "mpn_add_n.dst=src2" to select it. Some measuring routines do this
sort of thing with the "r" parameter currently.
----------------
Local variables:
mode: text
fill-column: 76
End:

View File

@@ -0,0 +1,59 @@
dnl Alpha time stamp counter access routine.
dnl Copyright 2000, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C void speed_cyclecounter (unsigned int p[2]);
C
C The rpcc instruction returns a 64-bit value split into two 32-bit fields.
C The lower 32 bits are set by the hardware, and the upper 32 bits are set
C by the operating system. The real per-process cycle count is the sum of
C these halves.
C Unfortunately, some operating systems don't get this right. NetBSD 1.3 is
C known to sometimes put garbage in the upper half. Whether newer NetBSD
C versions get it right, is unknown to us.
C rpcc measures cycles elapsed in the user program and hence should be very
C accurate even on a busy system. Losing cache contents due to task
C switching may have an effect though.
ASM_START()
PROLOGUE(speed_cyclecounter)
rpcc r0
srl r0,32,r1
addq r1,r0,r0
stl r0,0(r16)
stl r31,4(r16) C zero upper return word
ret r31,(r26),1
EPILOGUE(speed_cyclecounter)
ASM_END()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,50 @@
/* mpn/generic/div_qr_1, using tuned threshold and method.
Copyright 2013 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define TUNE_PROGRAM_BUILD 1
#include "gmp-impl.h"
mp_limb_t mpn_div_qr_1n_pi1_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, mp_limb_t);
mp_limb_t mpn_div_qr_1n_pi1_2 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, mp_limb_t);
mp_limb_t mpn_div_qr_1n_pi1_3 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, mp_limb_t);
mp_limb_t mpn_div_qr_1n_pi1_4 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t, mp_limb_t);
#if !HAVE_NATIVE_mpn_div_qr_1n_pi1
#define __gmpn_div_qr_1n_pi1 \
(div_qr_1n_pi1_method <= 2 \
? (div_qr_1n_pi1_method == 1 ? mpn_div_qr_1n_pi1_1 : mpn_div_qr_1n_pi1_2) \
: (div_qr_1n_pi1_method == 3 ? mpn_div_qr_1n_pi1_3 : mpn_div_qr_1n_pi1_4))
#endif
#undef mpn_div_qr_1
#define mpn_div_qr_1 mpn_div_qr_1_tune
#include "mpn/generic/div_qr_1.c"

View File

@@ -0,0 +1,38 @@
/* mpn/generic/div_qr_1n_pi1.c method 1.
Copyright 2013 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef DIV_QR_1N_METHOD
#define DIV_QR_1N_METHOD 1
#undef mpn_div_qr_1n_pi1
#define mpn_div_qr_1n_pi1 mpn_div_qr_1n_pi1_1
#include "mpn/generic/div_qr_1n_pi1.c"

View File

@@ -0,0 +1,38 @@
/* mpn/generic/div_qr_1n_pi1.c method 2.
Copyright 2013 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef DIV_QR_1N_METHOD
#define DIV_QR_1N_METHOD 2
#undef mpn_div_qr_1n_pi1
#define mpn_div_qr_1n_pi1 mpn_div_qr_1n_pi1_2
#include "mpn/generic/div_qr_1n_pi1.c"

View File

@@ -0,0 +1,38 @@
/* mpn/generic/div_qr_1n_pi1.c method 3.
Copyright 2013 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef DIV_QR_1N_METHOD
#define DIV_QR_1N_METHOD 3
#undef mpn_div_qr_1n_pi1
#define mpn_div_qr_1n_pi1 mpn_div_qr_1n_pi1_3
#include "mpn/generic/div_qr_1n_pi1.c"

View File

@@ -0,0 +1,38 @@
/* mpn/generic/div_qr_1n_pi1.c method 4.
Copyright 2013 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef DIV_QR_1N_METHOD
#define DIV_QR_1N_METHOD 4
#undef mpn_div_qr_1n_pi1
#define mpn_div_qr_1n_pi1 mpn_div_qr_1n_pi1_4
#include "mpn/generic/div_qr_1n_pi1.c"

View File

@@ -0,0 +1,41 @@
/* mpn/generic/divrem_1.c forced to use plain udiv_qrnnd.
Copyright 2000, 2003 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define OPERATION_divrem_1
#include "gmp-impl.h"
#undef DIVREM_1_NORM_THRESHOLD
#undef DIVREM_1_UNNORM_THRESHOLD
#define DIVREM_1_NORM_THRESHOLD MP_SIZE_T_MAX
#define DIVREM_1_UNNORM_THRESHOLD MP_SIZE_T_MAX
#define __gmpn_divrem_1 mpn_divrem_1_div
#include "mpn/generic/divrem_1.c"

View File

@@ -0,0 +1,41 @@
/* mpn/generic/divrem_1.c forced to use mul-by-inverse udiv_qrnnd_preinv.
Copyright 2000, 2003 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define OPERATION_divrem_1
#include "gmp-impl.h"
#undef DIVREM_1_NORM_THRESHOLD
#undef DIVREM_1_UNNORM_THRESHOLD
#define DIVREM_1_NORM_THRESHOLD 0
#define DIVREM_1_UNNORM_THRESHOLD 0
#define __gmpn_divrem_1 mpn_divrem_1_inv
#include "mpn/generic/divrem_1.c"

View File

@@ -0,0 +1,40 @@
/* mpn/generic/divrem_2.c forced to use plain udiv_qrnnd. */
/*
Copyright 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#ifdef DIVREM_2_THRESHOLD
#undef DIVREM_2_THRESHOLD
#endif
#define DIVREM_2_THRESHOLD MP_SIZE_T_MAX
#define __gmpn_divrem_2 mpn_divrem_2_div
#include "mpn/generic/divrem_2.c"

View File

@@ -0,0 +1,40 @@
/* mpn/generic/divrem_2.c forced to use udiv_qrnnd_preinv. */
/*
Copyright 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#ifdef DIVREM_2_THRESHOLD
#undef DIVREM_2_THRESHOLD
#endif
#define DIVREM_2_THRESHOLD 0
#define __gmpn_divrem_2 mpn_divrem_2_inv
#include "mpn/generic/divrem_2.c"

View File

@@ -0,0 +1,893 @@
/* CPU frequency determination.
Copyright 1999-2004 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/* Currently we don't get a CPU frequency on the following systems,
alphaev5-cray-unicosmk2.0.6.X
times() has been seen at 13.33 ns (75 MHz), which is probably not the
cpu frequency. Measuring the cycle counter against that would be
possible though. But currently we don't use the cycle counter due to
unicos having int==8bytes where tune/alpha.asm assumes int==4bytes.
m68040-unknown-netbsd1.4.1
Not sure if the system even knows the cpu frequency. There's no
cycle counter to measure, though we could perhaps make a loop taking
a known number of cycles and measure that.
power-ibm-aix4.2.1.0
power2-ibm-aix4.3.1.0
powerpc604-ibm-aix4.3.1.0
powerpc604-ibm-aix4.3.3.0
powerpc630-ibm-aix4.3.3.0
powerpc-unknown-netbsd1.6
Don't know where any info hides on these. mftb is not related to the
cpu frequency so doesn't help.
sparc-unknown-linux-gnu [maybe]
Don't know where any info hides on this.
t90-cray-unicos10.0.X
The times() call seems to be for instance 2.22 nanoseconds, which
might be the cpu frequency (450 mhz), but need to confirm that.
*/
#include "config.h"
#if HAVE_INVENT_H
#include <invent.h> /* for IRIX invent_cpuinfo_t */
#endif
#include <stdio.h>
#include <stdlib.h> /* for getenv, qsort */
#include <string.h> /* for memcmp */
#if HAVE_UNISTD_H
#include <unistd.h> /* for sysconf */
#endif
#include <sys/types.h>
#if HAVE_SYS_ATTRIBUTES_H
#include <sys/attributes.h> /* for IRIX attr_get(), needs sys/types.h */
#endif
#if HAVE_SYS_IOGRAPH_H
#include <sys/iograph.h> /* for IRIX INFO_LBL_DETAIL_INVENT */
#endif
#if HAVE_SYS_PARAM_H /* for constants needed by NetBSD <sys/sysctl.h> */
#include <sys/param.h> /* and needed by HPUX <sys/pstat.h> */
#endif
#if HAVE_SYS_PSTAT_H
#include <sys/pstat.h> /* for HPUX pstat_getprocessor() */
#endif
#if HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h> /* for sysctlbyname() */
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h> /* for struct timeval */
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h> /* for struct rusage */
#endif
#if HAVE_SYS_PROCESSOR_H
#include <sys/processor.h> /* for solaris processor_info_t */
#endif
/* On AIX 5.1 with gcc 2.9-aix51-020209 in -maix64 mode, <sys/sysinfo.h>
gets an error about "fill" in "struct cpuinfo" having a negative size,
apparently due to __64BIT_KERNEL not being defined because _KERNEL is not
defined. Avoid this file if we don't actually need it, which we don't on
AIX since there's no getsysinfo there. */
#if HAVE_SYS_SYSINFO_H && HAVE_GETSYSINFO
#include <sys/sysinfo.h> /* for OSF getsysinfo */
#endif
#if HAVE_MACHINE_HAL_SYSINFO_H
#include <machine/hal_sysinfo.h> /* for OSF GSI_CPU_INFO, struct cpu_info */
#endif
/* Remove definitions from NetBSD <sys/param.h>, to avoid conflicts with
gmp-impl.h. */
#ifdef MIN
#undef MIN
#endif
#ifdef MAX
#undef MAX
#endif
#include "gmp-impl.h"
#include "speed.h"
#define HELP(str) \
if (help) \
{ \
printf (" - %s\n", str); \
return 0; \
}
/* GMP_CPU_FREQUENCY environment variable. Should be in Hertz and can be
floating point, for example "450e6". */
static int
freq_environment (int help)
{
char *e;
HELP ("environment variable GMP_CPU_FREQUENCY (in Hertz)");
e = getenv ("GMP_CPU_FREQUENCY");
if (e == NULL)
return 0;
speed_cycletime = 1.0 / atof (e);
if (speed_option_verbose)
printf ("Using GMP_CPU_FREQUENCY %.2f for cycle time %.3g\n",
atof (e), speed_cycletime);
return 1;
}
/* getsysinfo is available on OSF, or 4.0 and up at least.
The man page (on 4.0) suggests a 0 return indicates information not
available, but that seems to be the normal return for GSI_CPU_INFO. */
static int
freq_getsysinfo (int help)
{
#if HAVE_GETSYSINFO
struct cpu_info c;
int start;
HELP ("getsysinfo() GSI_CPU_INFO");
start = 0;
if (getsysinfo (GSI_CPU_INFO, (caddr_t) &c, sizeof (c),
&start, NULL, NULL) != -1)
{
speed_cycletime = 1e-6 / (double) c.mhz;
if (speed_option_verbose)
printf ("Using getsysinfo() GSI_CPU_INFO %u for cycle time %.3g\n",
c.mhz, speed_cycletime);
return 1;
}
#endif
return 0;
}
/* In HPUX 10 and up, pstat_getprocessor() psp_iticksperclktick is the
number of CPU cycles (ie. the CR16 register) per CLK_TCK. HPUX 9 doesn't
have that field in pst_processor though, and has no apparent
equivalent. */
static int
freq_pstat_getprocessor (int help)
{
#if HAVE_PSTAT_GETPROCESSOR && HAVE_PSP_ITICKSPERCLKTICK
struct pst_processor p;
HELP ("pstat_getprocessor() psp_iticksperclktick");
if (pstat_getprocessor (&p, sizeof(p), 1, 0) != -1)
{
long c = clk_tck();
speed_cycletime = 1.0 / (c * p.psp_iticksperclktick);
if (speed_option_verbose)
printf ("Using pstat_getprocessor() psp_iticksperclktick %lu and clk_tck %ld for cycle time %.3g\n",
(unsigned long) p.psp_iticksperclktick, c,
speed_cycletime);
return 1;
}
#endif
return 0;
}
/* i386 FreeBSD 2.2.8 sysctlbyname machdep.i586_freq is in Hertz.
There's no obvious defines available to get this from plain sysctl. */
static int
freq_sysctlbyname_i586_freq (int help)
{
#if HAVE_SYSCTLBYNAME
unsigned val;
size_t size;
HELP ("sysctlbyname() machdep.i586_freq");
size = sizeof(val);
if (sysctlbyname ("machdep.i586_freq", &val, &size, NULL, 0) == 0
&& size == sizeof(val))
{
speed_cycletime = 1.0 / (double) val;
if (speed_option_verbose)
printf ("Using sysctlbyname() machdep.i586_freq %u for cycle time %.3g\n",
val, speed_cycletime);
return 1;
}
#endif
return 0;
}
/* i368 FreeBSD 3.3 sysctlbyname machdep.tsc_freq is in Hertz.
There's no obvious defines to get this from plain sysctl. */
static int
freq_sysctlbyname_tsc_freq (int help)
{
#if HAVE_SYSCTLBYNAME
unsigned val;
size_t size;
HELP ("sysctlbyname() machdep.tsc_freq");
size = sizeof(val);
if (sysctlbyname ("machdep.tsc_freq", &val, &size, NULL, 0) == 0
&& size == sizeof(val))
{
speed_cycletime = 1.0 / (double) val;
if (speed_option_verbose)
printf ("Using sysctlbyname() machdep.tsc_freq %u for cycle time %.3g\n",
val, speed_cycletime);
return 1;
}
#endif
return 0;
}
/* Apple powerpc Darwin 1.3 sysctl hw.cpufrequency is in hertz. For some
reason only seems to be available from sysctl(), not sysctlbyname(). */
static int
freq_sysctl_hw_cpufrequency (int help)
{
#if HAVE_SYSCTL && defined (CTL_HW) && defined (HW_CPU_FREQ)
int mib[2];
unsigned val;
size_t size;
HELP ("sysctl() hw.cpufrequency");
mib[0] = CTL_HW;
mib[1] = HW_CPU_FREQ;
size = sizeof(val);
if (sysctl (mib, 2, &val, &size, NULL, 0) == 0)
{
speed_cycletime = 1.0 / (double) val;
if (speed_option_verbose)
printf ("Using sysctl() hw.cpufrequency %u for cycle time %.3g\n",
val, speed_cycletime);
return 1;
}
#endif
return 0;
}
/* The following ssyctl hw.model strings have been observed,
Alpha FreeBSD 4.1: Digital AlphaPC 164LX 599 MHz
NetBSD 1.4: Digital AlphaPC 164LX 599 MHz
NetBSD 1.6.1: CY7C601 @ 40 MHz, TMS390C602A FPU
NetBSD 1.4 doesn't seem to have sysctlbyname, so sysctl() is used. */
static int
freq_sysctl_hw_model (int help)
{
#if HAVE_SYSCTL && defined (CTL_HW) && defined (HW_MODEL)
int mib[2];
char str[128];
unsigned val;
size_t size;
char *p;
int end;
HELP ("sysctl() hw.model");
mib[0] = CTL_HW;
mib[1] = HW_MODEL;
size = sizeof(str);
if (sysctl (mib, 2, str, &size, NULL, 0) == 0)
{
for (p = str; *p != '\0'; p++)
{
end = 0;
if (sscanf (p, "%u MHz%n", &val, &end) == 1 && end != 0)
{
speed_cycletime = 1e-6 / (double) val;
if (speed_option_verbose)
printf ("Using sysctl() hw.model %u for cycle time %.3g\n",
val, speed_cycletime);
return 1;
}
}
}
#endif
return 0;
}
/* /proc/cpuinfo for linux kernel.
Linux doesn't seem to have any system call to get the CPU frequency, at
least not in 2.0.x or 2.2.x, so it's necessary to read /proc/cpuinfo.
i386 2.0.36 - "bogomips" is the CPU frequency.
i386 2.2.13 - has both "cpu MHz" and "bogomips", and it's "cpu MHz" which
is the frequency.
alpha 2.2.5 - "cycle frequency [Hz]" seems to be right, "BogoMIPS" is
very slightly different.
alpha 2.2.18pre21 - "cycle frequency [Hz]" is 0 on at least one system,
"BogoMIPS" seems near enough.
powerpc 2.2.19 - "clock" is the frequency, bogomips is something weird
*/
static int
freq_proc_cpuinfo (int help)
{
FILE *fp;
char buf[128];
double val;
int ret = 0;
int end;
HELP ("linux kernel /proc/cpuinfo file, cpu MHz or bogomips");
if ((fp = fopen ("/proc/cpuinfo", "r")) != NULL)
{
while (fgets (buf, sizeof (buf), fp) != NULL)
{
if (sscanf (buf, "cycle frequency [Hz] : %lf", &val) == 1
&& val != 0.0)
{
speed_cycletime = 1.0 / val;
if (speed_option_verbose)
printf ("Using /proc/cpuinfo \"cycle frequency\" %.2f for cycle time %.3g\n", val, speed_cycletime);
ret = 1;
break;
}
if (sscanf (buf, "cpu MHz : %lf\n", &val) == 1)
{
speed_cycletime = 1e-6 / val;
if (speed_option_verbose)
printf ("Using /proc/cpuinfo \"cpu MHz\" %.2f for cycle time %.3g\n", val, speed_cycletime);
ret = 1;
break;
}
end = 0;
if (sscanf (buf, "clock : %lfMHz\n%n", &val, &end) == 1 && end != 0)
{
speed_cycletime = 1e-6 / val;
if (speed_option_verbose)
printf ("Using /proc/cpuinfo \"clock\" %.2f for cycle time %.3g\n", val, speed_cycletime);
ret = 1;
break;
}
if (sscanf (buf, "bogomips : %lf\n", &val) == 1
|| sscanf (buf, "BogoMIPS : %lf\n", &val) == 1)
{
speed_cycletime = 1e-6 / val;
if (speed_option_verbose)
printf ("Using /proc/cpuinfo \"bogomips\" %.2f for cycle time %.3g\n", val, speed_cycletime);
ret = 1;
break;
}
}
fclose (fp);
}
return ret;
}
/* /bin/sysinfo for SunOS 4.
Prints a line like: cpu0 is a "75 MHz TI,TMS390Z55" CPU */
static int
freq_sunos_sysinfo (int help)
{
int ret = 0;
#if HAVE_POPEN
FILE *fp;
char buf[128];
double val;
int end;
HELP ("SunOS /bin/sysinfo program output, cpu0");
/* Error messages are sent to /dev/null in case /bin/sysinfo doesn't
exist. The brackets are necessary for some shells. */
if ((fp = popen ("(/bin/sysinfo) 2>/dev/null", "r")) != NULL)
{
while (fgets (buf, sizeof (buf), fp) != NULL)
{
end = 0;
if (sscanf (buf, " cpu0 is a \"%lf MHz%n", &val, &end) == 1
&& end != 0)
{
speed_cycletime = 1e-6 / val;
if (speed_option_verbose)
printf ("Using /bin/sysinfo \"cpu0 MHz\" %.2f for cycle time %.3g\n", val, speed_cycletime);
ret = 1;
break;
}
}
pclose (fp);
}
#endif
return ret;
}
/* "/etc/hw -r cpu" for SCO OpenUnix 8, printing a line like
The speed of the CPU is approximately 450MHz
*/
static int
freq_sco_etchw (int help)
{
int ret = 0;
#if HAVE_POPEN
FILE *fp;
char buf[128];
double val;
int end;
HELP ("SCO /etc/hw program output");
/* Error messages are sent to /dev/null in case /etc/hw doesn't exist.
The brackets are necessary for some shells. */
if ((fp = popen ("(/etc/hw -r cpu) 2>/dev/null", "r")) != NULL)
{
while (fgets (buf, sizeof (buf), fp) != NULL)
{
end = 0;
if (sscanf (buf, " The speed of the CPU is approximately %lfMHz%n",
&val, &end) == 1 && end != 0)
{
speed_cycletime = 1e-6 / val;
if (speed_option_verbose)
printf ("Using /etc/hw %.2f MHz, for cycle time %.3g\n",
val, speed_cycletime);
ret = 1;
break;
}
}
pclose (fp);
}
#endif
return ret;
}
/* attr_get("/hw/cpunum/0",INFO_LBL_DETAIL_INVENT) ic_cpu_info.cpufq for
IRIX 6.5. Past versions don't have INFO_LBL_DETAIL_INVENT,
invent_cpuinfo_t, or /hw/cpunum/0.
The same information is available from the "hinv -c processor" command,
but it seems better to make a system call where possible. */
static int
freq_attr_get_invent (int help)
{
int ret = 0;
#if HAVE_ATTR_GET && HAVE_INVENT_H && defined (INFO_LBL_DETAIL_INVENT)
invent_cpuinfo_t inv;
int len, val;
HELP ("attr_get(\"/hw/cpunum/0\") ic_cpu_info.cpufq");
len = sizeof (inv);
if (attr_get ("/hw/cpunum/0", INFO_LBL_DETAIL_INVENT,
(char *) &inv, &len, 0) == 0
&& len == sizeof (inv)
&& inv.ic_gen.ig_invclass == INV_PROCESSOR)
{
val = inv.ic_cpu_info.cpufq;
speed_cycletime = 1e-6 / val;
if (speed_option_verbose)
printf ("Using attr_get(\"/hw/cpunum/0\") ic_cpu_info.cpufq %d MHz for cycle time %.3g\n", val, speed_cycletime);
ret = 1;
}
#endif
return ret;
}
/* FreeBSD on i386 gives a line like the following at bootup, and which can
be read back from /var/run/dmesg.boot.
CPU: AMD Athlon(tm) Processor (755.29-MHz 686-class CPU)
CPU: Pentium 4 (1707.56-MHz 686-class CPU)
CPU: i486 DX4 (486-class CPU)
This is useful on FreeBSD 4.x, where there's no sysctl machdep.tsc_freq
or machdep.i586_freq.
It's better to use /var/run/dmesg.boot than to run /sbin/dmesg, since the
latter prints the current system message buffer, which is a limited size
and can wrap around if the system is up for a long time. */
static int
freq_bsd_dmesg (int help)
{
FILE *fp;
char buf[256], *p;
double val;
int ret = 0;
int end;
HELP ("BSD /var/run/dmesg.boot file");
if ((fp = fopen ("/var/run/dmesg.boot", "r")) != NULL)
{
while (fgets (buf, sizeof (buf), fp) != NULL)
{
if (memcmp (buf, "CPU:", 4) == 0)
{
for (p = buf; *p != '\0'; p++)
{
end = 0;
if (sscanf (p, "(%lf-MHz%n", &val, &end) == 1 && end != 0)
{
speed_cycletime = 1e-6 / val;
if (speed_option_verbose)
printf ("Using /var/run/dmesg.boot CPU: %.2f MHz for cycle time %.3g\n", val, speed_cycletime);
ret = 1;
break;
}
}
}
}
fclose (fp);
}
return ret;
}
/* "hinv -c processor" for IRIX. The following lines have been seen,
1 150 MHZ IP20 Processor
2 195 MHZ IP27 Processors
Processor 0: 500 MHZ IP35
This information is available from attr_get() on IRIX 6.5 (see above),
but on IRIX 6.2 it's not clear where to look, so fall back on
parsing. */
static int
freq_irix_hinv (int help)
{
int ret = 0;
#if HAVE_POPEN
FILE *fp;
char buf[128];
double val;
int nproc, end;
HELP ("IRIX \"hinv -c processor\" output");
/* Error messages are sent to /dev/null in case hinv doesn't exist. The
brackets are necessary for some shells. */
if ((fp = popen ("(hinv -c processor) 2>/dev/null", "r")) != NULL)
{
while (fgets (buf, sizeof (buf), fp) != NULL)
{
end = 0;
if (sscanf (buf, "Processor 0: %lf MHZ%n", &val, &end) == 1
&& end != 0)
{
found:
speed_cycletime = 1e-6 / val;
if (speed_option_verbose)
printf ("Using hinv -c processor \"%.2f MHZ\" for cycle time %.3g\n", val, speed_cycletime);
ret = 1;
break;
}
end = 0;
if (sscanf (buf, "%d %lf MHZ%n", &nproc, &val, &end) == 2
&& end != 0)
goto found;
}
pclose (fp);
}
#endif
return ret;
}
/* processor_info() for Solaris. "psrinfo" is the command-line interface to
this. "prtconf -vp" gives similar information.
Apple Darwin has a processor_info, but in an incompatible style. It
doesn't have <sys/processor.h>, so test for that. */
static int
freq_processor_info (int help)
{
#if HAVE_PROCESSOR_INFO && HAVE_SYS_PROCESSOR_H
processor_info_t p;
int i, n, mhz = 0;
HELP ("processor_info() pi_clock");
n = sysconf (_SC_NPROCESSORS_CONF);
for (i = 0; i < n; i++)
{
if (processor_info (i, &p) != 0)
continue;
if (p.pi_state != P_ONLINE)
continue;
if (mhz != 0 && p.pi_clock != mhz)
{
fprintf (stderr,
"freq_processor_info(): There's more than one CPU and they have different clock speeds\n");
return 0;
}
mhz = p.pi_clock;
}
speed_cycletime = 1.0e-6 / (double) mhz;
if (speed_option_verbose)
printf ("Using processor_info() %d mhz for cycle time %.3g\n",
mhz, speed_cycletime);
return 1;
#else
return 0;
#endif
}
#if HAVE_SPEED_CYCLECOUNTER && HAVE_GETTIMEOFDAY
static double
freq_measure_gettimeofday_one (void)
{
#define call_gettimeofday(t) gettimeofday (&(t), NULL)
#define timeval_tv_sec(t) ((t).tv_sec)
#define timeval_tv_usec(t) ((t).tv_usec)
FREQ_MEASURE_ONE ("gettimeofday", struct timeval,
call_gettimeofday, speed_cyclecounter,
timeval_tv_sec, timeval_tv_usec);
}
#endif
#if HAVE_SPEED_CYCLECOUNTER && HAVE_GETRUSAGE
static double
freq_measure_getrusage_one (void)
{
#define call_getrusage(t) getrusage (0, &(t))
#define rusage_tv_sec(t) ((t).ru_utime.tv_sec)
#define rusage_tv_usec(t) ((t).ru_utime.tv_usec)
FREQ_MEASURE_ONE ("getrusage", struct rusage,
call_getrusage, speed_cyclecounter,
rusage_tv_sec, rusage_tv_usec);
}
#endif
/* MEASURE_MATCH is how many readings within MEASURE_TOLERANCE of each other
are required. This must be at least 2. */
#define MEASURE_MAX_ATTEMPTS 20
#define MEASURE_TOLERANCE 1.005 /* 0.5% */
#define MEASURE_MATCH 3
double
freq_measure (const char *name, double (*one) (void))
{
double t[MEASURE_MAX_ATTEMPTS];
int i, j;
for (i = 0; i < numberof (t); i++)
{
t[i] = (*one) ();
qsort (t, i+1, sizeof(t[0]), (qsort_function_t) double_cmp_ptr);
if (speed_option_verbose >= 3)
for (j = 0; j <= i; j++)
printf (" t[%d] is %.6g\n", j, t[j]);
for (j = 0; j+MEASURE_MATCH-1 <= i; j++)
{
if (t[j+MEASURE_MATCH-1] <= t[j] * MEASURE_TOLERANCE)
{
/* use the average of the range found */
return (t[j+MEASURE_MATCH-1] + t[j]) / 2.0;
}
}
}
return -1.0;
}
static int
freq_measure_getrusage (int help)
{
#if HAVE_SPEED_CYCLECOUNTER && HAVE_GETRUSAGE
double cycletime;
if (! getrusage_microseconds_p ())
return 0;
if (! cycles_works_p ())
return 0;
HELP ("cycle counter measured with microsecond getrusage()");
cycletime = freq_measure ("getrusage", freq_measure_getrusage_one);
if (cycletime == -1.0)
return 0;
speed_cycletime = cycletime;
if (speed_option_verbose)
printf ("Using getrusage() measured cycle counter %.4g (%.2f MHz)\n",
speed_cycletime, 1e-6/speed_cycletime);
return 1;
#else
return 0;
#endif
}
static int
freq_measure_gettimeofday (int help)
{
#if HAVE_SPEED_CYCLECOUNTER && HAVE_GETTIMEOFDAY
double cycletime;
if (! gettimeofday_microseconds_p ())
return 0;
if (! cycles_works_p ())
return 0;
HELP ("cycle counter measured with microsecond gettimeofday()");
cycletime = freq_measure ("gettimeofday", freq_measure_gettimeofday_one);
if (cycletime == -1.0)
return 0;
speed_cycletime = cycletime;
if (speed_option_verbose)
printf ("Using gettimeofday() measured cycle counter %.4g (%.2f MHz)\n",
speed_cycletime, 1e-6/speed_cycletime);
return 1;
#else
return 0;
#endif
}
/* Each function returns 1 if it succeeds in setting speed_cycletime, or 0
if not.
In general system call tests are first since they're fast, then file
tests, then tests running programs. Necessary exceptions to this rule
are noted. The measuring is last since it's time consuming, and rather
wasteful of cpu. */
static int
freq_all (int help)
{
return
/* This should be first, so an environment variable can override
anything the system gives. */
freq_environment (help)
|| freq_attr_get_invent (help)
|| freq_getsysinfo (help)
|| freq_pstat_getprocessor (help)
|| freq_sysctl_hw_model (help)
|| freq_sysctl_hw_cpufrequency (help)
|| freq_sysctlbyname_i586_freq (help)
|| freq_sysctlbyname_tsc_freq (help)
/* SCO openunix 8 puts a dummy pi_clock==16 in processor_info, so be
sure to check /etc/hw before that function. */
|| freq_sco_etchw (help)
|| freq_processor_info (help)
|| freq_proc_cpuinfo (help)
|| freq_bsd_dmesg (help)
|| freq_irix_hinv (help)
|| freq_sunos_sysinfo (help)
|| freq_measure_getrusage (help)
|| freq_measure_gettimeofday (help);
}
void
speed_cycletime_init (void)
{
static int attempted = 0;
if (attempted)
return;
attempted = 1;
if (freq_all (0))
return;
if (speed_option_verbose)
printf ("CPU frequency couldn't be determined\n");
}
void
speed_cycletime_fail (const char *str)
{
fprintf (stderr, "Measuring with: %s\n", speed_time_string);
fprintf (stderr, "%s,\n", str);
fprintf (stderr, "but none of the following are available,\n");
freq_all (1);
abort ();
}
/* speed_time_init leaves speed_cycletime set to either 0.0 or 1.0 when the
CPU frequency is unknown. 0.0 is when the time base is in seconds, so
that's no good if cycles are wanted. 1.0 is when the time base is in
cycles, which conversely is no good if seconds are wanted. */
void
speed_cycletime_need_cycles (void)
{
speed_time_init ();
if (speed_cycletime == 0.0)
speed_cycletime_fail
("Need to know CPU frequency to give times in cycles");
}
void
speed_cycletime_need_seconds (void)
{
speed_time_init ();
if (speed_cycletime == 1.0)
speed_cycletime_fail
("Need to know CPU frequency to convert cycles to seconds");
}

View File

@@ -0,0 +1,38 @@
/* mpn/generic/gcdext.c forced to use double limb calculations. */
/*
Copyright 2000 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef GCDEXT_THRESHOLD
#define GCDEXT_THRESHOLD 0
#define __gmpn_gcdext mpn_gcdext_double
#include "../mpn/generic/gcdext.c"

View File

@@ -0,0 +1,38 @@
/* mpn/generic/gcdext.c forced to use single limb calculations. */
/*
Copyright 2000 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef GCDEXT_THRESHOLD
#define GCDEXT_THRESHOLD MP_SIZE_T_MAX
#define __gmpn_gcdext mpn_gcdext_single
#include "../mpn/generic/gcdext.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/gcdext.c forced to one double limb step. */
/*
Copyright 2000 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef GCDEXT_THRESHOLD
#define GCDEXT_THRESHOLD 0
#define WANT_GCDEXT_ONE_STEP 1
#define __gmpn_gcdext mpn_gcdext_one_double
#include "../mpn/generic/gcdext.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/gcdext.c forced to one single limb step. */
/*
Copyright 2000 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef GCDEXT_THRESHOLD
#define GCDEXT_THRESHOLD MP_SIZE_T_MAX
#define WANT_GCDEXT_ONE_STEP 1
#define __gmpn_gcdext mpn_gcdext_one_single
#include "../mpn/generic/gcdext.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/hgcd2.c method 1.
Copyright 2019 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD2_DIV1_METHOD
#define HGCD2_DIV1_METHOD 1
#define __gmpn_hgcd2 mpn_hgcd2_1
/* Not used, but renamed to not get duplicate definitions */
#define __gmpn_hgcd_mul_matrix1_vector mpn_hgcd_mul_matrix1_vector_1
#include "mpn/generic/hgcd2.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/hgcd2.c method 2.
Copyright 2019 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD2_DIV1_METHOD
#define HGCD2_DIV1_METHOD 2
#define __gmpn_hgcd2 mpn_hgcd2_2
/* Not used, but renamed to not get duplicate definitions */
#define __gmpn_hgcd_mul_matrix1_vector mpn_hgcd_mul_matrix1_vector_2
#include "mpn/generic/hgcd2.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/hgcd2.c method 3.
Copyright 2019 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD2_DIV1_METHOD
#define HGCD2_DIV1_METHOD 3
#define __gmpn_hgcd2 mpn_hgcd2_3
/* Not used, but renamed to not get duplicate definitions */
#define __gmpn_hgcd_mul_matrix1_vector mpn_hgcd_mul_matrix1_vector_3
#include "mpn/generic/hgcd2.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/hgcd2.c method 4.
Copyright 2019 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD2_DIV1_METHOD
#define HGCD2_DIV1_METHOD 4
#define __gmpn_hgcd2 mpn_hgcd2_4
/* Not used, but renamed to not get duplicate definitions */
#define __gmpn_hgcd_mul_matrix1_vector mpn_hgcd_mul_matrix1_vector_4
#include "mpn/generic/hgcd2.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/hgcd2.c method 5.
Copyright 2019 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD2_DIV1_METHOD
#define HGCD2_DIV1_METHOD 5
#define __gmpn_hgcd2 mpn_hgcd2_5
/* Not used, but renamed to not get duplicate definitions */
#define __gmpn_hgcd_mul_matrix1_vector mpn_hgcd_mul_matrix1_vector_5
#include "mpn/generic/hgcd2.c"

View File

@@ -0,0 +1,49 @@
/* mpn/generic/hgcd2.c for tuning
Copyright 2019 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define TUNE_PROGRAM_BUILD 1
#include "gmp-impl.h"
hgcd2_func_t mpn_hgcd2_default;
hgcd2_func_t *hgcd2_func = &mpn_hgcd2_default;
int
mpn_hgcd2 (mp_limb_t ah, mp_limb_t al, mp_limb_t bh, mp_limb_t bl,
struct hgcd_matrix1 *M)
{
return hgcd2_func(ah, al, bh, bl, M);
}
#undef mpn_hgcd2
#define mpn_hgcd2 mpn_hgcd2_default
#include "mpn/generic/hgcd2.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/hgcd_appr.c forced to use Lehmer's quadratic algorithm. */
/*
Copyright 2010, 2011 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD_APPR_THRESHOLD
#define HGCD_APPR_THRESHOLD MP_SIZE_T_MAX
#define __gmpn_hgcd_appr mpn_hgcd_appr_lehmer
#define __gmpn_hgcd_appr_itch mpn_hgcd_appr_lehmer_itch
#include "../mpn/generic/hgcd_appr.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/hgcd.c forced to use Lehmer's quadratic algorithm. */
/*
Copyright 2010 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD_THRESHOLD
#define HGCD_THRESHOLD MP_SIZE_T_MAX
#define __gmpn_hgcd mpn_hgcd_lehmer
#define __gmpn_hgcd_itch mpn_hgcd_lehmer_itch
#include "../mpn/generic/hgcd.c"

View File

@@ -0,0 +1,40 @@
/* mpn/generic/hgcd_reduce.c forced to use hgcd. */
/*
Copyright 2010 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD_REDUCE_THRESHOLD
#define HGCD_REDUCE_THRESHOLD MP_SIZE_T_MAX
#define __gmpn_hgcd_reduce mpn_hgcd_reduce_1
#define __gmpn_hgcd_reduce_itch mpn_hgcd_reduce_1_itch
#include "../mpn/generic/hgcd_reduce.c"

View File

@@ -0,0 +1,39 @@
/* mpn/generic/hgcd_reduce.c forced to use hgcd_appr. */
/*
Copyright 2010 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef HGCD_REDUCE_THRESHOLD
#define HGCD_REDUCE_THRESHOLD 0
#define __gmpn_hgcd_reduce mpn_hgcd_reduce_2
#define __gmpn_hgcd_reduce_itch mpn_hgcd_reduce_2_itch
#include "../mpn/generic/hgcd_reduce.c"

View File

@@ -0,0 +1,42 @@
dnl HPPA 32-bit time stamp counter access routine.
dnl Copyright 2000, 2002, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
dnl void speed_cyclecounter (unsigned p[2]);
dnl
dnl Get the HPPA interval timer.
PROLOGUE(speed_cyclecounter)
mfctl %cr16,%r28
stw %r28,0(0,%r26)
bv 0(%r2)
stw %r0,4(0,%r26)
EPILOGUE(speed_cyclecounter)

View File

@@ -0,0 +1,44 @@
dnl HPPA 64-bit time stamp counter access routine.
dnl Copyright 2000, 2002, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
dnl void speed_cyclecounter (unsigned p[2]);
dnl
dnl Get the HPPA interval timer.
.level 2.0
PROLOGUE(speed_cyclecounter)
mfctl %cr16,%r28
stw %r28,0(0,%r26) ; low word
extrd,u %r28,31,32,%r28
bve (%r2)
stw %r28,4(0,%r26) ; high word
EPILOGUE(speed_cyclecounter)

View File

@@ -0,0 +1,44 @@
dnl HPPA 64-bit time stamp counter access routine.
dnl Copyright 2000, 2002, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
dnl void speed_cyclecounter (unsigned p[2]);
dnl
dnl Get the HPPA interval timer.
.level 2.0w
PROLOGUE(speed_cyclecounter)
mfctl %cr16,%r28
stw %r28,0(0,%r26) ; low word
extrd,u %r28,31,32,%r28
bve (%r2)
stw %r28,4(0,%r26) ; high word
EPILOGUE(speed_cyclecounter)

View File

@@ -0,0 +1,47 @@
dnl IA-64 time stamp counter access routine.
dnl Copyright 2000, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C void speed_cyclecounter (unsigned int p[2]);
C
ASM_START()
PROLOGUE(speed_cyclecounter)
mov r14 = ar.itc
;;
st4 [r32] = r14, 4
shr.u r14 = r14, 32
;;
st4 [r32] = r14
br.ret.sptk.many b0
EPILOGUE(speed_cyclecounter)
ASM_END()

View File

@@ -0,0 +1,37 @@
/* mpn/generic/jacbase.c method 1.
Copyright 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef JACOBI_BASE_METHOD
#define JACOBI_BASE_METHOD 1
#define __gmpn_jacobi_base mpn_jacobi_base_1
#include "mpn/generic/jacbase.c"

View File

@@ -0,0 +1,37 @@
/* mpn/generic/jacbase.c method 2.
Copyright 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef JACOBI_BASE_METHOD
#define JACOBI_BASE_METHOD 2
#define __gmpn_jacobi_base mpn_jacobi_base_2
#include "mpn/generic/jacbase.c"

View File

@@ -0,0 +1,37 @@
/* mpn/generic/jacbase.c method 3.
Copyright 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef JACOBI_BASE_METHOD
#define JACOBI_BASE_METHOD 3
#define __gmpn_jacobi_base mpn_jacobi_base_3
#include "mpn/generic/jacbase.c"

View File

@@ -0,0 +1,37 @@
/* mpn/generic/jacbase.c method 4.
Copyright 2002, 2010 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef JACOBI_BASE_METHOD
#define JACOBI_BASE_METHOD 4
#define __gmpn_jacobi_base mpn_jacobi_base_4
#include "mpn/generic/jacbase.c"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
/* mpn/generic/mod_1_1.c method 1.
Copyright 2011 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef MOD_1_1P_METHOD
#define MOD_1_1P_METHOD 1
#undef mpn_mod_1_1p
#undef mpn_mod_1_1p_cps
#define mpn_mod_1_1p mpn_mod_1_1p_1
#define mpn_mod_1_1p_cps mpn_mod_1_1p_cps_1
#include "mpn/generic/mod_1_1.c"

View File

@@ -0,0 +1,40 @@
/* mpn/generic/mod_1_1.c method 2.
Copyright 2011 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef MOD_1_1P_METHOD
#define MOD_1_1P_METHOD 2
#undef mpn_mod_1_1p
#undef mpn_mod_1_1p_cps
#define mpn_mod_1_1p mpn_mod_1_1p_2
#define mpn_mod_1_1p_cps mpn_mod_1_1p_cps_2
#include "mpn/generic/mod_1_1.c"

View File

@@ -0,0 +1,45 @@
/* mpn/generic/mod_1.c forced to use plain udiv_qrnnd.
Copyright 2000, 2003 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define OPERATION_mod_1
#include "gmp-impl.h"
#undef MOD_1_NORM_THRESHOLD
#undef MOD_1_UNNORM_THRESHOLD
#undef MOD_1N_TO_MOD_1_1_THRESHOLD
#undef MOD_1U_TO_MOD_1_1_THRESHOLD
#define MOD_1_NORM_THRESHOLD MP_SIZE_T_MAX
#define MOD_1_UNNORM_THRESHOLD MP_SIZE_T_MAX
#define MOD_1N_TO_MOD_1_1_THRESHOLD MP_SIZE_T_MAX
#define MOD_1U_TO_MOD_1_1_THRESHOLD MP_SIZE_T_MAX
#define __gmpn_mod_1 mpn_mod_1_div
#include "mpn/generic/mod_1.c"

View File

@@ -0,0 +1,45 @@
/* mpn/generic/mod_1.c forced to use mul-by-inverse udiv_qrnnd_preinv.
Copyright 2000 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define OPERATION_mod_1
#include "gmp-impl.h"
#undef MOD_1_NORM_THRESHOLD
#undef MOD_1_UNNORM_THRESHOLD
#undef MOD_1N_TO_MOD_1_1_THRESHOLD
#undef MOD_1U_TO_MOD_1_1_THRESHOLD
#define MOD_1_NORM_THRESHOLD 0
#define MOD_1_UNNORM_THRESHOLD 0
#define MOD_1N_TO_MOD_1_1_THRESHOLD MP_SIZE_T_MAX
#define MOD_1U_TO_MOD_1_1_THRESHOLD MP_SIZE_T_MAX
#define __gmpn_mod_1 mpn_mod_1_inv
#include "mpn/generic/mod_1.c"

View File

@@ -0,0 +1,177 @@
/* Alternate implementations of binvert_limb to compare speeds. */
/*
Copyright 2000, 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include "gmp-impl.h"
#include "longlong.h"
#include "speed.h"
/* Like the standard version in gmp-impl.h, but with the expressions using a
"1-" form. This has the same number of steps, but "1-" is on the
dependent chain, whereas the "2*" in the standard version isn't.
Depending on the CPU this should be the same or a touch slower. */
#if GMP_LIMB_BITS <= 32
#define binvert_limb_mul1(inv,n) \
do { \
mp_limb_t __n = (n); \
mp_limb_t __inv; \
ASSERT ((__n & 1) == 1); \
__inv = binvert_limb_table[(__n&0xFF)/2]; /* 8 */ \
__inv = (1 - __n * __inv) * __inv + __inv; /* 16 */ \
__inv = (1 - __n * __inv) * __inv + __inv; /* 32 */ \
ASSERT (__inv * __n == 1); \
(inv) = __inv; \
} while (0)
#endif
#if GMP_LIMB_BITS > 32 && GMP_LIMB_BITS <= 64
#define binvert_limb_mul1(inv,n) \
do { \
mp_limb_t __n = (n); \
mp_limb_t __inv; \
ASSERT ((__n & 1) == 1); \
__inv = binvert_limb_table[(__n&0xFF)/2]; /* 8 */ \
__inv = (1 - __n * __inv) * __inv + __inv; /* 16 */ \
__inv = (1 - __n * __inv) * __inv + __inv; /* 32 */ \
__inv = (1 - __n * __inv) * __inv + __inv; /* 64 */ \
ASSERT (__inv * __n == 1); \
(inv) = __inv; \
} while (0)
#endif
/* The loop based version used in GMP 3.0 and earlier. Usually slower than
multiplying, due to the number of steps that must be performed. Much
slower when the processor has a good multiply. */
#define binvert_limb_loop(inv,n) \
do { \
mp_limb_t __v = (n); \
mp_limb_t __v_orig = __v; \
mp_limb_t __make_zero = 1; \
mp_limb_t __two_i = 1; \
mp_limb_t __v_inv = 0; \
\
ASSERT ((__v & 1) == 1); \
\
do \
{ \
while ((__two_i & __make_zero) == 0) \
__two_i <<= 1, __v <<= 1; \
__v_inv += __two_i; \
__make_zero -= __v; \
} \
while (__make_zero); \
\
ASSERT (__v_orig * __v_inv == 1); \
(inv) = __v_inv; \
} while (0)
/* Another loop based version with conditionals, but doing a fixed number of
steps. */
#define binvert_limb_cond(inv,n) \
do { \
mp_limb_t __n = (n); \
mp_limb_t __rem = (1 - __n) >> 1; \
mp_limb_t __inv = GMP_LIMB_HIGHBIT; \
int __count; \
\
ASSERT ((__n & 1) == 1); \
\
__count = GMP_LIMB_BITS-1; \
do \
{ \
__inv >>= 1; \
if (__rem & 1) \
{ \
__inv |= GMP_LIMB_HIGHBIT; \
__rem -= __n; \
} \
__rem >>= 1; \
} \
while (-- __count); \
\
ASSERT (__inv * __n == 1); \
(inv) = __inv; \
} while (0)
/* Another loop based bitwise version, but purely arithmetic, no
conditionals. */
#define binvert_limb_arith(inv,n) \
do { \
mp_limb_t __n = (n); \
mp_limb_t __rem = (1 - __n) >> 1; \
mp_limb_t __inv = GMP_LIMB_HIGHBIT; \
mp_limb_t __lowbit; \
int __count; \
\
ASSERT ((__n & 1) == 1); \
\
__count = GMP_LIMB_BITS-1; \
do \
{ \
__lowbit = __rem & 1; \
__inv = (__inv >> 1) | (__lowbit << (GMP_LIMB_BITS-1)); \
__rem = (__rem - (__n & -__lowbit)) >> 1; \
} \
while (-- __count); \
\
ASSERT (__inv * __n == 1); \
(inv) = __inv; \
} while (0)
double
speed_binvert_limb_mul1 (struct speed_params *s)
{
SPEED_ROUTINE_MODLIMB_INVERT (binvert_limb_mul1);
}
double
speed_binvert_limb_loop (struct speed_params *s)
{
SPEED_ROUTINE_MODLIMB_INVERT (binvert_limb_loop);
}
double
speed_binvert_limb_cond (struct speed_params *s)
{
SPEED_ROUTINE_MODLIMB_INVERT (binvert_limb_cond);
}
double
speed_binvert_limb_arith (struct speed_params *s)
{
SPEED_ROUTINE_MODLIMB_INVERT (binvert_limb_arith);
}

View File

@@ -0,0 +1,67 @@
/* Noop routines.
These are in a separate file to stop gcc recognising do-nothing functions
and optimizing away calls to them. */
/*
Copyright 1999, 2000 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#include "speed.h"
void
noop (void)
{
}
/*ARGSUSED*/
void
noop_1 (mp_limb_t n)
{
}
/*ARGSUSED*/
void
noop_wxs (mp_ptr wp, mp_srcptr xp, mp_size_t size)
{
}
/*ARGSUSED*/
void
noop_wxys (mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size)
{
}
/*ARGSUSED*/
void
mpn_cache_fill_dummy (mp_limb_t n)
{
}

View File

@@ -0,0 +1,60 @@
dnl x86 pentium time stamp counter access routine.
dnl Copyright 1999, 2000, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C void speed_cyclecounter (unsigned p[2]);
C
C Get the pentium rdtsc cycle counter, storing the least significant word in
C p[0] and the most significant in p[1].
C
C cpuid is used to serialize execution. On big measurements this won't be
C significant but it may help make small single measurements more accurate.
.text
ALIGN(8)
defframe(PARAM_P,4)
PROLOGUE(speed_cyclecounter)
deflit(`FRAME',0)
pushl %ebx
FRAME_pushl()
xorl %eax, %eax
cpuid
rdtsc
movl PARAM_P, %ebx
movl %eax, (%ebx)
movl %edx, 4(%ebx)
popl %ebx
ret
EPILOGUE()

View File

@@ -0,0 +1,53 @@
dnl PowerPC mftb_function -- read time base registers.
dnl Copyright 2002 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C void mftb_function (unsigned a[2]);
C
ASM_START()
PROLOGUE(mftb_function)
C r3 a
L(again):
mftbu r4
mftb r5
mftbu r6
cmpw cr0, r4, r6
bne L(again)
stw r5, 0(r3)
stw r4, 4(r3)
blr
EPILOGUE()

View File

@@ -0,0 +1,49 @@
dnl PowerPC mftb_function -- read time base registers, 64-bit integer.
dnl Copyright 2002-2004 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C void mftb_function (unsigned a[2]);
C
ASM_START()
PROLOGUE(mftb_function)
C r3 a
mftb r5
srdi r4, r5, 32
stw r5, 0(r3)
stw r4, 4(r3)
blr
EPILOGUE()

View File

@@ -0,0 +1,38 @@
/* mpz/powm.c forced to use division. */
/*
Copyright 2000 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#undef POWM_THRESHOLD
#define POWM_THRESHOLD 1
#define __gmpz_powm mpz_powm_mod
#include "../mpz/powm.c"

View File

@@ -0,0 +1,40 @@
/* mpz/powm.c forced to use REDC. */
/*
Copyright 2000 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
/* WANT_GLOBAL_REDC makes redc() available for speed and tune program use. */
#undef POWM_THRESHOLD
#define POWM_THRESHOLD MP_SIZE_T_MAX
#define WANT_REDC_GLOBAL 1
#define __gmpz_powm mpz_powm_redc
#include "../mpz/powm.c"

View File

@@ -0,0 +1,40 @@
/* mpn_preinv_divrem_1 -- if not already in libgmp.
Copyright 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#if ! USE_PREINV_DIVREM_1
#undef USE_PREINV_DIVREM_1
#define USE_PREINV_DIVREM_1 1
#include "mpn/generic/pre_divrem_1.c"
#endif

View File

@@ -0,0 +1,46 @@
/* mpn_set_str_basecase -- mpn_set_str forced to its basecase.
Copyright 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define __gmpn_set_str mpn_set_str_basecase
#define __gmpn_bc_set_str mpn_bc_set_str_basecase
#define __gmpn_dc_set_str mpn_dc_set_str_basecase
#include "gmp-impl.h"
#ifndef SIZE_T_MAX
#define SIZE_T_MAX ((size_t) ULONG_MAX)
#endif
#undef SET_STR_DC_THRESHOLD
#define SET_STR_DC_THRESHOLD SIZE_T_MAX /* always */
#undef SET_STR_PRECOMPUTE_THRESHOLD
#define SET_STR_PRECOMPUTE_THRESHOLD SIZE_T_MAX /* always */
#include "mpn/generic/set_str.c"

View File

@@ -0,0 +1,42 @@
/* mpn_set_str_subquad -- mpn_set_str forced to the sub-quadratic case.
Copyright 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define TUNE_PROGRAM_BUILD 1 /* for gmp-impl.h */
#include "gmp-impl.h"
void
mpn_pre_set_str (mp_ptr wp, unsigned char *str, size_t str_len, powers_t *powtab, mp_ptr tp)
{
if (BELOW_THRESHOLD (str_len, set_str_dc_threshold))
mpn_bc_set_str (wp, str, str_len, powtab->base);
else
mpn_dc_set_str (wp, str, str_len, powtab, tp);
}

View File

@@ -0,0 +1,42 @@
/* mpn_set_str_subquad -- mpn_set_str forced to the sub-quadratic case.
Copyright 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define __gmpn_set_str mpn_set_str_subquad
#define __gmpn_bc_set_str mpn_bc_set_str_subquad
#define __gmpn_dc_set_str mpn_dc_set_str_subquad
#include "gmp-impl.h"
#undef SET_STR_DC_THRESHOLD
#define SET_STR_DC_THRESHOLD 2 /* never */
#undef SET_STR_PRECOMPUTE_THRESHOLD
#define SET_STR_PRECOMPUTE_THRESHOLD 2 /* never */
#include "mpn/generic/set_str.c"

View File

@@ -0,0 +1,45 @@
dnl Sparc v9 32-bit time stamp counter access routine.
dnl Copyright 2000, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C void speed_cyclecounter (unsigned p[2]);
C
C Get the sparc v9 tick counter.
ASM_START()
PROLOGUE(speed_cyclecounter)
rd %tick,%g1
st %g1,[%o0] C low 32 bits
srlx %g1,32,%g4
retl
st %g4,[%o0+4] C high 32 bits
EPILOGUE(speed_cyclecounter)

View File

@@ -0,0 +1,233 @@
/* An example of extending the speed program to measure routines not in GMP.
Copyright 1999, 2000, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/* The extension here is three versions of an mpn arithmetic mean. These
aren't meant to be particularly useful, just examples.
You can run something like the following to compare their speeds.
./speed-ext -s 1-20 -c mean_calls mean_open mean_open2
On RISC chips, mean_open() might be fastest if the compiler is doing a
good job. On the register starved x86s, mean_calls will be fastest.
Notes:
SPEED_EXTRA_PROTOS and SPEED_EXTRA_ROUTINES are macros that get expanded
by speed.c in useful places. SPEED_EXTRA_PROTOS goes after the header
files, and SPEED_EXTRA_ROUTINES goes in the array of available routines.
The advantage of this #include "speed.c" scheme is that there's no
editing of a copy of that file, and new features in new versions of it
will be immediately available.
In a real program the routines mean_calls() etc would probably be in
separate C or assembler source files, and just the measuring
speed_mean_calls() etc would be here. Linking against other libraries
for things to measure is perfectly possible too.
When attempting to compare two versions of the same named routine, say
like the generic and assembler versions of mpn_add_n(), creative use of
cc -D or #define is suggested, so one or both can be renamed and linked
into the same program. It'll be much easier to compare them side by side
than with separate programs for each.
common.c has notes on writing speed measuring routines.
Remember to link against tune/libspeed.la (or tune/.libs/libspeed.a if
not using libtool) to get common.o and other objects needed by speed.c. */
#define SPEED_EXTRA_PROTOS \
double speed_mean_calls (struct speed_params *s); \
double speed_mean_open (struct speed_params *s); \
double speed_mean_open2 (struct speed_params *s);
#define SPEED_EXTRA_ROUTINES \
{ "mean_calls", speed_mean_calls }, \
{ "mean_open", speed_mean_open }, \
{ "mean_open2", speed_mean_open2 },
#include "speed.c"
/* A straightforward implementation calling mpn subroutines.
wp,size is set to (xp,size + yp,size) / 2. The return value is the
remainder from the division. The other versions are the same. */
mp_limb_t
mean_calls (mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size)
{
mp_limb_t c, ret;
ASSERT (size >= 1);
c = mpn_add_n (wp, xp, yp, size);
ret = mpn_rshift (wp, wp, size, 1) >> (GMP_LIMB_BITS-1);
wp[size-1] |= (c << (GMP_LIMB_BITS-1));
return ret;
}
/* An open-coded version, making one pass over the data. The right shift is
done as the added limbs are produced. The addition code follows
mpn/generic/add_n.c. */
mp_limb_t
mean_open (mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size)
{
mp_limb_t w, wprev, x, y, c, ret;
mp_size_t i;
ASSERT (size >= 1);
x = xp[0];
y = yp[0];
wprev = x + y;
c = (wprev < x);
ret = (wprev & 1);
#define RSHIFT(hi,lo) (((lo) >> 1) | ((hi) << (GMP_LIMB_BITS-1)))
for (i = 1; i < size; i++)
{
x = xp[i];
y = yp[i];
w = x + c;
c = (w < x);
w += y;
c += (w < y);
wp[i-1] = RSHIFT (w, wprev);
wprev = w;
}
wp[i-1] = RSHIFT (c, wprev);
return ret;
}
/* Another one-pass version, but right shifting the source limbs rather than
the result limbs. There's not much chance of this being better than the
above, but it's an alternative at least. */
mp_limb_t
mean_open2 (mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size)
{
mp_limb_t w, x, y, xnext, ynext, c, ret;
mp_size_t i;
ASSERT (size >= 1);
x = xp[0];
y = yp[0];
/* ret is the low bit of x+y, c is the carry out of that low bit add */
ret = (x ^ y) & 1;
c = (x & y) & 1;
for (i = 0; i < size-1; i++)
{
xnext = xp[i+1];
ynext = yp[i+1];
x = RSHIFT (xnext, x);
y = RSHIFT (ynext, y);
w = x + c;
c = (w < x);
w += y;
c += (w < y);
wp[i] = w;
x = xnext;
y = ynext;
}
wp[i] = (x >> 1) + (y >> 1) + c;
return ret;
}
/* The speed measuring routines are the same apart from which function they
run, so a macro is used. Actually this macro is the same as
SPEED_ROUTINE_MPN_BINARY_N. */
#define SPEED_ROUTINE_MEAN(mean_fun) \
{ \
unsigned i; \
mp_ptr wp; \
double t; \
TMP_DECL; \
\
SPEED_RESTRICT_COND (s->size >= 1); \
\
TMP_MARK; \
SPEED_TMP_ALLOC_LIMBS (wp, s->size, s->align_wp); \
\
speed_operand_src (s, s->xp, s->size); \
speed_operand_src (s, s->yp, s->size); \
speed_operand_dst (s, wp, s->size); \
speed_cache_fill (s); \
\
speed_starttime (); \
i = s->reps; \
do \
mean_fun (wp, s->xp, s->yp, s->size); \
while (--i != 0); \
t = speed_endtime (); \
\
TMP_FREE; \
return t; \
}
double
speed_mean_calls (struct speed_params *s)
{
SPEED_ROUTINE_MEAN (mean_calls);
}
double
speed_mean_open (struct speed_params *s)
{
SPEED_ROUTINE_MEAN (mean_open);
}
double
speed_mean_open2 (struct speed_params *s)
{
SPEED_ROUTINE_MEAN (mean_open2);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,225 @@
/* tune-gcd-p
Tune the choice for splitting p in divide-and-conquer gcd.
Copyright 2008, 2010, 2011 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* 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.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define TUNE_GCD_P 1
#include "../mpn/gcd.c"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "speed.h"
/* Search for minimum over a range. FIXME: Implement golden-section /
fibonacci search*/
static int
search (double *minp, double (*f)(void *, int), void *ctx, int start, int end)
{
int x[4];
double y[4];
int best_i;
x[0] = start;
x[3] = end;
y[0] = f(ctx, x[0]);
y[3] = f(ctx, x[3]);
for (;;)
{
int i;
int length = x[3] - x[0];
x[1] = x[0] + length/3;
x[2] = x[0] + 2*length/3;
y[1] = f(ctx, x[1]);
y[2] = f(ctx, x[2]);
#if 0
printf("%d: %f, %d: %f, %d:, %f %d: %f\n",
x[0], y[0], x[1], y[1], x[2], y[2], x[3], y[3]);
#endif
for (best_i = 0, i = 1; i < 4; i++)
if (y[i] < y[best_i])
best_i = i;
if (length <= 4)
break;
if (best_i >= 2)
{
x[0] = x[1];
y[0] = y[1];
}
else
{
x[3] = x[2];
y[3] = y[2];
}
}
*minp = y[best_i];
return x[best_i];
}
static int
compare_double(const void *ap, const void *bp)
{
double a = * (const double *) ap;
double b = * (const double *) bp;
if (a < b)
return -1;
else if (a > b)
return 1;
else
return 0;
}
static double
median (double *v, size_t n)
{
qsort(v, n, sizeof(*v), compare_double);
return v[n/2];
}
#define TIME(res, code) do { \
double time_measurement[5]; \
unsigned time_i; \
\
for (time_i = 0; time_i < 5; time_i++) \
{ \
speed_starttime(); \
code; \
time_measurement[time_i] = speed_endtime(); \
} \
res = median(time_measurement, 5); \
} while (0)
struct bench_data
{
mp_size_t n;
mp_ptr ap;
mp_ptr bp;
mp_ptr up;
mp_ptr vp;
mp_ptr gp;
};
static double
bench_gcd (void *ctx, int p)
{
struct bench_data *data = (struct bench_data *) ctx;
double t;
p_table[data->n] = p;
TIME(t, {
MPN_COPY (data->up, data->ap, data->n);
MPN_COPY (data->vp, data->bp, data->n);
mpn_gcd (data->gp, data->up, data->n, data->vp, data->n);
});
return t;
}
int
main(int argc, char **argv)
{
gmp_randstate_t rands; struct bench_data data;
mp_size_t n;
TMP_DECL;
/* Unbuffered so if output is redirected to a file it isn't lost if the
program is killed part way through. */
setbuf (stdout, NULL);
setbuf (stderr, NULL);
gmp_randinit_default (rands);
TMP_MARK;
data.ap = TMP_ALLOC_LIMBS (P_TABLE_SIZE);
data.bp = TMP_ALLOC_LIMBS (P_TABLE_SIZE);
data.up = TMP_ALLOC_LIMBS (P_TABLE_SIZE);
data.vp = TMP_ALLOC_LIMBS (P_TABLE_SIZE);
data.gp = TMP_ALLOC_LIMBS (P_TABLE_SIZE);
mpn_random (data.ap, P_TABLE_SIZE);
mpn_random (data.bp, P_TABLE_SIZE);
memset (p_table, 0, sizeof(p_table));
for (n = 100; n < P_TABLE_SIZE; n++)
{
mp_size_t p;
mp_size_t best_p;
double best_time;
double lehmer_time;
if (data.ap[n-1] == 0)
data.ap[n-1] = 1;
if (data.bp[n-1] == 0)
data.bp[n-1] = 1;
data.n = n;
lehmer_time = bench_gcd (&data, 0);
best_p = search (&best_time, bench_gcd, &data, n/5, 4*n/5);
if (best_time > lehmer_time)
best_p = 0;
printf("%6zu %6zu %5.3g", n, best_p, (double) best_p / n);
if (best_p > 0)
{
double speedup = 100 * (lehmer_time - best_time) / lehmer_time;
printf(" %5.3g%%", speedup);
if (speedup < 1.0)
{
printf(" (ignored)");
best_p = 0;
}
}
printf("\n");
p_table[n] = best_p;
}
TMP_FREE;
gmp_randclear(rands);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
dnl x86 pentium time stamp counter access routine.
dnl Copyright 1999, 2000, 2003-2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C void speed_cyclecounter (unsigned p[2]);
C
C Get the pentium rdtsc cycle counter, storing the least significant word in
C p[0] and the most significant in p[1].
C
C cpuid is used to serialize execution. On big measurements this won't be
C significant but it may help make small single measurements more accurate.
PROLOGUE(speed_cyclecounter)
C rdi p
movq %rbx, %r10
xorl %eax, %eax
cpuid
rdtsc
movl %eax, (%rdi)
movl %edx, 4(%rdi)
movq %r10, %rbx
ret
EPILOGUE()