60a0ce6f98
# Conflicts: # msvc/_msvc_filters.py # msvc/_msvc_project.py # msvc/_msvc_solution.py # msvc/cfg.h # msvc/check_config.bat # msvc/g2y.py # msvc/gen_config_h.bat # msvc/gen_mpir_h.bat # msvc/gen_test_config_props.bat # msvc/getopt.c # msvc/getopt.h # msvc/getrusage.c # msvc/getrusage.h # msvc/gettimeofday.c # msvc/gettimeofday.h # msvc/mpir_config.py # msvc/mpir_config.pyproj # msvc/mpir_config.sln # msvc/mpir_debug_dll.props # msvc/mpir_debug_lib.props # msvc/mpir_release_dll.props # msvc/mpir_release_lib.props # msvc/obsolete.c # msvc/out_copy_rename.bat # msvc/postbuild.bat # msvc/prebuild.bat # msvc/run-tests.py # msvc/unistd.h # msvc/vs13/dll_mpir_gc/dll_mpir_gc.vcxproj.filters # msvc/vs13/lib_mpir_cxx/lib_mpir_cxx.vcxproj # msvc/vs13/lib_mpir_cxx/lib_mpir_cxx.vcxproj.filters # msvc/vs13/lib_mpir_gc/lib_mpir_gc.vcxproj.filters # msvc/vs13/mpir-tests.sln # msvc/vs13/mpir-tune.sln # msvc/vs13/msbuild.bat # msvc/vs13/run-speed.py # msvc/vs13/run-tests.py # msvc/vs13/version_info.py # msvc/vs17/dll_mpir_gc/dll_mpir_gc.vcxproj.filters # msvc/vs17/lib_mpir_cxx/lib_mpir_cxx.vcxproj # msvc/vs17/lib_mpir_cxx/lib_mpir_cxx.vcxproj.filters # msvc/vs17/lib_mpir_gc/lib_mpir_gc.vcxproj.filters # msvc/vs17/mpir-tests.sln # msvc/vs17/mpir-tests/add-test-lib/add-test-lib.vcxproj # msvc/vs17/mpir-tests/add-test-lib/add-test-lib.vcxproj.filters # msvc/vs17/mpir-tests/cxx.assign/cxx.assign.vcxproj # msvc/vs17/mpir-tests/cxx.binary/cxx.binary.vcxproj # msvc/vs17/mpir-tests/cxx.cast/cxx.cast.vcxproj # msvc/vs17/mpir-tests/cxx.constr/cxx.constr.vcxproj # msvc/vs17/mpir-tests/cxx.istream/cxx.istream.vcxproj # msvc/vs17/mpir-tests/f.adjust/f.adjust.vcxproj # msvc/vs17/mpir-tests/f.adjust_sqrt2/f.adjust_sqrt2.vcxproj # msvc/vs17/mpir-tests/f.butterfly/f.butterfly.vcxproj # msvc/vs17/mpir-tests/f.butterfly_lshb/f.butterfly_lshb.vcxproj # msvc/vs17/mpir-tests/f.butterfly_rshb/f.butterfly_rshb.vcxproj # msvc/vs17/mpir-tests/f.butterfly_sqrt2/f.butterfly_sqrt2.vcxproj # msvc/vs17/mpir-tests/f.butterfly_twiddle/f.butterfly_twiddle.vcxproj # msvc/vs17/mpir-tests/f.div_2expmod_2expp1/f.div_2expmod_2expp1.vcxproj # msvc/vs17/mpir-tests/f.fft_ifft_mfa_trunc_sqrt2/f.fft_ifft_mfa_trunc_sqrt2.vcxproj # msvc/vs17/mpir-tests/f.fft_ifft_negacyclic/f.fft_ifft_negacyclic.vcxproj # msvc/vs17/mpir-tests/f.fft_ifft_radix2/f.fft_ifft_radix2.vcxproj # msvc/vs17/mpir-tests/f.fft_ifft_trunc/f.fft_ifft_trunc.vcxproj # msvc/vs17/mpir-tests/f.fft_ifft_trunc_sqrt2/f.fft_ifft_trunc_sqrt2.vcxproj # msvc/vs17/mpir-tests/f.mul_2expmod_2expp1/f.mul_2expmod_2expp1.vcxproj # msvc/vs17/mpir-tests/f.mul_fft_main/f.mul_fft_main.vcxproj # msvc/vs17/mpir-tests/f.mul_mfa_trunc_sqrt2/f.mul_mfa_trunc_sqrt2.vcxproj # msvc/vs17/mpir-tests/f.mul_trunc_sqrt2/f.mul_trunc_sqrt2.vcxproj # msvc/vs17/mpir-tests/f.mulmod_2expp1/f.mulmod_2expp1.vcxproj # msvc/vs17/mpir-tests/f.normmod_2expp1/f.normmod_2expp1.vcxproj # msvc/vs17/mpir-tests/f.split_combine_bits/f.split_combine_bits.vcxproj # msvc/vs17/mpir-tests/misc.printf/misc.printf.vcxproj # msvc/vs17/mpir-tests/misc.scanf/misc.scanf.vcxproj # msvc/vs17/mpir-tests/mpf.add/mpf.add.vcxproj # msvc/vs17/mpir-tests/mpf.cmp_d/mpf.cmp_d.vcxproj # msvc/vs17/mpir-tests/mpf.cmp_si/mpf.cmp_si.vcxproj # msvc/vs17/mpir-tests/mpf.conv/mpf.conv.vcxproj # msvc/vs17/mpir-tests/mpf.div/mpf.div.vcxproj # msvc/vs17/mpir-tests/mpf.dm2exp/mpf.dm2exp.vcxproj # msvc/vs17/mpir-tests/mpf.eq/mpf.eq.vcxproj # msvc/vs17/mpir-tests/mpf.fits/mpf.fits.vcxproj # msvc/vs17/mpir-tests/mpf.get_d/mpf.get_d.vcxproj # msvc/vs17/mpir-tests/mpf.get_d_2exp/mpf.get_d_2exp.vcxproj # msvc/vs17/mpir-tests/mpf.get_si/mpf.get_si.vcxproj # msvc/vs17/mpir-tests/mpf.get_ui/mpf.get_ui.vcxproj # msvc/vs17/mpir-tests/mpf.gsprec/mpf.gsprec.vcxproj # msvc/vs17/mpir-tests/mpf.inp_str/mpf.inp_str.vcxproj # msvc/vs17/mpir-tests/mpf.int_p/mpf.int_p.vcxproj # msvc/vs17/mpir-tests/mpf.mul_ui/mpf.mul_ui.vcxproj # msvc/vs17/mpir-tests/mpf.muldiv/mpf.muldiv.vcxproj # msvc/vs17/mpir-tests/mpf.reuse/mpf.reuse.vcxproj # msvc/vs17/mpir-tests/mpf.set/mpf.set.vcxproj # msvc/vs17/mpir-tests/mpf.set_q/mpf.set_q.vcxproj # msvc/vs17/mpir-tests/mpf.set_si/mpf.set_si.vcxproj # msvc/vs17/mpir-tests/mpf.set_ui/mpf.set_ui.vcxproj # msvc/vs17/mpir-tests/mpf.sqrt/mpf.sqrt.vcxproj # msvc/vs17/mpir-tests/mpf.sqrt_ui/mpf.sqrt_ui.vcxproj # msvc/vs17/mpir-tests/mpf.sub/mpf.sub.vcxproj # msvc/vs17/mpir-tests/mpf.trunc/mpf.trunc.vcxproj # msvc/vs17/mpir-tests/mpf.ui_div/mpf.ui_div.vcxproj # msvc/vs17/mpir-tests/mpn.addadd_n/mpn.addadd_n.vcxproj # msvc/vs17/mpir-tests/mpn.addsub_n/mpn.addsub_n.vcxproj # msvc/vs17/mpir-tests/mpn.aors_1/mpn.aors_1.vcxproj # msvc/vs17/mpir-tests/mpn.asmtype/mpn.asmtype.vcxproj # msvc/vs17/mpir-tests/mpn.dc_div_q/mpn.dc_div_q.vcxproj # msvc/vs17/mpir-tests/mpn.dc_div_qr/mpn.dc_div_qr.vcxproj # msvc/vs17/mpir-tests/mpn.dc_div_qr_n/mpn.dc_div_qr_n.vcxproj # msvc/vs17/mpir-tests/mpn.dc_divappr_q/mpn.dc_divappr_q.vcxproj # msvc/vs17/mpir-tests/mpn.divebyff/mpn.divebyff.vcxproj # msvc/vs17/mpir-tests/mpn.divebyfobm1/mpn.divebyfobm1.vcxproj # msvc/vs17/mpir-tests/mpn.divrem_1/mpn.divrem_1.vcxproj # msvc/vs17/mpir-tests/mpn.gcdext/mpn.gcdext.vcxproj # msvc/vs17/mpir-tests/mpn.get_d/mpn.get_d.vcxproj # msvc/vs17/mpir-tests/mpn.hgcd/mpn.hgcd.vcxproj # msvc/vs17/mpir-tests/mpn.instrument/mpn.instrument.vcxproj # msvc/vs17/mpir-tests/mpn.inv_divappr_q/mpn.inv_divappr_q.vcxproj # msvc/vs17/mpir-tests/mpn.invert/mpn.invert.vcxproj # msvc/vs17/mpir-tests/mpn.iord_u/mpn.iord_u.vcxproj # msvc/vs17/mpir-tests/mpn.logic/mpn.logic.vcxproj # msvc/vs17/mpir-tests/mpn.lorrshift1/mpn.lorrshift1.vcxproj # msvc/vs17/mpir-tests/mpn.matrix22/mpn.matrix22.vcxproj # msvc/vs17/mpir-tests/mpn.mp_bases/mpn.mp_bases.vcxproj # msvc/vs17/mpir-tests/mpn.mullow_basecase/mpn.mullow_basecase.vcxproj # msvc/vs17/mpir-tests/mpn.mullowhigh/mpn.mullowhigh.vcxproj # msvc/vs17/mpir-tests/mpn.mulmid/mpn.mulmid.vcxproj # msvc/vs17/mpir-tests/mpn.mulmod_2expm1/mpn.mulmod_2expm1.vcxproj # msvc/vs17/mpir-tests/mpn.neg/mpn.neg.vcxproj # msvc/vs17/mpir-tests/mpn.perfsqr/mpn.perfsqr.vcxproj # msvc/vs17/mpir-tests/mpn.redc_1/mpn.redc_1.vcxproj # msvc/vs17/mpir-tests/mpn.sb_div_q/mpn.sb_div_q.vcxproj # msvc/vs17/mpir-tests/mpn.sb_div_qr/mpn.sb_div_qr.vcxproj # msvc/vs17/mpir-tests/mpn.sb_divappr_q/mpn.sb_divappr_q.vcxproj # msvc/vs17/mpir-tests/mpn.scan/mpn.scan.vcxproj # msvc/vs17/mpir-tests/mpn.sizeinbase/mpn.sizeinbase.vcxproj # msvc/vs17/mpir-tests/mpn.subadd_n/mpn.subadd_n.vcxproj # msvc/vs17/mpir-tests/mpn.tdiv_q/mpn.tdiv_q.vcxproj # msvc/vs17/mpir-tests/mpq.aors/mpq.aors.vcxproj # msvc/vs17/mpir-tests/mpq.cmp/mpq.cmp.vcxproj # msvc/vs17/mpir-tests/mpq.cmp_si/mpq.cmp_si.vcxproj # msvc/vs17/mpir-tests/mpq.cmp_ui/mpq.cmp_ui.vcxproj # msvc/vs17/mpir-tests/mpq.equal/mpq.equal.vcxproj # msvc/vs17/mpir-tests/mpq.get_d/mpq.get_d.vcxproj # msvc/vs17/mpir-tests/mpq.get_str/mpq.get_str.vcxproj # msvc/vs17/mpir-tests/mpq.inp_str/mpq.inp_str.vcxproj # msvc/vs17/mpir-tests/mpq.md_2exp/mpq.md_2exp.vcxproj # msvc/vs17/mpir-tests/mpq.set_f/mpq.set_f.vcxproj # msvc/vs17/mpir-tests/mpq.set_str/mpq.set_str.vcxproj # msvc/vs17/mpir-tests/mpz.addsub/mpz.addsub.vcxproj # msvc/vs17/mpir-tests/mpz.aorsmul/mpz.aorsmul.vcxproj # msvc/vs17/mpir-tests/mpz.bin/mpz.bin.vcxproj # msvc/vs17/mpir-tests/mpz.bit/mpz.bit.vcxproj # msvc/vs17/mpir-tests/mpz.cdiv_ui/mpz.cdiv_ui.vcxproj # msvc/vs17/mpir-tests/mpz.cmp/mpz.cmp.vcxproj # msvc/vs17/mpir-tests/mpz.cmp_d/mpz.cmp_d.vcxproj # msvc/vs17/mpir-tests/mpz.cmp_si/mpz.cmp_si.vcxproj # msvc/vs17/mpir-tests/mpz.cong/mpz.cong.vcxproj # msvc/vs17/mpir-tests/mpz.cong_2exp/mpz.cong_2exp.vcxproj # msvc/vs17/mpir-tests/mpz.convert/mpz.convert.vcxproj # msvc/vs17/mpir-tests/mpz.div_2exp/mpz.div_2exp.vcxproj # msvc/vs17/mpir-tests/mpz.dive/mpz.dive.vcxproj # msvc/vs17/mpir-tests/mpz.dive_ui/mpz.dive_ui.vcxproj # msvc/vs17/mpir-tests/mpz.divis/mpz.divis.vcxproj # msvc/vs17/mpir-tests/mpz.divis_2exp/mpz.divis_2exp.vcxproj # msvc/vs17/mpir-tests/mpz.export/mpz.export.vcxproj # msvc/vs17/mpir-tests/mpz.fac_ui/mpz.fac_ui.vcxproj # msvc/vs17/mpir-tests/mpz.fdiv/mpz.fdiv.vcxproj # msvc/vs17/mpir-tests/mpz.fdiv_ui/mpz.fdiv_ui.vcxproj # msvc/vs17/mpir-tests/mpz.fib_ui/mpz.fib_ui.vcxproj # msvc/vs17/mpir-tests/mpz.fits/mpz.fits.vcxproj # msvc/vs17/mpir-tests/mpz.gcd/mpz.gcd.vcxproj # msvc/vs17/mpir-tests/mpz.gcd_ui/mpz.gcd_ui.vcxproj # msvc/vs17/mpir-tests/mpz.get_d/mpz.get_d.vcxproj # msvc/vs17/mpir-tests/mpz.get_d_2exp/mpz.get_d_2exp.vcxproj # msvc/vs17/mpir-tests/mpz.get_si/mpz.get_si.vcxproj # msvc/vs17/mpir-tests/mpz.get_sx/mpz.get_sx.vcxproj # msvc/vs17/mpir-tests/mpz.get_ux/mpz.get_ux.vcxproj # msvc/vs17/mpir-tests/mpz.hamdist/mpz.hamdist.vcxproj # msvc/vs17/mpir-tests/mpz.import/mpz.import.vcxproj # msvc/vs17/mpir-tests/mpz.inp_str/mpz.inp_str.vcxproj # msvc/vs17/mpir-tests/mpz.io_raw/mpz.io_raw.vcxproj # msvc/vs17/mpir-tests/mpz.jac/mpz.jac.vcxproj # msvc/vs17/mpir-tests/mpz.lcm/mpz.lcm.vcxproj # msvc/vs17/mpir-tests/mpz.likely_prime_p/mpz.likely_prime_p.vcxproj # msvc/vs17/mpir-tests/mpz.limbs/mpz.limbs.vcxproj # msvc/vs17/mpir-tests/mpz.logic/mpz.logic.vcxproj # msvc/vs17/mpir-tests/mpz.lucnum_ui/mpz.lucnum_ui.vcxproj # msvc/vs17/mpir-tests/mpz.mfac_uiui/mpz.mfac_uiui.vcxproj # msvc/vs17/mpir-tests/mpz.mul/mpz.mul.vcxproj # msvc/vs17/mpir-tests/mpz.mul_i/mpz.mul_i.vcxproj # msvc/vs17/mpir-tests/mpz.next_prime_candidate/mpz.next_prime_candidate.vcxproj # msvc/vs17/mpir-tests/mpz.oddeven/mpz.oddeven.vcxproj # msvc/vs17/mpir-tests/mpz.perfpow/mpz.perfpow.vcxproj # msvc/vs17/mpir-tests/mpz.perfsqr/mpz.perfsqr.vcxproj # msvc/vs17/mpir-tests/mpz.popcount/mpz.popcount.vcxproj # msvc/vs17/mpir-tests/mpz.pow/mpz.pow.vcxproj # msvc/vs17/mpir-tests/mpz.powm/mpz.powm.vcxproj # msvc/vs17/mpir-tests/mpz.powm_ui/mpz.powm_ui.vcxproj # msvc/vs17/mpir-tests/mpz.pprime_p/mpz.pprime_p.vcxproj # msvc/vs17/mpir-tests/mpz.primorial_ui/mpz.primorial_ui.vcxproj # msvc/vs17/mpir-tests/mpz.reuse/mpz.reuse.vcxproj # msvc/vs17/mpir-tests/mpz.root/mpz.root.vcxproj # msvc/vs17/mpir-tests/mpz.scan/mpz.scan.vcxproj # msvc/vs17/mpir-tests/mpz.set_d/mpz.set_d.vcxproj # msvc/vs17/mpir-tests/mpz.set_f/mpz.set_f.vcxproj # msvc/vs17/mpir-tests/mpz.set_si/mpz.set_si.vcxproj # msvc/vs17/mpir-tests/mpz.set_str/mpz.set_str.vcxproj # msvc/vs17/mpir-tests/mpz.set_sx/mpz.set_sx.vcxproj # msvc/vs17/mpir-tests/mpz.set_ux/mpz.set_ux.vcxproj # msvc/vs17/mpir-tests/mpz.sizeinbase/mpz.sizeinbase.vcxproj # msvc/vs17/mpir-tests/mpz.sqrtrem/mpz.sqrtrem.vcxproj # msvc/vs17/mpir-tests/mpz.tdiv/mpz.tdiv.vcxproj # msvc/vs17/mpir-tests/mpz.tdiv_ui/mpz.tdiv_ui.vcxproj # msvc/vs17/mpir-tests/mpz.trial_division/mpz.trial_division.vcxproj # msvc/vs17/mpir-tests/rand.iset/rand.iset.vcxproj # msvc/vs17/mpir-tests/rand.lc2exp/rand.lc2exp.vcxproj # msvc/vs17/mpir-tests/rand.mt/rand.mt.vcxproj # msvc/vs17/mpir-tests/rand.rand/rand.rand.vcxproj # msvc/vs17/mpir-tests/rand.urbui/rand.urbui.vcxproj # msvc/vs17/mpir-tests/rand.urmui/rand.urmui.vcxproj # msvc/vs17/mpir-tests/rand.urndmm/rand.urndmm.vcxproj # msvc/vs17/mpir-tests/run-tests.py # msvc/vs17/mpir-tune.sln # msvc/vs17/mpir-tune/lib_speed/lib_speed.vcxproj # msvc/vs17/mpir-tune/lib_speed/lib_speed.vcxproj.filters # msvc/vs17/mpir-tune/speed/speed.vcxproj # msvc/vs17/mpir-tune/speed/speed.vcxproj.filters # msvc/vs17/mpir-tune/try/try.vcxproj # msvc/vs17/mpir-tune/try/try.vcxproj.filters # msvc/vs17/mpir-tune/tune/divrem_1.c # msvc/vs17/mpir-tune/tune/fac_ui.c # msvc/vs17/mpir-tune/tune/mod_1.c # msvc/vs17/mpir-tune/tune/mulmod_2expp1.c # msvc/vs17/mpir-tune/tune/normmod_2expp1.c # msvc/vs17/mpir-tune/tune/revbin.c # msvc/vs17/mpir-tune/tune/split_bits.c # msvc/vs17/mpir-tune/tune/sqr_basecase.asm # msvc/vs17/mpir-tune/tune/tune.vcxproj # msvc/vs17/mpir-tune/tune/tune.vcxproj.filters # msvc/vs17/mpir-tune/tune/tune_prebuild.bat # msvc/vs17/mpir-tune/tune/tune_prebuild.py # msvc/vs17/msbuild.bat # msvc/vs17/run-speed.py # msvc/vs17/run-tests.py # msvc/vs17/version_info.py # msvc/vsyasm.props # msvc/vsyasm.xml # msvc/win_timing.c # msvc/win_timing.h
336 lines
10 KiB
Python
336 lines
10 KiB
Python
|
|
# A Python program to run speed and evaluate the performance of MPIR
|
|
# routines.
|
|
#
|
|
# Copyright (c) 2009, Brian Gladman, Worcester, UK.
|
|
#
|
|
# This file is part of the MPIR Library. The MPIR Library is free
|
|
# software; you can redistribute it and/or modify it under the terms
|
|
# of the GNU Lesser General Public License version 2.1 as published
|
|
# by the Free Software Foundation.
|
|
#
|
|
# The MPIR Library is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Lesser General Public License for more details. You should have
|
|
# received a copy of the GNU Lesser General Public License along
|
|
# with the MPIR Library; see the file COPYING.LIB. If not, write to
|
|
# the Free Software Foundation, Inc., 51Franklin Street, Fifth Floor,
|
|
# Boston, MA 02110-1301, USA.
|
|
|
|
from __future__ import print_function
|
|
import sys
|
|
import os
|
|
import shutil
|
|
import string
|
|
import copy
|
|
import code
|
|
import math
|
|
import platform
|
|
from subprocess import Popen, PIPE, STDOUT
|
|
|
|
if sys.platform.startswith('win'):
|
|
dir = '.\\x64\\release\\'
|
|
else :
|
|
dir = './'
|
|
|
|
ll = [
|
|
'-c -s 10(10)1000 noop',
|
|
'-c -s 10(10)1000 noop_wxs',
|
|
'-c -s 10(10)1000 noop_wxys',
|
|
'-c -s 10(10)1000 mpn_add_n',
|
|
'-c -s 10(10)1000 mpn_sub_n',
|
|
'-c -s 10(10)1000 mpn_addadd_n',
|
|
'-c -s 10(10)1000 mpn_subadd_n',
|
|
'-c -s 10(10)1000 mpn_addsub_n',
|
|
'-c -s 10(10)1000 mpn_karaadd',
|
|
'-c -s 10(10)1000 mpn_karasub',
|
|
'-c -s 10(10)1000 mpn_addmul_1.3333',
|
|
'-c -s 10(10)1000 mpn_submul_1.3333',
|
|
'-c -s 10(10)1000 mpn_submul_2',
|
|
'-c -s 10(10)1000 mpn_mul_1.3333',
|
|
'-c -s 10(10)1000 mpn_mul_1_inplace.3333',
|
|
'-c -s 10(10)1000 mpn_mul_2',
|
|
'-c -s 10(10)1000 mpn_divrem_euclidean_qr_1.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_euclidean_qr_2',
|
|
'-c -s 10(10)1000 mpn_divrem_euclidean_r_1.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_hensel_qr_1.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_hensel_qr_1_1.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_hensel_qr_1_2.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_hensel_r_1.3333',
|
|
'-c -s 10(10)1000 mpn_rsh_divrem_hensel_qr_1.3333',
|
|
'-c -s 10(10)1000 mpn_rsh_divrem_hensel_qr_1_1.3333',
|
|
'-c -s 10(10)1000 mpn_rsh_divrem_hensel_qr_1_2.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_hensel_rsh_qr_1.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_1.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_1f.3333',
|
|
'-c -s 10(10)1000 mpn_mod_1.3333',
|
|
'-c -s 10(10)1000 mpn_mod_1_1',
|
|
'-c -s 10(10)1000 mpn_mod_1_2',
|
|
'-c -s 10(10)1000 mpn_mod_1_3',
|
|
'-c -s 10(10)1000 mpn_mod_1_k.3',
|
|
'-c -s 10(10)1000 mpn_preinv_divrem_1.3333',
|
|
'-c -s 10(10)1000 mpn_preinv_divrem_1f.3333',
|
|
'-c -s 10(10)1000 mpn_preinv_mod_1.3333',
|
|
'-c -s 10(10)1000 mpn_add_err1_n',
|
|
'-c -s 10(10)1000 mpn_sub_err1_n',
|
|
'-c -s 10(10)1000 mpn_inv_divappr_q',
|
|
'-c -s 10(10)1000 mpn_inv_div_qr',
|
|
'-c -s 10(10)1000 mpn_dc_divappr_q',
|
|
'-c -s 10(10)1000 mpn_dc_div_qr_n',
|
|
'-c -s 10(10)1000 mpn_divrem_1_inv.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_1f_div.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_1f_inv.3333',
|
|
'-c -s 10(10)1000 mpn_mod_1_div.3333',
|
|
'-c -s 10(10)1000 mpn_mod_1_inv.3333',
|
|
'-c -s 10(10)1000 mpn_divrem_2',
|
|
'-c -s 10(10)1000 mpn_divrem_2_div',
|
|
'-c -s 10(10)1000 mpn_divrem_2_inv',
|
|
'-c -s 10(10)1000 mpn_divexact_1.3333',
|
|
'-c -s 10(10)1000 mpn_divexact_by3',
|
|
'-c -s 10(10)1000 mpn_divexact_byff',
|
|
'-c -s 10(10)1000 mpn_divexact_byfobm1.3333',
|
|
'-c -s 10(10)1000 mpn_modexact_1_odd.333',
|
|
'-c -s 10(10)1000 mpn_modexact_1c_odd.333',
|
|
'-c -s 10(10)1000 mpn_mod_34lsub1',
|
|
'-c -s 10(10)1000 mpn_dc_tdiv_qr',
|
|
'-c -s 10(10)1000 mpn_lshift.33',
|
|
'-c -s 10(10)1000 mpn_rshift.33',
|
|
'-c -s 10(10)1000 mpn_lshift1',
|
|
'-c -s 10(10)1000 mpn_rshift1',
|
|
'-c -s 10(10)1000 mpn_double',
|
|
'-c -s 10(10)1000 mpn_half',
|
|
'-c -s 10(10)1000 mpn_lshift2',
|
|
'-c -s 10(10)1000 mpn_rshift2',
|
|
'-c -s 10(10)1000 mpn_and_n',
|
|
'-c -s 10(10)1000 mpn_andn_n',
|
|
'-c -s 10(10)1000 mpn_nand_n',
|
|
'-c -s 10(10)1000 mpn_ior_n',
|
|
'-c -s 10(10)1000 mpn_iorn_n',
|
|
'-c -s 10(10)1000 mpn_nior_n',
|
|
'-c -s 10(10)1000 mpn_xor_n',
|
|
'-c -s 10(10)1000 mpn_xnor_n',
|
|
'-c -s 10(10)1000 mpn_com_n',
|
|
'-c -s 10(10)1000 mpn_not',
|
|
'-c -s 10(10)1000 mpn_popcount',
|
|
'-c -s 10(10)1000 mpn_hamdist',
|
|
|
|
'-c -s 10(10)1000 MPN_ZERO',
|
|
'-c -s 10(10)1000 MPN_COPY',
|
|
'-c -s 10(10)1000 MPN_COPY_INCR',
|
|
'-c -s 10(10)1000 MPN_COPY_DECR',
|
|
|
|
'-c -s 10(10)1000 count_leading_zeros',
|
|
'-c -s 10(10)1000 gmp_allocate_free',
|
|
'-c -s 10(10)1000 malloc_realloc_free',
|
|
'-c -s 10(10)1000 gmp_allocate_reallocate_free',
|
|
'-c -s 10(10)1000 malloc_free',
|
|
'-c -s 10(10)1000 mpn_umul_ppmm',
|
|
'-c -s 10(10)1000 mpz_add',
|
|
'-c -s 10(10)1000 mpz_init_realloc_clear',
|
|
'-c -s 10(10)1000 mpz_init_clear',
|
|
'-c -s 10(10)1000 udiv_qrnnd',
|
|
'-c -s 10(10)1000 udiv_qrnnd_c',
|
|
'-c -s 10(10)1000 udiv_qrnnd_preinv1',
|
|
'-c -s 10(10)1000 udiv_qrnnd_preinv2',
|
|
'-c -s 10(10)1000 umul_ppmm',
|
|
'-c -s 10(10)1000 mpn_popcount',
|
|
'-c -s 10(10)1000 mpn_hamdist',
|
|
|
|
]
|
|
|
|
lq = [
|
|
'-c -s 10(10)1000 mpn_dc_divrem_n',
|
|
'-c -s 10(10)1000 mpn_dc_divrem_sb',
|
|
'-c -s 10(10)1000 mpn_dc_tdiv_qr',
|
|
'-c -s 10(10)1000 mpn_kara_mul_n',
|
|
'-c -s 10(10)1000 mpn_kara_sqr_n',
|
|
'-c -s 10(10)1000 mpn_mul_basecase',
|
|
'-c -s 1000(500)10000 -t 10 mpn_mul_fft_full',
|
|
'-c -s 10(10)1000 mpn_mul_n',
|
|
'-c -s 10(10)1000 mpn_sqr_basecase',
|
|
'-c -s 10(10)1000 mpn_sqr_n',
|
|
'-c -s 50(10)1000 mpn_toom3_mul_n',
|
|
'-c -s 50(10)1000 mpn_toom3_sqr_n',
|
|
'-c -s 1(5)100 mpz_powm',
|
|
]
|
|
|
|
# run an executable and return its error return value and any output
|
|
def run_exe(exe, args, inp) :
|
|
al = {'stdin' : PIPE, 'stdout' : PIPE, 'stderr' : STDOUT }
|
|
if sys.platform.startswith('win') :
|
|
al['creationflags'] = 0x08000000
|
|
p = Popen([exe] + args.split(' '), **al)
|
|
res = p.communicate(inp.encode())[0].decode()
|
|
ret = p.poll()
|
|
return (ret, res)
|
|
|
|
# output a matrix implemented as a dictionary
|
|
def mout(m, n) :
|
|
for r in range(n) :
|
|
print('\n{0:3d}'.format(r), end='')
|
|
for c in range(n) :
|
|
print('{0:18.4f}'.format(m[(r,c)]) , end='')
|
|
print
|
|
|
|
# output a vector
|
|
def vout(v) :
|
|
print(' ' , end='')
|
|
for c in v :
|
|
print('{0:18.4f}'.format(c) , end='')
|
|
print()
|
|
|
|
# In-place LU matrix decomposition. The diagonal
|
|
# elements of the upper triangular matrix U are
|
|
# all 1 and are not stored. Pivoting is used and
|
|
# the matrix is implemented as a dictionary. It
|
|
# is only intended for use with small matrices.
|
|
|
|
def LU_decompose(A, n) :
|
|
p = [0] * n
|
|
for k in range(n) :
|
|
# find pivot
|
|
p[k] = k
|
|
max = math.fabs(A[(k,k)])
|
|
for j in range(k + 1, n) :
|
|
if max < math.fabs(A[(j,k)]) :
|
|
max = math.fabs(A[(j,k)])
|
|
p[k] = j
|
|
# exchange rows if necessary
|
|
if p[k] != k :
|
|
for j in range(n) :
|
|
A[(k,j)], A[(p[k],j)] = A[(p[k],j)], A[(k,j)]
|
|
|
|
# exit if matrix is singular
|
|
if A[(k,k)] == 0.0 :
|
|
return None
|
|
|
|
# set upper triangular elements
|
|
for j in range(k + 1,n) :
|
|
A[(k,j)] /= A[(k,k)]
|
|
|
|
# update remaining part of original matrix
|
|
for i in range(k + 1, n) :
|
|
for j in range(k + 1, n) :
|
|
A[(i,j)] -= A[(i,k)] * A[(k,j)]
|
|
|
|
# return pivot array
|
|
return p
|
|
|
|
# Use the LU decomposition above to solve the matrix
|
|
# equation A x = b for x given A and b
|
|
|
|
def LU_solve(A, p, b) :
|
|
n = len(p)
|
|
x = [0] * n
|
|
|
|
# calculate U x = L^-1 b
|
|
for k in range(n) :
|
|
if p[k] != k :
|
|
b[k], b[p[k]] = b[p[k]], b[k]
|
|
x[k] = b[k]
|
|
for i in range(k) :
|
|
x[k] -= x[i] * A[(k,i)]
|
|
x[k] /= A[(k,k)]
|
|
|
|
# back substitute for x = U^-1 (L^-1 b)
|
|
for k in reversed(range(n)) :
|
|
if p[k] != k :
|
|
b[k], b[p[k]], b[p[k]], b[k]
|
|
for i in range(k + 1, n) :
|
|
x[k] -= x[i] * A[(k,i)]
|
|
return x
|
|
|
|
def lsq_solve(x, y, n) :
|
|
m = {} # matrix as dictionary
|
|
v = [] # vector as list
|
|
# set up matrix and vectors for least squares
|
|
for i in range(n) :
|
|
v.append(sum(xx ** i * yy for xx, yy in zip(x, y)))
|
|
for j in range(i, n) :
|
|
m[(i,j)] = m[(j,i)] = sum(xx ** (i + j) for xx in x)
|
|
# decompose the matrix into lower and upper triangular
|
|
# matrices
|
|
p = LU_decompose(m, n)
|
|
if p != None :
|
|
return LU_solve(m, p, v)
|
|
else :
|
|
return None
|
|
|
|
def do_lsq(x, y, lsq_size) :
|
|
# get least squares coefficients
|
|
f = lsq_solve(x, y, lsq_size)
|
|
|
|
# now find the standard deviation from the curve
|
|
s = 0
|
|
for i in range(len(x)) :
|
|
t = sum(f[j] * x[i] ** j for j in range(lsq_size))
|
|
s += (y[i] - t) ** 2
|
|
sd = 2 * math.sqrt(s / len(x))
|
|
|
|
# now remove 'outliers' - data points outside twice
|
|
# the standard deviation
|
|
sc = 0
|
|
for i in reversed(range(len(x))) :
|
|
t = sum(f[j] * x[i] ** j for j in range(lsq_size))
|
|
if math.fabs(y[i] - t) > sd :
|
|
del x[i]
|
|
del y[i]
|
|
sc += 1
|
|
|
|
# if we had to remove more than 10% of measurements
|
|
# declare that the result is not stable
|
|
if 10 * sc > len(x) :
|
|
return None
|
|
else :
|
|
return f
|
|
|
|
print('Machine:', platform.processor())
|
|
print('Running:', platform.platform())
|
|
print('SPEED CURVE (l: no of limbs) cycles: c[0] + c[1] * l + c[2] * l^2')
|
|
print('ROUTINE ', end = '')
|
|
print(' c[0] c[1] c[2]')
|
|
lines = ''
|
|
cnt = 0
|
|
lsq_size = 4
|
|
for args in ll + lq :
|
|
cnt += 1
|
|
# run speed for each routine in the list above
|
|
ret = run_exe(os.path.join(dir, 'speed'), args, '')
|
|
# parse the output to produce limbs[] and times[]
|
|
x = []
|
|
y = []
|
|
lines = ret[1].split('\n')
|
|
for l in lines :
|
|
if len(l) :
|
|
s = l.split()
|
|
try :
|
|
t = [float(i) for i in s]
|
|
except :
|
|
continue
|
|
x += [t[0]]
|
|
y += [t[1]]
|
|
|
|
# output the name of the routine
|
|
nn = args.split(' ')[-1]
|
|
print('{0:<30s}'.format(nn) , end='')
|
|
if not len(x) :
|
|
# print(ret[1].strip(), '(failed to parse output)')
|
|
print('(failed to parse output)')
|
|
continue
|
|
|
|
q = 0 if args in ll else 1
|
|
rep = q
|
|
while rep < 3 :
|
|
rep += 1
|
|
f = do_lsq(x, y, lsq_size)
|
|
if f != None :
|
|
break
|
|
else :
|
|
print('not stable')
|
|
continue
|
|
if args in lq :
|
|
print('{0[0]:11.1f} {0[1]:11.1f} {0[2]:11.1f}'.format(f))
|
|
else :
|
|
print('{0[0]:11.1f} {0[1]:11.1f}'.format(f))
|