├── inc ├── debug.h ├── knobs.h ├── prefetcher.h ├── uncore.h ├── ppf_dev.h ├── bitmap.h ├── ipcp_vars.h ├── stride.h ├── spp_dev2.h ├── streamer.h ├── bop.h ├── ipcp_L2.h ├── learning_engine_base.h ├── ampm.h ├── next_line.h ├── pref_power7.h ├── learning_engine_basic.h ├── learning_engine_featurewise.h ├── sandbox.h ├── memory_class.h ├── util.h ├── ipcp_L1.h ├── sms.h ├── champsim.h └── champsim.h.bak ├── docs ├── _config.yml └── index.md.bak ├── scripts ├── Math │ ├── libPARI │ │ ├── post-noinline.h │ │ ├── pre-noinline.h │ │ ├── gphelp │ │ ├── ._gphelp │ │ ├── gphelp-ini │ │ ├── ._Makefile.PL │ │ ├── ._codes_2014 │ │ ├── ._gphelp-ini │ │ ├── ._expected_codes │ │ ├── ._pre-noinline.h │ │ ├── ._extract_codes.pl │ │ ├── ._post-noinline.h │ │ ├── expected_codes │ │ ├── codes_2014 │ │ └── extract_codes.pl │ ├── ._t │ ├── ._TODO │ ├── ._utils │ ├── Changes │ ├── Pari.xs │ ├── ._Changes │ ├── ._INSTALL │ ├── ._Pari.pm │ ├── ._Pari.xs │ ├── ._README │ ├── ._libPARI │ ├── ._patches │ ├── ._typemap │ ├── ._MANIFEST │ ├── ._META.json │ ├── ._META.yml │ ├── ._gdbinit-my │ ├── ._test_eng │ ├── utils │ │ ├── ._Math │ │ ├── ._README │ │ ├── ._inc.h │ │ ├── ._notes │ │ ├── ._foncpari.pl │ │ ├── ._inc_h.diff │ │ ├── ._chap3_to_pod │ │ ├── ._comp_funcs.pl │ │ ├── ._paridoc_to_pod │ │ ├── Math │ │ │ └── ._PariBuild.pm │ │ ├── ._01_no_extra_newlines.test │ │ ├── 01_no_extra_newlines.test │ │ ├── README │ │ ├── inc_h.diff │ │ ├── inc.h │ │ └── notes │ ├── ._Makefile.PL │ ├── ._PariInit.pm │ ├── ._func_codes.h │ ├── t │ │ ├── ._00_Pari.t │ │ ├── ._PlotRect.t │ │ ├── ._zz_leak.t │ │ ├── ._02_sections.t │ │ ├── ._000_load-problem.t │ │ ├── ._01_no_extra_newlines.t │ │ ├── 01_no_extra_newlines.t │ │ ├── zz_leak.t │ │ ├── 02_sections.t │ │ ├── 000_load-problem.t │ │ └── PlotRect.t │ ├── test_eng │ │ ├── ._ex.t │ │ ├── ._Testout.pm │ │ └── ex.t │ ├── patches │ │ ├── ._diff-2.9.0-all │ │ ├── ._diff-2.9.5-all │ │ ├── ._diff_2.1.7_-O │ │ ├── ._diff_2.1.7_div │ │ ├── ._diff-2.11.0-all │ │ ├── ._diff_2.1.2_gccism │ │ ├── diff_2.1.7_restart │ │ ├── ._diff-2.5.0-tune_opt │ │ ├── ._diff_2.1.6_ploth64 │ │ ├── ._diff_2.1.7_restart │ │ ├── ._diff_add_gnuplotAdd │ │ ├── ._diff_add_gnuplotAll │ │ ├── ._diff-2.5.0-exceptions │ │ ├── ._diff-2.5.0-x-prototype │ │ ├── ._diff-2.5.5-exceptions │ │ ├── ._diff-2.7.0-exceptions │ │ ├── ._diff-2.7.0-x-prototype │ │ ├── ._diff_2.1.3_interface │ │ ├── ._diff_2.1.4_interface │ │ ├── ._diff_2.1.6_no-common │ │ ├── ._diff_2.1.7_mingw-w64 │ │ ├── ._diff_2.2.2_interface │ │ ├── ._diff_2.3.5_mingw-w64 │ │ ├── ._diff_add_gnuplotNeeded │ │ ├── ._diff_2.1.6_align_power_of_2 │ │ ├── ._diff_2.3.5_mingw_longlong │ │ ├── ._diff_2.3.5_stderr_clobber │ │ ├── ._diff_pari-2.1.3-ix86-divl │ │ ├── ._diff-2.7.0-reinstall-foreigh │ │ ├── ._patch-pari-unnormalized-float │ │ ├── ._diff-2.7.0-reinstall-foreigh-full │ │ ├── diff_2.1.7_-O │ │ ├── diff_pari-2.1.3-ix86-divl │ │ ├── diff_2.1.2_gccism │ │ ├── diff_2.1.7_div │ │ ├── diff-2.5.0-tune_opt │ │ ├── diff_2.1.6_no-common │ │ ├── diff_2.1.6_align_power_of_2 │ │ ├── diff_2.1.3_interface │ │ ├── diff_2.1.4_interface │ │ ├── diff_2.3.5_mingw-w64 │ │ ├── diff_2.1.7_mingw-w64 │ │ ├── diff_2.2.2_interface │ │ ├── patch-pari-unnormalized-float │ │ ├── diff_2.3.5_stderr_clobber │ │ ├── diff_2.1.6_ploth64 │ │ ├── diff_2.3.5_mingw_longlong │ │ ├── diff-2.5.0-exceptions │ │ ├── diff-2.5.5-exceptions │ │ ├── diff-2.7.0-exceptions │ │ ├── diff-2.7.0-reinstall-foreigh │ │ └── diff-2.7.0-reinstall-foreigh-full │ ├── META.yml │ ├── META.json │ ├── TODO │ ├── gdbinit-my │ ├── typemap │ ├── PariInit.pm │ └── MANIFEST ├── Math-Combinatorics-0.09 │ ├── MANIFEST │ ├── META.yml │ ├── Makefile.PL │ ├── Changes │ ├── t │ │ ├── 02.t │ │ └── 03.t │ └── README ├── Crypt │ └── Random │ │ ├── Provider │ │ ├── devrandom.pm │ │ ├── devurandom.pm │ │ ├── rand.pm │ │ ├── File.pm │ │ └── egd.pm │ │ └── Generator.pm ├── Metric.pm ├── Trace.pm ├── Exp.pm ├── download_traces.pl ├── gen_feature_exps.pl └── create_jobfile.pl ├── config ├── nopref.ini ├── streamer.ini ├── stride.ini ├── spp_dev2.ini ├── spp_ppf_dev.ini ├── next_line.ini ├── ampm.ini ├── mlop.ini ├── sms.ini ├── sandbox.ini ├── power7.ini ├── bop.ini ├── bingo.ini ├── dspatch.ini └── pythia.ini ├── experiments ├── rollup_1C_varying_DRAM_bw.mfile ├── rollup_4C.mfile ├── experiments_1C │ └── README.md ├── experiments_4C │ └── README.md ├── MICRO21_data_template.xlsx ├── rollup_1C_base_config.mfile ├── automate_rollup.sh ├── rollup_4C.exp ├── MICRO21_4C.exp ├── rollup_1C_base_config.exp ├── extras │ └── more_experiments_1C.exp ├── rollup_1C_varying_DRAM_bw.exp └── MICRO21_1C.exp ├── logo.png ├── wrapper.sh ├── setvars.sh ├── tracer ├── clean_tracer.sh ├── quick_make.sh ├── make_tracer.sh ├── makefile └── makefile.rules ├── src ├── uncore.cc ├── bakshalipour_framework.cc ├── learning_engine_base.cc └── bitmap.cc ├── .gitignore ├── patches └── 17-cannot-compile-libbf.patch ├── prefetcher ├── no.l1d_pref ├── l1d_prefetcher.cc ├── no.l2c_pref ├── no.llc_pref ├── l2c_prefetcher.cc ├── llc_prefetcher.cc └── multi.l1d_pref ├── branch ├── bimodal.bpred ├── branch_predictor.cc └── gshare.bpred ├── CITATION.cff ├── LICENSE ├── replacement ├── lru.llc_repl ├── llc_replacement.cc ├── srrip.llc_repl └── base_replacement.cc └── Makefile /inc/debug.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /scripts/Math/libPARI/post-noinline.h: -------------------------------------------------------------------------------- 1 | #endif 2 | -------------------------------------------------------------------------------- /config/nopref.ini: -------------------------------------------------------------------------------- 1 | l2c_prefetcher_types = none 2 | -------------------------------------------------------------------------------- /scripts/Math/libPARI/pre-noinline.h: -------------------------------------------------------------------------------- 1 | #ifndef ASMINLINE 2 | -------------------------------------------------------------------------------- /experiments/rollup_1C_varying_DRAM_bw.mfile: -------------------------------------------------------------------------------- 1 | Core_0_IPC : sum 2 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/logo.png -------------------------------------------------------------------------------- /wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Original cmd-> $1 $2" 4 | $1 $2 5 | -------------------------------------------------------------------------------- /config/streamer.ini: -------------------------------------------------------------------------------- 1 | streamer_num_trackers = 64 2 | streamer_pref_degree = 5 -------------------------------------------------------------------------------- /config/stride.ini: -------------------------------------------------------------------------------- 1 | stride_num_trackers = 256 2 | stride_pref_degree = 2 3 | -------------------------------------------------------------------------------- /config/spp_dev2.ini: -------------------------------------------------------------------------------- 1 | spp_dev2_fill_threshold = 90 2 | spp_dev2_pf_threshold = 40 3 | -------------------------------------------------------------------------------- /config/spp_ppf_dev.ini: -------------------------------------------------------------------------------- 1 | ppf_perc_threshold_hi = -5 2 | ppf_perc_threshold_lo = -15 3 | -------------------------------------------------------------------------------- /scripts/Math/._t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._t -------------------------------------------------------------------------------- /scripts/Math/._TODO: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._TODO -------------------------------------------------------------------------------- /scripts/Math/._utils: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._utils -------------------------------------------------------------------------------- /scripts/Math/Changes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/Changes -------------------------------------------------------------------------------- /scripts/Math/Pari.xs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/Pari.xs -------------------------------------------------------------------------------- /scripts/Math/._Changes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._Changes -------------------------------------------------------------------------------- /scripts/Math/._INSTALL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._INSTALL -------------------------------------------------------------------------------- /scripts/Math/._Pari.pm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._Pari.pm -------------------------------------------------------------------------------- /scripts/Math/._Pari.xs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._Pari.xs -------------------------------------------------------------------------------- /scripts/Math/._README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._README -------------------------------------------------------------------------------- /scripts/Math/._libPARI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._libPARI -------------------------------------------------------------------------------- /scripts/Math/._patches: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._patches -------------------------------------------------------------------------------- /scripts/Math/._typemap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._typemap -------------------------------------------------------------------------------- /scripts/Math/._MANIFEST: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._MANIFEST -------------------------------------------------------------------------------- /scripts/Math/._META.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._META.json -------------------------------------------------------------------------------- /scripts/Math/._META.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._META.yml -------------------------------------------------------------------------------- /scripts/Math/._gdbinit-my: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._gdbinit-my -------------------------------------------------------------------------------- /scripts/Math/._test_eng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._test_eng -------------------------------------------------------------------------------- /scripts/Math/utils/._Math: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._Math -------------------------------------------------------------------------------- /scripts/Math/._Makefile.PL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._Makefile.PL -------------------------------------------------------------------------------- /scripts/Math/._PariInit.pm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._PariInit.pm -------------------------------------------------------------------------------- /scripts/Math/._func_codes.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/._func_codes.h -------------------------------------------------------------------------------- /scripts/Math/libPARI/gphelp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/gphelp -------------------------------------------------------------------------------- /scripts/Math/t/._00_Pari.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/t/._00_Pari.t -------------------------------------------------------------------------------- /scripts/Math/t/._PlotRect.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/t/._PlotRect.t -------------------------------------------------------------------------------- /scripts/Math/t/._zz_leak.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/t/._zz_leak.t -------------------------------------------------------------------------------- /scripts/Math/utils/._README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._README -------------------------------------------------------------------------------- /scripts/Math/utils/._inc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._inc.h -------------------------------------------------------------------------------- /scripts/Math/utils/._notes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._notes -------------------------------------------------------------------------------- /experiments/rollup_4C.mfile: -------------------------------------------------------------------------------- 1 | Core_0_IPC : sum 2 | Core_1_IPC : sum 3 | Core_2_IPC : sum 4 | Core_3_IPC : sum 5 | -------------------------------------------------------------------------------- /scripts/Math/libPARI/._gphelp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/._gphelp -------------------------------------------------------------------------------- /scripts/Math/t/._02_sections.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/t/._02_sections.t -------------------------------------------------------------------------------- /scripts/Math/test_eng/._ex.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/test_eng/._ex.t -------------------------------------------------------------------------------- /setvars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export PYTHIA_HOME=`pwd` 4 | export PERL5LIB=$PERL5LIB:$PYTHIA_HOME/scripts 5 | -------------------------------------------------------------------------------- /experiments/experiments_1C/README.md: -------------------------------------------------------------------------------- 1 | This is the directory to run all experiments using single-core configuration. 2 | -------------------------------------------------------------------------------- /experiments/experiments_4C/README.md: -------------------------------------------------------------------------------- 1 | This is the directory to run all experiments using four-core configuration. 2 | -------------------------------------------------------------------------------- /scripts/Math/libPARI/gphelp-ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/gphelp-ini -------------------------------------------------------------------------------- /scripts/Math/utils/._foncpari.pl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._foncpari.pl -------------------------------------------------------------------------------- /scripts/Math/utils/._inc_h.diff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._inc_h.diff -------------------------------------------------------------------------------- /scripts/Math/libPARI/._Makefile.PL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/._Makefile.PL -------------------------------------------------------------------------------- /scripts/Math/libPARI/._codes_2014: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/._codes_2014 -------------------------------------------------------------------------------- /scripts/Math/libPARI/._gphelp-ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/._gphelp-ini -------------------------------------------------------------------------------- /scripts/Math/t/._000_load-problem.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/t/._000_load-problem.t -------------------------------------------------------------------------------- /scripts/Math/test_eng/._Testout.pm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/test_eng/._Testout.pm -------------------------------------------------------------------------------- /scripts/Math/utils/._chap3_to_pod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._chap3_to_pod -------------------------------------------------------------------------------- /scripts/Math/utils/._comp_funcs.pl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._comp_funcs.pl -------------------------------------------------------------------------------- /scripts/Math/utils/._paridoc_to_pod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._paridoc_to_pod -------------------------------------------------------------------------------- /tracer/clean_tracer.sh: -------------------------------------------------------------------------------- 1 | export PIN_ROOT=/mnt/panzer/rahbera/softwares/pin-3.11-97998-g7ecce2dac-gcc-linux 2 | make clean 3 | -------------------------------------------------------------------------------- /scripts/Math/libPARI/._expected_codes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/._expected_codes -------------------------------------------------------------------------------- /scripts/Math/libPARI/._pre-noinline.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/._pre-noinline.h -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.9.0-all: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.9.0-all -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.9.5-all: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.9.5-all -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.7_-O: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.7_-O -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.7_div: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.7_div -------------------------------------------------------------------------------- /experiments/MICRO21_data_template.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/experiments/MICRO21_data_template.xlsx -------------------------------------------------------------------------------- /scripts/Math/libPARI/._extract_codes.pl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/._extract_codes.pl -------------------------------------------------------------------------------- /scripts/Math/libPARI/._post-noinline.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/libPARI/._post-noinline.h -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.11.0-all: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.11.0-all -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.2_gccism: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.2_gccism -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.7_restart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/diff_2.1.7_restart -------------------------------------------------------------------------------- /scripts/Math/t/._01_no_extra_newlines.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/t/._01_no_extra_newlines.t -------------------------------------------------------------------------------- /scripts/Math/utils/Math/._PariBuild.pm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/Math/._PariBuild.pm -------------------------------------------------------------------------------- /config/next_line.ini: -------------------------------------------------------------------------------- 1 | # next-line specific knobs 2 | next_line_deltas = 1 3 | next_line_delta_prob = 1.0 4 | next_line_pref_degree = 2 5 | -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.5.0-tune_opt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.5.0-tune_opt -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.6_ploth64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.6_ploth64 -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.7_restart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.7_restart -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_add_gnuplotAdd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_add_gnuplotAdd -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_add_gnuplotAll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_add_gnuplotAll -------------------------------------------------------------------------------- /tracer/quick_make.sh: -------------------------------------------------------------------------------- 1 | make PIN_ROOT=/mnt/panzer/rahbera/softwares/pin-3.11-97998-g7ecce2dac-gcc-linux obj-intel64/champsim_tracer.so 2 | -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.5.0-exceptions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.5.0-exceptions -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.5.0-x-prototype: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.5.0-x-prototype -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.5.5-exceptions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.5.5-exceptions -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.7.0-exceptions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.7.0-exceptions -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.7.0-x-prototype: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.7.0-x-prototype -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.3_interface: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.3_interface -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.4_interface: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.4_interface -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.6_no-common: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.6_no-common -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.7_mingw-w64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.7_mingw-w64 -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.2.2_interface: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.2.2_interface -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.3.5_mingw-w64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.3.5_mingw-w64 -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_add_gnuplotNeeded: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_add_gnuplotNeeded -------------------------------------------------------------------------------- /scripts/Math/utils/._01_no_extra_newlines.test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/utils/._01_no_extra_newlines.test -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.1.6_align_power_of_2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.1.6_align_power_of_2 -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.3.5_mingw_longlong: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.3.5_mingw_longlong -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_2.3.5_stderr_clobber: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_2.3.5_stderr_clobber -------------------------------------------------------------------------------- /scripts/Math/patches/._diff_pari-2.1.3-ix86-divl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff_pari-2.1.3-ix86-divl -------------------------------------------------------------------------------- /config/ampm.ini: -------------------------------------------------------------------------------- 1 | ampm_pb_size = 64 2 | ampm_pred_degree = 4 3 | ampm_pref_degree = 4 4 | ampm_enable_pref_buffer = true 5 | ampm_pref_buffer_size = 256 6 | -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.7.0-reinstall-foreigh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.7.0-reinstall-foreigh -------------------------------------------------------------------------------- /scripts/Math/patches/._patch-pari-unnormalized-float: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._patch-pari-unnormalized-float -------------------------------------------------------------------------------- /src/uncore.cc: -------------------------------------------------------------------------------- 1 | #include "uncore.h" 2 | 3 | // uncore 4 | UNCORE uncore; 5 | 6 | // constructor 7 | UNCORE::UNCORE() { 8 | cycle = 0; 9 | } 10 | -------------------------------------------------------------------------------- /scripts/Math/patches/._diff-2.7.0-reinstall-foreigh-full: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMU-SAFARI/Pythia/HEAD/scripts/Math/patches/._diff-2.7.0-reinstall-foreigh-full -------------------------------------------------------------------------------- /tracer/make_tracer.sh: -------------------------------------------------------------------------------- 1 | export PIN_ROOT=/mnt/panzer/rahbera/softwares/pin-3.11-97998-g7ecce2dac-gcc-linux 2 | mkdir -p obj-intel64 3 | make obj-intel64/champsim_tracer.so 4 | -------------------------------------------------------------------------------- /config/mlop.ini: -------------------------------------------------------------------------------- 1 | mlop_pref_degree = 16 2 | mlop_num_updates = 500 3 | mlop_l1d_thresh = 2.0 # disabled 4 | mlop_l2c_thresh = 0.75 5 | mlop_llc_thresh = 0.3 6 | mlop_debug_level = 0 7 | -------------------------------------------------------------------------------- /scripts/Math/utils/01_no_extra_newlines.test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | use Math::Pari; 3 | use strict; 4 | 5 | my $x = PARI(0); 6 | my $y = eval{$x/$x} || eval {$x**-1}; 7 | 1; 8 | 9 | -------------------------------------------------------------------------------- /experiments/rollup_1C_base_config.mfile: -------------------------------------------------------------------------------- 1 | Core_0_IPC : sum 2 | Core_0_LLC_total_miss : sum 3 | Core_0_LLC_load_miss : sum 4 | Core_0_LLC_RFO_miss : sum 5 | Core_0_LLC_writeback_miss : sum 6 | -------------------------------------------------------------------------------- /scripts/Math/utils/README: -------------------------------------------------------------------------------- 1 | inc.h: used to detect which functions are present. 2 | 3 | notes: Most of these remarks are related to unknown versions of Math::Pari 4 | and/or GP/PARI. 5 | 6 | The rest is obsolete scripts. 7 | 8 | -------------------------------------------------------------------------------- /scripts/Math-Combinatorics-0.09/MANIFEST: -------------------------------------------------------------------------------- 1 | Changes 2 | MANIFEST 3 | Makefile.PL 4 | README 5 | lib/Math/Combinatorics.pm 6 | t/01.t 7 | t/02.t 8 | t/03.t 9 | META.yml Module meta-data (added by MakeMaker) 10 | -------------------------------------------------------------------------------- /scripts/Math/utils/inc_h.diff: -------------------------------------------------------------------------------- 1 | --- ./utils/inc.h Tue Sep 25 07:17:18 2001 2 | +++ ./utils/inc.h1 Thu Dec 10 16:44:36 2009 3 | @@ -12,4 +12,4 @@ 4 | #include 5 | 6 | int x; 7 | -int y = CLK_TCK * x; 8 | +int y = CLK_TCK * x; 9 | -------------------------------------------------------------------------------- /config/sms.ini: -------------------------------------------------------------------------------- 1 | # SMS specification 2 | sms_ft_size = 64 3 | sms_at_size = 32 4 | sms_pht_size = 2048 5 | sms_pht_assoc = 16 6 | sms_region_size = 4096 7 | sms_pref_degree = 4 8 | sms_enable_pref_buffer = true 9 | sms_pref_buffer_size = 256 10 | -------------------------------------------------------------------------------- /config/sandbox.ini: -------------------------------------------------------------------------------- 1 | sandbox_pref_degree = 4 2 | sandbox_enable_stream_detect = true 3 | sandbox_stream_detect_length = 3 4 | sandbox_num_access_in_phase = 256 5 | sandbox_num_cycle_offsets = 4 6 | sandbox_bloom_filter_size = 2048 7 | sandbox_seed = 300 8 | -------------------------------------------------------------------------------- /config/power7.ini: -------------------------------------------------------------------------------- 1 | power7_explore_epoch = 20000 2 | power7_exploit_epoch = 200000 3 | power7_default_streamer_degree = 4 4 | 5 | streamer_num_trackers = 64 6 | streamer_pref_degree = 4 7 | 8 | stride_num_trackers = 64 9 | stride_pref_degree = 2 10 | -------------------------------------------------------------------------------- /config/bop.ini: -------------------------------------------------------------------------------- 1 | # BOP specific knobs 2 | bop_candidates = 1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60 3 | bop_rr_size = 256 4 | bop_max_rounds = 100 5 | bop_max_score = 31 6 | bop_top_n = 1 7 | bop_enable_pref_buffer = false 8 | bop_pref_buffer_size = 256 9 | bop_pref_degree = 4 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Auto-created directories 2 | .DS_Store 3 | ._.DS_Store 4 | .vscode/ 5 | 6 | # Executable 7 | bin/ 8 | obj/ 9 | 10 | # Traces 11 | dpc3_traces/ 12 | traces/ 13 | cvp1_traces/ 14 | 15 | # Run directory 16 | runs/ 17 | 18 | # Others 19 | tracer/obj-intel64/ 20 | tags 21 | *.out 22 | libbf/ 23 | -------------------------------------------------------------------------------- /patches/17-cannot-compile-libbf.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/bitvector.cpp b/src/bitvector.cpp 2 | index ba4b3ac..1617256 100644 3 | --- a/src/bitvector.cpp 4 | +++ b/src/bitvector.cpp 5 | @@ -2,6 +2,7 @@ 6 | 7 | #include 8 | #include 9 | +#include 10 | 11 | namespace bf { 12 | 13 | -------------------------------------------------------------------------------- /scripts/Math/utils/inc.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int x; 15 | int y = CLK_TCK * x; 16 | -------------------------------------------------------------------------------- /scripts/Math-Combinatorics-0.09/META.yml: -------------------------------------------------------------------------------- 1 | # http://module-build.sourceforge.net/META-spec.html 2 | #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# 3 | name: Math-Combinatorics 4 | version: 0.09 5 | version_from: lib/Math/Combinatorics.pm 6 | installdirs: site 7 | requires: 8 | 9 | distribution_type: module 10 | generated_by: ExtUtils::MakeMaker version 6.17 11 | -------------------------------------------------------------------------------- /config/bingo.ini: -------------------------------------------------------------------------------- 1 | bingo_region_size = 2048 2 | bingo_pattern_len = 32 3 | bingo_pc_width = 16 4 | bingo_min_addr_width = 5 5 | bingo_max_addr_width = 16 6 | bingo_ft_size = 64 7 | bingo_at_size = 128 8 | bingo_pht_size = 4096 9 | bingo_pht_ways = 16 10 | bingo_pf_streamer_size = 128 11 | bingo_debug_level = 0 12 | bingo_l1d_thresh = 1.01 13 | bingo_l2c_thresh = 0.80 14 | bingo_llc_thresh = 0.05 15 | bingo_pc_address_fill_level = L2 16 | -------------------------------------------------------------------------------- /scripts/Math/t/01_no_extra_newlines.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | BEGIN { unshift @INC, './lib', '../lib'; 4 | require Config; import Config; 5 | } 6 | 7 | $test = 0; 8 | $| = 1; 9 | print "1..",&last,"\n"; 10 | 11 | sub test { 12 | $test++; if (shift) {print "ok $test\n";1} else {print "not ok $test\n";0} 13 | } 14 | 15 | use Math::Pari; 16 | 17 | my $x=PARI(0); 18 | test( eval{$x/$x} || eval {$x**-1} || 1); 19 | sub last {1} 20 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.7_-O: -------------------------------------------------------------------------------- 1 | --- ./src/headers/parisys.h~ Fri Oct 28 17:44:06 2005 2 | +++ ./src/headers/parisys.h Fri Oct 28 17:43:12 2005 3 | @@ -48,7 +48,7 @@ 4 | # ifdef __GNUC__ 5 | # define VOLATILE __volatile__ 6 | # ifdef GCC_INLINE 7 | -# ifndef __OPTIMIZE__ 8 | +# ifdef __OPTIMIZE__NONE 9 | # error "no inlining without -O. Put back -O or remove -DGCC_INLINE" 10 | # else 11 | # define INLINE __inline__ static 12 | -------------------------------------------------------------------------------- /config/dspatch.ini: -------------------------------------------------------------------------------- 1 | dspatch_log2_region_size = 11 2 | dspatch_pb_size = 64 3 | dspatch_num_spt_entries = 256 4 | dspatch_compression_granularity = 2 5 | dspatch_pred_throttle_bw_thr = 3 6 | dspatch_bitmap_selection_policy = 3 7 | dspatch_sig_type = 1 8 | dspatch_sig_hash_type = 2 9 | dspatch_or_count_max = 3 10 | dspatch_measure_covP_max = 3 11 | dspatch_measure_accP_max = 3 12 | dspatch_acc_thr = 50 13 | dspatch_cov_thr = 50 14 | dspatch_enable_pref_buffer = true 15 | dspatch_pref_buffer_size = 256 16 | dspatch_pref_degree = 4 17 | -------------------------------------------------------------------------------- /scripts/Crypt/Random/Provider/devrandom.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -sw 2 | ## 3 | ## Copyright (c) 1998-2018, Vipul Ved Prakash. All rights reserved. 4 | ## This code is free software; you can redistribute it and/or modify 5 | ## it under the same terms as Perl itself. 6 | 7 | package Crypt::Random::Provider::devrandom; 8 | use strict; 9 | use lib qw(lib); 10 | use Crypt::Random::Provider::File; 11 | use vars qw(@ISA); 12 | @ISA = qw(Crypt::Random::Provider::File); 13 | 14 | sub _defaultsource { return "/dev/random" } 15 | 16 | 1; 17 | 18 | -------------------------------------------------------------------------------- /scripts/Crypt/Random/Provider/devurandom.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -sw 2 | ## 3 | ## Copyright (c) 1998-2018, Vipul Ved Prakash. All rights reserved. 4 | ## This code is free software; you can redistribute it and/or modify 5 | ## it under the same terms as Perl itself. 6 | 7 | package Crypt::Random::Provider::devurandom; 8 | use strict; 9 | use lib qw(lib); 10 | use Crypt::Random::Provider::File; 11 | use vars qw(@ISA); 12 | @ISA = qw(Crypt::Random::Provider::File); 13 | 14 | sub _defaultsource { return "/dev/urandom" } 15 | 16 | 1; 17 | 18 | -------------------------------------------------------------------------------- /inc/knobs.h: -------------------------------------------------------------------------------- 1 | #ifndef KNOBS_H 2 | #define KNOBS_H 3 | 4 | #include 5 | #include 6 | #define MAX_LEN 256 7 | 8 | void parse_args(int argc, char* argv[]); 9 | void parse_config(char *config_file_name); 10 | int parse_knobs(void* user, const char* section, const char* name, const char* value); 11 | int handler(void* user, const char* section, const char* name, const char* value); 12 | 13 | /* auxiliary functions */ 14 | std::vector get_array_int(const char *str); 15 | std::vector get_array_float(const char *str); 16 | 17 | #endif /* KNOBS_H */ -------------------------------------------------------------------------------- /inc/prefetcher.h: -------------------------------------------------------------------------------- 1 | #ifndef PREFETCHER_H 2 | #define PREFETCHER_H 3 | 4 | #include 5 | #include 6 | 7 | class Prefetcher 8 | { 9 | protected: 10 | std::string type; 11 | 12 | public: 13 | Prefetcher(std::string _type) {type = _type;} 14 | ~Prefetcher(){} 15 | std::string get_type() {return type;} 16 | virtual void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, std::vector &pref_addr) = 0; 17 | virtual void dump_stats() = 0; 18 | virtual void print_config() = 0; 19 | }; 20 | 21 | #endif /* PREFETCHER_H */ 22 | -------------------------------------------------------------------------------- /scripts/Math/libPARI/expected_codes: -------------------------------------------------------------------------------- 1 | 0 p 2 | 1 Gp 3 | 2 GG 4 | 3 GGG 5 | 4 GGGG 6 | 10 lG 7 | 11 L 8 | 12 GnP 9 | 13 GD0,L,D0,G, 10 | 14 GDn 11 | 15 Ll 12 | 16 ls 13 | 18 G 14 | 19 vLL 15 | 20 lGG 16 | 21 GL 17 | 22 GVI 18 | 23 GL 19 | 24 LG 20 | 25 GGD0,L, 21 | 26 GnG 22 | 27 V=GIp 23 | 28 GDVDI 24 | 29 GGp 25 | 30 lGGG 26 | 31 GGDGD& 27 | 32 GGL 28 | 33 GGGD0,L,p 29 | 34 vLLL 30 | 35 vLGG 31 | 37 V=GGIp 32 | 44 LLLL 33 | 45 LGD0,L, 34 | 47 V=GGID1,G, 35 | 48 V=GGID0,G, 36 | 49 GGDVDVDI 37 | 59 vLGGGG 38 | 73 LV=GGIpD0,L,D0,L, 39 | 83 vV=GGI 40 | 84 vGVI 41 | 86 vV=GGGI 42 | 87 vV=GID0,L, 43 | -------------------------------------------------------------------------------- /inc/uncore.h: -------------------------------------------------------------------------------- 1 | #ifndef UNCORE_H 2 | #define UNCORE_H 3 | 4 | #include "champsim.h" 5 | #include "cache.h" 6 | #include "dram_controller.h" 7 | //#include "drc_controller.h" 8 | 9 | //#define DRC_MSHR_SIZE 48 10 | 11 | // uncore 12 | class UNCORE { 13 | public: 14 | 15 | // LLC 16 | CACHE LLC{"LLC", LLC_SET, LLC_WAY, LLC_SET*LLC_WAY, LLC_WQ_SIZE, LLC_RQ_SIZE, LLC_PQ_SIZE, LLC_MSHR_SIZE}; 17 | 18 | // DRAM 19 | MEMORY_CONTROLLER DRAM{"DRAM"}; 20 | 21 | // cycle 22 | uint64_t cycle; 23 | 24 | UNCORE(); 25 | }; 26 | 27 | extern UNCORE uncore; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /scripts/Math/test_eng/ex.t: -------------------------------------------------------------------------------- 1 | #! perl -w 2 | delete $ENV{DISPLAY} if $ENV{AUTOMATED_TESTING}; 3 | $file = __FILE__; 4 | $file =~ m|^(.*)[\\/]([^\\/.]*)\.t$|s or die; 5 | $dir = $1; 6 | $name = $2; 7 | $name =~ s/^55_//; 8 | $long_bits = 8 * length pack( ($] < 5.006 ? 'L' : 'L!'), 0); 9 | $long_bits = 64 if $^O =~ /^MSWin/i and 8 == length pack 'p', 'dfd'; 10 | $dir1 = "CHANGE_ME"; 11 | $dir1 = "$dir/../$dir1" unless $dir1 =~ m|^([a-z]:)?[\\/]|i; 12 | @ARGV = "$dir1/src/test/$long_bits/$name"; 13 | @ARGV = "$dir1/src/test/32/$name" unless -r $ARGV[0]; 14 | do './test_eng/Testout.pm'; 15 | die if $@; 16 | -------------------------------------------------------------------------------- /scripts/Math/META.yml: -------------------------------------------------------------------------------- 1 | --- 2 | abstract: 'Perl interface to PARI.' 3 | author: 4 | - 'Ilya Zakharevich ' 5 | build_requires: 6 | ExtUtils::MakeMaker: 0 7 | configure_requires: 8 | ExtUtils::MakeMaker: 0 9 | dynamic_config: 1 10 | generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.130880' 11 | license: unknown 12 | meta-spec: 13 | url: http://module-build.sourceforge.net/META-spec-v1.4.html 14 | version: 1.4 15 | name: Math-Pari 16 | no_index: 17 | directory: 18 | - t 19 | - inc 20 | requires: {} 21 | version: 2.030518 22 | -------------------------------------------------------------------------------- /scripts/Math-Combinatorics-0.09/Makefile.PL: -------------------------------------------------------------------------------- 1 | use ExtUtils::MakeMaker; 2 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence 3 | # the contents of the Makefile that is written. 4 | WriteMakefile( 5 | 'NAME' => 'Math::Combinatorics', 6 | 'VERSION_FROM' => 'lib/Math/Combinatorics.pm', # finds $VERSION 7 | 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 8 | ($] >= 5.005 ? ## Add these new keywords supported since 5.005 9 | (ABSTRACT_FROM => 'lib/Math/Combinatorics.pm', # retrieve abstract from module 10 | AUTHOR => 'Allen Day ') : ()), 11 | ); 12 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_pari-2.1.3-ix86-divl: -------------------------------------------------------------------------------- 1 | --- ./src/kernel/ix86/level0.h-pre Fri Nov 3 13:00:24 2000 2 | +++ ./src/kernel/ix86/level0.h Mon Apr 8 15:41:16 2002 3 | @@ -173,7 +173,7 @@ extern ulong hiremainder; 4 | ({ ulong __value, __arg1 = (a), __arg2 = (b); \ 5 | __asm__ ("divl %4" \ 6 | : "=a" /* %eax */ (__value), "=d" /* %edx */ (hiremainder) \ 7 | - : "0" /* %eax */ (__arg1), "1" /* %edx */ (hiremainder), "g" (__arg2)); \ 8 | + : "0" /* %eax */ (__arg1), "1" /* %edx */ (hiremainder), "mr" /* memory or general register */ (__arg2)); \ 9 | __value; \ 10 | }) 11 | 12 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.2_gccism: -------------------------------------------------------------------------------- 1 | --- pari-2.1.2/src/basemath/arith1.c~ Fri Oct 12 13:56:27 2001 2 | +++ pari-2.1.2/src/basemath/arith1.c Tue Oct 23 18:55:36 2001 3 | @@ -2265,7 +2265,15 @@ two_rank(GEN x) 4 | } 5 | 6 | #define MAXFORM 11 7 | -#define _low(x) ({GEN __x=(GEN)x; __x[lgefint(x)-1];}) 8 | +/* #define _low(x) ({GEN __x=(GEN)x; __x[lgefint(x)-1];}) */ 9 | + 10 | +static long 11 | +__low(GEN x) 12 | +{ 13 | + return x[lgefint(x)-1]; 14 | +} 15 | + 16 | +#define _low(x) __low((GEN)(x)) 17 | 18 | /* h(x) for x<0 using Baby Step/Giant Step. 19 | * Assumes G is not too far from being cyclic. 20 | -------------------------------------------------------------------------------- /scripts/Math/libPARI/codes_2014: -------------------------------------------------------------------------------- 1 | 1 Gp 2 | 2 GG 3 | 3 GGG 4 | 4 GGGG 5 | 10 lG 6 | 11 L 7 | 12 GnP 8 | 13 GD0,L,D0,G, 9 | 14 GDn 10 | 16 ls 11 | 18 G 12 | 19 vLL 13 | 20 lGG 14 | 21 GL 15 | 22 GVI 16 | 23 GL 17 | 24 LG 18 | 25 GGD0,L, 19 | 26 GnG 20 | 27 V=GIp 21 | 28 GDVDI 22 | 29 GGp 23 | 30 lGGG 24 | 31 GGDGD& 25 | 32 GGL 26 | 33 GGGD0,L,p 27 | 34 vLLL 28 | 35 vLGG 29 | 37 V=GGIp 30 | 45 LGD0,L, 31 | 47 V=GGID1,G, 32 | 48 V=GGID0,G, 33 | 49 GGDVDVDI 34 | 57 vLs 35 | 59 vLGGGG 36 | 62 GD0,G,D0,G,D0,L,p 37 | 73 LV=GGIpD0,L,D0,L, 38 | 83 vV=GGI 39 | 84 vGVI 40 | 85 vS 41 | 86 vV=GGGI 42 | 87 vV=GID0,L, 43 | 91 GD0,L,DGp 44 | 96 GD0,L,DGp 45 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.7_div: -------------------------------------------------------------------------------- 1 | This patch is intended to fix 2 | Error: suffix or operands invalid for `div' 3 | (from <20091028221750.GA32213@pari.math.u-bordeaux.fr> on pari-dev list) 4 | 5 | --- ./src/kernel/ix86/level0.h.orig 6 | +++ ./src/kernel/ix86/level0.h 7 | @@ -173,7 +173,7 @@ 8 | ({ ulong __value, __arg1 = (a), __arg2 = (b); \ 9 | __asm__ ("divl %4" \ 10 | : "=a" /* %eax */ (__value), "=d" /* %edx */ (hiremainder) \ 11 | - : "0" /* %eax */ (__arg1), "1" /* %edx */ (hiremainder), "g" (__arg2)); \ 12 | + : "0" /* %eax */ (__arg1), "1" /* %edx */ (hiremainder), "mr" (__arg2)); \ 13 | __value; \ 14 | }) 15 | 16 | -------------------------------------------------------------------------------- /scripts/Metric.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | package Metric; 4 | use warnings; 5 | 6 | sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s }; 7 | 8 | sub parse 9 | { 10 | my ($filename) = @_; 11 | open($fh, '<', $filename) or die "cannot open file $trace_file\n"; 12 | chomp(my @lines = <$fh>); 13 | close($fh); 14 | 15 | my @metric_info; 16 | my $rec; 17 | foreach $elem (@lines) 18 | { 19 | undef $rec; 20 | $elem = trim($elem); 21 | if($elem eq "") {next;} 22 | if($elem =~ /^#/) {next;} 23 | 24 | my ($name, $type) = split(/:/, $elem); 25 | $rec->{"NAME"} = trim($name); 26 | $rec->{"TYPE"} = trim($type); 27 | push @metric_info, $rec; 28 | } 29 | 30 | return @metric_info; 31 | } 32 | 33 | 1; -------------------------------------------------------------------------------- /tracer/makefile: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # 3 | # DO NOT EDIT THIS FILE! 4 | # 5 | ############################################################## 6 | 7 | # If the tool is built out of the kit, PIN_ROOT must be specified in the make invocation and point to the kit root. 8 | ifdef PIN_ROOT 9 | CONFIG_ROOT := $(PIN_ROOT)/source/tools/Config 10 | else 11 | CONFIG_ROOT := ../Config 12 | endif 13 | include $(CONFIG_ROOT)/makefile.config 14 | include makefile.rules 15 | include $(TOOLS_ROOT)/Config/makefile.default.rules 16 | 17 | ############################################################## 18 | # 19 | # DO NOT EDIT THIS FILE! 20 | # 21 | ############################################################## 22 | -------------------------------------------------------------------------------- /experiments/automate_rollup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ROLLUP_SCRIPT=$PYTHIA_HOME/scripts/rollup.pl 4 | 5 | echo "Rolling up statistics for 1C_base_config..." 6 | cd experiments_1C/ 7 | $ROLLUP_SCRIPT --tlist ../MICRO21_1C.tlist --exp ../rollup_1C_base_config.exp --mfile ../rollup_1C_base_config.mfile > ../rollup_1C_base_config.csv 8 | cd - 9 | 10 | echo "Rolling up statistics for 1C_varying_DRAM_bw..." 11 | cd experiments_1C/ 12 | $ROLLUP_SCRIPT --tlist ../MICRO21_1C.tlist --exp ../rollup_1C_varying_DRAM_bw.exp --mfile ../rollup_1C_varying_DRAM_bw.mfile > ../rollup_1C_varying_DRAM_bw.csv 13 | cd - 14 | 15 | echo "Rolling up statistics for 4C..." 16 | cd experiments_4C/ 17 | $ROLLUP_SCRIPT --tlist ../MICRO21_4C.tlist --exp ../rollup_4C.exp --mfile ../rollup_4C.mfile > ../rollup_4C.csv 18 | cd - 19 | -------------------------------------------------------------------------------- /scripts/Math/t/zz_leak.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | my $test = 0; 5 | my $c; 6 | $| = 1; 7 | print "1..",&last,"\n"; 8 | 9 | sub test { 10 | $test++; 11 | my $mess = shift() ? '' : 'not '; 12 | my $what = shift; 13 | print "${mess}ok $test # $what\n"; 14 | return !$mess; 15 | } 16 | 17 | use Math::Pari; 18 | 19 | test(1, "before the test"); # 1 20 | my $x; 21 | 22 | for my $by ([1, "easy case: 1"], 23 | [0, "harder: 0"]) { 24 | my $t = PARI($by->[0]); 25 | for (1..100) { 26 | for my $i ((1) x 1e4) { # Was leaking with 0, no leaks with 1 27 | $x = 256*$t; 28 | } 29 | #print '.' unless $_ % 100; # Give chance to free temporaries 30 | $c++; 31 | } 32 | test(1, "after: $by->[1]"); # 2, 3: after the test 33 | } 34 | 35 | sub last {3} 36 | -------------------------------------------------------------------------------- /scripts/Trace.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | package Trace; 4 | use warnings; 5 | 6 | sub parse 7 | { 8 | my ($filename) = @_; 9 | open($fh, '<', $filename) or die "cannot open file $trace_file\n"; 10 | chomp(my @lines = <$fh>); 11 | close($fh); 12 | 13 | my @trace_info; 14 | my $rec; 15 | undef $rec; 16 | foreach $elem (@lines) 17 | { 18 | if($elem ne "") 19 | { 20 | my $idx = index($elem, "="); 21 | my $key = substr($elem, 0, $idx); 22 | my $value = substr($elem, $idx+1); 23 | # my ($key, $value) = split(/=/, $elem); 24 | if($key eq "NAME") 25 | { 26 | if(defined $rec) 27 | { 28 | push @trace_info, $rec; 29 | undef $rec; 30 | } 31 | } 32 | $rec->{$key} = $value; 33 | } 34 | } 35 | push @trace_info, $rec; 36 | 37 | return @trace_info; 38 | } 39 | 40 | 1; -------------------------------------------------------------------------------- /src/bakshalipour_framework.cc: -------------------------------------------------------------------------------- 1 | #include "bakshalipour_framework.h" 2 | 3 | /** 4 | * A very simple and efficient hash function that: 5 | * 1) Splits key into blocks of length `index_len` bits and computes the XOR of all blocks. 6 | * 2) Replaces the least significant block of key with computed block. 7 | * With this hash function, the index will depend on all bits in the key. As a consequence, entries 8 | * will be more randomly distributed among the sets. 9 | * NOTE: Applying this hash function twice with the same `index_len` acts as the identity function. 10 | */ 11 | uint64_t hash_index(uint64_t key, int index_len) { 12 | if (index_len == 0) 13 | return key; 14 | for (uint64_t tag = (key >> index_len); tag > 0; tag >>= index_len) 15 | key ^= tag & ((1 << index_len) - 1); 16 | return key; 17 | } 18 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff-2.5.0-tune_opt: -------------------------------------------------------------------------------- 1 | --- pari-2.5.0/src/headers/parisys.h-pre 2011-05-30 02:28:34.000000000 -0700 2 | +++ pari-2.5.0/src/headers/parisys.h 2019-02-27 02:46:33.888574100 -0800 3 | @@ -82,3 +82,8 @@ ENDEXTERN 4 | #else 5 | #define CHECK_CTRLC 6 | #endif 7 | + 8 | +#define aOPTas__(what) __attribute__((optimize(what))) 9 | +#define aOPTas__Og aOPTas__("Og") 10 | +#define aOPTas__O0 aOPTas__("O0") 11 | +#define aOPTas__O1 aOPTas__("O1") 12 | --- pari-2.5.0/src/basemath/bibli2.c-pre 2011-05-30 02:28:33.000000000 -0700 13 | +++ pari-2.5.0/src/basemath/bibli2.c 2019-02-27 04:03:17.398259900 -0800 14 | @@ -1388,6 +1388,9 @@ closurecmp(void *data, GEN x, GEN y) 15 | #define cmp_LEX 2 16 | #define cmp_REV 4 17 | #define cmp_UNIQ 8 18 | +#ifdef aOPT__vecsort0 19 | + aOPT__vecsort0 20 | +#endif 21 | GEN 22 | vecsort0(GEN x, GEN k, long flag) 23 | { 24 | -------------------------------------------------------------------------------- /scripts/Math/t/02_sections.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | BEGIN { unshift @INC, './lib', '../lib'; 4 | require Config; import Config; 5 | } 6 | 7 | $test = 0; 8 | $| = 1; 9 | my %sec = qw(1 max 2 lift 3 erfc 4 factorint 5 elleta 6 idealnorm 7 polresultant 8 matrank 9 sumalt 10 ploth 11 forstep); # 2.3.5 10 | my $secs = keys %sec; 11 | my $mx = 10; 12 | $mx < $_ and $mx = $_ for keys %sec; 13 | print "1..", &last ,"\n"; 14 | 15 | sub test { 16 | $test++; if (shift) {print "ok $test\n";1} else {print "not ok $test\n";0} 17 | } 18 | 19 | use Math::Pari; 20 | 21 | my %secOf; 22 | for my $sec (0..$mx) { 23 | $secOf{$_} = $sec for Math::Pari::listPari($sec); 24 | test(1); 25 | } 26 | for my $sec (sort keys %sec) { 27 | my $f = $sec{$sec}; 28 | # warn "$f => actual=$secOf{$f}\n"; 29 | warn "Mismatch: $f => stored=$sec, actual=$secOf{$f}\n" 30 | unless test( $secOf{$f} == $sec ); 31 | } 32 | sub last {1+$mx+keys %sec} 33 | -------------------------------------------------------------------------------- /prefetcher/no.l1d_pref: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | void CACHE::l1d_prefetcher_initialize() 4 | { 5 | 6 | } 7 | 8 | void CACHE::l1d_prefetcher_operate(uint64_t addr, uint64_t ip, uint8_t cache_hit, uint8_t type) 9 | { 10 | 11 | } 12 | 13 | void CACHE::l1d_prefetcher_cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr, uint32_t metadata_in) 14 | { 15 | 16 | } 17 | 18 | void CACHE::l1d_prefetcher_final_stats() 19 | { 20 | 21 | } 22 | 23 | uint32_t CACHE::l1d_prefetcher_prefetch_hit(uint64_t addr, uint64_t ip, uint32_t metadata_in) 24 | { 25 | return metadata_in; 26 | } 27 | 28 | void CACHE::l1d_prefetcher_print_config() 29 | { 30 | 31 | } 32 | 33 | void CACHE::l1d_prefetcher_broadcast_bw(uint8_t bw_level) 34 | { 35 | 36 | } 37 | 38 | void CACHE::l1d_prefetcher_broadcast_ipc(uint8_t ipc) 39 | { 40 | 41 | } 42 | 43 | void CACHE::l1d_prefetcher_broadcast_acc(uint32_t acc_level) 44 | { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /prefetcher/l1d_prefetcher.cc: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | void CACHE::l1d_prefetcher_initialize() 4 | { 5 | 6 | } 7 | 8 | void CACHE::l1d_prefetcher_operate(uint64_t addr, uint64_t ip, uint8_t cache_hit, uint8_t type) 9 | { 10 | 11 | } 12 | 13 | void CACHE::l1d_prefetcher_cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr, uint32_t metadata_in) 14 | { 15 | 16 | } 17 | 18 | void CACHE::l1d_prefetcher_final_stats() 19 | { 20 | 21 | } 22 | 23 | uint32_t CACHE::l1d_prefetcher_prefetch_hit(uint64_t addr, uint64_t ip, uint32_t metadata_in) 24 | { 25 | return metadata_in; 26 | } 27 | 28 | void CACHE::l1d_prefetcher_print_config() 29 | { 30 | 31 | } 32 | 33 | void CACHE::l1d_prefetcher_broadcast_bw(uint8_t bw_level) 34 | { 35 | 36 | } 37 | 38 | void CACHE::l1d_prefetcher_broadcast_ipc(uint8_t ipc) 39 | { 40 | 41 | } 42 | 43 | void CACHE::l1d_prefetcher_broadcast_acc(uint32_t acc_level) 44 | { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /inc/ppf_dev.h: -------------------------------------------------------------------------------- 1 | #ifndef PPF_DEV_H 2 | #define PPF_DEV_H 3 | 4 | #include "prefetcher.h" 5 | #include "ppf_dev_helper.h" 6 | #include "cache.h" 7 | 8 | using namespace spp_ppf; 9 | 10 | /* SPP+PPF imnplementation */ 11 | class SPP_PPF_dev : public Prefetcher 12 | { 13 | public: 14 | CACHE *m_parent_cache; 15 | spp_ppf::SIGNATURE_TABLE ST; 16 | spp_ppf::PATTERN_TABLE PT; 17 | spp_ppf::PREFETCH_FILTER FILTER; 18 | spp_ppf::GLOBAL_REGISTER GHR; 19 | spp_ppf::PERCEPTRON PERC; 20 | 21 | private: 22 | void init_knobs(); 23 | void init_stats(); 24 | 25 | public: 26 | SPP_PPF_dev(std::string type, CACHE *cache); 27 | ~SPP_PPF_dev(); 28 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, std::vector &pref_addr); 29 | void dump_stats(); 30 | void print_config(); 31 | void cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr); 32 | }; 33 | 34 | #endif /* PPF_DEV_H */ 35 | 36 | -------------------------------------------------------------------------------- /branch/bimodal.bpred: -------------------------------------------------------------------------------- 1 | #include "ooo_cpu.h" 2 | 3 | #define BIMODAL_TABLE_SIZE 16384 4 | #define BIMODAL_PRIME 16381 5 | #define MAX_COUNTER 3 6 | int bimodal_table[NUM_CPUS][BIMODAL_TABLE_SIZE]; 7 | 8 | void O3_CPU::initialize_branch_predictor() 9 | { 10 | cout << "CPU " << cpu << " Bimodal branch predictor" << endl; 11 | 12 | for(int i = 0; i < BIMODAL_TABLE_SIZE; i++) 13 | bimodal_table[cpu][i] = 0; 14 | } 15 | 16 | uint8_t O3_CPU::predict_branch(uint64_t ip) 17 | { 18 | uint32_t hash = ip % BIMODAL_PRIME; 19 | uint8_t prediction = (bimodal_table[cpu][hash] >= ((MAX_COUNTER + 1)/2)) ? 1 : 0; 20 | 21 | return prediction; 22 | } 23 | 24 | void O3_CPU::last_branch_result(uint64_t ip, uint8_t taken) 25 | { 26 | uint32_t hash = ip % BIMODAL_PRIME; 27 | 28 | if (taken && (bimodal_table[cpu][hash] < MAX_COUNTER)) 29 | bimodal_table[cpu][hash]++; 30 | else if ((taken == 0) && (bimodal_table[cpu][hash] > 0)) 31 | bimodal_table[cpu][hash]--; 32 | } 33 | -------------------------------------------------------------------------------- /branch/branch_predictor.cc: -------------------------------------------------------------------------------- 1 | #include "ooo_cpu.h" 2 | 3 | #define BIMODAL_TABLE_SIZE 16384 4 | #define BIMODAL_PRIME 16381 5 | #define MAX_COUNTER 3 6 | int bimodal_table[NUM_CPUS][BIMODAL_TABLE_SIZE]; 7 | 8 | void O3_CPU::initialize_branch_predictor() 9 | { 10 | cout << "CPU " << cpu << " Bimodal branch predictor" << endl; 11 | 12 | for(int i = 0; i < BIMODAL_TABLE_SIZE; i++) 13 | bimodal_table[cpu][i] = 0; 14 | } 15 | 16 | uint8_t O3_CPU::predict_branch(uint64_t ip) 17 | { 18 | uint32_t hash = ip % BIMODAL_PRIME; 19 | uint8_t prediction = (bimodal_table[cpu][hash] >= ((MAX_COUNTER + 1)/2)) ? 1 : 0; 20 | 21 | return prediction; 22 | } 23 | 24 | void O3_CPU::last_branch_result(uint64_t ip, uint8_t taken) 25 | { 26 | uint32_t hash = ip % BIMODAL_PRIME; 27 | 28 | if (taken && (bimodal_table[cpu][hash] < MAX_COUNTER)) 29 | bimodal_table[cpu][hash]++; 30 | else if ((taken == 0) && (bimodal_table[cpu][hash] > 0)) 31 | bimodal_table[cpu][hash]--; 32 | } 33 | -------------------------------------------------------------------------------- /prefetcher/no.l2c_pref: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | void CACHE::l2c_prefetcher_initialize() 4 | { 5 | 6 | } 7 | 8 | uint32_t CACHE::l2c_prefetcher_operate(uint64_t addr, uint64_t ip, uint8_t cache_hit, uint8_t type, uint32_t metadata_in) 9 | { 10 | return metadata_in; 11 | } 12 | 13 | uint32_t CACHE::l2c_prefetcher_cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr, uint32_t metadata_in) 14 | { 15 | return metadata_in; 16 | } 17 | 18 | void CACHE::l2c_prefetcher_final_stats() 19 | { 20 | 21 | } 22 | 23 | uint32_t CACHE::l2c_prefetcher_prefetch_hit(uint64_t addr, uint64_t ip, uint32_t metadata_in) 24 | { 25 | return metadata_in; 26 | } 27 | 28 | void CACHE::l2c_prefetcher_print_config() 29 | { 30 | 31 | } 32 | 33 | void CACHE::l2c_prefetcher_broadcast_bw(uint8_t bw_level) 34 | { 35 | 36 | } 37 | 38 | void CACHE::l2c_prefetcher_broadcast_ipc(uint8_t ipc) 39 | { 40 | 41 | } 42 | 43 | void CACHE::l2c_prefetcher_broadcast_acc(uint32_t acc_level) 44 | { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /prefetcher/no.llc_pref: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | void CACHE::llc_prefetcher_initialize() 4 | { 5 | 6 | } 7 | 8 | uint32_t CACHE::llc_prefetcher_operate(uint64_t addr, uint64_t ip, uint8_t cache_hit, uint8_t type, uint32_t metadata_in) 9 | { 10 | return metadata_in; 11 | } 12 | 13 | uint32_t CACHE::llc_prefetcher_cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr, uint32_t metadata_in) 14 | { 15 | return metadata_in; 16 | } 17 | 18 | void CACHE::llc_prefetcher_final_stats() 19 | { 20 | 21 | } 22 | 23 | uint32_t CACHE::llc_prefetcher_prefetch_hit(uint64_t addr, uint64_t ip, uint32_t metadata_in) 24 | { 25 | return metadata_in; 26 | } 27 | 28 | void CACHE::llc_prefetcher_print_config() 29 | { 30 | 31 | } 32 | 33 | void CACHE::llc_prefetcher_broadcast_bw(uint8_t bw_level) 34 | { 35 | 36 | } 37 | 38 | void CACHE::llc_prefetcher_broadcast_ipc(uint8_t ipc) 39 | { 40 | 41 | } 42 | 43 | void CACHE::llc_prefetcher_broadcast_acc(uint32_t acc_level) 44 | { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /prefetcher/l2c_prefetcher.cc: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | void CACHE::l2c_prefetcher_initialize() 4 | { 5 | 6 | } 7 | 8 | uint32_t CACHE::l2c_prefetcher_operate(uint64_t addr, uint64_t ip, uint8_t cache_hit, uint8_t type, uint32_t metadata_in) 9 | { 10 | return metadata_in; 11 | } 12 | 13 | uint32_t CACHE::l2c_prefetcher_cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr, uint32_t metadata_in) 14 | { 15 | return metadata_in; 16 | } 17 | 18 | void CACHE::l2c_prefetcher_final_stats() 19 | { 20 | 21 | } 22 | 23 | uint32_t CACHE::l2c_prefetcher_prefetch_hit(uint64_t addr, uint64_t ip, uint32_t metadata_in) 24 | { 25 | return metadata_in; 26 | } 27 | 28 | void CACHE::l2c_prefetcher_print_config() 29 | { 30 | 31 | } 32 | 33 | void CACHE::l2c_prefetcher_broadcast_bw(uint8_t bw_level) 34 | { 35 | 36 | } 37 | 38 | void CACHE::l2c_prefetcher_broadcast_ipc(uint8_t ipc) 39 | { 40 | 41 | } 42 | 43 | void CACHE::l2c_prefetcher_broadcast_acc(uint32_t acc_level) 44 | { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /prefetcher/llc_prefetcher.cc: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | void CACHE::llc_prefetcher_initialize() 4 | { 5 | 6 | } 7 | 8 | uint32_t CACHE::llc_prefetcher_operate(uint64_t addr, uint64_t ip, uint8_t cache_hit, uint8_t type, uint32_t metadata_in) 9 | { 10 | return metadata_in; 11 | } 12 | 13 | uint32_t CACHE::llc_prefetcher_cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr, uint32_t metadata_in) 14 | { 15 | return metadata_in; 16 | } 17 | 18 | void CACHE::llc_prefetcher_final_stats() 19 | { 20 | 21 | } 22 | 23 | uint32_t CACHE::llc_prefetcher_prefetch_hit(uint64_t addr, uint64_t ip, uint32_t metadata_in) 24 | { 25 | return metadata_in; 26 | } 27 | 28 | void CACHE::llc_prefetcher_print_config() 29 | { 30 | 31 | } 32 | 33 | void CACHE::llc_prefetcher_broadcast_bw(uint8_t bw_level) 34 | { 35 | 36 | } 37 | 38 | void CACHE::llc_prefetcher_broadcast_ipc(uint8_t ipc) 39 | { 40 | 41 | } 42 | 43 | void CACHE::llc_prefetcher_broadcast_acc(uint32_t acc_level) 44 | { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.6_no-common: -------------------------------------------------------------------------------- 1 | --- ./src/kernel/none/level0.h~ Fri Nov 3 13:00:26 2000 2 | +++ ./src/kernel/none/level0.h Mon Dec 27 13:44:46 2004 3 | @@ -50,8 +50,9 @@ ENDEXTERN 4 | 5 | #else 6 | 7 | -ulong overflow; 8 | -ulong hiremainder; 9 | +#define NEED_OVERFLOW_HIREMAINDER 10 | +extern ulong overflow; 11 | +extern ulong hiremainder; 12 | 13 | INLINE long 14 | addll(ulong x, ulong y) 15 | --- ./src/kernel/none/mp.c~ Tue Jan 29 05:46:23 2002 16 | +++ ./src/kernel/none/mp.c Mon Dec 27 13:46:30 2004 17 | @@ -22,6 +22,11 @@ Foundation, Inc., 59 Temple Place - Suit 18 | /* version (#ifdef __M68K__) since they are defined in mp.s */ 19 | #include "pari.h" 20 | 21 | +#ifdef NEED_OVERFLOW_HIREMAINDER 22 | +ulong overflow; 23 | +ulong hiremainder; 24 | +#endif 25 | + 26 | /* NOTE: arguments of "spec" routines (muliispec, addiispec, etc.) aren't 27 | * GENs but pairs (long *a, long na) representing a list of digits (in basis 28 | * BITS_IN_LONG) : a[0], ..., a[na-1]. [ In ordre to facilitate splitting: no 29 | -------------------------------------------------------------------------------- /scripts/Math/t/000_load-problem.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | use strict; 3 | 4 | $| = 1; 5 | print "1..1\nok 1\n"; # report success 6 | 7 | # `centerlift' is usually the first failing symbol detected... 8 | exit if eval 'use Math::Pari; use Math::Pari "centerlift"; 1'; 9 | 10 | # If failed, report build parameters 11 | 12 | sub report_build_parameters ($) { 13 | my ($makefile, $in) = (shift, ''); 14 | warn "# reporting $makefile header:\n# ==========================\n"; 15 | open M, "< $makefile" or die "Can't open $makefile"; 16 | $in = while defined $in and $in !~ /MakeMaker \s+ Parameters/xi; 17 | $in = ; # Reload till first non-empty line after "Param" one: 18 | $in = while defined $in and $in !~ /\S/; 19 | warn $in and $in = while defined $in and $in =~ /^#/; 20 | close M; 21 | warn "# ==========================\n"; 22 | } 23 | 24 | my ($base_d, $in) = (-f "t/000_load-problem.t" ? '.' : '..', ''); 25 | report_build_parameters("$base_d/Makefile"); 26 | report_build_parameters("$base_d/libPARI/Makefile"); 27 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.6_align_power_of_2: -------------------------------------------------------------------------------- 1 | This patch (from http://mail-index.netbsd.org/pkgsrc-bugs/2007/09/06/msg024597.html) 2 | is intended to fix 3 | kernel1.s: Assembler messages: 4 | kernel1.s:18: Error: alignment not a power of 2 5 | 6 | --- ./src/kernel/ix86/l0asm.c.orig 7 | +++ ./src/kernel/ix86/l0asm.c 8 | @@ -36,7 +36,7 @@ 9 | global variable `hiremainder'. */ 10 | 11 | /* This should ideally be determined at configure time. */ 12 | -#if defined(__EMX__) || defined(__DJGCC__) || defined(__GO32__) || (defined(linux) && !defined(__ELF__)) || defined(__386BSD__) || defined(__NetBSD__) || (defined(__FreeBSD__) && !defined(__ELF__)) || defined(NeXT) || defined(__CYGWIN32__) || defined(__MINGW32__) 13 | +#if defined(__EMX__) || defined(__DJGCC__) || defined(__GO32__) || (defined(linux) && !defined(__ELF__)) || defined(__386BSD__) || (defined(__NetBSD__) && !defined(__ELF__)) || (defined(__FreeBSD__) && !defined(__ELF__)) || defined(NeXT) || defined(__CYGWIN32__) || defined(__MINGW32__) 14 | # define ASM_UNDERSCORE 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.3_interface: -------------------------------------------------------------------------------- 1 | --- ./src/language/init.c-pre Thu Sep 27 10:01:14 2001 2 | +++ ./src/language/init.c Fri Apr 19 18:17:20 2002 3 | @@ -1875,7 +1875,7 @@ entree functions_basic[]={ 4 | {"idealmul",99,(void*)idealmul0,6,"GGGD0,L,p"}, 5 | {"idealnorm",2,(void*)idealnorm,6,"GG"}, 6 | {"idealpow",99,(void*)idealpow0,6,"GGGD0,L,p"}, 7 | -{"idealprimedec",29,(void*)primedec,6,"GG"}, 8 | +{"idealprimedec",2,(void*)primedec,6,"GG"}, 9 | {"idealprincipal",2,(void*)principalideal,6,"GG"}, 10 | {"idealred",99,(void*)ideallllred,6,"GGDGp"}, 11 | {"idealstar",99,(void*)idealstar0,6,"GGD1,L,"}, 12 | @@ -2060,7 +2060,7 @@ entree functions_basic[]={ 13 | {"rnfbasis",2,(void*)rnfbasis,6,"GG"}, 14 | {"rnfbasistoalg",2,(void*)rnfbasistoalg,6,"GG"}, 15 | {"rnfcharpoly",99,(void*)rnfcharpoly,6,"GGGDn"}, 16 | -{"rnfconductor",29,(void*)rnfconductor,6,"GGD0,L,p"}, 17 | +{"rnfconductor",99,(void*)rnfconductor,6,"GGD0,L,p"}, 18 | {"rnfdedekind",99,(void*)rnfdedekind,6,"GGG"}, 19 | {"rnfdet",99,(void*)rnfdet0,6,"GGDG"}, 20 | {"rnfdisc",2,(void*)rnfdiscf,6,"GG"}, 21 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.4_interface: -------------------------------------------------------------------------------- 1 | --- ./src/language/init.c-pre Thu Sep 27 10:01:08 2001 2 | +++ ./src/language/init.c Tue Mar 18 20:58:44 2003 3 | @@ -1875,7 +1875,7 @@ entree functions_basic[]={ 4 | {"idealmul",99,(void*)idealmul0,6,"GGGD0,L,p"}, 5 | {"idealnorm",2,(void*)idealnorm,6,"GG"}, 6 | {"idealpow",99,(void*)idealpow0,6,"GGGD0,L,p"}, 7 | -{"idealprimedec",29,(void*)primedec,6,"GG"}, 8 | +{"idealprimedec",2,(void*)primedec,6,"GG"}, 9 | {"idealprincipal",2,(void*)principalideal,6,"GG"}, 10 | {"idealred",99,(void*)ideallllred,6,"GGDGp"}, 11 | {"idealstar",99,(void*)idealstar0,6,"GGD1,L,"}, 12 | @@ -2060,7 +2060,7 @@ entree functions_basic[]={ 13 | {"rnfbasis",2,(void*)rnfbasis,6,"GG"}, 14 | {"rnfbasistoalg",2,(void*)rnfbasistoalg,6,"GG"}, 15 | {"rnfcharpoly",99,(void*)rnfcharpoly,6,"GGGDn"}, 16 | -{"rnfconductor",29,(void*)rnfconductor,6,"GGD0,L,p"}, 17 | +{"rnfconductor",99,(void*)rnfconductor,6,"GGD0,L,p"}, 18 | {"rnfdedekind",99,(void*)rnfdedekind,6,"GGG"}, 19 | {"rnfdet",99,(void*)rnfdet0,6,"GGDG"}, 20 | {"rnfdisc",2,(void*)rnfdiscf,6,"GG"}, 21 | -------------------------------------------------------------------------------- /scripts/Math/META.json: -------------------------------------------------------------------------------- 1 | { 2 | "abstract" : "Perl interface to PARI.", 3 | "author" : [ 4 | "Ilya Zakharevich " 5 | ], 6 | "dynamic_config" : 1, 7 | "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.130880", 8 | "license" : [ 9 | "perl_5", 10 | "gpl_2" 11 | ], 12 | "meta-spec" : { 13 | "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", 14 | "version" : "2" 15 | }, 16 | "name" : "Math-Pari", 17 | "no_index" : { 18 | "directory" : [ 19 | "t", 20 | "inc" 21 | ] 22 | }, 23 | "prereqs" : { 24 | "build" : { 25 | "requires" : { 26 | "ExtUtils::MakeMaker" : "0" 27 | } 28 | }, 29 | "configure" : { 30 | "requires" : { 31 | "ExtUtils::MakeMaker" : "0" 32 | } 33 | }, 34 | "runtime" : { 35 | "requires" : {} 36 | } 37 | }, 38 | "release_status" : "stable", 39 | "version" : "2.030518" 40 | } 41 | -------------------------------------------------------------------------------- /scripts/Math-Combinatorics-0.09/Changes: -------------------------------------------------------------------------------- 1 | Revision history for Perl extension Math::Combinatorics. 2 | 3 | 0.01 Tue Sep 21 19:06:32 2004 4 | - original version; created by h2xs 1.21 with options 5 | -AXn Math::Combinatorics 6 | 7 | 0.02 o Bugfix to permute() method, reported by Marc Logghe. 8 | o Combinations/Permutations now calculated using iterator. 9 | Uses less memory for very large sets (David Coppit, Tye, 10 | Christopher Eltschka). 11 | 12 | 0.03 o Added reference to Set::Scalar, Set::Bag 13 | o new() accepts a 'compare' option. 14 | o new() presorts the set by this ('compare' value is a sorting 15 | subroutine code reference). this addresses a combine/permute 16 | bug when using a set of references, identified by Ying Yang 17 | . 18 | 19 | 0.06 o Added multiset, string, and derangement methods for OO mode 20 | o Corrections to documentation examples 21 | 22 | 0.07 o Fixed syntax error under 5.8.7 23 | 0.08 o Eh? 24 | 0.09 o Optimized re-implemention of derange() by Carlos Rica 25 | 26 | -------------------------------------------------------------------------------- /experiments/rollup_4C.exp: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | ## 3 | ## This file contains all the experiments required 4 | ## to reproduce four-core performance results of Pythia. 5 | ## 6 | ## Please follow the README to know how to use this file. 7 | ## 8 | ## Owner: Rahul Bera (write2bera@gmail.com) 9 | ## 10 | ############################################################### 11 | 12 | 13 | # configurations 14 | BASE = --warmup_instructions=50000000 --simulation_instructions=150000000 15 | NOPREF = --config=$(PYTHIA_HOME)/config/nopref.ini 16 | STRIDE = --l2c_prefetcher_types=stride --config=$(PYTHIA_HOME)/config/stride.ini 17 | SPP_DEV2 = --l2c_prefetcher_types=spp_dev2 --config=$(PYTHIA_HOME)/config/spp_dev2.ini 18 | MLOP = --l2c_prefetcher_types=mlop --config=$(PYTHIA_HOME)/config/mlop.ini 19 | BINGO = --l2c_prefetcher_types=bingo --config=$(PYTHIA_HOME)/config/bingo.ini 20 | PYTHIA = --l2c_prefetcher_types=scooby --config=$(PYTHIA_HOME)/config/pythia.ini 21 | 22 | nopref $(BASE) $(NOPREF) 23 | spp $(BASE) $(SPP_DEV2) 24 | bingo $(BASE) $(BINGO) 25 | mlop $(BASE) $(MLOP) 26 | pythia $(BASE) $(PYTHIA) 27 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use our framework to evaluate Pythia, please cite the work as follows." 3 | authors: 4 | - family-names: "Bera" 5 | given-names: "Rahul" 6 | - family-names: "Kanellopoulos" 7 | given-names: "Konstantinos" 8 | title: "Pythia: A Customizable Hardware Prefetching Framework Using Online Reinforcement Learning" 9 | version: 1.3 10 | doi: 10.5281/zenodo.5520125 11 | date-released: 2021-09-22 12 | url: "https://github.com/CMU-SAFARI/Pythia" 13 | preferred-citation: 14 | title: "Pythia: A Customizable Hardware Prefetching Framework Using Online Reinforcement Learning" 15 | type: proceedings 16 | year: 2021 17 | conference: 18 | name: "54th International Symposium on Microarchitecture(MICRO)" 19 | authors: 20 | - family-names: "Bera" 21 | given-names: "Rahul" 22 | - family-names: "Kanellopoulos" 23 | given-names: "Konstantinos" 24 | - family-names: "Nori" 25 | given-names: "Anant V." 26 | - family-names: "Shahroodi" 27 | given-names: "Taha" 28 | - family-names: "Subramoney" 29 | given-names: "Sreenivas" 30 | - family-names: "Mutlu" 31 | given-names: "Onur" 32 | doi: "10.1145/3466752.3480114" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 SAFARI Research Group at ETH Zurich University 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /experiments/MICRO21_4C.exp: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | ## 3 | ## This file contains all the experiments required 4 | ## to reproduce four-core performance results of Pythia. 5 | ## 6 | ## Please follow the README to know how to use this file. 7 | ## 8 | ## Owner: Rahul Bera (write2bera@gmail.com) 9 | ## 10 | ############################################################### 11 | 12 | 13 | # configurations 14 | BASE = --warmup_instructions=50000000 --simulation_instructions=150000000 15 | NOPREF = --config=$(PYTHIA_HOME)/config/nopref.ini 16 | STRIDE = --l2c_prefetcher_types=stride --config=$(PYTHIA_HOME)/config/stride.ini 17 | SPP_DEV2 = --l2c_prefetcher_types=spp_dev2 --config=$(PYTHIA_HOME)/config/spp_dev2.ini 18 | MLOP = --l2c_prefetcher_types=mlop --config=$(PYTHIA_HOME)/config/mlop.ini 19 | BINGO = --l2c_prefetcher_types=bingo --config=$(PYTHIA_HOME)/config/bingo.ini 20 | PYTHIA = --l2c_prefetcher_types=scooby --config=$(PYTHIA_HOME)/config/pythia.ini 21 | 22 | # Experiments for Figure 11(a) 23 | nopref $(BASE) $(NOPREF) 24 | spp $(BASE) $(SPP_DEV2) 25 | bingo $(BASE) $(BINGO) 26 | mlop $(BASE) $(MLOP) 27 | pythia $(BASE) $(PYTHIA) 28 | -------------------------------------------------------------------------------- /experiments/rollup_1C_base_config.exp: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | ## 3 | ## This file contains all the experiments required 4 | ## to reproduce single-core performance results of Pythia. 5 | ## 6 | ## Please follow the README to know how to use this file. 7 | ## 8 | ## Owner: Rahul Bera (write2bera@gmail.com) 9 | ## 10 | ############################################################### 11 | 12 | 13 | # configurations 14 | BASE = --warmup_instructions=100000000 --simulation_instructions=500000000 15 | NOPREF = --config=$(PYTHIA_HOME)/config/nopref.ini 16 | STRIDE = --l2c_prefetcher_types=stride --config=$(PYTHIA_HOME)/config/stride.ini 17 | SPP_DEV2 = --l2c_prefetcher_types=spp_dev2 --config=$(PYTHIA_HOME)/config/spp_dev2.ini 18 | MLOP = --l2c_prefetcher_types=mlop --config=$(PYTHIA_HOME)/config/mlop.ini 19 | BINGO = --l2c_prefetcher_types=bingo --config=$(PYTHIA_HOME)/config/bingo.ini 20 | PYTHIA = --l2c_prefetcher_types=scooby --config=$(PYTHIA_HOME)/config/pythia.ini 21 | 22 | # experiments for Figure 10(a) and Figure 8 23 | nopref $(BASE) $(NOPREF) 24 | spp $(BASE) $(SPP_DEV2) 25 | bingo $(BASE) $(BINGO) 26 | mlop $(BASE) $(MLOP) 27 | pythia $(BASE) $(PYTHIA) 28 | -------------------------------------------------------------------------------- /inc/bitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAP_H 2 | #define BITMAP_H 3 | 4 | #include 5 | #include 6 | #define BITMAP_MAX_SIZE 64 7 | 8 | typedef std::bitset Bitmap; 9 | 10 | class BitmapHelper 11 | { 12 | public: 13 | static uint64_t value(Bitmap bmp, uint32_t size = BITMAP_MAX_SIZE); 14 | static std::string to_string(Bitmap bmp, uint32_t size = BITMAP_MAX_SIZE); 15 | static uint32_t count_bits_set(Bitmap bmp, uint32_t size = BITMAP_MAX_SIZE); 16 | static uint32_t count_bits_same(Bitmap bmp1, Bitmap bmp2, uint32_t size = BITMAP_MAX_SIZE); 17 | static uint32_t count_bits_diff(Bitmap bmp1, Bitmap bmp2, uint32_t size = BITMAP_MAX_SIZE); 18 | static Bitmap rotate_left(Bitmap bmp, uint32_t amount, uint32_t size = BITMAP_MAX_SIZE); 19 | static Bitmap rotate_right(Bitmap bmp, uint32_t amount, uint32_t size = BITMAP_MAX_SIZE); 20 | static Bitmap compress(Bitmap bmp, uint32_t granularity, uint32_t size = BITMAP_MAX_SIZE); 21 | static Bitmap decompress(Bitmap bmp, uint32_t granularity, uint32_t size = BITMAP_MAX_SIZE); 22 | static Bitmap bitwise_or(Bitmap bmp1, Bitmap bmp2, uint32_t size = BITMAP_MAX_SIZE); 23 | static Bitmap bitwise_and(Bitmap bmp1, Bitmap bmp2, uint32_t size = BITMAP_MAX_SIZE); 24 | }; 25 | 26 | #endif /* BITMAP_H */ -------------------------------------------------------------------------------- /scripts/Math/TODO: -------------------------------------------------------------------------------- 1 | *) Temporarily skip nfisincl() in tests - segfaults in 2.2.10 (CVS)... 2 | 3 | *) With 2.2.10 (CVS) 4 | Failed Test Stat Wstat Total Fail Failed List of Failed 5 | ------------------------------------------------------------------ 6 | t/intnum.t 50 9 18.00% 11 23-25 27 41-42 45 49 7 | 8 | ULONG test is not robust enough. 9 | 10 | ASMINLINE? For -g? 11 | 12 | *) One scenario to have highremainder problem: cc=gcc, but cpp is not 13 | gcc-based; thus __GNUC__ is not defined when building kernel.o, and 14 | wrong code is assembled (Solaris). 15 | 16 | I tried 17 | perl Makefile.PL cpp="gcc -E" 18 | and 19 | perl Makefile.PL CPP="gcc -E" 20 | but the correct define for CPP did not make it into the important part of 21 | libPARI/Makefile. With CPP = gcc -E in makefile things build fine. 22 | 23 | *) Document in the code what happens when a Math::Pari object is free()ed which 24 | from Perl-called-from-PARI-called-from-Perl, and the object was created 25 | on stack before the call to PARI function. 26 | 27 | *) Apparently, fill_outvect() use of oldavma is good only if the data is 28 | not on stack, or there is exactly one value on stack, and void return 29 | value... 30 | -------------------------------------------------------------------------------- /scripts/Math-Combinatorics-0.09/t/02.t: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | use lib 'lib'; 3 | use strict; 4 | use Test::More; 5 | 6 | plan tests => 5; 7 | 8 | use_ok('Data::Dumper'); 9 | use_ok('Math::Combinatorics'); 10 | } 11 | 12 | my $c; 13 | my $f = 0; 14 | my @r; 15 | my @data; 16 | 17 | @data = ( 'a', [], 'b', [] ); 18 | $c = Math::Combinatorics->new( 19 | data => \@data, 20 | count => 2, 21 | ); 22 | $f = 0; 23 | while(my(@combo) = $c->next_combination){ 24 | #warn "combo $f is: ".join " ", @combo; 25 | $f++; 26 | } 27 | ok($f == 6, ">>> $f == 6 <<<"); 28 | 29 | @data = ([],[],[],[]); 30 | $c = Math::Combinatorics->new( 31 | data => \@data, 32 | count => 2, 33 | ); 34 | $f = 0; 35 | while(my(@combo) = $c->next_combination){ 36 | $f++; 37 | } 38 | ok($f == 6, ">>> $f == 6 <<<"); 39 | 40 | @data = (1..10); 41 | $c = Math::Combinatorics->new( 42 | data => \@data, 43 | count => 2, 44 | ); 45 | $f = 0; 46 | while(my(@combo) = $c->next_combination){ 47 | $f++; 48 | } 49 | ok($f == 45, ">>> $f == 45 <<<"); 50 | 51 | -------------------------------------------------------------------------------- /scripts/Crypt/Random/Provider/rand.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -sw 2 | ## 3 | ## Copyright (c) 1998-2018, Vipul Ved Prakash. All rights reserved. 4 | ## This code is free software; you can redistribute it and/or modify 5 | ## it under the same terms as Perl itself. 6 | 7 | package Crypt::Random::Provider::rand; 8 | use strict; 9 | use Math::Pari qw(pari2num); 10 | 11 | sub new { 12 | 13 | my ($class, %params) = @_; 14 | my $self = { Source => $params{Source} || sub { return rand($_[0]) } }; 15 | return bless $self, $class; 16 | 17 | } 18 | 19 | 20 | sub get_data { 21 | 22 | my ($self, %params) = @_; 23 | $self = {} unless ref $self; 24 | 25 | my $size = $params{Size}; 26 | my $skip = $params{Skip} || $$self{Skip}; 27 | 28 | if ($size && ref $size eq "Math::Pari") { 29 | $size = pari2num($size); 30 | } 31 | 32 | my $bytes = $params{Length} || (int($size / 8) + 1); 33 | my $source = $$self{Source} || sub { rand($_[0]) }; 34 | 35 | my($r, $read, $rt) = ('', 0); 36 | while ($read < $bytes) { 37 | $rt = chr(int(&$source(256))); 38 | unless ($skip && $skip =~ /\Q$rt\E/) { 39 | $r .= $rt; $read++; 40 | } 41 | } 42 | 43 | $r; 44 | 45 | } 46 | 47 | 48 | sub available { 49 | 50 | return 1; 51 | 52 | } 53 | 54 | 55 | 1; 56 | 57 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.3.5_mingw-w64: -------------------------------------------------------------------------------- 1 | diff -ru pari-2.3.5.orig\src\gp\highlvl.c pari-2.3.5\src\gp\highlvl.c 2 | --- pari-2.3.5.orig\src\gp\highlvl.c Thu Feb 04 11:55:42 2010 3 | +++ pari-2.3.5\src\gp\highlvl.c Wed Mar 03 12:28:18 2010 4 | @@ -18,6 +18,13 @@ 5 | /* SOME GP FUNCTION THAT MAY BE USEFUL OUTSIDE OF IT */ 6 | /* */ 7 | /*******************************************************************/ 8 | + 9 | +/* we need to include windows.h quite early to avoid some macro name collisions */ 10 | +#ifdef _WIN32 11 | +# define WIN32_LEAN_AND_MEAN 12 | +# include 13 | +#endif 14 | + 15 | #include "pari.h" 16 | #include "paripriv.h" 17 | #include "../graph/rect.h" 18 | --- ./src/language/es.c.orig 2008-03-31 04:43:58.000000000 -0700 19 | +++ ./src/language/es.c 2018-07-29 00:36:28.971866700 -0700 20 | @@ -2836,6 +2836,10 @@ os_read(long fd, char ch[], long s) 21 | #endif 22 | } 23 | 24 | +#ifdef HAS_OPENDIR 25 | +# include 26 | +#endif 27 | + 28 | long 29 | os_open(char *s, int mode) 30 | { 31 | @@ -2872,7 +2876,6 @@ static char *last_filename = NULL; 32 | 33 | #ifdef HAS_OPENDIR 34 | /* slow, but more portable than stat + S_I[FS]DIR */ 35 | -# include 36 | static int 37 | is_dir_opendir(char *name) 38 | { 39 | -------------------------------------------------------------------------------- /scripts/Math/gdbinit-my: -------------------------------------------------------------------------------- 1 | # include as in gdb --init-command gdbinit-my --args perl OPTIONS 2 | 3 | # See https://pari.math.u-bordeaux.fr/Events/PARI2012/talks/source.pdf 4 | # No `document Foo Bar' commands there! 5 | 6 | # conflicts with `info' 7 | define i 8 | call output((GEN)$arg0) 9 | end 10 | 11 | # What do these functions do with Pari stack??? 12 | 13 | define ilb 14 | call outmat(lift(lift(lift((GEN)$arg0)))) 15 | end 16 | 17 | # prec_w: shallow copy with precision decreased 18 | 19 | define isb 20 | call outmat(gprec_w((GEN)$arg0,3)) 21 | end 22 | 23 | # Recursively display structure, truncating leaves at 2 words (or the second argument) [($argc > 1 ? $arg1 : 2) does not work] 24 | 25 | define v 26 | if $argc > 1 27 | call dbgGEN((GEN)$arg0, $arg1) 28 | else 29 | call dbgGEN((GEN)$arg0, 2) 30 | end 31 | end 32 | 33 | # ============ Added ============ 34 | 35 | define heap 36 | call dbg_pari_heap() 37 | end 38 | 39 | # ============ Advanced (with bb renamed to be, cc to ss ============ 40 | 41 | define w1 42 | shell rm -f /tmp/gp.tmp1 43 | call gpwritebin("/tmp/gp.tmp1",$arg0) 44 | end 45 | define be 46 | break pari_err 47 | # break pari_err2GEN 48 | end 49 | define ss 50 | signal SIGINT 51 | end 52 | define fs 53 | p fill_stack() 54 | end 55 | -------------------------------------------------------------------------------- /scripts/Exp.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | package Exp; 4 | use warnings; 5 | 6 | sub parse 7 | { 8 | my ($filename) = @_; 9 | open($fh, '<', $filename) or die "cannot open file $trace_file\n"; 10 | chomp(my @lines = <$fh>); 11 | close($fh); 12 | 13 | my %exp_configs; 14 | my @exps; 15 | my $exp; 16 | foreach $elem (@lines) 17 | { 18 | $elem =~ s/^\s+|\s+$//g; 19 | if($elem eq "") {next;} 20 | if($elem =~ /^#/) {next;} 21 | 22 | my @tokens = split(/\s+/, $elem); 23 | if($tokens[1] eq "=") # exp config variable 24 | { 25 | $exp_configs{$tokens[0]} = join(" ", @tokens[2..$#tokens]); 26 | #print("config: $tokens[0]\n"); 27 | } 28 | else # exp declaration 29 | { 30 | $exp->{"NAME"} = $tokens[0]; 31 | my @args; 32 | foreach $token (@tokens[1..$#tokens]) 33 | { 34 | if($token =~ /^\$/) # exp config variable 35 | { 36 | $token =~ s/\$|\(|\)//g; 37 | if(exists($exp_configs{$token})) 38 | { 39 | push(@args, $exp_configs{$token}); 40 | } 41 | else 42 | { 43 | die "$token is not defined before exp $tokens[0]\n"; 44 | } 45 | } 46 | else 47 | { 48 | push(@args, $token); 49 | } 50 | } 51 | $exp->{"KNOBS"} = join(" ", @args); 52 | push(@exps, $exp); 53 | undef $args; 54 | undef $exp; 55 | } 56 | } 57 | 58 | return @exps; 59 | } 60 | 61 | 1; -------------------------------------------------------------------------------- /inc/ipcp_vars.h: -------------------------------------------------------------------------------- 1 | #ifndef IPCP_VARS_H 2 | #define IPCP_VARS_H 3 | 4 | /*************************************************************************** 5 | Code taken from 6 | Samuel Pakalapati - samuelpakalapati@gmail.com 7 | Biswabandan Panda - biswap@cse.iitk.ac.in 8 | ***************************************************************************/ 9 | 10 | #define NUM_IP_TABLE_L1_ENTRIES 1024 // IP table entries 11 | #define NUM_GHB_ENTRIES 16 // Entries in the GHB 12 | #define NUM_IP_INDEX_BITS 10 // Bits to index into the IP table 13 | #define NUM_IP_TAG_BITS 6 // Tag bits per IP table entry 14 | #define S_TYPE 1 // stream 15 | #define CS_TYPE 2 // constant stride 16 | #define CPLX_TYPE 3 // complex stride 17 | #define NL_TYPE 4 // next line 18 | #define NUM_IP_TABLE_L2_ENTRIES 1024 19 | 20 | // #define SIG_DEBUG_PRINT 21 | #ifdef SIG_DEBUG_PRINT 22 | #define SIG_DP(x) x 23 | #else 24 | #define SIG_DP(x) 25 | #endif 26 | 27 | // #define SIG_DEBUG_PRINT_L2 28 | #ifdef SIG_DEBUG_PRINT_L2 29 | #define SIG_DP(x) x 30 | #else 31 | #define SIG_DP(x) 32 | #endif 33 | 34 | #endif /* IPCP_VARS_H */ 35 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.7_mingw-w64: -------------------------------------------------------------------------------- 1 | diff -ru pari-2.1.7.orig\src\gp\highlvl.c pari-2.1.7\src\gp\highlvl.c 2 | --- pari-2.1.7.orig\src\gp\highlvl.c Tue Apr 23 17:29:37 2002 3 | +++ pari-2.1.7\src\gp\highlvl.c Wed Mar 03 09:21:11 2010 4 | @@ -18,6 +18,13 @@ 5 | /* SOME GP FUNCTION THAT MAY BE USEFUL OUTSIDE OF IT */ 6 | /* */ 7 | /*******************************************************************/ 8 | + 9 | +/* we need to include windows.h quite early to avoid some macro name collisions */ 10 | +#ifdef _WIN32 11 | +# define WIN32_LEAN_AND_MEAN 12 | +# include 13 | +#endif 14 | + 15 | #include "pari.h" 16 | #ifdef macintosh 17 | # include "rect.h" 18 | --- ./src/language/es.c-pre 2002-06-23 05:49:48.000000000 -0700 19 | +++ ./src/language/es.c 2014-06-01 10:48:39.046597000 -0700 20 | @@ -2223,6 +2223,10 @@ os_read(long fd, char ch[], long s) 21 | #endif 22 | } 23 | 24 | +#ifdef HAS_OPENDIR 25 | +# include 26 | +#endif 27 | + 28 | long 29 | os_open(char *s, int mode) 30 | { 31 | @@ -2259,9 +2263,6 @@ os_getenv(char *s) 32 | static char *last_filename = NULL; 33 | static char **dir_list = NULL; 34 | 35 | -#ifdef HAS_OPENDIR 36 | -# include 37 | -#endif 38 | /* slow, but more portable than stat + S_I[FS]DIR */ 39 | int 40 | pari_is_dir(char *name) 41 | -------------------------------------------------------------------------------- /docs/index.md.bak: -------------------------------------------------------------------------------- 1 | ## Welcome to GitHub Pages 2 | 3 | You can use the [editor on GitHub](https://github.com/CMU-SAFARI/Pythia/edit/master/docs/index.md) to maintain and preview the content for your website in Markdown files. 4 | 5 | Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files. 6 | 7 | ### Markdown 8 | 9 | Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for 10 | 11 | ```markdown 12 | Syntax highlighted code block 13 | 14 | # Header 1 15 | ## Header 2 16 | ### Header 3 17 | 18 | - Bulleted 19 | - List 20 | 21 | 1. Numbered 22 | 2. List 23 | 24 | **Bold** and _Italic_ and `Code` text 25 | 26 | [Link](url) and ![Image](src) 27 | ``` 28 | 29 | For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/). 30 | 31 | ### Jekyll Themes 32 | 33 | Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/CMU-SAFARI/Pythia/settings/pages). The name of this theme is saved in the Jekyll `_config.yml` configuration file. 34 | 35 | ### Support or Contact 36 | 37 | Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out. 38 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.2.2_interface: -------------------------------------------------------------------------------- 1 | --- ./src/language/init.c-pre-interface Fri Jan 11 15:05:20 2002 2 | +++ ./src/language/init.c Sat Apr 20 01:26:30 2002 3 | @@ -2046,7 +2046,7 @@ entree functions_basic[]={ 4 | {"dirmul",2,(void*)dirmul,4,"GG"}, 5 | {"dirzetak",2,(void*)dirzetak,6,"GG"}, 6 | {"divisors",18,(void*)divisors,4,"G"}, 7 | -{"divrem",2,(void*)divrem,1,"GGDn"}, 8 | +{"divrem",99,(void*)divrem,1,"GGDn"}, 9 | {"eint1",99,(void*)veceint1,3,"GDGp"}, 10 | {"elladd",3,(void*)addell,5,"GGG"}, 11 | {"ellak",2,(void*)akell,5,"GG"}, 12 | @@ -2124,7 +2124,7 @@ entree functions_basic[]={ 13 | {"idealfactor",2,(void*)idealfactor,6,"GG"}, 14 | {"idealhnf",99,(void*)idealhnf0,6,"GGDG"}, 15 | {"idealintersect",3,(void*)idealintersect,6,"GGG"}, 16 | -{"idealinv",25,(void*)idealinv,6,"GG"}, 17 | +{"idealinv",2,(void*)idealinv,6,"GG"}, 18 | {"ideallist",99,(void*)ideallist0,6,"GLD4,L,"}, 19 | {"ideallistarch",99,(void*)ideallistarch0,6,"GGDGD0,L,"}, 20 | {"ideallog",3,(void*)zideallog,6,"GGG"}, 21 | @@ -2132,7 +2132,7 @@ entree functions_basic[]={ 22 | {"idealmul",99,(void*)idealmul0,6,"GGGD0,L,p"}, 23 | {"idealnorm",2,(void*)idealnorm,6,"GG"}, 24 | {"idealpow",99,(void*)idealpow0,6,"GGGD0,L,p"}, 25 | -{"idealprimedec",29,(void*)primedec,6,"GG"}, 26 | +{"idealprimedec",2,(void*)primedec,6,"GG"}, 27 | {"idealprincipal",2,(void*)principalideal,6,"GG"}, 28 | {"idealred",99,(void*)ideallllred,6,"GGDGp"}, 29 | {"idealstar",99,(void*)idealstar0,6,"GGD1,L,"}, 30 | -------------------------------------------------------------------------------- /scripts/Crypt/Random/Provider/File.pm: -------------------------------------------------------------------------------- 1 | package Crypt::Random::Provider::File; 2 | use strict; 3 | use Carp; 4 | use Math::Pari qw(pari2num); 5 | use Fcntl; 6 | 7 | sub _defaultsource { 8 | return; 9 | } 10 | 11 | 12 | sub new { 13 | 14 | my ($class, %args) = @_; 15 | my $self = { Source => $args{File} || $args{Device} || $args{Filename} || $class->_defaultsource() }; 16 | return bless $self, $class; 17 | 18 | } 19 | 20 | 21 | sub get_data { 22 | 23 | my ($self, %params) = @_; 24 | $self = {} unless ref $self; 25 | 26 | my $size = $params{Size}; 27 | my $skip = $params{Skip} || $$self{Skip} || ''; 28 | my $q_skip = quotemeta($skip); 29 | 30 | if ($size && ref $size eq "Math::Pari") { 31 | $size = pari2num($size); 32 | } 33 | 34 | my $bytes = $params{Length} || (int($size / 8) + 1); 35 | 36 | sysopen RANDOM, $$self{Source}, O_RDONLY; 37 | 38 | my($r, $read, $rt) = ('', 0); 39 | while ($read < $bytes) { 40 | my $howmany = sysread RANDOM, $rt, $bytes - $read; 41 | next unless $howmany; 42 | if ($howmany == -1) { 43 | croak "Error while reading from $$self{Source}. $!" 44 | } 45 | $rt =~ s/[$q_skip]//g if $skip; 46 | $r .= $rt; 47 | $read = length $r; 48 | } 49 | 50 | $r; 51 | 52 | } 53 | 54 | 55 | sub available { 56 | my ($class) = @_; 57 | return -e $class->_defaultsource(); 58 | } 59 | 60 | 61 | 1; 62 | 63 | -------------------------------------------------------------------------------- /inc/stride.h: -------------------------------------------------------------------------------- 1 | #ifndef STRIDE_H 2 | #define STRIDE_H 3 | 4 | #include 5 | #include 6 | #include "prefetcher.h" 7 | 8 | using namespace std; 9 | 10 | class Tracker 11 | { 12 | public: 13 | uint64_t pc; 14 | uint64_t last_cl_addr; 15 | int64_t last_stride; 16 | 17 | Tracker() 18 | { 19 | pc = 0; 20 | last_cl_addr = 0; 21 | last_stride = 0; 22 | }; 23 | }; 24 | 25 | class StridePrefetcher : public Prefetcher 26 | { 27 | private: 28 | deque trackers; 29 | 30 | /* stats */ 31 | struct 32 | { 33 | struct 34 | { 35 | uint64_t lookup; 36 | uint64_t evict; 37 | uint64_t insert; 38 | uint64_t hit; 39 | } tracker; 40 | 41 | struct 42 | { 43 | uint64_t pos; 44 | uint64_t neg; 45 | uint64_t zero; 46 | } stride; 47 | 48 | struct 49 | { 50 | uint64_t stride_match; 51 | uint64_t generated; 52 | } pref; 53 | 54 | } stats; 55 | 56 | private: 57 | void init_knobs(); 58 | void init_stats(); 59 | uint32_t generate_prefetch(uint64_t address, int32_t stride, vector &pref_addr); 60 | 61 | public: 62 | StridePrefetcher(string type); 63 | ~StridePrefetcher(); 64 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, vector &pref_addr); 65 | void dump_stats(); 66 | void print_config(); 67 | }; 68 | 69 | 70 | #endif /* STRIDE_H */ 71 | -------------------------------------------------------------------------------- /inc/spp_dev2.h: -------------------------------------------------------------------------------- 1 | #ifndef SPP_DEV2_H 2 | #define SPP_DEV2_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "prefetcher.h" 8 | #include "spp_dev2_helper.h" 9 | #include "cache.h" 10 | //using namespace spp; 11 | 12 | /* SPP Prefetcher */ 13 | class SPP_dev2 : public Prefetcher 14 | { 15 | private: 16 | CACHE *m_parent_cache; 17 | SIGNATURE_TABLE ST; 18 | PATTERN_TABLE PT; 19 | PREFETCH_FILTER FILTER; 20 | GLOBAL_REGISTER GHR; 21 | 22 | /* stats by rbera */ 23 | struct 24 | { 25 | struct 26 | { 27 | uint64_t total; 28 | uint64_t at_L2; 29 | uint64_t at_LLC; 30 | } pref; 31 | 32 | struct 33 | { 34 | uint64_t count; 35 | uint64_t total; 36 | uint64_t max; 37 | uint64_t min; 38 | } depth; 39 | 40 | struct 41 | { 42 | uint64_t count; 43 | uint64_t total; 44 | uint64_t max; 45 | uint64_t min; 46 | } breadth; 47 | } stats; 48 | 49 | unordered_map delta_histogram; 50 | unordered_map > depth_delta_histogram; 51 | 52 | private: 53 | void init_knobs(); 54 | void init_stats(); 55 | 56 | public: 57 | SPP_dev2(std::string type, CACHE *cache); 58 | ~SPP_dev2(); 59 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, std::vector &pref_addr); 60 | void dump_stats(); 61 | void print_config(); 62 | void cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr); 63 | }; 64 | 65 | #endif /* SPP_DEV2_H */ 66 | 67 | -------------------------------------------------------------------------------- /scripts/Math/utils/notes: -------------------------------------------------------------------------------- 1 | Most of these remarks are related to unknown versions of Math::Pari 2 | and/or GP/PARI. 3 | 4 | Need an additional field to ep_produce: where parsing ended. 5 | fmt_nb only a placeholder. 6 | NOEXP2 needs to be fixed. 7 | init_opts declared in gp/gp.h. 8 | wrong dependence for none/kernel0.o 9 | Need to use $(AS) on sparcs, alpha, hppa. 10 | 11 | changevalue() and installep() are statics. 12 | numvar() disappeared. 13 | l0asm.c, Gnuplot.h, plotport.c anal.h, init.c, anal.c edited. 14 | 15 | Add for -g: 16 | 17 | dummy$(OBJ_EXT): pariinl.h 18 | $(CCCMD) $(CCCDLFLAGS) $(DEFINE) -o $@ pariinl.h 19 | 20 | pariinl.c: pariinl.h 21 | $(CPP) -I. $(INC) -I../../src/kernel/ix86/ $(DEFINE) $(CPPMINUS) < ../../src/kernel/none/level0.c | perl -ne "s/%s+/%/g; print unless /^s*#/" > $@ 22 | 23 | dummy$(OBJ_EXT): pariinl.c 24 | $(CCCMD) $(CCCDLFLAGS) $(DEFINE) -o $@ pariinl.c 25 | 26 | install() installs at the head of the chain, but findentry() expects 27 | that the installed entry goes into the end of the chain. 28 | 29 | err_recover() was flush()ing before giving the caller the possibility to 30 | die(). 31 | 32 | coinit() assumes that a long can be put in 9 chars ?! 33 | p-adic was outputting extra space. 34 | 35 | bruteall() was overwriting old sp. 36 | 37 | a) T_PariPtr (to process &) is not implemented. 38 | 1) Lookup for autoloaded functions happens too early: after 39 | functions_hash, but before gp_hash. Say, `kill' wants to be autoloaded. 40 | 2) default() uses a static. 41 | 3) tests/analyz does not check answers... 42 | -------------------------------------------------------------------------------- /scripts/Math/t/PlotRect.t: -------------------------------------------------------------------------------- 1 | #! perl -w 2 | use Math::Pari ':all'; 3 | 4 | if ($ENV{MP_NOGNUPLOT}) { 5 | print "1..0 # skipped: per MP_NOGNUPLOT\n"; 6 | exit; 7 | } 8 | unless (Math::Pari::have_highlevel()) { 9 | print STDERR "# This build has no highlevel functions, ignoring the test\n"; 10 | print "1..0 # skipped: this build has no highlevel functions\n"; 11 | exit; 12 | } 13 | eval { link_gnuplot() }; 14 | if ($@ =~ m%^Can't locate Term/Gnuplot.pm in \@INC%) { 15 | print STDERR "# Can't locate Term/Gnuplot.pm in \@INC, ignoring the test\n"; 16 | print "1..0 # skipped: Can't locate Term/Gnuplot.pm in \@INC\n"; 17 | exit; 18 | } elsif ($@) { 19 | die $@; 20 | } else { 21 | print "1..1\n"; 22 | } 23 | setprecision 9; 24 | $x = PARIvar 'x'; 25 | 26 | $t = plothsizes(); 27 | die if Math::Pari::typ($t) < 17; 28 | $w=floor($t->[0]*0.42)-1; 29 | $h=floor($t->[1]*0.42)-1; 30 | $dw=floor($t->[0]*0.05)+1; 31 | $dh=floor($t->[1]*0.05)+1; 32 | plotinit(2, 2*$w+10, 2*$h+10); 33 | plotinit(3, $w, $h); 34 | plotrecth(3, $x, -5, 5, sub {sin($x)}, 2, 0); 35 | plotcopy(3, 2, $dw, $dh); 36 | plotinit(3, $w, $h); 37 | plotrecth(3, $x, -5, 5, sub {[sin($x),cos(2*$x)]}, 0, 0); 38 | plotcopy(3, 2, $w + 2*$dw, $dh); 39 | plotinit(3, $w, $h); 40 | plotrecth(3, $x, -5, 5, sub {[sin(3*$x), cos(2*$x)]}, 1, 0); 41 | plotcopy(3, 2, $dw, $h + 2*$dh); 42 | plotinit(3, $w, $h); 43 | plotrecth(3, $x, -5, 5, sub {[sin($x), cos($x), sin(3*$x),cos(2*$x)]}, 1, 0); 44 | plotcopy(3, 2, $w+2*$dw, $h+2*$dh); 45 | plotdraw([2, 0, 0]); 46 | 47 | print "ok 1\n"; 48 | print STDERR "Press ENTER\n"; 49 | <>; 50 | -------------------------------------------------------------------------------- /inc/streamer.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMER_H 2 | #define STREAMER_H 3 | 4 | #include 5 | #include "prefetcher.h" 6 | using namespace std; 7 | 8 | class Stream_Tracker 9 | { 10 | public: 11 | uint64_t page; 12 | uint32_t last_offset; 13 | int32_t last_dir; /* +1 means +ve stream, -1 means -ve stream, 0: init */ 14 | uint8_t conf; 15 | 16 | public: 17 | Stream_Tracker(uint64_t _page, uint32_t _last_offset) 18 | { 19 | page = _page; 20 | last_offset = _last_offset; 21 | last_dir = 0; 22 | conf = 0; 23 | } 24 | ~Stream_Tracker(){} 25 | }; 26 | 27 | class Streamer : public Prefetcher 28 | { 29 | private: 30 | deque trackers; 31 | 32 | struct 33 | { 34 | uint64_t called; 35 | struct 36 | { 37 | uint64_t missed; 38 | uint64_t evict; 39 | uint64_t insert; 40 | uint64_t hit; 41 | uint64_t same_offset; 42 | uint64_t dir_match; 43 | uint64_t dir_mismatch; 44 | } tracker; 45 | struct 46 | { 47 | uint64_t dir_match; 48 | uint64_t total; 49 | } pred; 50 | } stats; 51 | 52 | private: 53 | void init_knobs(); 54 | void init_stats(); 55 | 56 | public: 57 | Streamer(string type); 58 | ~Streamer(); 59 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, vector &pref_addr); 60 | void dump_stats(); 61 | void print_config(); 62 | }; 63 | 64 | #endif /* STREAMER_H */ 65 | 66 | -------------------------------------------------------------------------------- /scripts/Math/typemap: -------------------------------------------------------------------------------- 1 | # $Id: typemap,v 1.1 1994/11/21 03:02:46 ilya Exp ilya $ 2 | 3 | GEN T_Pari 4 | GENCOL T_PariCol 5 | GENMAT T_PariMat 6 | bool T_bool 7 | PariVar T_PariVar 8 | PariExpr T_PariExpr 9 | PariExpr2 T_PariExpr2 10 | PariName T_PariName 11 | 12 | ################################ 13 | 14 | INPUT 15 | 16 | T_Pari 17 | $var = sv2pari($arg) 18 | T_PariCol 19 | $var = sv2pari($arg); 20 | if (typ($var) != T_VEC) croak("Not a vector when vector-column expected"); 21 | settyp($var, T_COL) 22 | T_PariMat 23 | $var = sv2parimat($arg) 24 | T_bool 25 | $var = SvTRUE($arg) 26 | T_PariVar 27 | $var = bindVariable($arg) 28 | T_PariName 29 | $var = findVariable($arg, 0) 30 | T_PariExpr 31 | AssignPariExpr($var,$arg) 32 | T_PariExpr2 33 | AssignPariExpr2($var,$arg) 34 | 35 | 36 | ################################ 37 | 38 | OUTPUT 39 | 40 | T_bool 41 | $arg=$var? &sv_yes : &sv_no; 42 | 43 | ##### We put an address into SvIV(SvRV). We also need to keep oldavma 44 | ##### and previous SV on the Pari stack. If previous SV is NULL, the 45 | ##### corresponding GEN is moved off the stack. If it is PariStack, 46 | ##### then this SV is the first Perl value put on the stack. 47 | 48 | ##### The result of sv_setref_pv is reference to PVMG. We put previous 49 | ##### SV into xpv_pv, and offset of oldavma into xpv_cur. 50 | 51 | T_Pari 52 | setSVpari($arg, $var, oldavma); 53 | T_PariCol 54 | setSVpari($arg, $var, oldavma); 55 | T_PariMat 56 | setSVpari($arg, $var, oldavma); 57 | T_PariVar 58 | Not Supported; 59 | T_PariName 60 | Not Supported; 61 | T_PariExpr 62 | Not Supported; 63 | -------------------------------------------------------------------------------- /inc/bop.h: -------------------------------------------------------------------------------- 1 | #ifndef BOP_H 2 | #define BOP_H 3 | 4 | #include 5 | #include 6 | #include "prefetcher.h" 7 | using namespace std; 8 | 9 | class BOPrefetcher : public Prefetcher 10 | { 11 | private: 12 | deque rr; 13 | vector scores; 14 | deque pref_buffer; 15 | 16 | uint32_t round_counter; 17 | uint32_t candidate_ptr; 18 | vector best_offsets; 19 | 20 | struct 21 | { 22 | struct 23 | { 24 | uint64_t max_round; 25 | uint64_t max_score; 26 | } end_phase; 27 | 28 | struct 29 | { 30 | uint64_t called; 31 | uint64_t insert_rr; 32 | } fill; 33 | 34 | struct 35 | { 36 | uint64_t hit; 37 | uint64_t evict; 38 | uint64_t insert; 39 | } insert_rr; 40 | 41 | struct 42 | { 43 | uint64_t buffered; 44 | uint64_t spilled; 45 | uint64_t issued; 46 | } pref_buffer; 47 | 48 | uint64_t total_phases; 49 | uint64_t pref_issued; 50 | } stats; 51 | 52 | private: 53 | void init_knobs(); 54 | void init_stats(); 55 | 56 | bool check_end_of_phase(); 57 | void phase_end(); 58 | bool search_rr(uint64_t address); 59 | void buffer_prefetch(vector pref_addr); 60 | void issue_prefetch(vector &pref_addr); 61 | void insert_rr(uint64_t address); 62 | 63 | public: 64 | BOPrefetcher(string type); 65 | ~BOPrefetcher(); 66 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, vector &pref_addr); 67 | void register_fill(uint64_t address); 68 | void dump_stats(); 69 | void print_config(); 70 | }; 71 | 72 | #endif /* BOP_H */ 73 | 74 | -------------------------------------------------------------------------------- /scripts/Math/libPARI/extract_codes.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -wn 2 | BEGIN { 3 | @ARGV = ("$ARGV[0]/src/language/init.c", "$ARGV[0]/src/gp/highlvl.c") 4 | if @ARGV == 1; 5 | @ARGV == 2 or die <) { 11 | die < $b} keys %descr) { 31 | next if $k == 99; 32 | if (@{$descr{$k}} > 1) { 33 | warn "Multiple descriptors for code $k: @{$descr{$k}}\n" 34 | if $k; 35 | } elsif (@{$descr{$k}} == 0){ 36 | warn "Empty descriptors for code $k." 37 | } elsif (exists $expected{$k} and $expected{$k} ne $descr{$k}[0]){ 38 | warn < 2 | #include "learning_engine_base.h" 3 | 4 | const char* PolicyString[] = {"EGreddy"}; 5 | const char* MapPolicyString(Policy policy) 6 | { 7 | assert((uint32_t)policy < Policy::NumPolicies); 8 | return PolicyString[(uint32_t)policy]; 9 | } 10 | 11 | const char* LearningTypeString[] = {"QLearning", "SARSA"}; 12 | const char* MapLearningTypeString(LearningType type) 13 | { 14 | assert((uint32_t)type < LearningType::NumLearningTypes); 15 | return LearningTypeString[(uint32_t)type]; 16 | } 17 | 18 | LearningEngineBase::LearningEngineBase(Prefetcher *parent, float alpha, float gamma, float epsilon, uint32_t actions, uint32_t states, uint64_t seed, std::string policy, std::string type) 19 | : m_parent(parent) 20 | , m_alpha(alpha) 21 | , m_gamma(gamma) 22 | , m_epsilon(epsilon) // make it small, as true value indicates exploration 23 | , m_actions(actions) 24 | , m_states(states) 25 | , m_seed(seed) 26 | , m_policy(parsePolicy(policy)) 27 | , m_type(parseLearningType(type)) 28 | { 29 | 30 | } 31 | 32 | LearningType LearningEngineBase::parseLearningType(std::string str) 33 | { 34 | if(!str.compare("QLearning")) return LearningType::QLearning; 35 | if(!str.compare("SARSA")) return LearningType::SARSA; 36 | 37 | printf("unsupported learning_type %s\n", str.c_str()); 38 | assert(false); 39 | return LearningType::InvalidLearningType; 40 | } 41 | 42 | Policy LearningEngineBase::parsePolicy(std::string str) 43 | { 44 | if(!str.compare("EGreedy")) return Policy::EGreedy; 45 | 46 | printf("unsupported policy %s\n", str.c_str()); 47 | assert(false); 48 | return Policy::InvalidPolicy; 49 | } -------------------------------------------------------------------------------- /inc/ipcp_L2.h: -------------------------------------------------------------------------------- 1 | #ifndef IPCP_L2_H 2 | #define IPCP_L2_H 3 | 4 | /***************************************************** 5 | Code taken from 6 | Samuel Pakalapati - pakalapatisamuel@gmail.com 7 | Biswabandan Panda - biswap@cse.iitk.ac.in 8 | ******************************************************/ 9 | 10 | #include "cache.h" 11 | #include "prefetcher.h" 12 | #include "ipcp_vars.h" 13 | 14 | class IP_TRACKER 15 | { 16 | public: 17 | uint64_t ip_tag; 18 | uint16_t ip_valid; 19 | uint32_t pref_type; // prefetch class type 20 | int stride; // last stride sent by metadata 21 | 22 | IP_TRACKER () { 23 | ip_tag = 0; 24 | ip_valid = 0; 25 | pref_type = 0; 26 | stride = 0; 27 | }; 28 | }; 29 | 30 | class IPCP_L2 : public Prefetcher 31 | { 32 | public: 33 | CACHE *m_parent_cache; 34 | uint32_t spec_nl_l2[NUM_CPUS] = {0}; 35 | IP_TRACKER trackers[NUM_CPUS][NUM_IP_TABLE_L2_ENTRIES]; 36 | 37 | private: 38 | void init_knobs(); 39 | void init_stats(); 40 | int decode_stride(uint32_t metadata); 41 | 42 | public: 43 | IPCP_L2(std::string type, CACHE *cache); 44 | ~IPCP_L2(); 45 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, std::vector &pref_addr) {} 46 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, uint32_t metadata_in, std::vector &pref_addr); 47 | void dump_stats(); 48 | void print_config(); 49 | void cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr); 50 | }; 51 | 52 | #endif /* IPCP_L2_H */ 53 | -------------------------------------------------------------------------------- /scripts/download_traces.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use warnings; 4 | use Getopt::Long; 5 | 6 | die "\$PYTHIA_HOME env variable is not defined.\nHave you sourced setvars.sh?\n" unless defined $ENV{'PYTHIA_HOME'}; 7 | 8 | my $megatool_exe = "$ENV{'PYTHIA_HOME'}/scripts/megatools-1.11.1.20230212-linux-x86_64/megatools"; 9 | my $input_file; 10 | my $dir="."; 11 | GetOptions('csv=s' => \$input_file, 12 | 'dir=s' => \$dir, 13 | ) or die "Usage $0 --csv --dir \n"; 14 | 15 | die "Supply csv file with --csv" unless defined $input_file; 16 | 17 | open(my $fh, '<', $input_file) or die "Could not open $input_file\n"; 18 | chomp(my @lines = <$fh>); 19 | close($fh); 20 | 21 | foreach my $line (@lines) 22 | { 23 | my @tokens = split(',', trim($line)); 24 | $trace_file_name = trim($tokens[0]); 25 | $trace_file_url = trim($tokens[1]); 26 | print "Downloading $trace_file_name...\n"; 27 | my $cmd; 28 | if($trace_file_url =~ /mega\.nz/) 29 | { 30 | $cmd = "$megatool_exe dl --path=$dir $trace_file_url"; 31 | } 32 | else 33 | { 34 | $cmd = "wget --no-check-certificate $trace_file_url -O $dir/$trace_file_name"; 35 | } 36 | system($cmd); 37 | #print("$cmd\n"); 38 | } 39 | 40 | my $total_traces = `wc -l $input_file | awk '{print \$1}'`; 41 | my $downloaded = `ls -1 $dir | wc -l`; 42 | chomp($total_traces); 43 | chomp($downloaded); 44 | 45 | print "\n"; 46 | print "================================\n"; 47 | print "Trace downloading completed\n"; 48 | print "Downloaded $downloaded/$total_traces traces\n"; 49 | print "================================\n"; 50 | 51 | sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s }; 52 | -------------------------------------------------------------------------------- /scripts/Math/PariInit.pm: -------------------------------------------------------------------------------- 1 | package Math::Pari; 2 | 3 | my %shift = ( k => 10, K => 10, m => 20, M => 20, g => 30, G=> 30); 4 | 5 | sub _human2decimal { 6 | local $_ = shift; 7 | $_ <<= $shift{$1} if s/([kmg])$//i; 8 | $_ 9 | } 10 | 11 | sub Math::PariInit::import { 12 | my $seen; 13 | CORE::shift; 14 | my @args = map { 15 | /^:?(primes|stack)=(\d+((\.\d*)?[eE][-+]?\d+)?)[kKmMgG]?$/ 16 | ? do { ($1 eq 'primes' ? $initprimes : $initmem) = _human2decimal $2; 17 | $seen++; 18 | () } 19 | : $_ 20 | } @_; 21 | if ($seen && defined &Math::Pari::pari2iv) { 22 | require Carp; 23 | Carp::croak( 24 | "Can't set primelimit and stack size after Math::Pari is loaded") 25 | } 26 | require Math::Pari; 27 | @_ = ('Math::Pari', @args); 28 | goto &Math::Pari::import; 29 | } 30 | 31 | 1; 32 | 33 | package Math::PariInit; # Otherwise MetaCPAN parser would confuse this with Math::Pari docs 34 | 35 | =head1 NAME 36 | 37 | Math::PariInit - load C with specified $primelimit and $initmem. 38 | 39 | =head1 SYNOPSIS 40 | 41 | use Math::PariInit qw(:DEFAULT :int primes=1.2e7 stack=1e7 prime) 42 | $bigprime = prime(500000); 43 | 44 | =head1 DESCRIPTION 45 | 46 | C takes the same arguments as C 47 | with the addition of C<:primes=I> and C<:stack=I> which 48 | specify up to which number the initial list of primes should be 49 | precalculated, and how large should be the arena for PARI calculations. 50 | 51 | The arguments C and C cannot be specified if 52 | Math::Pari is already loaded. Use setprimelimit() and allocatemem() instead. 53 | 54 | 55 | =head1 AUTHOR 56 | 57 | Ilya Zakharevich L 58 | 59 | =cut 60 | 61 | -------------------------------------------------------------------------------- /inc/learning_engine_base.h: -------------------------------------------------------------------------------- 1 | #ifndef LEARNING_ENGINE_BASE_H 2 | #define LEARNING_ENGINE_BASE_H 3 | 4 | #include "prefetcher.h" 5 | 6 | #define MAX_ACTIONS 64 7 | 8 | enum Policy 9 | { 10 | InvalidPolicy = 0, 11 | EGreedy, 12 | 13 | NumPolicies 14 | }; 15 | 16 | enum LearningType 17 | { 18 | InvalidLearningType = 0, 19 | QLearning, 20 | SARSA, 21 | 22 | NumLearningTypes 23 | }; 24 | 25 | const char* MapPolicyString(Policy policy); 26 | const char* MapLearningTypeString(LearningType type); 27 | 28 | class LearningEngineBase 29 | { 30 | protected: 31 | Prefetcher *m_parent; 32 | float m_alpha; 33 | float m_gamma; 34 | float m_epsilon; 35 | uint32_t m_actions; 36 | uint32_t m_states; 37 | uint64_t m_seed; 38 | Policy m_policy; 39 | LearningType m_type; 40 | 41 | protected: 42 | LearningType parseLearningType(std::string str); 43 | Policy parsePolicy(std::string str); 44 | 45 | public: 46 | LearningEngineBase(Prefetcher *p, float alpha, float gamma, float epsilon, uint32_t actions, uint32_t states, uint64_t seed, std::string policy, std::string type); 47 | virtual ~LearningEngineBase(){}; 48 | virtual void dump_stats() = 0; 49 | 50 | inline void setAlpha(float alpha){m_alpha = alpha;} 51 | inline float getAlpha(){return m_alpha;} 52 | inline void setGamma(float gamma){m_gamma = gamma;} 53 | inline float getGamma(){return m_gamma;} 54 | inline void setEpsilon(float epsilon){m_epsilon = epsilon;} 55 | inline float getEpsilon(){return m_epsilon;} 56 | inline void setStates(uint32_t states){m_states = states;} 57 | inline uint32_t getStates(){return m_states;} 58 | inline void setActions(uint32_t actions){m_actions = actions;} 59 | inline uint32_t getActions(){return m_actions;} 60 | }; 61 | 62 | #endif /* LEARNING_ENGINE_BASE_H */ 63 | 64 | -------------------------------------------------------------------------------- /replacement/lru.llc_repl: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | // initialize replacement state 4 | void CACHE::llc_initialize_replacement(uint64_t rand_seed) 5 | { 6 | 7 | } 8 | 9 | // find replacement victim 10 | uint32_t CACHE::llc_find_victim(uint32_t cpu, uint64_t instr_id, uint32_t set, const BLOCK *current_set, uint64_t ip, uint64_t full_addr, uint32_t type) 11 | { 12 | // baseline LRU 13 | return lru_victim(cpu, instr_id, set, current_set, ip, full_addr, type); 14 | } 15 | 16 | // called on every cache hit and cache fill 17 | void CACHE::llc_update_replacement_state(uint32_t cpu, uint32_t set, uint32_t way, uint64_t full_addr, uint64_t ip, uint64_t victim_addr, uint32_t type, uint8_t hit) 18 | { 19 | string TYPE_NAME; 20 | if (type == LOAD) 21 | TYPE_NAME = "LOAD"; 22 | else if (type == RFO) 23 | TYPE_NAME = "RFO"; 24 | else if (type == PREFETCH) 25 | TYPE_NAME = "PF"; 26 | else if (type == WRITEBACK) 27 | TYPE_NAME = "WB"; 28 | else 29 | assert(0); 30 | 31 | if (hit) 32 | TYPE_NAME += "_HIT"; 33 | else 34 | TYPE_NAME += "_MISS"; 35 | 36 | if ((type == WRITEBACK) && ip) 37 | assert(0); 38 | 39 | // uncomment this line to see the LLC accesses 40 | // cout << "CPU: " << cpu << " LLC " << setw(9) << TYPE_NAME << " set: " << setw(5) << set << " way: " << setw(2) << way; 41 | // cout << hex << " paddr: " << setw(12) << paddr << " ip: " << setw(8) << ip << " victim_addr: " << victim_addr << dec << endl; 42 | 43 | // baseline LRU 44 | if (hit && (type == WRITEBACK)) // writeback hit does not update LRU state 45 | return; 46 | 47 | return lru_update(set, way); 48 | } 49 | 50 | void CACHE::llc_replacement_final_stats() 51 | { 52 | 53 | } 54 | -------------------------------------------------------------------------------- /replacement/llc_replacement.cc: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | // initialize replacement state 4 | void CACHE::llc_initialize_replacement(uint64_t rand_seed) 5 | { 6 | 7 | } 8 | 9 | // find replacement victim 10 | uint32_t CACHE::llc_find_victim(uint32_t cpu, uint64_t instr_id, uint32_t set, const BLOCK *current_set, uint64_t ip, uint64_t full_addr, uint32_t type) 11 | { 12 | // baseline LRU 13 | return lru_victim(cpu, instr_id, set, current_set, ip, full_addr, type); 14 | } 15 | 16 | // called on every cache hit and cache fill 17 | void CACHE::llc_update_replacement_state(uint32_t cpu, uint32_t set, uint32_t way, uint64_t full_addr, uint64_t ip, uint64_t victim_addr, uint32_t type, uint8_t hit) 18 | { 19 | string TYPE_NAME; 20 | if (type == LOAD) 21 | TYPE_NAME = "LOAD"; 22 | else if (type == RFO) 23 | TYPE_NAME = "RFO"; 24 | else if (type == PREFETCH) 25 | TYPE_NAME = "PF"; 26 | else if (type == WRITEBACK) 27 | TYPE_NAME = "WB"; 28 | else 29 | assert(0); 30 | 31 | if (hit) 32 | TYPE_NAME += "_HIT"; 33 | else 34 | TYPE_NAME += "_MISS"; 35 | 36 | if ((type == WRITEBACK) && ip) 37 | assert(0); 38 | 39 | // uncomment this line to see the LLC accesses 40 | // cout << "CPU: " << cpu << " LLC " << setw(9) << TYPE_NAME << " set: " << setw(5) << set << " way: " << setw(2) << way; 41 | // cout << hex << " paddr: " << setw(12) << paddr << " ip: " << setw(8) << ip << " victim_addr: " << victim_addr << dec << endl; 42 | 43 | // baseline LRU 44 | if (hit && (type == WRITEBACK)) // writeback hit does not update LRU state 45 | return; 46 | 47 | return lru_update(set, way); 48 | } 49 | 50 | void CACHE::llc_replacement_final_stats() 51 | { 52 | 53 | } 54 | -------------------------------------------------------------------------------- /scripts/gen_feature_exps.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use lib '/mnt/panzer/rahbera/ChampSim/scripts'; 4 | use warnings; 5 | use Math::Combinatorics; 6 | 7 | my @feature_names = ("PC", "Offset", "Delta", "Address", "PC_Offset", "PC_Address", "PC_Page", "PC_Path", "Delta_Path", "Offset_Path", "PC_Delta", "PC_Offset_Delta", "Page", "PC_Path_Offset", "PC_Path_Offset_Path", "PC_Path_Delta", "PC_Path_Delta_Path", "PC_Path_Offset_Path_Delta_Path", "Offset_Path_PC", "Delta_Path_PC"); 8 | 9 | ############# CHANGE ONLY THESE PARAMS ############# 10 | my @selected_features = ("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"); 11 | my @num_combs = ("1", "2"); 12 | my $tilings = 3; 13 | my $tiles = 128; 14 | #################################################### 15 | 16 | foreach $num_comb (@num_combs) 17 | { 18 | my $num_tilings = join(",", ($tilings)x$num_comb); 19 | my $num_tlies = join(",", ($tiles)x$num_comb); 20 | my $hash_types = join(",", (2)x$num_comb); 21 | my $enable_tiling_offset = join(",", (1)x$num_comb); 22 | my $weights = join(",", (1)x$num_comb); 23 | my $cmdline = "--le_featurewise_num_tilings=$num_tilings --le_featurewise_num_tiles=$num_tlies --le_featurewise_hash_types=$hash_types --le_featurewise_enable_tiling_offset=$enable_tiling_offset --le_featurewise_feature_weights=$weights"; 24 | 25 | my @combinations = combine($num_comb, @selected_features); 26 | 27 | print "#Combinations using $num_comb features\n"; 28 | foreach my $combo (@combinations) 29 | { 30 | my @combo2 = @$combo; 31 | $sel_feat_ids = join(",", @combo2); 32 | $sel_feat_names = join("+", map { $feature_names[$_] } @combo2); 33 | $exp_name = "scooby_${sel_feat_names}_${tilings}x${tiles}"; 34 | print "${exp_name} \$(BASE) \$(SCOOBY) --le_featurewise_active_features=${sel_feat_ids} $cmdline\n"; 35 | } 36 | print "\n"; 37 | } 38 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | app = champsim 2 | 3 | srcExt = cc 4 | srcDir = src branch replacement prefetcher 5 | objDir = obj 6 | binDir = bin 7 | inc = inc 8 | 9 | debug = 1 10 | 11 | CFlags = -Wall -O3 -std=c++11 -D_DEFAULT_SOURCE -I./libbf/ 12 | LDFlags = ./libbf/build/lib/libbf.a 13 | libs = 14 | libDir = 15 | 16 | 17 | #************************ DO NOT EDIT BELOW THIS LINE! ************************ 18 | 19 | ifeq ($(debug),1) 20 | debug=-g 21 | else 22 | debug= 23 | endif 24 | inc := $(addprefix -I,$(inc)) 25 | libs := $(addprefix -l,$(libs)) 26 | libDir := $(addprefix -L,$(libDir)) 27 | CFlags += -c $(debug) $(inc) $(libDir) $(libs) 28 | sources := $(shell find $(srcDir) -name '*.$(srcExt)') 29 | srcDirs := $(shell find . -name '*.$(srcExt)' -exec dirname {} \; | uniq) 30 | objects := $(patsubst %.$(srcExt),$(objDir)/%.o,$(sources)) 31 | 32 | ifeq ($(srcExt),cc) 33 | CC = $(CXX) 34 | else 35 | CFlags += -std=gnu99 36 | endif 37 | 38 | .phony: all clean distclean 39 | 40 | 41 | all: $(binDir)/$(app) 42 | 43 | $(binDir)/$(app): buildrepo $(objects) 44 | @mkdir -p `dirname $@` 45 | @echo "Linking $@..." 46 | @$(CC) $(objects) $(LDFlags) -o $@ 47 | 48 | $(objDir)/%.o: %.$(srcExt) 49 | @echo "Generating dependencies for $<..." 50 | @$(call make-depend,$<,$@,$(subst .o,.d,$@)) 51 | @echo "Compiling $<..." 52 | @$(CC) $(CFlags) $< -o $@ 53 | 54 | clean: 55 | $(RM) -r $(objDir) 56 | 57 | distclean: clean 58 | $(RM) -r $(binDir)/$(app) 59 | 60 | buildrepo: 61 | @$(call make-repo) 62 | 63 | define make-repo 64 | for dir in $(srcDirs); \ 65 | do \ 66 | mkdir -p $(objDir)/$$dir; \ 67 | done 68 | endef 69 | 70 | 71 | # usage: $(call make-depend,source-file,object-file,depend-file) 72 | define make-depend 73 | $(CC) -MM \ 74 | -MF $3 \ 75 | -MP \ 76 | -MT $2 \ 77 | $(CFlags) \ 78 | $1 79 | endef 80 | -------------------------------------------------------------------------------- /inc/ampm.h: -------------------------------------------------------------------------------- 1 | #ifndef AMPM_H 2 | #define AMPM_H 3 | 4 | #include 5 | #include 6 | #include "prefetcher.h" 7 | #include "bitmap.h" 8 | using namespace std; 9 | 10 | #define MAX_OFFSETS 64 11 | 12 | class AMPM_PB_Entry 13 | { 14 | public: 15 | uint64_t page_id; 16 | Bitmap bitmap; 17 | 18 | AMPM_PB_Entry() 19 | { 20 | page_id = 0xdeadbeef; 21 | bitmap.reset(); 22 | } 23 | ~AMPM_PB_Entry(){} 24 | }; 25 | 26 | 27 | class AMPM : public Prefetcher 28 | { 29 | private: 30 | deque page_buffer; 31 | deque pref_buffer; 32 | 33 | struct 34 | { 35 | uint64_t invoke_called; 36 | struct 37 | { 38 | uint64_t hit; 39 | uint64_t evict; 40 | uint64_t insert; 41 | } pb; 42 | 43 | struct 44 | { 45 | uint64_t pos_histogram[MAX_OFFSETS]; 46 | uint64_t neg_histogram[MAX_OFFSETS]; 47 | uint64_t total; 48 | uint64_t degree_reached_pos; 49 | uint64_t degree_reached_neg; 50 | } pred; 51 | 52 | struct 53 | { 54 | uint64_t hit; 55 | uint64_t dropped; 56 | uint64_t insert; 57 | uint64_t issued; 58 | } pref_buffer; 59 | 60 | struct 61 | { 62 | uint64_t total; 63 | } pref; 64 | 65 | } stats; 66 | 67 | private: 68 | void init_knobs(); 69 | void init_stats(); 70 | void buffer_prefetch(vector predicted_addrs); 71 | void issue_prefetch(vector &pref_addr); 72 | 73 | public: 74 | AMPM(string type); 75 | ~AMPM(); 76 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, vector &pref_addr); 77 | void dump_stats(); 78 | void print_config(); 79 | }; 80 | 81 | #endif /* AMPM_H */ 82 | 83 | -------------------------------------------------------------------------------- /branch/gshare.bpred: -------------------------------------------------------------------------------- 1 | #include "ooo_cpu.h" 2 | 3 | #define GLOBAL_HISTORY_LENGTH 14 4 | #define GLOBAL_HISTORY_MASK (1 << GLOBAL_HISTORY_LENGTH) - 1 5 | int branch_history_vector[NUM_CPUS]; 6 | 7 | #define GS_HISTORY_TABLE_SIZE 16384 8 | int gs_history_table[NUM_CPUS][GS_HISTORY_TABLE_SIZE]; 9 | int my_last_prediction[NUM_CPUS]; 10 | 11 | void O3_CPU::initialize_branch_predictor() 12 | { 13 | cout << "CPU " << cpu << " GSHARE branch predictor" << endl; 14 | 15 | branch_history_vector[cpu] = 0; 16 | my_last_prediction[cpu] = 0; 17 | 18 | for(int i=0; i>GLOBAL_HISTORY_LENGTH)^(ip>>(GLOBAL_HISTORY_LENGTH*2))^bh_vector; 25 | hash = hash%GS_HISTORY_TABLE_SIZE; 26 | 27 | //printf("%d\n", hash); 28 | 29 | return hash; 30 | } 31 | 32 | uint8_t O3_CPU::predict_branch(uint64_t ip) 33 | { 34 | int prediction = 1; 35 | 36 | int gs_hash = gs_table_hash(ip, branch_history_vector[cpu]); 37 | 38 | if(gs_history_table[cpu][gs_hash] >= 2) 39 | prediction = 1; 40 | else 41 | prediction = 0; 42 | 43 | my_last_prediction[cpu] = prediction; 44 | 45 | return prediction; 46 | } 47 | 48 | void O3_CPU::last_branch_result(uint64_t ip, uint8_t taken) 49 | { 50 | int gs_hash = gs_table_hash(ip, branch_history_vector[cpu]); 51 | 52 | if(taken == 1) { 53 | if(gs_history_table[cpu][gs_hash] < 3) 54 | gs_history_table[cpu][gs_hash]++; 55 | } else { 56 | if(gs_history_table[cpu][gs_hash] > 0) 57 | gs_history_table[cpu][gs_hash]--; 58 | } 59 | 60 | // update branch history vector 61 | branch_history_vector[cpu] <<= 1; 62 | branch_history_vector[cpu] &= GLOBAL_HISTORY_MASK; 63 | branch_history_vector[cpu] |= taken; 64 | } 65 | -------------------------------------------------------------------------------- /scripts/Math/MANIFEST: -------------------------------------------------------------------------------- 1 | Changes 2 | Pari.pm 3 | Pari.xs 4 | PariInit.pm 5 | MANIFEST 6 | INSTALL 7 | Makefile.PL 8 | README 9 | TODO 10 | func_codes.h 11 | libPARI/Makefile.PL 12 | libPARI/gphelp 13 | libPARI/gphelp-ini 14 | libPARI/extract_codes.pl 15 | libPARI/expected_codes 16 | libPARI/codes_2014 17 | libPARI/pre-noinline.h 18 | libPARI/post-noinline.h 19 | patches/diff_2.1.2_gccism 20 | patches/diff_2.1.3_interface 21 | patches/diff_2.1.4_interface 22 | patches/diff_2.2.2_interface 23 | patches/diff_pari-2.1.3-ix86-divl 24 | patches/diff_2.1.6_ploth64 25 | patches/diff_2.1.6_no-common 26 | patches/patch-pari-unnormalized-float 27 | patches/diff_2.1.7_restart 28 | patches/diff_2.1.7_-O 29 | patches/diff_2.1.7_div 30 | patches/diff_2.1.6_align_power_of_2 31 | patches/diff_2.1.7_mingw-w64 32 | patches/diff_2.3.5_mingw-w64 33 | patches/diff_2.3.5_stderr_clobber 34 | patches/diff_add_gnuplotNeeded 35 | patches/diff_add_gnuplotAdd 36 | patches/diff_add_gnuplotAll 37 | patches/diff-2.5.0-x-prototype 38 | patches/diff-2.5.0-exceptions 39 | patches/diff-2.5.5-exceptions 40 | patches/diff-2.5.0-tune_opt 41 | patches/diff-2.7.0-x-prototype 42 | patches/diff-2.7.0-exceptions 43 | patches/diff-2.7.0-reinstall-foreigh 44 | patches/diff-2.7.0-reinstall-foreigh-full 45 | patches/diff-2.9.0-all 46 | patches/diff-2.9.5-all 47 | patches/diff-2.11.0-all 48 | patches/diff_2.3.5_mingw_longlong 49 | t/000_load-problem.t 50 | t/00_Pari.t 51 | t/01_no_extra_newlines.t 52 | t/02_sections.t 53 | t/PlotRect.t 54 | t/zz_leak.t 55 | test_eng/Testout.pm 56 | test_eng/ex.t 57 | typemap 58 | utils/README 59 | utils/chap3_to_pod 60 | utils/comp_funcs.pl 61 | utils/foncpari.pl 62 | utils/inc.h 63 | utils/notes 64 | utils/paridoc_to_pod 65 | utils/Math/PariBuild.pm 66 | utils/inc_h.diff 67 | utils/01_no_extra_newlines.test 68 | META.yml Module meta-data (added by MakeMaker) 69 | META.json Module JSON meta-data (added by MakeMaker) 70 | gdbinit-my 71 | -------------------------------------------------------------------------------- /inc/next_line.h: -------------------------------------------------------------------------------- 1 | #ifndef NEXT_LINE 2 | #define NEXT_LINE 3 | 4 | #include 5 | #include 6 | #include "prefetcher.h" 7 | using namespace std; 8 | 9 | #define MAX_DELTAS 16 10 | 11 | class NL_PTEntry 12 | { 13 | public: 14 | uint64_t address; 15 | bool fill; 16 | int32_t timely; 17 | 18 | NL_PTEntry(uint64_t addr, bool f) : address(addr), fill(f), timely(-1) {} 19 | ~NL_PTEntry(){} 20 | }; 21 | 22 | class NextLinePrefetcher : public Prefetcher 23 | { 24 | private: 25 | deque prefetch_tracker; 26 | vector delta_probability; 27 | default_random_engine generator; 28 | uniform_real_distribution *deltagen; 29 | 30 | uint64_t trace_timestamp; 31 | uint32_t trace_interval; 32 | FILE *trace; 33 | 34 | struct 35 | { 36 | struct 37 | { 38 | uint64_t select[MAX_DELTAS]; 39 | uint64_t issue[MAX_DELTAS]; 40 | uint64_t out_of_bounds[MAX_DELTAS]; 41 | uint64_t tracker_hit[MAX_DELTAS]; 42 | } predict; 43 | 44 | struct 45 | { 46 | uint64_t called; 47 | uint64_t pt_miss; 48 | uint64_t evict; 49 | uint64_t insert; 50 | uint64_t pt_hit; 51 | } track; 52 | 53 | struct 54 | { 55 | uint64_t called; 56 | uint64_t fill; 57 | } register_fill; 58 | 59 | struct 60 | { 61 | uint64_t called; 62 | uint64_t hit; 63 | uint64_t timely; 64 | uint64_t untimely; 65 | } record_demand; 66 | 67 | struct 68 | { 69 | uint64_t total; 70 | uint64_t timely; 71 | uint64_t untimely; 72 | uint64_t incorrect; 73 | } pref; 74 | 75 | } stats; 76 | 77 | private: 78 | void init_knobs(); 79 | void init_stats(); 80 | bool track(uint64_t address); 81 | NL_PTEntry* search_pt(uint64_t address); 82 | void measure_stats(NL_PTEntry *ptentry); 83 | void record_demand(uint64_t address); 84 | uint32_t gen_delta(); 85 | 86 | public: 87 | NextLinePrefetcher(string type); 88 | ~NextLinePrefetcher(); 89 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, vector &pref_addr); 90 | void register_fill(uint64_t address); 91 | void dump_stats(); 92 | void print_config(); 93 | }; 94 | 95 | 96 | #endif /* NEXT_LINE */ 97 | 98 | -------------------------------------------------------------------------------- /inc/pref_power7.h: -------------------------------------------------------------------------------- 1 | #ifndef PREF_POWER7_H 2 | #define PREF_POWER7_H 3 | 4 | #include "prefetcher.h" 5 | #include "streamer.h" 6 | #include "stride.h" 7 | #include "cache.h" 8 | using namespace std; 9 | 10 | typedef enum 11 | { 12 | Default = 0, /* streamer degree 5, stride disabled */ 13 | Off, 14 | Shallowest, S_Shallowest, 15 | Shallow, S_Shallow, 16 | Medium, S_Medium, 17 | Deep, S_Deep, 18 | Deeper, S_Deeper, 19 | Deepest, S_Deepest, 20 | 21 | NumConfigs 22 | } Config; 23 | 24 | typedef enum 25 | { 26 | Explore = 0, 27 | Exploit, 28 | 29 | NumModes 30 | } Mode; 31 | 32 | class POWER7_Pref : public Prefetcher 33 | { 34 | public: 35 | CACHE *m_parent_cache; 36 | Config config; 37 | Mode mode; 38 | uint64_t access_counter; 39 | uint64_t cycle_stats[NumConfigs]; 40 | uint64_t cycle_stamp; 41 | StridePrefetcher *stride; 42 | Streamer *streamer; 43 | 44 | /* stats */ 45 | struct 46 | { 47 | uint64_t called; 48 | struct 49 | { 50 | uint64_t explore; 51 | uint64_t exploit; 52 | uint64_t explore_to_exploit; 53 | uint64_t exploit_to_explore; 54 | } mode; 55 | 56 | struct 57 | { 58 | uint64_t histogram[Config::NumConfigs][Mode::NumModes]; 59 | } config; 60 | 61 | struct 62 | { 63 | uint64_t total; 64 | uint64_t streamer; 65 | uint64_t stride; 66 | } pred; 67 | } stats; 68 | 69 | 70 | private: 71 | void init_knobs(); 72 | void init_stats(); 73 | void set_params(); 74 | uint32_t get_streamer_degree(Config config); 75 | uint32_t get_stride_degree(Config config); 76 | bool empty_cycle_stats(); 77 | void clear_cycle_stats(); 78 | Config get_winner_config(); 79 | string get_config_string(Config cfg); 80 | string get_mode_string(Mode mode); 81 | 82 | public : 83 | POWER7_Pref(string type, CACHE *cache); 84 | ~POWER7_Pref(); 85 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, vector &pref_addr); 86 | void dump_stats(); 87 | void print_config(); 88 | }; 89 | 90 | #endif /* PREF_POWER7 */ 91 | 92 | -------------------------------------------------------------------------------- /replacement/srrip.llc_repl: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | #define maxRRPV 3 4 | uint32_t rrpv[LLC_SET][LLC_WAY]; 5 | 6 | // initialize replacement state 7 | void CACHE::llc_initialize_replacement(uint64_t rand_seed) 8 | { 9 | cout << "Initialize SRRIP state" << endl; 10 | 11 | for (int i=0; i> mant_len) - exp_mid); 13 | - z[1] = e | evalsigne(x<0? -1: 1); 14 | - z[2] = (fi.i << expo_len) | HIGHBIT; 15 | + { 16 | + const ulong a = fi.i; 17 | + ulong A; 18 | + e = ((a & (HIGHBIT-1)) >> mant_len) - exp_mid; 19 | + if (e == exp_mid+1) err(talker, "NaN or Infinity in dbltor"); 20 | + A = a << expo_len; 21 | + if (e == -exp_mid) 22 | + { /* unnormalized values */ 23 | + int sh = bfffo(A); 24 | + e -= sh-1; 25 | + z[2] = A << sh; 26 | + } 27 | + else 28 | + z[2] = HIGHBIT | A; 29 | + z[1] = evalexpo(e) | evalsigne(x<0? -1: 1); 30 | + } 31 | return z; 32 | } 33 | 34 | @@ -2370,10 +2383,35 @@ 35 | { 36 | const ulong a = fi.i[INDEX0]; 37 | const ulong b = fi.i[INDEX1]; 38 | - e = evalexpo(((a & (HIGHBIT-1)) >> shift) - exp_mid); 39 | - z[1] = e | evalsigne(x<0? -1: 1); 40 | - z[3] = b << expo_len; 41 | - z[2] = HIGHBIT | b >> (BITS_IN_LONG-expo_len) | (a << expo_len); 42 | + ulong A, B; 43 | + e = ((a & (HIGHBIT-1)) >> shift) - exp_mid; 44 | + if (e == exp_mid+1) err(talker, "NaN or Infinity in dbltor"); 45 | + A = b >> (BITS_IN_LONG-expo_len) | (a << expo_len); 46 | + B = b << expo_len; 47 | + if (e == -exp_mid) 48 | + { /* unnormalized values */ 49 | + int sh; 50 | + if (A) 51 | + { 52 | + sh = bfffo(A); 53 | + e -= sh-1; 54 | + z[2] = (A << sh) | (B >> (32-sh)); 55 | + z[3] = B << sh; 56 | + } 57 | + else 58 | + { 59 | + sh = bfffo(B); /* B != 0 */ 60 | + e -= sh-1 + 32; 61 | + z[2] = B << sh; 62 | + z[3] = 0; 63 | + } 64 | + } 65 | + else 66 | + { 67 | + z[3] = B; 68 | + z[2] = HIGHBIT | A; 69 | + } 70 | + z[1] = evalexpo(e) | evalsigne(x<0? -1: 1); 71 | } 72 | return z; 73 | } 74 | -------------------------------------------------------------------------------- /experiments/extras/more_experiments_1C.exp: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | ## 3 | ## This file contains all the experiments required 4 | ## to reproduce single-core performance results of Pythia. 5 | ## 6 | ## Please follow the README to know how to use this file. 7 | ## 8 | ## Owner: Rahul Bera (write2bera@gmail.com) 9 | ## 10 | ############################################################### 11 | 12 | 13 | # configurations 14 | BASE = --warmup_instructions=100000000 --simulation_instructions=500000000 15 | NOPREF = --config=/insert/your/path/here/nopref.ini 16 | STRIDE = --l2c_prefetcher_types=stride --config=/insert/your/path/here/stride_MICRO21.ini 17 | SMS = --l2c_prefetcher_types=sms --config=/insert/your/path/here/sms_MICRO21.ini 18 | SPP_DEV2 = --l2c_prefetcher_types=spp_dev2 --config=/insert/your/path/here/spp_dev2_MICRO21.ini 19 | SPP_PPF_DEV = --l2c_prefetcher_types=spp_ppf_dev --config=/insert/your/path/here/spp_ppf_dev_MICRO21.ini 20 | MLOP = --l2c_prefetcher_types=mlop --config=/insert/your/path/here/mlop_MICRO21.ini 21 | BINGO = --l2c_prefetcher_types=bingo --config=/insert/your/path/here/bingo_MICRO21.ini 22 | DSPATCH = --l2c_prefetcher_types=dspatch --config=/insert/your/path/here/dspatch_MICRO21.ini 23 | IPCP_NEW = --l1d_prefetcher_types=ipcp --l2c_prefetcher_types=ipcp 24 | POWER7 = --l2c_prefetcher_types=power7 --config=/insert/your/path/here/power7_MICRO21.ini 25 | PYTHIA = --l2c_prefetcher_types=scooby --config=/insert/your/path/here/pythia_MICRO21.ini 26 | STRIDE_AT_L1 = --l1d_prefetcher_types=stride --config=/insert/your/path/here/stride_MICRO21.ini 27 | 28 | # experiments 29 | nopref $(BASE) $(NOPREF) 30 | perfect_L1 $(BASE) --l1d_perfect=true 31 | perfect_L2 $(BASE) --l2c_perfect=true 32 | semi_perfect_L2 $(BASE) --l2c_semi_perfect=true 33 | stride $(BASE) $(STRIDE) 34 | sms $(BASE) $(SMS) 35 | spp_dspatch $(BASE) $(SPP_DEV2) $(DSPATCH) 36 | spp_bingo $(BASE) $(SPP_DEV2) $(BINGO) --bingo_pht_size=4096 37 | stride_spp $(BASE) $(STRIDE) $(SPP_DEV2) 38 | stride_spp_bingo $(BASE) $(STRIDE) $(SPP_DEV2) $(BINGO) 39 | stride_spp_bingo_dspatch $(BASE) $(STRIDE) $(SPP_DEV2) $(BINGO) $(DSPATCH) 40 | stride_spp_bingo_dspatch_mlop $(BASE) $(STRIDE) $(SPP_DEV2) $(BINGO) $(DSPATCH) $(MLOP) 41 | ipcp_L1_L2 $(BASE) $(IPCP_NEW) 42 | power7 $(BASE) $(POWER7) 43 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.3.5_stderr_clobber: -------------------------------------------------------------------------------- 1 | --- ./src/language/init.c-pre 2008-03-31 04:43:58.000000000 -0700 2 | +++ ./src/language/init.c 2014-04-25 11:50:25.678357100 -0700 3 | @@ -1026,19 +1026,22 @@ err_recover(long numerr) 4 | longjmp(GP_DATA->env, numerr); 5 | } 6 | 7 | +static int stderr_was_newline = 1; 8 | + 9 | void 10 | pari_warn(long numerr, ...) 11 | { 12 | char *ch1; 13 | PariOUT *out = pariOut; 14 | + int out_was_newline = pari_last_was_newline(); 15 | va_list ap; 16 | 17 | va_start(ap,numerr); 18 | 19 | - if (!pari_last_was_newline()) 20 | - pariputc('\n'); /* make sure pari_err msg starts at the beginning of line */ 21 | pariflush(); pariOut = pariErr; 22 | pariflush(); term_color(c_ERR); 23 | + if (!stderr_was_newline) 24 | + pariputc('\n'); /* make sure pari_err msg starts at the beginning of line */ 25 | 26 | if (gp_function_name) 27 | pariprintf(" *** %s: %s", gp_function_name, errmessage[numerr]); 28 | @@ -1061,7 +1064,9 @@ pari_warn(long numerr, ...) 29 | break; 30 | } 31 | term_color(c_NONE); va_end(ap); 32 | + stderr_was_newline = pari_last_was_newline(); /* Always true with warn */ 33 | pariOut = out; 34 | + pari_set_last_newline(out_was_newline); 35 | flusherr(); 36 | } 37 | 38 | @@ -1070,6 +1075,7 @@ pari_err(long numerr, ...) 39 | { 40 | char s[128], *ch1; 41 | PariOUT *out = pariOut; 42 | + int out_was_newline = pari_last_was_newline(); 43 | va_list ap; 44 | 45 | va_start(ap,numerr); 46 | @@ -1091,10 +1097,10 @@ pari_err(long numerr, ...) 47 | } 48 | } 49 | 50 | - if (!pari_last_was_newline()) 51 | - pariputc('\n'); /* make sure pari_err msg starts at the beginning of line */ 52 | pariflush(); pariOut = pariErr; 53 | pariflush(); term_color(c_ERR); 54 | + if (!stderr_was_newline) 55 | + pariputc('\n'); /* make sure pari_err msg starts at the beginning of line */ 56 | 57 | if (numerr <= cant_deflate) 58 | { 59 | @@ -1182,7 +1188,9 @@ pari_err(long numerr, ...) 60 | fprintferr("\n current stack size: %lu (%.3f Mbytes)\n", d, d/1048576.); 61 | fprintferr(" [hint] you can increase GP stack with allocatemem()\n"); 62 | } 63 | + stderr_was_newline = pari_last_was_newline(); 64 | pariOut = out; 65 | + pari_set_last_newline(out_was_newline); 66 | gp_function_name=NULL; 67 | if (default_exception_handler) 68 | { 69 | -------------------------------------------------------------------------------- /inc/learning_engine_basic.h: -------------------------------------------------------------------------------- 1 | #ifndef LEARNING_ENGINE 2 | #define LEARNING_ENGINE 3 | 4 | #include 5 | #include 6 | #include "prefetcher.h" 7 | #include "learning_engine_base.h" 8 | 9 | #define MAX_ACTIONS 64 10 | 11 | /* 12 | * table format 13 | * |action 0| action 1| action 2|...| action n 14 | state 0 | 15 | state 1 | 16 | | ____ _ _ _ 17 | | / __ \ | | | | | | 18 | | | | | |______| |_ __ _| |__ | | ___ 19 | | | | | |______| __/ _` | '_ \| |/ _ \ 20 | | | |__| | | || (_| | |_) | | __/ 21 | | \___\_\ \__\__,_|_.__/|_|\___| 22 | | 23 | state m | 24 | */ 25 | 26 | class LearningEngineBasic : public LearningEngineBase 27 | { 28 | private: 29 | float init_value; 30 | 31 | std::default_random_engine generator; 32 | std::bernoulli_distribution *explore; 33 | std::uniform_int_distribution *actiongen; 34 | 35 | float **qtable; 36 | 37 | /* tracing related knobs */ 38 | uint32_t trace_interval; 39 | uint64_t trace_timestamp; 40 | FILE *trace; 41 | uint32_t action_trace_interval; 42 | uint64_t action_trace_timestamp; 43 | FILE *action_trace; 44 | uint64_t m_action_counter; 45 | uint64_t m_early_exploration_window; 46 | 47 | struct 48 | { 49 | struct 50 | { 51 | uint64_t called; 52 | uint64_t explore; 53 | uint64_t exploit; 54 | uint64_t dist[MAX_ACTIONS][2]; /* 0:explored, 1:exploited */ 55 | } action; 56 | 57 | struct 58 | { 59 | uint64_t called; 60 | } learn; 61 | } stats; 62 | 63 | float consultQ(uint32_t state, uint32_t action); 64 | void updateQ(uint32_t state, uint32_t action, float value); 65 | std::string getStringQ(uint32_t state); 66 | uint32_t getMaxAction(uint32_t state); 67 | void print_aux_stats(); 68 | void dump_state_trace(uint32_t state); 69 | void plot_scores(); 70 | void dump_action_trace(uint32_t action); 71 | 72 | public: 73 | LearningEngineBasic(Prefetcher *p, float alpha, float gamma, float epsilon, uint32_t actions, uint32_t states, uint64_t seed, std::string policy, std::string type, bool zero_init, uint64_t early_exploration_window); 74 | ~LearningEngineBasic(); 75 | 76 | uint32_t chooseAction(uint32_t state); 77 | void learn(uint32_t state1, uint32_t action1, int32_t reward, uint32_t state2, uint32_t action2); 78 | void dump_stats(); 79 | }; 80 | 81 | #endif /* LEARNING_ENGINE */ 82 | 83 | -------------------------------------------------------------------------------- /scripts/Crypt/Random/Provider/egd.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -sw 2 | ## 3 | ## Copyright (c) 1998-2018, Vipul Ved Prakash. All rights reserved. 4 | ## This code is free software; you can redistribute it and/or modify 5 | ## it under the same terms as Perl itself. 6 | 7 | package Crypt::Random::Provider::egd; 8 | use strict; 9 | 10 | use IO::Socket; 11 | use Carp; 12 | use Math::Pari qw(pari2num); 13 | 14 | 15 | sub _defaultsource { 16 | 17 | my $source; 18 | for my $d (qw( /var/run/egd-pool /dev/egd-pool /etc/entropy )) { 19 | if (IO::Socket::UNIX->new(Peer => $d)) { $source = $d; last } 20 | } 21 | return $source; 22 | 23 | } 24 | 25 | 26 | sub new { 27 | 28 | my ($class, %args) = @_; 29 | my $self = { Source => $args{Source} || $args{Device} || $args{Filename} }; 30 | $$self{Source} = $class->_defaultsource() unless $$self{Source}; 31 | croak "egd entropy pool file not found.\n" unless $$self{Source}; 32 | return bless $self, $class; 33 | 34 | } 35 | 36 | 37 | sub get_data { 38 | 39 | my ( $self, %params ) = @_; 40 | my $class = ref $self || $self; 41 | $self = {} unless ref $self; 42 | 43 | my $bytes = $params{Length} || 44 | (int( pari2num($params{ Size }) / 8) + 1); 45 | my $dev = $params{Source} || $$self{Source}; 46 | my $skip = $params{Skip}; 47 | 48 | croak "$dev doesn't exist. aborting." unless $dev && -e $dev; 49 | 50 | my $s = IO::Socket::UNIX->new(Peer => $dev); 51 | croak "couldn't talk to egd. $!" unless $s; 52 | 53 | my($r, $read) = ('', 0); 54 | while ($read < $bytes) { 55 | my $msg = pack "CC", 0x01, 1; 56 | $s->syswrite($msg, length $msg); 57 | my $rt; 58 | my $nread = $s->sysread($rt, 1); 59 | croak "read from entropy socket failed" unless $nread == 1; 60 | my $count = unpack("C", $rt); 61 | $nread = $s->sysread($rt, $count); 62 | croak "couldn't get all the requested entropy. aborting." 63 | unless $nread == $count; 64 | unless ($skip && $skip =~ /\Q$rt\E/) { 65 | if ($params{Verbosity}) { print '.' unless $read % 2 } 66 | $r .= $rt; 67 | $read++; 68 | } 69 | } 70 | 71 | $r; 72 | } 73 | 74 | 75 | sub available { 76 | 77 | my $class = shift; 78 | return 1 if $class->_defaultsource(); 79 | return; 80 | 81 | } 82 | 83 | 84 | 1; 85 | 86 | 87 | -------------------------------------------------------------------------------- /inc/learning_engine_featurewise.h: -------------------------------------------------------------------------------- 1 | #ifndef LEARNING_ENGINE_FEATUREWISE_H 2 | #define LEARNING_ENGINE_FEATUREWISE_H 3 | 4 | #include 5 | #include "learning_engine_base.h" 6 | #include "feature_knowledge.h" 7 | 8 | class LearningEngineFeaturewise : public LearningEngineBase 9 | { 10 | private: 11 | FeatureKnowledge* m_feature_knowledges[NumFeatureTypes]; 12 | float m_max_q_value; 13 | 14 | std::default_random_engine m_generator; 15 | std::bernoulli_distribution *m_explore; 16 | std::uniform_int_distribution *m_actiongen; 17 | 18 | vector m_q_value_buckets; 19 | vector m_q_value_histogram; 20 | 21 | /* tracing related knobs */ 22 | uint32_t trace_interval; 23 | uint64_t trace_timestamp; 24 | FILE *trace; 25 | 26 | /* stats */ 27 | struct 28 | { 29 | struct 30 | { 31 | uint64_t called; 32 | uint64_t explore; 33 | uint64_t exploit; 34 | uint64_t dist[MAX_ACTIONS][2]; /* 0:explored, 1:exploited */ 35 | uint64_t fallback; 36 | uint64_t dyn_fallback_saved_bw; 37 | uint64_t dyn_fallback_saved_bw_acc; 38 | } action; 39 | 40 | struct 41 | { 42 | uint64_t called; 43 | uint64_t su_skip[NumFeatureTypes]; 44 | } learn; 45 | 46 | struct 47 | { 48 | uint64_t total; 49 | uint64_t feature_align_dist[NumFeatureTypes]; 50 | uint64_t feature_align_all; 51 | } consensus; 52 | 53 | } stats; 54 | 55 | private: 56 | void init_knobs(); 57 | void init_stats(); 58 | uint32_t getMaxAction(State *state, float &max_q, float &max_to_avg_q_ratio, vector &consensus_vec); 59 | float consultQ(State *state, uint32_t action); 60 | void gather_stats(float max_q, float max_to_avg_q_ratio); 61 | void action_selection_consensus(State *state, uint32_t selected_action, vector &consensus_vec); 62 | void adjust_feature_weights(vector consensus_vec, RewardType reward_type); 63 | bool do_fallback(State *state); 64 | void plot_scores(); 65 | 66 | public: 67 | LearningEngineFeaturewise(Prefetcher *p, float alpha, float gamma, float epsilon, uint32_t actions, uint64_t seed, std::string policy, std::string type, bool zero_init); 68 | ~LearningEngineFeaturewise(); 69 | uint32_t chooseAction(State *state, float &max_to_avg_q_ratio, vector &consensus_vec); 70 | void learn(State *state1, uint32_t action1, int32_t reward, State *state2, uint32_t action2, vector consensus_vec, RewardType reward_type); 71 | void dump_stats(); 72 | }; 73 | 74 | #endif /* LEARNING_ENGINE_FEATUREWISE_H */ 75 | -------------------------------------------------------------------------------- /inc/sandbox.h: -------------------------------------------------------------------------------- 1 | #ifndef SANDBOX_PREFETCHER_H 2 | #define SANDBOX_PREFETCHER_H 3 | 4 | #include 5 | #include 6 | #include "prefetcher.h" 7 | #include "bf/all.hpp" 8 | using namespace std; 9 | 10 | class Score 11 | { 12 | public: 13 | int32_t offset; 14 | uint32_t score; 15 | Score() : offset(0), score(0) {} 16 | Score(int32_t _offset) : offset(_offset), score(0) {} 17 | Score(int32_t _offset, uint32_t _score) : offset(_offset), score(_score) {} 18 | ~Score(){} 19 | }; 20 | 21 | class SandboxPrefetcher : public Prefetcher 22 | { 23 | private: 24 | deque evaluated_offsets; 25 | deque non_evaluated_offsets; 26 | uint32_t pref_degree; /* degree per direction */ 27 | struct 28 | { 29 | uint32_t curr_ptr; 30 | uint32_t total_demand; 31 | uint32_t filter_hit; 32 | } eval; 33 | 34 | /* Bloom Filter */ 35 | uint32_t opt_hash_functions; 36 | bf::basic_bloom_filter *bf; 37 | 38 | /* stats */ 39 | struct 40 | { 41 | uint64_t called; 42 | 43 | struct 44 | { 45 | uint64_t filter_lookup; 46 | uint64_t filter_hit ; 47 | } step1; 48 | 49 | struct 50 | { 51 | uint64_t filter_add; 52 | } step2; 53 | 54 | struct 55 | { 56 | uint64_t end_of_phase; 57 | uint64_t end_of_round; 58 | } step3; 59 | 60 | struct 61 | { 62 | uint64_t pref_generated; 63 | uint64_t pref_generated_pos; 64 | uint64_t pref_generated_neg; 65 | } step4; 66 | 67 | uint64_t pref_delta_dist[128]; 68 | } stats; 69 | 70 | private: 71 | void init_knobs(); 72 | void init_stats(); 73 | void init_evaluated_offsets(); 74 | void init_non_evaluated_offsets(); 75 | void reset_eval(); 76 | void get_offset_list_sorted(vector &pos_offsets, vector &neg_offsets); 77 | void generate_prefetch(vector offset_list, uint32_t pref_degree, uint64_t page, uint32_t offset, vector &pref_addr); 78 | void destroy_offset_list(vector offset_list); 79 | uint64_t generate_address(uint64_t page, uint32_t offset, int32_t delta, uint32_t lookahead = 1); 80 | void end_of_round(); 81 | void filter_add(uint64_t address); 82 | bool filter_lookup(uint64_t address); 83 | void record_pref_stats(int32_t offset, uint32_t pref_count); 84 | 85 | public: 86 | SandboxPrefetcher(string type); 87 | ~SandboxPrefetcher(); 88 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, vector &pref_addr); 89 | void dump_stats(); 90 | void print_config(); 91 | }; 92 | 93 | #endif /* SANDBOX_PREFETCHER_H */ 94 | 95 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff_2.1.6_ploth64: -------------------------------------------------------------------------------- 1 | --- pari-2.1.6/src/test/64/ploth Sun Mar 12 09:27:46 2000 2 | +++ pari-2.1.6/src/test/64/ploth-32 Sun Mar 12 09:27:46 2000 3 | @@ -1,2 +1,3 @@ 4 | + echo = 1 (on) 5 | ? default(realprecision,9) 6 | realprecision = 9 significant digits 7 | @@ -11,5 +12,5 @@ 8 | ? plotlines(0,vector(5,k,50*k),vector(5,k,10*k*k)) 9 | ? plotmove(0,243,583);plotcursor(0) 10 | -% = [243, 583] 11 | +[243, 583] 12 | ? plot(x=-5,5,sin(x)) 13 | 14 | @@ -38,30 +39,30 @@ 15 | -5 5 16 | ? ploth(x=-5,5,sin(x)) 17 | -% = [-5.00000000, 5.00000000, -0.999996411, 0.999996410] 18 | +[-5.00000000, 5.00000000, -0.999996411, 0.999996410] 19 | ? ploth(t=0,2*Pi,[sin(5*t),sin(7*t)]) 20 | -% = [0.E-92, 6.28318530, -0.999998764, 0.999998764] 21 | +[0.E-92, 6.28318530, -0.999998764, 0.999998765] 22 | ? ploth(t=0,2*Pi,[sin(5*t),sin(7*t)],1,100) 23 | -% = [-0.999874128, 0.999874127, -0.999874128, 0.999874127] 24 | +[-0.999874125, 0.999874127, -0.999874127, 0.999874128] 25 | ? ploth(t=0,2*Pi,[sin(5*t),sin(7*t)],2,100) 26 | *** multi-curves cannot be plot recursively. 27 | ? ploth(t=0,2*Pi,[sin(5*t),sin(7*t)],3,100) 28 | -% = [-1.00000000, 1.00000000, -1.00000000, 1.00000000] 29 | +[-1.00000000, 0.999999999, -1.00000000, 0.999999999] 30 | ? plothraw(vector(501,k,k-1),vector(501,k,(k-1)*(k-1)/500)) 31 | -% = [0.E-92, 500.000000, 0.E-92, 500.000000] 32 | +[0.E-92, 500.000000, 0.E-92, 500.000000] 33 | ? plothraw(vector(501,k,k-1),vector(501,k,(k-1)*(k-1)/500),1) 34 | -% = [0.E-92, 500.000000, 0.E-92, 500.000000] 35 | +[0.E-92, 500.000000, 0.E-92, 500.000000] 36 | ? plotpoints(0,225,334) 37 | ? plotpoints(0,vector(10,k,10*k),vector(10,k,5*k*k)) 38 | ? psploth(x=-5,5,sin(x)) 39 | -% = [-5.00000000, 5.00000000, -0.999996411, 0.999996410] 40 | +[-5.00000000, 5.00000000, -0.999996411, 0.999996410] 41 | ? psplothraw(vector(501,k,k-1),vector(501,k,(k-1)*(k-1)/500),1) 42 | -% = [0.E-92, 500.000000, 0.E-92, 500.000000] 43 | +[0.E-92, 500.000000, 0.E-92, 500.000000] 44 | ? plotmove(0,50,50);plotrbox(0,50,50) 45 | ? plotrline(0,150,100) 46 | ? plotcolor(0,4); 47 | ? plotcursor(0) 48 | -% = [200, 150] 49 | +[200, 150] 50 | ? plotrmove(0,5,5);plotcursor(0) 51 | -% = [205, 155] 52 | +[205, 155] 53 | ? plotrpoint(0,20,20) 54 | ? plotmove(0,100,100);plotstring(0,Pi) 55 | @@ -70,5 +71,4 @@ 56 | ? psdraw([0,10,10]) 57 | ? print("Total time spent: ",gettime); 58 | -Total time spent: 2196 59 | +Total time spent: 1205 60 | ? \q 61 | -Good bye! 62 | -------------------------------------------------------------------------------- /inc/memory_class.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_CLASS_H 2 | #define MEMORY_CLASS_H 3 | 4 | #include "champsim.h" 5 | #include "block.h" 6 | 7 | // CACHE ACCESS TYPE 8 | #define LOAD 0 9 | #define RFO 1 10 | #define PREFETCH 2 11 | #define WRITEBACK 3 12 | #define NUM_TYPES 4 13 | 14 | extern uint32_t tRP, // Row Precharge (RP) latency 15 | tRCD, // Row address to Column address (RCD) latency 16 | tCAS; // Column Address Strobe (CAS) latency 17 | 18 | extern uint64_t l2pf_access; 19 | 20 | const char* GetAccessType(uint8_t type); 21 | 22 | class MEMORY { 23 | public: 24 | // memory interface 25 | MEMORY *upper_level_icache[NUM_CPUS], *upper_level_dcache[NUM_CPUS], *lower_level, *extra_interface; 26 | 27 | // empty queues 28 | PACKET_QUEUE WQ{"EMPTY", 1}, RQ{"EMPTY", 1}, PQ{"EMPTY", 1}, MSHR{"EMPTY", 1}; 29 | 30 | // functions 31 | virtual int add_rq(PACKET *packet) = 0; 32 | virtual int add_wq(PACKET *packet) = 0; 33 | virtual int add_pq(PACKET *packet) = 0; 34 | virtual void return_data(PACKET *packet) = 0; 35 | virtual void operate() = 0; 36 | virtual void increment_WQ_FULL(uint64_t address) = 0; 37 | virtual uint32_t get_occupancy(uint8_t queue_type, uint64_t address) = 0; 38 | virtual uint32_t get_size(uint8_t queue_type, uint64_t address) = 0; 39 | void broadcast_bw(uint8_t bw_level){} 40 | 41 | // stats 42 | uint64_t ACCESS[NUM_TYPES], HIT[NUM_TYPES], MISS[NUM_TYPES], MSHR_MERGED[NUM_TYPES], STALL[NUM_TYPES]; 43 | 44 | MEMORY() { 45 | for (uint32_t i=0; i>>\msys\1.0\bin;%path% 2 | sh ./Configure --without-gmp --with-qt=no 2>&1 | tee -a 00c00 3 | 4 | Replace paricfg.h by the Math::Pari version (with PARIVERSION PARIINFO added for gp.c) 5 | Change DOTEST line to have 64 in <<>>/Makefile. 6 | With plotting patch: plotterm should have Unixified line-endings. 7 | 8 | make -k bench 2>&1 | tee -a 00t00 9 | 10 | The only problem: install() 11 | 12 | --- pari-2.3.5/src/language/init.c-pre 2019-03-28 21:32:27.308266800 -0700 13 | +++ pari-2.3.5/src/language/init.c 2019-03-28 21:43:52.938482600 -0700 14 | @@ -19,15 +19,16 @@ Foundation, Inc., 59 Temple Place - Suit 15 | /* */ 16 | /*******************************************************************/ 17 | #include 18 | -#include "pari.h" 19 | -#include "paripriv.h" 20 | -#include "anal.h" 21 | #ifdef _WIN32 22 | # ifndef WINCE 23 | # include 24 | # endif 25 | #endif 26 | 27 | +#include "pari.h" 28 | +#include "paripriv.h" 29 | +#include "anal.h" 30 | + 31 | GEN gnil, gen_0, gen_1, gen_m1, gen_2, ghalf, gi; 32 | GEN gpi, geuler, bernzone; 33 | GEN primetab; /* private primetable */ 34 | --- pari-2.3.5/src/language/es.c-pre 2019-03-28 21:32:27.193260200 -0700 35 | +++ pari-2.3.5/src/language/es.c 2019-03-28 21:40:33.206058600 -0700 36 | @@ -18,6 +18,13 @@ Foundation, Inc., 59 Temple Place - Suit 37 | /** INPUT/OUTPUT SUBROUTINES **/ 38 | /** **/ 39 | /*******************************************************************/ 40 | +#ifdef HAS_STAT 41 | +#include 42 | +#endif 43 | +#ifdef HAS_OPENDIR 44 | +#include 45 | +#endif 46 | + 47 | #include "pari.h" 48 | #include "paripriv.h" 49 | #include "anal.h" 50 | --- pari-2.3.5/src/headers/parigen.h-pre 2019-03-28 21:32:25.971190300 -0700 51 | +++ pari-2.3.5/src/headers/parigen.h 2019-03-28 21:36:03.087608700 -0700 52 | @@ -15,8 +15,19 @@ Foundation, Inc., 59 Temple Place - Suit 53 | 54 | /* This file defines the parameters of the GEN type */ 55 | 56 | -typedef long *GEN; 57 | +#ifdef _WIN64 58 | +typedef unsigned long long pari_ulong; 59 | +#define long long long 60 | +#define labs llabs 61 | +#define atol atoll 62 | +#define atoul atoull 63 | +#define strtol strtoll 64 | +#define strtoul strtoull 65 | +#else 66 | typedef unsigned long pari_ulong; 67 | +#endif 68 | + 69 | +typedef long *GEN; 70 | #define ulong pari_ulong 71 | 72 | #ifdef LONG_IS_64BIT 73 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff-2.5.0-exceptions: -------------------------------------------------------------------------------- 1 | --- pari-2.5.0/src/headers/paricom.h-pre 2011-05-30 02:28:34.000000000 -0700 2 | +++ pari-2.5.0/src/headers/paricom.h 2018-09-16 00:04:16.527215600 -0700 3 | @@ -73,6 +73,10 @@ extern void (*cb_pari_sigint)(void); 4 | extern int (*cb_pari_handle_exception)(long); 5 | extern void (*cb_pari_err_recover)(long); 6 | 7 | +#define CB_EXCEPTION_FLAGS 1 8 | +extern int cb_exception_resets_avma; 9 | +extern int cb_exception_flushes_err; 10 | + 11 | enum manage_var_t { 12 | manage_var_create, 13 | manage_var_delete, 14 | --- pari-2.5.0/src/language/eval.c-pre 2018-08-06 12:00:59.504359600 -0700 15 | +++ pari-2.5.0/src/language/eval.c 2018-09-16 00:10:41.286291400 -0700 16 | @@ -1316,7 +1316,8 @@ evalstate_reset(void) 17 | s_trace.n = 0; 18 | reset_break(); 19 | compilestate_reset(); 20 | - avma = top; 21 | + if (!cb_exception_resets_avma) 22 | + avma = top; 23 | } 24 | 25 | void 26 | --- pari-2.5.0/src/language/init.c-pre 2011-05-30 02:28:26.000000000 -0700 27 | +++ pari-2.5.0/src/language/init.c 2018-09-19 03:34:41.813699200 -0700 28 | @@ -93,6 +93,9 @@ int (*cb_pari_whatnow)(PariOUT *out, co 29 | void (*cb_pari_sigint)(void); 30 | void (*cb_pari_err_recover)(long); 31 | 32 | +int cb_exception_resets_avma = 0; 33 | +int cb_exception_flushes_err = 0; 34 | + 35 | typedef struct { 36 | jmp_buf *penv; 37 | long flag; 38 | @@ -896,8 +899,11 @@ err_recover(long numerr) 39 | s_ERR_CATCH.n = 0; 40 | dbg_release(); 41 | global_err_data = NULL; 42 | - out_puts(pariErr, "\n"); 43 | - pariErr->flush(); 44 | + 45 | + if (!cb_exception_flushes_err) { 46 | + out_puts(pariErr, "\n"); /* What is this doing in generic code? It was flushed already, so this is just an empty error message! */ 47 | + pariErr->flush(); /* If an empty line is needed by gp, this should be done in gp's error handler! */ 48 | + } 49 | 50 | cb_pari_err_recover(numerr); 51 | } 52 | @@ -975,7 +981,8 @@ pari_sigint(const char *time_s) 53 | out_puts(pariErr, "user interrupt after "); 54 | out_puts(pariErr, time_s); 55 | out_term_color(pariErr, c_NONE); 56 | - pariErr->flush(); 57 | + if (!cb_exception_flushes_err) 58 | + pariErr->flush(); 59 | if (cb_pari_handle_exception && 60 | cb_pari_handle_exception(-1)) return; 61 | err_recover(talker); 62 | @@ -1118,7 +1125,8 @@ pari_err(int numerr, ...) 63 | pariErr->puts(buf); 64 | pariErr->puts(" [hint] you can increase GP stack with allocatemem()\n"); 65 | } 66 | - pariErr->flush(); 67 | + if (!cb_exception_flushes_err) 68 | + pariErr->flush(); 69 | if (cb_pari_handle_exception && 70 | cb_pari_handle_exception(numerr)) return; 71 | err_recover(numerr); 72 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff-2.5.5-exceptions: -------------------------------------------------------------------------------- 1 | --- pari-2.5.0/src/headers/paricom.h-pre 2011-05-30 02:28:34.000000000 -0700 2 | +++ pari-2.5.0/src/headers/paricom.h 2018-09-16 00:04:16.527215600 -0700 3 | @@ -73,6 +73,10 @@ extern void (*cb_pari_sigint)(void); 4 | extern int (*cb_pari_handle_exception)(long); 5 | extern void (*cb_pari_err_recover)(long); 6 | 7 | +#define CB_EXCEPTION_FLAGS 1 8 | +extern int cb_exception_resets_avma; 9 | +extern int cb_exception_flushes_err; 10 | + 11 | enum manage_var_t { 12 | manage_var_create, 13 | manage_var_delete, 14 | --- pari-2.5.5/src/language/eval.c.orig 2013-06-24 16:06:58.000000000 -0700 15 | +++ pari-2.5.5/src/language/eval.c 2019-02-27 04:19:10.374415800 -0800 16 | @@ -1323,7 +1323,8 @@ evalstate_reset(void) 17 | reset_break(); 18 | compilestate_reset(); 19 | parsestate_reset(); 20 | - avma = top; 21 | + if (!cb_exception_resets_avma) 22 | + avma = top; 23 | } 24 | 25 | void 26 | --- pari-2.5.0/src/language/init.c-pre 2011-05-30 02:28:26.000000000 -0700 27 | +++ pari-2.5.0/src/language/init.c 2018-09-19 03:34:41.813699200 -0700 28 | @@ -93,6 +93,9 @@ int (*cb_pari_whatnow)(PariOUT *out, co 29 | void (*cb_pari_sigint)(void); 30 | void (*cb_pari_err_recover)(long); 31 | 32 | +int cb_exception_resets_avma = 0; 33 | +int cb_exception_flushes_err = 0; 34 | + 35 | typedef struct { 36 | jmp_buf *penv; 37 | long flag; 38 | @@ -896,8 +899,11 @@ err_recover(long numerr) 39 | s_ERR_CATCH.n = 0; 40 | dbg_release(); 41 | global_err_data = NULL; 42 | - out_puts(pariErr, "\n"); 43 | - pariErr->flush(); 44 | + 45 | + if (!cb_exception_flushes_err) { 46 | + out_puts(pariErr, "\n"); /* What is this doing in generic code? It was flushed already, so this is just an empty error message! */ 47 | + pariErr->flush(); /* If an empty line is needed by gp, this should be done in gp's error handler! */ 48 | + } 49 | 50 | cb_pari_err_recover(numerr); 51 | } 52 | @@ -975,7 +981,8 @@ pari_sigint(const char *time_s) 53 | out_puts(pariErr, "user interrupt after "); 54 | out_puts(pariErr, time_s); 55 | out_term_color(pariErr, c_NONE); 56 | - pariErr->flush(); 57 | + if (!cb_exception_flushes_err) 58 | + pariErr->flush(); 59 | if (cb_pari_handle_exception && 60 | cb_pari_handle_exception(-1)) return; 61 | err_recover(talker); 62 | @@ -1118,7 +1125,8 @@ pari_err(int numerr, ...) 63 | pariErr->puts(buf); 64 | pariErr->puts(" [hint] you can increase GP stack with allocatemem()\n"); 65 | } 66 | - pariErr->flush(); 67 | + if (!cb_exception_flushes_err) 68 | + pariErr->flush(); 69 | if (cb_pari_handle_exception && 70 | cb_pari_handle_exception(numerr)) return; 71 | err_recover(numerr); 72 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff-2.7.0-exceptions: -------------------------------------------------------------------------------- 1 | --- pari-2.5.0/src/headers/paricom.h-pre 2011-05-30 02:28:34.000000000 -0700 2 | +++ pari-2.5.0/src/headers/paricom.h 2018-09-16 00:04:16.527215600 -0700 3 | @@ -73,6 +73,10 @@ extern void (*cb_pari_sigint)(void); 4 | extern int (*cb_pari_handle_exception)(long); 5 | extern void (*cb_pari_err_recover)(long); 6 | 7 | +#define CB_EXCEPTION_FLAGS 1 8 | +extern int cb_exception_resets_avma; 9 | +extern int cb_exception_flushes_err; 10 | + 11 | enum manage_var_t { 12 | manage_var_create, 13 | manage_var_delete, 14 | --- pari-2.5.5/src/language/eval.c.orig 2013-06-24 16:06:58.000000000 -0700 15 | +++ pari-2.5.5/src/language/eval.c 2019-02-27 04:19:10.374415800 -0800 16 | @@ -1323,7 +1323,8 @@ evalstate_reset(void) 17 | reset_break(); 18 | compilestate_reset(); 19 | parsestate_reset(); 20 | - avma = top; 21 | + if (!cb_exception_resets_avma) 22 | + avma = top; 23 | } 24 | 25 | void 26 | --- pari-2.7.0/src/language/init.c.orig 2014-03-20 01:59:28.000000000 -0700 27 | +++ pari-2.7.0/src/language/init.c 2019-03-01 03:44:51.207967500 -0800 28 | @@ -93,6 +93,9 @@ void (*cb_pari_pre_recover)(long); 29 | void (*cb_pari_err_recover)(long); 30 | const char * pari_library_path = NULL; 31 | 32 | +int cb_exception_resets_avma = 0; 33 | +int cb_exception_flushes_err = 0; 34 | + 35 | static THREAD GEN global_err_data; 36 | THREAD jmp_buf *iferr_env; 37 | const long CATCH_ALL = -1; 38 | @@ -885,8 +888,11 @@ err_recover(long numerr) 39 | evalstate_reset(); 40 | killallfiles(); 41 | pari_init_errcatch(); 42 | - out_puts(pariErr, "\n"); 43 | - pariErr->flush(); 44 | + 45 | + if (!cb_exception_flushes_err) { 46 | + out_puts(pariErr, "\n"); /* What is this doing in generic code? It was flushed already, so this is just an empty error message! */ 47 | + pariErr->flush(); /* If an empty line is needed by gp, this should be done in gp's error handler! */ 48 | + } 49 | 50 | cb_pari_err_recover(numerr); 51 | } 52 | @@ -966,7 +972,8 @@ pari_sigint(const char *time_s) 53 | out_puts(pariErr, "user interrupt after "); 54 | out_puts(pariErr, time_s); 55 | out_term_color(pariErr, c_NONE); 56 | - pariErr->flush(); 57 | + if (!cb_exception_flushes_err) 58 | + pariErr->flush(); 59 | if (cb_pari_handle_exception) 60 | recover = cb_pari_handle_exception(-1); 61 | if (!recover && !block) 62 | @@ -1318,7 +1325,8 @@ pari_err(int numerr, ...) 63 | pari_err_display(E); 64 | out_term_color(pariErr, c_NONE); 65 | va_end(ap); 66 | - pariErr->flush(); 67 | + if (!cb_exception_flushes_err) 68 | + pariErr->flush(); 69 | if (cb_pari_handle_exception && 70 | cb_pari_handle_exception(numerr)) return; 71 | err_recover(numerr); 72 | -------------------------------------------------------------------------------- /inc/util.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_H 2 | #define UTIL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | void gen_random(char *s, const int len); 10 | uint32_t folded_xor(uint64_t value, uint32_t num_folds); 11 | 12 | template std::string array_to_string(std::vector array, bool hex = false, uint32_t size = 0) 13 | { 14 | std::stringstream ss; 15 | if (size == 0) size = array.size(); 16 | for(uint32_t index = 0; index < size; ++index) 17 | { 18 | if(hex) 19 | { 20 | ss << std::hex << array[index] << std::dec; 21 | } 22 | else 23 | { 24 | ss << array[index]; 25 | } 26 | ss << ","; 27 | } 28 | return ss.str(); 29 | } 30 | 31 | class HashZoo 32 | { 33 | public: 34 | static uint32_t jenkins(uint32_t key); 35 | static uint32_t knuth(uint32_t key); 36 | static uint32_t murmur3(uint32_t key); 37 | static uint32_t jenkins32(uint32_t key); 38 | static uint32_t hash32shift(uint32_t key); 39 | static uint32_t hash32shiftmult(uint32_t key); 40 | static uint32_t hash64shift(uint32_t key); 41 | static uint32_t hash5shift(uint32_t key); 42 | static uint32_t hash7shift(uint32_t key); 43 | static uint32_t Wang6shift(uint32_t key); 44 | static uint32_t Wang5shift(uint32_t key); 45 | static uint32_t Wang4shift( uint32_t key); 46 | static uint32_t Wang3shift( uint32_t key); 47 | 48 | static uint32_t three_hybrid1(uint32_t key); 49 | static uint32_t three_hybrid2(uint32_t key); 50 | static uint32_t three_hybrid3(uint32_t key); 51 | static uint32_t three_hybrid4(uint32_t key); 52 | static uint32_t three_hybrid5(uint32_t key); 53 | static uint32_t three_hybrid6(uint32_t key); 54 | static uint32_t three_hybrid7(uint32_t key); 55 | static uint32_t three_hybrid8(uint32_t key); 56 | static uint32_t three_hybrid9(uint32_t key); 57 | static uint32_t three_hybrid10(uint32_t key); 58 | static uint32_t three_hybrid11(uint32_t key); 59 | static uint32_t three_hybrid12(uint32_t key); 60 | 61 | static uint32_t four_hybrid1(uint32_t key); 62 | static uint32_t four_hybrid2(uint32_t key); 63 | static uint32_t four_hybrid3(uint32_t key); 64 | static uint32_t four_hybrid4(uint32_t key); 65 | static uint32_t four_hybrid5(uint32_t key); 66 | static uint32_t four_hybrid6(uint32_t key); 67 | static uint32_t four_hybrid7(uint32_t key); 68 | static uint32_t four_hybrid8(uint32_t key); 69 | static uint32_t four_hybrid9(uint32_t key); 70 | static uint32_t four_hybrid10(uint32_t key); 71 | static uint32_t four_hybrid11(uint32_t key); 72 | static uint32_t four_hybrid12(uint32_t key); 73 | 74 | static uint32_t getHash(uint32_t selector, uint32_t key); 75 | }; 76 | 77 | #endif /* UTIL_H */ 78 | 79 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff-2.7.0-reinstall-foreigh: -------------------------------------------------------------------------------- 1 | --- pari-2.7.0/src/language/eval.c-pre 2019-03-01 03:30:30.428655500 -0800 2 | +++ pari-2.7.0/src/language/eval.c 2019-03-01 17:29:05.309988700 -0800 3 | @@ -136,6 +136,9 @@ pop_val(entree *ep) 4 | void 5 | freeep(entree *ep) 6 | { 7 | + if (foreignFuncFree && ep->code && (*ep->code == 'x')) 8 | + (*foreignFuncFree)(ep); /* function created by foreign interpreter */ 9 | + 10 | if (EpSTATIC(ep)) return; /* gp function loaded at init time */ 11 | if (ep->help) {pari_free((void*)ep->help); ep->help=NULL;} 12 | if (ep->code) {pari_free((void*)ep->code); ep->code=NULL;} 13 | --- pari-2.7.0/src/language/init.c-pre 2019-03-01 03:44:51.207967500 -0800 14 | +++ pari-2.7.0/src/language/init.c 2019-03-01 17:28:05.405883500 -0800 15 | @@ -85,6 +85,9 @@ static pari_stack s_MODULES, s_OLDMODULE 16 | const long functions_tblsz = 135; /* size of functions_hash */ 17 | entree **functions_hash, **defaults_hash; 18 | 19 | +entree* (*foreignAutoload)(const char*, long len); /* Autoloader */ 20 | +void (*foreignFuncFree)(entree *); /* How to free external entree. */ 21 | + 22 | void (*cb_pari_ask_confirm)(const char *); 23 | int (*cb_pari_handle_exception)(long); 24 | int (*cb_pari_whatnow)(PariOUT *out, const char *, int); 25 | @@ -2340,6 +2346,12 @@ pari_version(void) 26 | * 27 | * Syntax requirements: 28 | * = Separator '=' required. 29 | + * 30 | + * Origin: 31 | + * x Installed foreign function. Put the ep of the function as the 32 | + * first argument, fill the rest with PARI arguments, 33 | + * then call installedHandler with these arguments. 34 | + * Should be the first char in the code. 35 | **************************************************************************** 36 | */ 37 | #include "init.h" 38 | --- pari-2.7.0/src/language/anal.h-pre 2014-03-20 01:59:28.000000000 -0700 39 | +++ pari-2.7.0/src/language/anal.h 2019-03-01 17:21:54.576632100 -0800 40 | @@ -33,6 +33,9 @@ void pari_fill_hashtable(entree **tabl 41 | void compile_err(const char *msg, const char *str); 42 | void compile_varerr(const char *str); 43 | 44 | +extern entree * (*foreignAutoload)(const char*, long len); 45 | +extern void (*foreignFuncFree)(entree *); 46 | + 47 | #ifdef STACK_CHECK 48 | extern THREAD void *PARI_stack_limit; 49 | #endif 50 | --- pari-2.7.0/src/language/anal.c-pre 2019-03-01 03:36:32.318091200 -0800 51 | +++ pari-2.7.0/src/language/anal.c 2019-03-01 17:24:51.107542200 -0800 52 | @@ -753,6 +753,8 @@ findentry(const char *name, long len, en 53 | entree *ep; 54 | for (ep = ep1; ep; ep = ep->next) 55 | if (!strncmp(ep->name, name, len) && !(ep->name)[len]) return ep; 56 | + if (foreignAutoload) /* Try to autoload. */ 57 | + return foreignAutoload(name,len); 58 | return NULL; /* not found */ 59 | } 60 | 61 | -------------------------------------------------------------------------------- /scripts/Math-Combinatorics-0.09/t/03.t: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | use lib 'lib'; 3 | use strict; 4 | use Test::More; 5 | 6 | plan tests => 3; 7 | 8 | use_ok('Data::Dumper'); 9 | use_ok('Math::Combinatorics'); 10 | } 11 | 12 | my @S = qw(d a c b); 13 | my @R = map {\$_} qw(d a c b); 14 | 15 | my $rsort = sub { my ($a,$b) = @_; return $b cmp $a }; 16 | #my $rsort = sub { my ($a,$b) = @_; return $b cmp $a }; 17 | 18 | my $set = Math::Combinatorics->new( 19 | count => scalar(@S) , 20 | data => [ @S ] , 21 | compare => $rsort , 22 | ); 23 | $c = join '', $set->next_combination(); 24 | is( $c, q{dcba}, q{expecting reverse ordered array} ); 25 | 26 | __DATA__ 27 | #! /usr/bin/perl 28 | 29 | use warnings; 30 | use strict; 31 | 32 | use lib q{.}; 33 | use Math::Combinatorics qw; 34 | use Data::Dumper; 35 | 36 | use Test::More tests => 5; 37 | 38 | # test with a regular array and with an array of references 39 | # 40 | my @TEST_ARR = qw{d a c b}; 41 | my @TEST_REF = \( qw{d a c b} ); 42 | 43 | # Combine without passing a compare function, Combination should be sorted 44 | # by the internal compare function, which sorts alphabetically. 45 | # 46 | { 47 | my $c = join q{}, @{ (combine(scalar @TEST_ARR, @TEST_ARR))[0] }; 48 | is( $c, q{abcd}, q{expecting ordered array} ); 49 | } 50 | 51 | # Combine with passing a compare function as defined in the manual. I expect 52 | # it to die. 53 | # 54 | { 55 | my $alphabetically = sub { 56 | my $a = shift; die qq{REFARGS\n} if ref $a; 57 | my $b = shift; die qq{REFARGS\n} if ref $b; 58 | return $a cmp $b; 59 | }; 60 | my $c = join q{}, eval { 61 | my $set = Math::Combinatorics->new( 62 | count => scalar @TEST_ARR , 63 | data => [ @TEST_ARR ] , 64 | compare => $alphabetically , 65 | ); 66 | $set->next_combination(); 67 | }; 68 | is( $@, q{}, q{expecting compare not to die} ); 69 | is( $c, q{abcd}, q{expecting ordered array} ); 70 | } 71 | 72 | # do the same with a list of references 73 | # 74 | { 75 | my $alphabetically = sub { 76 | my $a = shift; die qq{NOREFARGS\n} unless q{SCALAR} eq ref $a; 77 | my $b = shift; die qq{NOREFARGS\n} unless q{SCALAR} eq ref $a; 78 | return $$a cmp $$b; 79 | }; 80 | 81 | # we now have an array of refs, so we need a map {} in between 82 | # 83 | my $c = join q{}, map { $$_ } eval { 84 | my $set = Math::Combinatorics->new( 85 | count => scalar @TEST_REF , 86 | data => [ @TEST_REF ] , 87 | compare => $alphabetically , 88 | ); 89 | $set->next_combination(); 90 | }; 91 | is( $@, q{}, q{expecting compare not to die} ); 92 | is( $c, q{abcd}, q{expecting ordered array} ); 93 | } 94 | -------------------------------------------------------------------------------- /inc/ipcp_L1.h: -------------------------------------------------------------------------------- 1 | #ifndef IPCP_L1_H 2 | #define IPCP_L1_H 3 | 4 | /*************************************************************************** 5 | Code taken from 6 | Samuel Pakalapati - samuelpakalapati@gmail.com 7 | Biswabandan Panda - biswap@cse.iitk.ac.in 8 | ***************************************************************************/ 9 | 10 | #include "cache.h" 11 | #include "prefetcher.h" 12 | #include "ipcp_vars.h" 13 | 14 | class IP_TABLE_L1 15 | { 16 | public: 17 | uint64_t ip_tag; 18 | uint64_t last_page; // last page seen by IP 19 | uint64_t last_cl_offset; // last cl offset in the 4KB page 20 | int64_t last_stride; // last delta observed 21 | uint16_t ip_valid; // Valid IP or not 22 | int conf; // CS conf 23 | uint16_t signature; // CPLX signature 24 | uint16_t str_dir; // stream direction 25 | uint16_t str_valid; // stream valid 26 | uint16_t str_strength; // stream strength 27 | 28 | IP_TABLE_L1 () 29 | { 30 | ip_tag = 0; 31 | last_page = 0; 32 | last_cl_offset = 0; 33 | last_stride = 0; 34 | ip_valid = 0; 35 | signature = 0; 36 | conf = 0; 37 | str_dir = 0; 38 | str_valid = 0; 39 | str_strength = 0; 40 | }; 41 | }; 42 | 43 | class DELTA_PRED_TABLE 44 | { 45 | public: 46 | int delta; 47 | int conf; 48 | 49 | DELTA_PRED_TABLE () 50 | { 51 | delta = 0; 52 | conf = 0; 53 | }; 54 | }; 55 | 56 | class IPCP_L1 : public Prefetcher 57 | { 58 | public: 59 | CACHE *m_parent_cache; 60 | IP_TABLE_L1 trackers_l1[NUM_CPUS][NUM_IP_TABLE_L1_ENTRIES]; 61 | DELTA_PRED_TABLE DPT_l1[NUM_CPUS][4096]; 62 | uint64_t ghb_l1[NUM_CPUS][NUM_GHB_ENTRIES]; 63 | uint64_t prev_cpu_cycle[NUM_CPUS]; 64 | uint64_t num_misses[NUM_CPUS]; 65 | float mpkc[NUM_CPUS] = {0}; 66 | int spec_nl[NUM_CPUS] = {0}; 67 | 68 | private: 69 | void init_stats(); 70 | void init_knobs(); 71 | uint16_t update_sig_l1(uint16_t old_sig, int delta); 72 | uint32_t encode_metadata(int stride, uint16_t type, int spec_nl); 73 | void check_for_stream_l1(int index, uint64_t cl_addr, uint8_t cpu); 74 | int update_conf(int stride, int pred_stride, int conf); 75 | 76 | public: 77 | IPCP_L1(std::string type, CACHE *cache); 78 | ~IPCP_L1(); 79 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, std::vector &pref_addr); 80 | void dump_stats(); 81 | void print_config(); 82 | void cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr); 83 | }; 84 | 85 | #endif /* IPCP_L1_H */ 86 | -------------------------------------------------------------------------------- /experiments/rollup_1C_varying_DRAM_bw.exp: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | ## 3 | ## This file contains all the experiments required 4 | ## to reproduce single-core performance results of Pythia. 5 | ## 6 | ## Please follow the README to know how to use this file. 7 | ## 8 | ## Owner: Rahul Bera (write2bera@gmail.com) 9 | ## 10 | ############################################################### 11 | 12 | 13 | # configurations 14 | BASE = --warmup_instructions=100000000 --simulation_instructions=500000000 15 | NOPREF = --config=$(PYTHIA_HOME)/config/nopref.ini 16 | STRIDE = --l2c_prefetcher_types=stride --config=$(PYTHIA_HOME)/config/stride.ini 17 | SPP_DEV2 = --l2c_prefetcher_types=spp_dev2 --config=$(PYTHIA_HOME)/config/spp_dev2.ini 18 | MLOP = --l2c_prefetcher_types=mlop --config=$(PYTHIA_HOME)/config/mlop.ini 19 | BINGO = --l2c_prefetcher_types=bingo --config=$(PYTHIA_HOME)/config/bingo.ini 20 | PYTHIA = --l2c_prefetcher_types=scooby --config=$(PYTHIA_HOME)/config/pythia.ini 21 | 22 | nopref $(BASE) $(NOPREF) 23 | spp $(BASE) $(SPP_DEV2) 24 | bingo $(BASE) $(BINGO) 25 | mlop $(BASE) $(MLOP) 26 | pythia $(BASE) $(PYTHIA) 27 | 28 | nopref_MTPS150 $(BASE) $(NOPREF) --dram_io_freq=150 29 | spp_MTPS150 $(BASE) $(SPP_DEV2) --dram_io_freq=150 30 | bingo_MTPS150 $(BASE) $(BINGO) --dram_io_freq=150 31 | mlop_MTPS150 $(BASE) $(MLOP) --dram_io_freq=150 32 | pythia_MTPS150 $(BASE) $(PYTHIA) --dram_io_freq=150 33 | 34 | nopref_MTPS300 $(BASE) $(NOPREF) --dram_io_freq=300 35 | spp_MTPS300 $(BASE) $(SPP_DEV2) --dram_io_freq=300 36 | bingo_MTPS300 $(BASE) $(BINGO) --dram_io_freq=300 37 | mlop_MTPS300 $(BASE) $(MLOP) --dram_io_freq=300 38 | pythia_MTPS300 $(BASE) $(PYTHIA) --dram_io_freq=300 39 | 40 | nopref_MTPS600 $(BASE) $(NOPREF) --dram_io_freq=600 41 | spp_MTPS600 $(BASE) $(SPP_DEV2) --dram_io_freq=600 42 | bingo_MTPS600 $(BASE) $(BINGO) --dram_io_freq=600 43 | mlop_MTPS600 $(BASE) $(MLOP) --dram_io_freq=600 44 | pythia_MTPS600 $(BASE) $(PYTHIA) --dram_io_freq=600 45 | 46 | nopref_MTPS1200 $(BASE) $(NOPREF) --dram_io_freq=1200 47 | spp_MTPS1200 $(BASE) $(SPP_DEV2) --dram_io_freq=1200 48 | bingo_MTPS1200 $(BASE) $(BINGO) --dram_io_freq=1200 49 | mlop_MTPS1200 $(BASE) $(MLOP) --dram_io_freq=1200 50 | pythia_MTPS1200 $(BASE) $(PYTHIA) --dram_io_freq=1200 51 | 52 | nopref_MTPS4800 $(BASE) $(NOPREF) --dram_io_freq=4800 53 | spp_MTPS4800 $(BASE) $(SPP_DEV2) --dram_io_freq=4800 54 | bingo_MTPS4800 $(BASE) $(BINGO) --dram_io_freq=4800 55 | mlop_MTPS4800 $(BASE) $(MLOP) --dram_io_freq=4800 56 | pythia_MTPS4800 $(BASE) $(PYTHIA) --dram_io_freq=4800 57 | 58 | nopref_MTPS9600 $(BASE) $(NOPREF) --dram_io_freq=9600 59 | spp_MTPS9600 $(BASE) $(SPP_DEV2) --dram_io_freq=9600 60 | bingo_MTPS9600 $(BASE) $(BINGO) --dram_io_freq=9600 61 | mlop_MTPS9600 $(BASE) $(MLOP) --dram_io_freq=9600 62 | pythia_MTPS9600 $(BASE) $(PYTHIA) --dram_io_freq=9600 63 | -------------------------------------------------------------------------------- /tracer/makefile.rules: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # 3 | # This file includes all the test targets as well as all the 4 | # non-default build rules and test recipes. 5 | # 6 | ############################################################## 7 | 8 | 9 | ############################################################## 10 | # 11 | # Test targets 12 | # 13 | ############################################################## 14 | 15 | ###### Place all generic definitions here ###### 16 | 17 | # This defines tests which run tools of the same name. This is simply for convenience to avoid 18 | # defining the test name twice (once in TOOL_ROOTS and again in TEST_ROOTS). 19 | # Tests defined here should not be defined in TOOL_ROOTS and TEST_ROOTS. 20 | TEST_TOOL_ROOTS := MyPinTool 21 | 22 | # This defines the tests to be run that were not already defined in TEST_TOOL_ROOTS. 23 | TEST_ROOTS := 24 | 25 | # This defines a list of tests that should run in the "short" sanity. Tests in this list must also 26 | # appear either in the TEST_TOOL_ROOTS or the TEST_ROOTS list. 27 | # If the entire directory should be tested in sanity, assign TEST_TOOL_ROOTS and TEST_ROOTS to the 28 | # SANITY_SUBSET variable in the tests section below (see example in makefile.rules.tmpl). 29 | SANITY_SUBSET := 30 | 31 | # This defines the tools which will be run during the the tests, and were not already defined in 32 | # TEST_TOOL_ROOTS. 33 | TOOL_ROOTS := 34 | 35 | # This defines the static analysis tools which will be run during the the tests. They should not 36 | # be defined in TEST_TOOL_ROOTS. If a test with the same name exists, it should be defined in 37 | # TEST_ROOTS. 38 | # Note: Static analysis tools are in fact executables linked with the Pin Static Analysis Library. 39 | # This library provides a subset of the Pin APIs which allows the tool to perform static analysis 40 | # of an application or dll. Pin itself is not used when this tool runs. 41 | SA_TOOL_ROOTS := 42 | 43 | # This defines all the applications that will be run during the tests. 44 | APP_ROOTS := 45 | 46 | # This defines any additional object files that need to be compiled. 47 | OBJECT_ROOTS := 48 | 49 | # This defines any additional dlls (shared objects), other than the pintools, that need to be compiled. 50 | DLL_ROOTS := 51 | 52 | # This defines any static libraries (archives), that need to be built. 53 | LIB_ROOTS := 54 | 55 | 56 | ############################################################## 57 | # 58 | # Test recipes 59 | # 60 | ############################################################## 61 | 62 | # This section contains recipes for tests other than the default. 63 | # See makefile.default.rules for the default test rules. 64 | # All tests in this section should adhere to the naming convention: .test 65 | 66 | 67 | ############################################################## 68 | # 69 | # Build rules 70 | # 71 | ############################################################## 72 | 73 | # This section contains the build rules for all binaries that have special build rules. 74 | # See makefile.default.rules for the default build rules. 75 | -------------------------------------------------------------------------------- /scripts/Math/patches/diff-2.7.0-reinstall-foreigh-full: -------------------------------------------------------------------------------- 1 | --- pari-2.7.0/src/language/eval.c-pre 2019-03-01 03:30:30.428655500 -0800 2 | +++ pari-2.7.0/src/language/eval.c 2019-03-01 17:29:05.309988700 -0800 3 | @@ -136,6 +136,9 @@ pop_val(entree *ep) 4 | void 5 | freeep(entree *ep) 6 | { 7 | + if (foreignFuncFree && ep->code && (*ep->code == 'x')) 8 | + (*foreignFuncFree)(ep); /* function created by foreign interpreter */ 9 | + 10 | if (EpSTATIC(ep)) return; /* gp function loaded at init time */ 11 | if (ep->help) {pari_free((void*)ep->help); ep->help=NULL;} 12 | if (ep->code) {pari_free((void*)ep->code); ep->code=NULL;} 13 | --- pari-2.7.0/src/language/init.c-pre 2019-03-01 03:44:51.207967500 -0800 14 | +++ pari-2.7.0/src/language/init.c 2019-03-01 17:28:05.405883500 -0800 15 | @@ -85,6 +85,12 @@ static pari_stack s_MODULES, s_OLDMODULE 16 | const long functions_tblsz = 135; /* size of functions_hash */ 17 | entree **functions_hash, **defaults_hash; 18 | 19 | +void *foreignHandler; /* Handler for foreign commands. */ 20 | +char foreignExprSwitch = 3; /* Just some unprobable char. */ 21 | +GEN (*foreignExprHandler)(char*); /* Handler for foreign expressions.*/ 22 | +entree* (*foreignAutoload)(const char*, long len); /* Autoloader */ 23 | +void (*foreignFuncFree)(entree *); /* How to free external entree. */ 24 | + 25 | void (*cb_pari_ask_confirm)(const char *); 26 | int (*cb_pari_handle_exception)(long); 27 | int (*cb_pari_whatnow)(PariOUT *out, const char *, int); 28 | @@ -2340,6 +2346,12 @@ pari_version(void) 29 | * 30 | * Syntax requirements: 31 | * = Separator '=' required. 32 | + * 33 | + * Origin: 34 | + * x Installed foreign function. Put the ep of the function as the 35 | + * first argument, fill the rest with PARI arguments, 36 | + * then call installedHandler with these arguments. 37 | + * Should be the first char in the code. 38 | **************************************************************************** 39 | */ 40 | #include "init.h" 41 | --- pari-2.7.0/src/language/anal.h-pre 2014-03-20 01:59:28.000000000 -0700 42 | +++ pari-2.7.0/src/language/anal.h 2019-03-01 17:21:54.576632100 -0800 43 | @@ -33,6 +33,12 @@ void pari_fill_hashtable(entree **tabl 44 | void compile_err(const char *msg, const char *str); 45 | void compile_varerr(const char *str); 46 | 47 | +extern void *foreignHandler; 48 | +extern GEN (*foreignExprHandler)(char*); 49 | +extern char foreignExprSwitch; 50 | +extern entree * (*foreignAutoload)(const char*, long len); 51 | +extern void (*foreignFuncFree)(entree *); 52 | + 53 | #ifdef STACK_CHECK 54 | extern THREAD void *PARI_stack_limit; 55 | #endif 56 | --- pari-2.7.0/src/language/anal.c-pre 2019-03-01 03:36:32.318091200 -0800 57 | +++ pari-2.7.0/src/language/anal.c 2019-03-01 17:24:51.107542200 -0800 58 | @@ -753,6 +753,8 @@ findentry(const char *name, long len, en 59 | entree *ep; 60 | for (ep = ep1; ep; ep = ep->next) 61 | if (!strncmp(ep->name, name, len) && !(ep->name)[len]) return ep; 62 | + if (foreignAutoload) /* Try to autoload. */ 63 | + return foreignAutoload(name,len); 64 | return NULL; /* not found */ 65 | } 66 | 67 | -------------------------------------------------------------------------------- /scripts/Crypt/Random/Generator.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -sw 2 | ## 3 | ## Copyright (c) 1998-2018, Vipul Ved Prakash. All rights reserved. 4 | ## This code is free software; you can redistribute it and/or modify 5 | ## it under the same terms as Perl itself. 6 | 7 | package Crypt::Random::Generator; 8 | use Crypt::Random qw(makerandom makerandom_itv makerandom_octet); 9 | use Carp; 10 | 11 | my @PROVIDERS = qw(devrandom devurandom egd rand); 12 | my %STRENGTH = ( 0 => [ qw(devurandom egd rand) ], 1 => [ qw(devrandom egd rand) ] ); 13 | 14 | sub new { 15 | 16 | my ($class, %params) = @_; 17 | 18 | my $self = { _STRENGTH => \%STRENGTH, _PROVIDERS => \@PROVIDERS }; 19 | 20 | $$self{Strength} = $params{Strength} || 0; 21 | $$self{Uniform} = $params{Uniform} || 0; 22 | $$self{Provider} = $params{Provider} || ""; 23 | $$self{ProviderParams} = $params{ProviderParams} || ""; 24 | 25 | bless $self, $class; 26 | 27 | unless ($$self{Provider}) { 28 | SELECT_PROVIDER: for ($self->strength_order($$self{Strength})) { 29 | my $pname = $_; my $fqpname = "Crypt::Random::Provider::$pname"; 30 | if (eval "use $fqpname; $fqpname->available()") { 31 | if (grep { $pname eq $_ } $self->providers) { 32 | $$self{Provider} = $pname; 33 | last SELECT_PROVIDER; 34 | } 35 | } 36 | } 37 | } 38 | 39 | croak "No provider available.\n" unless $$self{Provider}; 40 | return $self; 41 | 42 | } 43 | 44 | 45 | sub providers { 46 | 47 | my ($self, @args) = @_; 48 | if (@args) { $$self{_PROVIDERS} = [@args] } 49 | return @{$$self{_PROVIDERS}}; 50 | 51 | } 52 | 53 | 54 | sub strength_order { 55 | 56 | my ($self, $strength, @args) = @_; 57 | if (@args) { $$self{_STRENGTH}{$strength} = [@args] } 58 | return @{$$self{_STRENGTH}{$strength}} 59 | 60 | } 61 | 62 | 63 | sub integer { 64 | 65 | my ($self, %params) = @_; 66 | if ($params{Size}) { 67 | return makerandom ( 68 | Size => $params{Size}, 69 | Provider => $$self{Provider}, 70 | Verbosity => $params{Verbosity} || $$self{Verbosity}, 71 | Uniform => $params{Uniform} || $$self{Uniform}, 72 | %{$$self{ProviderParams}}, 73 | ) 74 | } elsif ($params{Upper}) { 75 | return makerandom_itv ( 76 | Lower => $params{Lower} || 0, 77 | Upper => $params{Upper}, 78 | Provider => $$self{Provider}, 79 | Verbosity => $params{Verbosity} || $$self{Verbosity}, 80 | Uniform => $params{Uniform} || $$self{Uniform}, 81 | %{$$self{ProviderParams}}, 82 | ) 83 | } 84 | 85 | } 86 | 87 | 88 | sub string { 89 | 90 | my ($self, %params) = @_; 91 | return makerandom_octet ( 92 | %params, 93 | Provider => $$self{Provider}, 94 | Verbosity => $params{Verbosity} || $$self{Verbosity}, 95 | %{$$self{ProviderParams}}, 96 | ) 97 | 98 | } 99 | 100 | 101 | -------------------------------------------------------------------------------- /experiments/MICRO21_1C.exp: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | ## 3 | ## This file contains all the experiments required 4 | ## to reproduce single-core performance results of Pythia. 5 | ## 6 | ## Please follow the README to know how to use this file. 7 | ## 8 | ## Owner: Rahul Bera (write2bera@gmail.com) 9 | ## 10 | ############################################################### 11 | 12 | 13 | # configurations 14 | BASE = --warmup_instructions=100000000 --simulation_instructions=500000000 15 | NOPREF = --config=$(PYTHIA_HOME)/config/nopref.ini 16 | STRIDE = --l2c_prefetcher_types=stride --config=$(PYTHIA_HOME)/config/stride.ini 17 | SPP_DEV2 = --l2c_prefetcher_types=spp_dev2 --config=$(PYTHIA_HOME)/config/spp_dev2.ini 18 | MLOP = --l2c_prefetcher_types=mlop --config=$(PYTHIA_HOME)/config/mlop.ini 19 | BINGO = --l2c_prefetcher_types=bingo --config=$(PYTHIA_HOME)/config/bingo.ini 20 | DSPATCH = --l2c_prefetcher_types=dspatch --config=$(PYTHIA_HOME)/config/dspatch.ini 21 | SPP_PPF_DEV = --l2c_prefetcher_types=spp_ppf_dev --config=$(PYTHIA_HOME)/config/spp_ppf_dev.ini 22 | PYTHIA = --l2c_prefetcher_types=scooby --config=$(PYTHIA_HOME)/config/pythia.ini 23 | 24 | # experiments for Figure 10(a) and Figure 8 25 | nopref $(BASE) $(NOPREF) 26 | spp $(BASE) $(SPP_DEV2) 27 | bingo $(BASE) $(BINGO) 28 | mlop $(BASE) $(MLOP) 29 | pythia $(BASE) $(PYTHIA) 30 | 31 | 32 | # Experiments for Figure 9(b) 33 | nopref_MTPS150 $(BASE) $(NOPREF) --dram_io_freq=150 34 | spp_MTPS150 $(BASE) $(SPP_DEV2) --dram_io_freq=150 35 | bingo_MTPS150 $(BASE) $(BINGO) --dram_io_freq=150 36 | mlop_MTPS150 $(BASE) $(MLOP) --dram_io_freq=150 37 | pythia_MTPS150 $(BASE) $(PYTHIA) --dram_io_freq=150 38 | 39 | nopref_MTPS300 $(BASE) $(NOPREF) --dram_io_freq=300 40 | spp_MTPS300 $(BASE) $(SPP_DEV2) --dram_io_freq=300 41 | bingo_MTPS300 $(BASE) $(BINGO) --dram_io_freq=300 42 | mlop_MTPS300 $(BASE) $(MLOP) --dram_io_freq=300 43 | pythia_MTPS300 $(BASE) $(PYTHIA) --dram_io_freq=300 44 | 45 | nopref_MTPS600 $(BASE) $(NOPREF) --dram_io_freq=600 46 | spp_MTPS600 $(BASE) $(SPP_DEV2) --dram_io_freq=600 47 | bingo_MTPS600 $(BASE) $(BINGO) --dram_io_freq=600 48 | mlop_MTPS600 $(BASE) $(MLOP) --dram_io_freq=600 49 | pythia_MTPS600 $(BASE) $(PYTHIA) --dram_io_freq=600 50 | 51 | nopref_MTPS1200 $(BASE) $(NOPREF) --dram_io_freq=1200 52 | spp_MTPS1200 $(BASE) $(SPP_DEV2) --dram_io_freq=1200 53 | bingo_MTPS1200 $(BASE) $(BINGO) --dram_io_freq=1200 54 | mlop_MTPS1200 $(BASE) $(MLOP) --dram_io_freq=1200 55 | pythia_MTPS1200 $(BASE) $(PYTHIA) --dram_io_freq=1200 56 | 57 | nopref_MTPS4800 $(BASE) $(NOPREF) --dram_io_freq=4800 58 | spp_MTPS4800 $(BASE) $(SPP_DEV2) --dram_io_freq=4800 59 | bingo_MTPS4800 $(BASE) $(BINGO) --dram_io_freq=4800 60 | mlop_MTPS4800 $(BASE) $(MLOP) --dram_io_freq=4800 61 | pythia_MTPS4800 $(BASE) $(PYTHIA) --dram_io_freq=4800 62 | 63 | nopref_MTPS9600 $(BASE) $(NOPREF) --dram_io_freq=9600 64 | spp_MTPS9600 $(BASE) $(SPP_DEV2) --dram_io_freq=9600 65 | bingo_MTPS9600 $(BASE) $(BINGO) --dram_io_freq=9600 66 | mlop_MTPS9600 $(BASE) $(MLOP) --dram_io_freq=9600 67 | pythia_MTPS9600 $(BASE) $(PYTHIA) --dram_io_freq=9600 68 | -------------------------------------------------------------------------------- /replacement/base_replacement.cc: -------------------------------------------------------------------------------- 1 | #include "cache.h" 2 | 3 | uint32_t CACHE::find_victim(uint32_t cpu, uint64_t instr_id, uint32_t set, const BLOCK *current_set, uint64_t ip, uint64_t full_addr, uint32_t type) 4 | { 5 | // baseline LRU replacement policy for other caches 6 | return lru_victim(cpu, instr_id, set, current_set, ip, full_addr, type); 7 | } 8 | 9 | void CACHE::update_replacement_state(uint32_t cpu, uint32_t set, uint32_t way, uint64_t full_addr, uint64_t ip, uint64_t victim_addr, uint32_t type, uint8_t hit) 10 | { 11 | if (type == WRITEBACK) { 12 | if (hit) // wrietback hit does not update LRU state 13 | return; 14 | } 15 | 16 | return lru_update(set, way); 17 | } 18 | 19 | uint32_t CACHE::lru_victim(uint32_t cpu, uint64_t instr_id, uint32_t set, const BLOCK *current_set, uint64_t ip, uint64_t full_addr, uint32_t type) 20 | { 21 | uint32_t way = 0; 22 | 23 | // fill invalid line first 24 | for (way=0; way>LOG2_BLOCK_SIZE) << " victim address: " << block[set][way].address << " data: " << block[set][way].data; 30 | cout << dec << " lru: " << block[set][way].lru << endl; }); 31 | 32 | break; 33 | } 34 | } 35 | 36 | // LRU victim 37 | if (way == NUM_WAY) { 38 | for (way=0; way>LOG2_BLOCK_SIZE) << " victim address: " << block[set][way].address << " data: " << block[set][way].data; 44 | cout << dec << " lru: " << block[set][way].lru << endl; }); 45 | 46 | break; 47 | } 48 | } 49 | } 50 | 51 | if (way == NUM_WAY) { 52 | cerr << "[" << NAME << "] " << __func__ << " no victim! set: " << set << endl; 53 | assert(0); 54 | } 55 | 56 | return way; 57 | } 58 | 59 | void CACHE::lru_update(uint32_t set, uint32_t way) 60 | { 61 | // update lru replacement state 62 | for (uint32_t i=0; i \$tlist_file, 20 | 'exp=s' => \$exp_file, 21 | 'exe=s' => \$exe, 22 | 'ncores=s' => \$ncores, 23 | 'local=s' => \$local, 24 | 'exclude=s' => \$exclude_list, 25 | 'partition=s' => \$slurm_partition, 26 | 'exclude=s' => \$exclude_list, 27 | 'include=s' => \$include_list, 28 | 'extra=s' => \$extra, 29 | ) or die "Usage: $0 --exe --exp --tlist \n"; 30 | 31 | die "\$PYTHIA_HOME env variable is not defined.\nHave you sourced setvars.sh?\n" unless defined $ENV{'PYTHIA_HOME'}; 32 | 33 | die "Supply exe\n" unless defined $exe; 34 | die "Supply tlist\n" unless defined $tlist_file; 35 | die "Supply exp\n" unless defined $exp_file; 36 | 37 | my $exclude_nodes_list = ""; 38 | $exclude_nodes_list = "kratos[$exclude_list]" if defined $exclude_list; 39 | my $include_nodes_list = ""; 40 | $include_nodes_list = "kratos[$include_list]" if defined $include_list; 41 | 42 | my @trace_info = Trace::parse($tlist_file); 43 | my @exp_info = Exp::parse($exp_file); 44 | if($ncores == 0) 45 | { 46 | print "have to supply -ncores\n"; 47 | exit 1; 48 | } 49 | 50 | # preamble for sbatch script 51 | if($local eq "0") 52 | { 53 | print "#!/bin/bash -l\n"; 54 | print "#\n"; 55 | print "#\n"; 56 | } 57 | else 58 | { 59 | print "#!/bin/bash\n"; 60 | print "#\n"; 61 | print "#\n"; 62 | } 63 | 64 | print "#\n"; 65 | print "# Traces:\n"; 66 | foreach $trace (@trace_info) 67 | { 68 | my $trace_name = $trace->{"NAME"}; 69 | print "# $trace_name\n"; 70 | } 71 | print "#\n"; 72 | 73 | print "#\n"; 74 | print "# Experiments:\n"; 75 | foreach $exp (@exp_info) 76 | { 77 | my $exp_name = $exp->{"NAME"}; 78 | my $exp_knobs = $exp->{"KNOBS"}; 79 | print "# $exp_name: $exp_knobs\n"; 80 | } 81 | print "#\n"; 82 | print "#\n"; 83 | print "#\n"; 84 | print "#\n"; 85 | 86 | foreach $trace (@trace_info) 87 | { 88 | foreach $exp (@exp_info) 89 | { 90 | my $exp_name = $exp->{"NAME"}; 91 | my $exp_knobs = $exp->{"KNOBS"}; 92 | my $trace_name = $trace->{"NAME"}; 93 | my $trace_input = $trace->{"TRACE"}; 94 | my $trace_knobs = $trace->{"KNOBS"}; 95 | 96 | my $cmdline; 97 | if($local) 98 | { 99 | $cmdline = "$exe $exp_knobs $trace_knobs -traces $trace_input > ${trace_name}_${exp_name}.out 2>&1"; 100 | } 101 | else 102 | { 103 | $slurm_cmd = "sbatch -p $slurm_partition --mincpus=1"; 104 | if (defined $include_list) 105 | { 106 | $slurm_cmd = $slurm_cmd." --nodelist=${include_nodes_list}"; 107 | } 108 | if (defined $exclude_list) 109 | { 110 | $slurm_cmd = $slurm_cmd." --exclude=${exclude_nodes_list}"; 111 | } 112 | if (defined $extra) 113 | { 114 | $slurm_cmd = $slurm_cmd." $extra"; 115 | } 116 | $slurm_cmd = $slurm_cmd." -c $ncores -J ${trace_name}_${exp_name} -o ${trace_name}_${exp_name}.out -e ${trace_name}_${exp_name}.err"; 117 | $cmdline = "$slurm_cmd $ENV{'PYTHIA_HOME'}/wrapper.sh $exe \"$exp_knobs $trace_knobs -traces $trace_input\""; 118 | } 119 | 120 | # Additional hook replace 121 | $cmdline =~ s/\$\(PYTHIA_HOME\)/$ENV{'PYTHIA_HOME'}/g; 122 | $cmdline =~ s/\$\(EXP\)/$exp_name/g; 123 | $cmdline =~ s/\$\(TRACE\)/$trace_name/g; 124 | $cmdline =~ s/\$\(NCORES\)/$ncores/g; 125 | 126 | print "$cmdline\n"; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /inc/sms.h: -------------------------------------------------------------------------------- 1 | #ifndef SMS_H 2 | #define SMS_H 3 | 4 | #include 5 | #include 6 | #include "bitmap.h" 7 | #include "prefetcher.h" 8 | 9 | using namespace std; 10 | 11 | class FTEntry 12 | { 13 | public: 14 | uint64_t page; 15 | uint64_t pc; 16 | uint32_t trigger_offset; 17 | 18 | public: 19 | void reset() 20 | { 21 | page = 0xdeadbeef; 22 | pc = 0xdeadbeef; 23 | trigger_offset = 0; 24 | } 25 | FTEntry(){reset();} 26 | ~FTEntry(){} 27 | }; 28 | 29 | class ATEntry 30 | { 31 | public: 32 | uint64_t page; 33 | uint64_t pc; 34 | uint32_t trigger_offset; 35 | Bitmap pattern; 36 | uint32_t age; 37 | 38 | public: 39 | void reset() 40 | { 41 | page = pc = 0xdeadbeef; 42 | trigger_offset = 0; 43 | pattern.reset(); 44 | age = 0; 45 | } 46 | ATEntry(){reset();} 47 | ~ATEntry(){} 48 | }; 49 | 50 | class PHTEntry 51 | { 52 | public: 53 | uint64_t signature; 54 | Bitmap pattern; 55 | uint32_t age; 56 | 57 | public: 58 | void reset() 59 | { 60 | signature = 0xdeadbeef; 61 | pattern.reset(); 62 | age = 0; 63 | } 64 | PHTEntry(){reset();} 65 | ~PHTEntry(){} 66 | }; 67 | 68 | class SMSPrefetcher : public Prefetcher 69 | { 70 | private: 71 | deque filter_table; 72 | deque acc_table; 73 | vector > pht; 74 | uint32_t pht_sets; 75 | deque pref_buffer; 76 | 77 | struct 78 | { 79 | struct 80 | { 81 | uint64_t lookup; 82 | uint64_t hit; 83 | uint64_t insert; 84 | uint64_t evict; 85 | } ft; 86 | struct 87 | { 88 | uint64_t lookup; 89 | uint64_t hit; 90 | uint64_t insert; 91 | uint64_t evict; 92 | } at; 93 | struct 94 | { 95 | uint64_t lookup; 96 | uint64_t hit; 97 | uint64_t insert; 98 | uint64_t evict; 99 | } pht; 100 | struct 101 | { 102 | uint64_t called; 103 | uint64_t pht_miss; 104 | uint64_t pref_generated; 105 | } generate_prefetch; 106 | struct 107 | { 108 | uint64_t spilled; 109 | uint64_t buffered; 110 | uint64_t issued; 111 | } pref_buffer; 112 | 113 | } stats; 114 | 115 | private: 116 | void init_knobs(); 117 | void init_stats(); 118 | 119 | deque::iterator search_filter_table(uint64_t page); 120 | deque::iterator search_victim_filter_table(); 121 | void evict_filter_table(deque::iterator victim); 122 | void insert_filter_table(uint64_t pc, uint64_t page, uint32_t offset); 123 | 124 | deque::iterator search_acc_table(uint64_t page); 125 | deque::iterator search_victim_acc_table(); 126 | void evict_acc_table(deque::iterator victim); 127 | void update_age_acc_table(deque::iterator current); 128 | void insert_acc_table(FTEntry *ftentry, uint32_t offset); 129 | 130 | deque::iterator search_pht(uint64_t signature, int32_t *set); 131 | deque::iterator search_victim_pht(int32_t set); 132 | void evcit_pht(int32_t set, deque::iterator victim); 133 | void update_age_pht(int32_t set, deque::iterator current); 134 | void insert_pht_table(ATEntry *atentry); 135 | 136 | uint64_t create_signature(uint64_t pc, uint32_t offset); 137 | int generate_prefetch(uint64_t pc, uint64_t address, uint64_t page, uint32_t offset, vector &pref_addr); 138 | void buffer_prefetch(vector pref_addr); 139 | void issue_prefetch(vector &pref_addr); 140 | 141 | public: 142 | SMSPrefetcher(string type); 143 | ~SMSPrefetcher(); 144 | void invoke_prefetcher(uint64_t pc, uint64_t address, uint8_t cache_hit, uint8_t type, vector &pref_addr); 145 | void dump_stats(); 146 | void print_config(); 147 | }; 148 | 149 | #endif /* SMS_H */ -------------------------------------------------------------------------------- /prefetcher/multi.l1d_pref: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "cache.h" 4 | #include "prefetcher.h" 5 | #include "next_line.h" 6 | #include "stride.h" 7 | #include "ipcp_L1.h" 8 | 9 | using namespace std; 10 | 11 | namespace knob 12 | { 13 | extern vector l1d_prefetcher_types; 14 | } 15 | 16 | void CACHE::l1d_prefetcher_initialize() 17 | { 18 | for(uint32_t index = 0; index < knob::l1d_prefetcher_types.size(); ++index) 19 | { 20 | if(!knob::l1d_prefetcher_types[index].compare("none")) 21 | { 22 | cout << "adding L1D_PREFETCHER: NONE" << endl; 23 | } 24 | else if(!knob::l1d_prefetcher_types[index].compare("next_line")) 25 | { 26 | cout << "adding L1D_PREFETCHER: next_line" << endl; 27 | NextLinePrefetcher *pref_nl = new NextLinePrefetcher(knob::l1d_prefetcher_types[index]); 28 | l1d_prefetchers.push_back(pref_nl); 29 | } 30 | else if(!knob::l1d_prefetcher_types[index].compare("stride")) 31 | { 32 | cout << "adding L1D_PREFETCHER: Stride" << endl; 33 | StridePrefetcher *pref_stride = new StridePrefetcher(knob::l1d_prefetcher_types[index]); 34 | l1d_prefetchers.push_back(pref_stride); 35 | } 36 | else if(!knob::l1d_prefetcher_types[index].compare("ipcp")) 37 | { 38 | cout << "adding L1D_PREFETCHER: IPCP" << endl; 39 | IPCP_L1 *pref_ipcp_l1 = new IPCP_L1(knob::l1d_prefetcher_types[index], this); 40 | l1d_prefetchers.push_back(pref_ipcp_l1); 41 | } 42 | else 43 | { 44 | cout << "unsupported prefetcher type " << knob::l1d_prefetcher_types[index] << endl; 45 | exit(1); 46 | } 47 | } 48 | 49 | assert(knob::l1d_prefetcher_types.size() == l1d_prefetchers.size() || !knob::l1d_prefetcher_types[0].compare("none")); 50 | } 51 | 52 | void CACHE::l1d_prefetcher_operate(uint64_t addr, uint64_t ip, uint8_t cache_hit, uint8_t type) 53 | { 54 | vector pref_addr; 55 | for(uint32_t index = 0; index < l1d_prefetchers.size(); ++index) 56 | { 57 | l1d_prefetchers[index]->invoke_prefetcher(ip, addr, cache_hit, type, pref_addr); 58 | if(knob::l1d_prefetcher_types[index].compare("ipcp") 59 | && !pref_addr.empty()) 60 | { 61 | for(uint32_t addr_index = 0; addr_index < pref_addr.size(); ++addr_index) 62 | { 63 | prefetch_line(ip, addr, pref_addr[addr_index], FILL_L1, 0); 64 | } 65 | } 66 | pref_addr.clear(); 67 | } 68 | } 69 | 70 | void CACHE::l1d_prefetcher_cache_fill(uint64_t addr, uint32_t set, uint32_t way, uint8_t prefetch, uint64_t evicted_addr, uint32_t metadata_in) 71 | { 72 | if(prefetch) 73 | { 74 | for(uint32_t index = 0; index < l1d_prefetchers.size(); ++index) 75 | { 76 | if(!l1d_prefetchers[index]->get_type().compare("next_line")) 77 | { 78 | NextLinePrefetcher *pref_nl = (NextLinePrefetcher*)l1d_prefetchers[index]; 79 | pref_nl->register_fill(addr); 80 | } 81 | } 82 | } 83 | } 84 | 85 | uint32_t CACHE::l1d_prefetcher_prefetch_hit(uint64_t addr, uint64_t ip, uint32_t metadata_in) 86 | { 87 | return metadata_in; 88 | } 89 | 90 | void CACHE::l1d_prefetcher_final_stats() 91 | { 92 | for(uint32_t index = 0; index < l1d_prefetchers.size(); ++index) 93 | { 94 | l1d_prefetchers[index]->dump_stats(); 95 | } 96 | } 97 | 98 | void CACHE::l1d_prefetcher_print_config() 99 | { 100 | for(uint32_t index = 0; index < l1d_prefetchers.size(); ++index) 101 | { 102 | l1d_prefetchers[index]->print_config(); 103 | } 104 | } 105 | 106 | void CACHE::l1d_prefetcher_broadcast_bw(uint8_t bw_level) 107 | { 108 | 109 | } 110 | 111 | void CACHE::l1d_prefetcher_broadcast_ipc(uint8_t ipc) 112 | { 113 | 114 | } 115 | 116 | void CACHE::l1d_prefetcher_broadcast_acc(uint32_t acc_level) 117 | { 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/bitmap.cc: -------------------------------------------------------------------------------- 1 | #include "bitmap.h" 2 | #include 3 | #include 4 | 5 | std::string BitmapHelper::to_string(Bitmap bmp, uint32_t size) 6 | { 7 | // return bmp.to_string(); 8 | std::stringstream ss; 9 | for(int32_t bit = size-1; bit >= 0; --bit) 10 | { 11 | ss << bmp[bit]; 12 | } 13 | return ss.str(); 14 | } 15 | 16 | uint32_t BitmapHelper::count_bits_set(Bitmap bmp, uint32_t size) 17 | { 18 | // return static_cast(bmp.count()); 19 | uint32_t count = 0; 20 | for(uint32_t index = 0; index < size; ++index) 21 | { 22 | if(bmp[index]) count++; 23 | } 24 | return count; 25 | } 26 | 27 | uint32_t BitmapHelper::count_bits_same(Bitmap bmp1, Bitmap bmp2, uint32_t size) 28 | { 29 | uint32_t count_same = 0; 30 | for(uint32_t index = 0; index < size; ++index) 31 | { 32 | if(bmp1[index] && bmp1[index] == bmp2[index]) 33 | { 34 | count_same++; 35 | } 36 | } 37 | return count_same; 38 | } 39 | 40 | uint32_t BitmapHelper::count_bits_diff(Bitmap bmp1, Bitmap bmp2, uint32_t size) 41 | { 42 | uint32_t count_diff = 0; 43 | for(uint32_t index = 0; index < size; ++index) 44 | { 45 | if(bmp1[index] && !bmp2[index]) 46 | { 47 | count_diff++; 48 | } 49 | } 50 | return count_diff; 51 | } 52 | 53 | uint64_t BitmapHelper::value(Bitmap bmp, uint32_t size) 54 | { 55 | return bmp.to_ullong(); 56 | } 57 | 58 | Bitmap BitmapHelper::rotate_left(Bitmap bmp, uint32_t amount, uint32_t size) 59 | { 60 | Bitmap result; 61 | for(uint32_t index = 0; index < (size - amount); ++index) 62 | { 63 | result[index+amount] = bmp[index]; 64 | } 65 | for(uint32_t index = 0; index < amount; ++index) 66 | { 67 | result[index] = bmp[index+size-amount]; 68 | } 69 | return result; 70 | } 71 | 72 | Bitmap BitmapHelper::rotate_right(Bitmap bmp, uint32_t amount, uint32_t size) 73 | { 74 | Bitmap result; 75 | for(uint32_t index = 0; index < size - amount; ++index) 76 | { 77 | result[index] = bmp[index+amount]; 78 | } 79 | for(uint32_t index = 0; index < amount; ++index) 80 | { 81 | result[size-amount+index] = bmp[index]; 82 | } 83 | return result; 84 | 85 | } 86 | 87 | Bitmap BitmapHelper::compress(Bitmap bmp, uint32_t granularity, uint32_t size) 88 | { 89 | assert(size % granularity == 0); 90 | uint32_t index = 0; 91 | Bitmap result; 92 | uint32_t ptr = 0; 93 | 94 | while(index < size) 95 | { 96 | bool res = false; 97 | uint32_t gran = 0; 98 | for(gran = 0; gran < granularity; ++gran) 99 | { 100 | assert(index + gran < size); 101 | res = res | bmp[index+gran]; 102 | } 103 | result[ptr] = res; 104 | ptr++; 105 | index = index + gran; 106 | } 107 | return result; 108 | } 109 | 110 | Bitmap BitmapHelper::decompress(Bitmap bmp, uint32_t granularity, uint32_t size) 111 | { 112 | Bitmap result; 113 | result.reset(); 114 | assert(size*granularity <= BITMAP_MAX_SIZE); 115 | for(uint32_t index = 0; index < size; ++index) 116 | { 117 | if(bmp[index]) 118 | { 119 | uint32_t ptr = index * granularity; 120 | for(uint32_t count = 0; count < granularity; ++count) 121 | { 122 | result[ptr+count] = true; 123 | } 124 | } 125 | } 126 | return result; 127 | } 128 | 129 | Bitmap BitmapHelper::bitwise_or(Bitmap bmp1, Bitmap bmp2, uint32_t size) 130 | { 131 | Bitmap result; 132 | for(uint32_t index = 0; index < size; ++index) 133 | { 134 | if(bmp1[index] || bmp2[index]) 135 | { 136 | result[index] = true; 137 | } 138 | } 139 | return result; 140 | } 141 | 142 | Bitmap BitmapHelper::bitwise_and(Bitmap bmp1, Bitmap bmp2, uint32_t size) 143 | { 144 | Bitmap result; 145 | for(uint32_t index = 0; index < size; ++index) 146 | { 147 | if(bmp1[index] && bmp2[index]) 148 | { 149 | result[index] = true; 150 | } 151 | } 152 | return result; 153 | } -------------------------------------------------------------------------------- /inc/champsim.h: -------------------------------------------------------------------------------- 1 | #ifndef CHAMPSIM_H 2 | #define CHAMPSIM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | // USEFUL MACROS 23 | //#define DEBUG_PRINT 24 | #define SANITY_CHECK 25 | #define LLC_BYPASS 26 | #define DRC_BYPASS 27 | #define NO_CRC2_COMPILE 28 | 29 | #ifdef DEBUG_PRINT 30 | #define DP(x) x 31 | #else 32 | #define DP(x) 33 | #endif 34 | 35 | // CPU 36 | #define NUM_CPUS 1 37 | #define CPU_FREQ 4000 38 | #define DRAM_IO_FREQ 2400 // DDR4-2400 39 | #define PAGE_SIZE 4096 40 | #define LOG2_PAGE_SIZE 12 41 | 42 | // CACHE 43 | #define BLOCK_SIZE 64 44 | #define LOG2_BLOCK_SIZE 6 45 | #define MAX_READ_PER_CYCLE 8 46 | #define MAX_FILL_PER_CYCLE 1 47 | 48 | #define INFLIGHT 1 49 | #define COMPLETED 2 50 | 51 | #define FILL_L1 1 52 | #define FILL_L2 2 53 | #define FILL_LLC 4 54 | #define FILL_DRC 8 55 | #define FILL_DRAM 16 56 | 57 | // DRAM 58 | #define DRAM_CHANNELS 1 // default: assuming one DIMM per one channel 4GB * 1 => 4GB off-chip memory 59 | #define LOG2_DRAM_CHANNELS 0 60 | #define DRAM_RANKS 1 // 512MB * 8 ranks => 4GB per DIMM 61 | #define LOG2_DRAM_RANKS 0 62 | #define DRAM_BANKS 8 // 64MB * 8 banks => 512MB per rank 63 | #define LOG2_DRAM_BANKS 3 64 | #define DRAM_ROWS 65536 // 2KB * 32K rows => 64MB per bank 65 | #define LOG2_DRAM_ROWS 16 66 | #define DRAM_COLUMNS 128 // 64B * 32 column chunks (Assuming 1B DRAM cell * 8 chips * 8 transactions = 64B size of column chunks) => 2KB per row 67 | #define LOG2_DRAM_COLUMNS 7 68 | #define DRAM_ROW_SIZE (BLOCK_SIZE*DRAM_COLUMNS/1024) 69 | 70 | #define DRAM_SIZE (DRAM_CHANNELS*DRAM_RANKS*DRAM_BANKS*DRAM_ROWS*DRAM_ROW_SIZE/1024) 71 | #define DRAM_PAGES ((DRAM_SIZE<<10)>>2) 72 | //#define DRAM_PAGES 10 73 | #define DRAM_BW_LEVELS 4 74 | 75 | using namespace std; 76 | 77 | extern uint8_t warmup_complete[NUM_CPUS], 78 | simulation_complete[NUM_CPUS], 79 | all_warmup_complete, 80 | all_simulation_complete, 81 | MAX_INSTR_DESTINATIONS, 82 | knob_cloudsuite, 83 | knob_low_bandwidth; 84 | 85 | extern uint64_t current_core_cycle[NUM_CPUS], 86 | stall_cycle[NUM_CPUS], 87 | last_drc_read_mode, 88 | last_drc_write_mode, 89 | drc_blocks; 90 | 91 | extern queue page_queue; 92 | extern map page_table, inverse_table, recent_page, unique_cl[NUM_CPUS]; 93 | extern uint64_t previous_ppage, num_adjacent_page, num_cl[NUM_CPUS], allocated_pages, num_page[NUM_CPUS], minor_fault[NUM_CPUS], major_fault[NUM_CPUS]; 94 | 95 | void print_stats(); 96 | uint64_t rotl64 (uint64_t n, unsigned int c), 97 | rotr64 (uint64_t n, unsigned int c), 98 | va_to_pa(uint32_t cpu, uint64_t instr_id, uint64_t va, uint64_t unique_vpage); 99 | 100 | // log base 2 function from efectiu 101 | int lg2(int n); 102 | 103 | // get CPU cycle 104 | inline uint64_t get_cpu_cycle(uint32_t cpu) {return current_core_cycle[cpu];} 105 | 106 | // smart random number generator 107 | class RANDOM { 108 | public: 109 | std::random_device rd; 110 | std::mt19937_64 engine{rd()}; 111 | std::uniform_int_distribution dist{0, 0xFFFFFFFFF}; // used to generate random physical page numbers 112 | 113 | RANDOM (uint64_t seed) { 114 | engine.seed(seed); 115 | } 116 | 117 | uint64_t draw_rand() { 118 | return dist(engine); 119 | }; 120 | }; 121 | extern uint64_t champsim_seed; 122 | #endif 123 | -------------------------------------------------------------------------------- /inc/champsim.h.bak: -------------------------------------------------------------------------------- 1 | #ifndef CHAMPSIM_H 2 | #define CHAMPSIM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | // USEFUL MACROS 23 | //#define DEBUG_PRINT 24 | #define SANITY_CHECK 25 | #define LLC_BYPASS 26 | #define DRC_BYPASS 27 | #define NO_CRC2_COMPILE 28 | 29 | #ifdef DEBUG_PRINT 30 | #define DP(x) x 31 | #else 32 | #define DP(x) 33 | #endif 34 | 35 | // CPU 36 | #define NUM_CPUS 1 37 | #define CPU_FREQ 4000 38 | #define DRAM_IO_FREQ 2400 // DDR4-2400 39 | #define PAGE_SIZE 4096 40 | #define LOG2_PAGE_SIZE 12 41 | 42 | // CACHE 43 | #define BLOCK_SIZE 64 44 | #define LOG2_BLOCK_SIZE 6 45 | #define MAX_READ_PER_CYCLE 8 46 | #define MAX_FILL_PER_CYCLE 1 47 | 48 | #define INFLIGHT 1 49 | #define COMPLETED 2 50 | 51 | #define FILL_L1 1 52 | #define FILL_L2 2 53 | #define FILL_LLC 4 54 | #define FILL_DRC 8 55 | #define FILL_DRAM 16 56 | 57 | // DRAM 58 | #define DRAM_CHANNELS 1 // default: assuming one DIMM per one channel 4GB * 1 => 4GB off-chip memory 59 | #define LOG2_DRAM_CHANNELS 0 60 | #define DRAM_RANKS 1 // 512MB * 8 ranks => 4GB per DIMM 61 | #define LOG2_DRAM_RANKS 0 62 | #define DRAM_BANKS 8 // 64MB * 8 banks => 512MB per rank 63 | #define LOG2_DRAM_BANKS 3 64 | #define DRAM_ROWS 65536 // 2KB * 32K rows => 64MB per bank 65 | #define LOG2_DRAM_ROWS 16 66 | #define DRAM_COLUMNS 128 // 64B * 32 column chunks (Assuming 1B DRAM cell * 8 chips * 8 transactions = 64B size of column chunks) => 2KB per row 67 | #define LOG2_DRAM_COLUMNS 7 68 | #define DRAM_ROW_SIZE (BLOCK_SIZE*DRAM_COLUMNS/1024) 69 | 70 | #define DRAM_SIZE (DRAM_CHANNELS*DRAM_RANKS*DRAM_BANKS*DRAM_ROWS*DRAM_ROW_SIZE/1024) 71 | #define DRAM_PAGES ((DRAM_SIZE<<10)>>2) 72 | //#define DRAM_PAGES 10 73 | #define DRAM_BW_LEVELS 4 74 | 75 | using namespace std; 76 | 77 | extern uint8_t warmup_complete[NUM_CPUS], 78 | simulation_complete[NUM_CPUS], 79 | all_warmup_complete, 80 | all_simulation_complete, 81 | MAX_INSTR_DESTINATIONS, 82 | knob_cloudsuite, 83 | knob_low_bandwidth; 84 | 85 | extern uint64_t current_core_cycle[NUM_CPUS], 86 | stall_cycle[NUM_CPUS], 87 | last_drc_read_mode, 88 | last_drc_write_mode, 89 | drc_blocks; 90 | 91 | extern queue page_queue; 92 | extern map page_table, inverse_table, recent_page, unique_cl[NUM_CPUS]; 93 | extern uint64_t previous_ppage, num_adjacent_page, num_cl[NUM_CPUS], allocated_pages, num_page[NUM_CPUS], minor_fault[NUM_CPUS], major_fault[NUM_CPUS]; 94 | 95 | void print_stats(); 96 | uint64_t rotl64 (uint64_t n, unsigned int c), 97 | rotr64 (uint64_t n, unsigned int c), 98 | va_to_pa(uint32_t cpu, uint64_t instr_id, uint64_t va, uint64_t unique_vpage); 99 | 100 | // log base 2 function from efectiu 101 | int lg2(int n); 102 | 103 | // get CPU cycle 104 | inline uint64_t get_cpu_cycle(uint32_t cpu) {return current_core_cycle[cpu];} 105 | 106 | // smart random number generator 107 | class RANDOM { 108 | public: 109 | std::random_device rd; 110 | std::mt19937_64 engine{rd()}; 111 | std::uniform_int_distribution dist{0, 0xFFFFFFFFF}; // used to generate random physical page numbers 112 | 113 | RANDOM (uint64_t seed) { 114 | engine.seed(seed); 115 | } 116 | 117 | uint64_t draw_rand() { 118 | return dist(engine); 119 | }; 120 | }; 121 | extern uint64_t champsim_seed; 122 | #endif 123 | -------------------------------------------------------------------------------- /scripts/Math-Combinatorics-0.09/README: -------------------------------------------------------------------------------- 1 | NAME 2 | Math::Combinatorics - Perform combinations and permutations on lists 3 | 4 | SYNOPSIS 5 | Available as an object oriented API. 6 | 7 | use Math::Combinatorics; 8 | 9 | my @n = qw(a b c); 10 | my $combinat = Math::Combinatorics->new(count => 2, 11 | data => [@n], 12 | ); 13 | 14 | print "combinations of 2 from: ".join(" ",@n)."\n"; 15 | print "------------------------".("--" x scalar(@n))."\n"; 16 | while(my @combo = $combinat->next_combination){ 17 | print join(' ', @combo)."\n"; 18 | } 19 | 20 | print "\n"; 21 | 22 | print "combinations of 2 from: ".join(" ",@n)."\n"; 23 | print "------------------------".("--" x scalar(@n))."\n"; 24 | while(my @permu = $combinat->next_permutation){ 25 | print join(' ', @permu)."\n"; 26 | } 27 | 28 | output: 29 | 30 | Or available via exported functions 'permute', 'combine', and 31 | 'factorial'. 32 | 33 | use Math::Combinatorics; 34 | 35 | my @n = qw(a b c); 36 | print "combinations of 2 from: ".join(" ",@n)."\n"; 37 | print "------------------------".("--" x scalar(@n))."\n"; 38 | print join("\n", map { join " ", @$_ } combine(2,@n)),"\n"; 39 | print "\n"; 40 | print "permutations of 3 from: ".join(" ",@n)."\n"; 41 | print "------------------------".("--" x scalar(@n))."\n"; 42 | print join("\n", map { join " ", @$_ } permute(@n)),"\n"; 43 | 44 | Output: 45 | 46 | combinations of 2 from: a b c 47 | ------------------------------ 48 | a b 49 | a c 50 | b c 51 | 52 | combinations of 2 from: a b c 53 | ------------------------------ 54 | a b c 55 | a c b 56 | b a c 57 | b c a 58 | c a b 59 | c b a 60 | 61 | Output from both types of calls is the same, but the object-oriented 62 | approach consumes much less memory for large sets. 63 | 64 | DESCRIPTION 65 | Combinatorics is the branch of mathematics studying the enumeration, 66 | combination, and permutation of sets of elements and the mathematical 67 | relations that characterize their properties. As a jumping off point, 68 | refer to: 69 | 70 | http://mathworld.wolfram.com/Combinatorics.html 71 | 72 | This module provides a pure-perl implementation of nCk, nPk, and n! 73 | (combination, permutation, and factorial, respectively). Functional and 74 | object-oriented usages allow problems such as the following to be 75 | solved: 76 | 77 | nCk "Fun questions to ask the pizza parlor wait staff: how many possible 78 | combinations of 2 toppings can I get on my pizza?". 79 | 80 | nPk "Master Mind Game: ways to arrange pieces of different colors in a 81 | certain number of positions, without repetition of a color". 82 | 83 | Object-oriented usage additionally allows solving these problems by 84 | calling the new() entry elsewhere in this document with a frequency 85 | vector: 86 | 87 | nPRk "morse signals: diferent signals of 3 positions using the 2 two 88 | symbol - and .". 89 | 90 | nCRk "ways to extract 3 balls at once of a bag with black and white 91 | balls". 92 | 93 | nPRk "different words obtained permuting the letters of the word 94 | PARROT". 95 | 96 | AUTHOR 97 | Allen Day , with algorithmic contributions from 98 | Christopher Eltschka and Tye. 99 | 100 | ACKNOWLEDGEMENTS 101 | Thanks to everyone for helping to make this a better module. 102 | 103 | For adding new features: Carlos Rica, David Coppit 104 | 105 | For bug reports: Ying Yang, Joerg Beyer, Marc Logghe 106 | 107 | LICENSE AND COPYRIGHT 108 | 109 | Copyright (c) 2004 Allen Day. All rights reserved. This program is 110 | free software; you can redistribute it and/or modify it under the same 111 | terms as Perl itself. 112 | --------------------------------------------------------------------------------