├── .clang-format ├── .gitignore ├── .gitmodules ├── BUILD ├── LICENSE ├── README.md ├── WORKSPACE ├── benchmarks.cfg ├── run.sh ├── scripts ├── BUILD ├── bmk.py ├── compare_stat.py ├── counters.py ├── molecool.py ├── parse_res.py ├── perfmon.py ├── run_spec.py ├── run_tests.py ├── spec.py ├── vtl.py ├── xiosim_driver.py └── xiosim_stat.py ├── tests ├── BUILD ├── Makefile ├── atomics.cpp ├── cmpjmp.cpp ├── fib.cpp ├── ignore.cpp ├── k8 │ ├── atomics │ ├── chase │ ├── fib │ ├── fib..pintool.1.pp │ ├── fib..pintool.2.pp │ ├── ignore │ ├── loop │ ├── misses │ ├── prefetch │ ├── rdtsc │ ├── rep │ ├── repl │ ├── roi │ ├── segf │ ├── step │ ├── time │ └── time_vdso ├── loop.cpp ├── misses.cpp ├── piii │ ├── chase │ ├── fib │ ├── fib..pintool.1.pp │ ├── fib..pintool.2.pp │ ├── ignore │ ├── loop │ ├── misses │ ├── prefetch │ ├── rdtsc │ ├── rep │ ├── repl │ ├── roi │ ├── segf │ ├── step │ └── time ├── prefetch.cpp ├── rdtsc.cpp ├── rep.cpp ├── repl.cpp ├── roi.cpp ├── segf.cpp ├── step.cpp └── time.cpp ├── third_party ├── InstLib │ ├── BUILD │ ├── LICENSE │ ├── alarm.H │ ├── control.H │ ├── control_stats.H │ ├── debugger-shell.H │ ├── debugger-shell.cpp │ ├── filter.H │ ├── follow_child.H │ ├── icount.H │ ├── legacy_instlib.H │ ├── parse_address_count.H │ ├── pinpoint_alarm.H │ ├── pinpoint_control.H │ ├── regions_control.H │ ├── skipper.H │ └── time_warp.H ├── boost │ ├── BUILD │ └── BUILD.external ├── catch │ ├── BUILD │ └── BUILD.external ├── confuse │ ├── BUILD │ ├── BUILD.external │ ├── config.h │ └── lexer.c ├── ezOptionParser │ ├── BUILD │ ├── LICENSE │ ├── ezOptionParser.hpp │ └── ezOptionParser_clean.hpp ├── mcpat │ ├── Alpha21364.xml │ ├── BUILD │ ├── LICENSE │ ├── Niagara1.xml │ ├── Niagara1_sharing.xml │ ├── Niagara1_sharing_DC.xml │ ├── Niagara1_sharing_SBT.xml │ ├── Niagara1_sharing_ST.xml │ ├── Niagara2.xml │ ├── Penryn.xml │ ├── README │ ├── XML_Parse.cc │ ├── XML_Parse.h │ ├── Xeon.xml │ ├── arch_const.h │ ├── array.cc │ ├── array.h │ ├── basic_components.cc │ ├── basic_components.h │ ├── cacti │ │ ├── BUILD │ │ ├── README │ │ ├── Ucache.cc │ │ ├── Ucache.h │ │ ├── arbiter.cc │ │ ├── arbiter.h │ │ ├── area.cc │ │ ├── area.h │ │ ├── bank.cc │ │ ├── bank.h │ │ ├── basic_circuit.cc │ │ ├── basic_circuit.h │ │ ├── batch_tests │ │ ├── cache.cfg │ │ ├── cacti.i │ │ ├── cacti_interface.cc │ │ ├── cacti_interface.h │ │ ├── component.cc │ │ ├── component.h │ │ ├── const.h │ │ ├── contention.dat │ │ ├── crossbar.cc │ │ ├── crossbar.h │ │ ├── decoder.cc │ │ ├── decoder.h │ │ ├── globalvar.h │ │ ├── highradix.cc │ │ ├── highradix.h │ │ ├── htree2.cc │ │ ├── htree2.h │ │ ├── io.cc │ │ ├── io.h │ │ ├── main.cc │ │ ├── makefile │ │ ├── mat.cc │ │ ├── mat.h │ │ ├── nuca.cc │ │ ├── nuca.h │ │ ├── out_batch_test_result.csv │ │ ├── parameter.cc │ │ ├── parameter.h │ │ ├── powergating.cc │ │ ├── powergating.h │ │ ├── router.cc │ │ ├── router.h │ │ ├── subarray.cc │ │ ├── subarray.h │ │ ├── technology.cc │ │ ├── uca.cc │ │ ├── uca.h │ │ ├── version_cacti.h │ │ ├── wire.cc │ │ └── wire.h │ ├── core.cc │ ├── core.h │ ├── globalvar.h │ ├── interconnect.cc │ ├── interconnect.h │ ├── iocontrollers.cc │ ├── iocontrollers.h │ ├── logic.cc │ ├── logic.h │ ├── main.cc │ ├── makefile │ ├── mcpat.h │ ├── mcpatXeonCore.mk │ ├── memoryctrl.cc │ ├── memoryctrl.h │ ├── noc.cc │ ├── noc.h │ ├── processor.cc │ ├── processor.h │ ├── results │ │ ├── Alpha21364 │ │ ├── Alpha21364_90nm │ │ ├── Penryn │ │ ├── T1 │ │ ├── T1_DC_64 │ │ ├── T1_SBT_64 │ │ ├── T1_ST_64 │ │ ├── T2 │ │ ├── Xeon_core │ │ └── Xeon_uncore │ ├── sharedcache.cc │ ├── sharedcache.h │ ├── slave.cc │ ├── technology_xeon_core.cc │ ├── version.h │ ├── xmlParser.cc │ └── xmlParser.h └── pin │ ├── BUILD │ ├── BUILD.external │ └── weaken.bzl ├── tools └── bazel.rc ├── tools_local └── cpp │ ├── BUILD │ └── CROSSTOOL └── xiosim ├── 2bitc.h ├── BUILD ├── LICENSE.zesto ├── ZCOMPS-MC ├── MC-dramsim.cpp ├── MC-ideal.cpp └── MC-simple.cpp ├── ZCOMPS-bpred ├── bpred-2bc.cpp ├── bpred-2lev.cpp ├── bpred-alloyedperceptron.cpp ├── bpred-bimode.cpp ├── bpred-blg.cpp ├── bpred-btfnt.cpp ├── bpred-magic.cpp ├── bpred-nottaken.cpp ├── bpred-pathneural.cpp ├── bpred-perceptron.cpp ├── bpred-perfect.cpp ├── bpred-pwl.cpp ├── bpred-random.cpp ├── bpred-skewed.cpp ├── bpred-tage.cpp ├── bpred-taken.cpp └── bpred-yags.cpp ├── ZCOMPS-btb ├── btb-2levbtac.cpp ├── btb-btac.cpp └── btb-perfect.cpp ├── ZCOMPS-coherence ├── const.cpp └── none.cpp ├── ZCOMPS-dram ├── dram-simplescalar.cpp ├── dram-simplesdram-infbw.cpp └── dram-simplesdram.cpp ├── ZCOMPS-dvfs ├── none.cpp └── sample.cpp ├── ZCOMPS-fusion ├── fusion-colt.cpp ├── fusion-mcfarling.cpp ├── fusion-multihybrid.cpp ├── fusion-oracle.cpp ├── fusion-priority.cpp ├── fusion-random.cpp └── fusion-singleton.cpp ├── ZCOMPS-memdep ├── memdep-blind.cpp ├── memdep-lwt.cpp ├── memdep-none.cpp └── memdep-oracle.cpp ├── ZCOMPS-prefetch ├── prefetch-2lev-IP.cpp ├── prefetch-IP.cpp ├── prefetch-context.cpp ├── prefetch-nextline.cpp └── prefetch-stream.cpp ├── ZCOMPS-ras ├── ras-multistack.cpp ├── ras-perfect.cpp └── ras-stack.cpp ├── ZCOMPS-repeater ├── repeater-default.cpp └── repeater-none.cpp ├── ZCORE-power ├── power-DPM.cpp ├── power-IO-DPM.cpp └── power-none.cpp ├── ZPIPE-alloc ├── alloc-DPM.cpp ├── alloc-IO-DPM.cpp ├── alloc-STM.cpp └── alloc-none.cpp ├── ZPIPE-commit ├── commit-DPM.cpp ├── commit-IO-DPM.cpp ├── commit-STM.cpp └── commit-none.cpp ├── ZPIPE-decode ├── decode-DPM.cpp ├── decode-STM.cpp └── decode-none.cpp ├── ZPIPE-exec ├── exec-DPM.cpp ├── exec-IO-DPM.cpp ├── exec-STM.cpp └── exec-none.cpp ├── ZPIPE-fetch ├── fetch-DPM.cpp ├── fetch-STM.cpp └── fetch-none.cpp ├── boost_statistics.h ├── catch_impl.cpp ├── components.bzl ├── config ├── A.cfg ├── H.cfg ├── N.cfg ├── default.cfg └── none.cfg ├── core-set.h ├── core_const.h ├── decode.cpp ├── decode.h ├── expression.h ├── expression_impl.cpp ├── expression_impl.h ├── fu.cpp ├── fu.h ├── helix.h ├── host.h ├── knobs.h ├── libsim.h ├── memory.cpp ├── memory.h ├── misc.cpp ├── misc.h ├── misc_test.cpp ├── pintool ├── BUILD ├── BufferManager.cpp ├── BufferManager.h ├── BufferManagerConsumer.cpp ├── BufferManagerConsumer.h ├── BufferManagerProducer.cpp ├── BufferManagerProducer.h ├── allocators_impl.h ├── base_allocator.cpp ├── base_allocator.h ├── base_speedup_model.cpp ├── base_speedup_model.h ├── boost_interprocess.h ├── buffer.h ├── feeder.h ├── feeder_zesto.cpp ├── gang_allocator.cpp ├── handshake_container.h ├── harness.cpp ├── ignore_ins.cpp ├── ignore_ins.h ├── ildjit.cpp ├── ildjit.h ├── ipc_queues.cpp ├── ipc_queues.h ├── linear_speedup_model.cpp ├── linreg.cpp ├── linreg.h ├── local_opt_allocator.cpp ├── log_speedup_model.cpp ├── mpkeys.h ├── mpkeys_impl.cpp ├── multiprocess_shared.cpp ├── multiprocess_shared.h ├── optimization_targets.cpp ├── optimization_targets.h ├── paravirt.cpp ├── paravirt.h ├── parse_speedup.cpp ├── parse_speedup.h ├── penalty_allocator.cpp ├── profiling.cpp ├── profiling.h ├── replace_function.cpp ├── replace_function.h ├── roi.cpp ├── roi.h ├── scheduler.cpp ├── scheduler.h ├── shared_common.h ├── shared_map.h ├── shared_map_example.cpp ├── shared_unordered_common.h ├── shared_unordered_map.h ├── speculation.cpp ├── speculation.h ├── speedup_models.h ├── sync_pthreads.cpp ├── sync_pthreads.h ├── syscall_handling.cpp ├── syscall_handling.h ├── test_allocation.cpp ├── test_data │ └── loop_speedup_data.csv ├── test_handshake_serialization.cpp ├── test_parse_speedup.cpp ├── test_speedup_models.cpp ├── timing_sim.cpp ├── timing_sim.h ├── utils.cpp ├── utils.h ├── vdso.cpp └── vdso.h ├── regs.h ├── shadow_MopQ.cpp ├── shadow_MopQ.h ├── sim-loop.cpp ├── sim-loop.h ├── sim.cpp ├── sim.h ├── slices.cpp ├── slices.h ├── stat_database.h ├── statistic.h ├── stats.cpp ├── stats.h ├── synchronization.h ├── test_data ├── gzopen.gz ├── test_stat.database.out ├── test_stat.distribution.labeled.out ├── test_stat.distribution.unlabeled.out ├── test_stat.histogram.out ├── test_stat.histogram_scaled.out ├── test_stat.reg_api.out └── test_stat.singlevalue_int.out ├── test_decoder.cpp ├── test_parse_configs.cpp ├── test_stat_database.cpp ├── test_uop_cracker.cpp ├── test_xed_context.h ├── uop_cracker.cpp ├── uop_cracker.h ├── valcheck.h ├── zesto-MC.cpp ├── zesto-MC.h ├── zesto-alloc.cpp ├── zesto-alloc.h ├── zesto-bpred.cpp ├── zesto-bpred.h ├── zesto-cache.cpp ├── zesto-cache.h ├── zesto-coherence.cpp ├── zesto-coherence.h ├── zesto-commit.cpp ├── zesto-commit.h ├── zesto-config-params.cpp ├── zesto-config.cpp ├── zesto-config.h ├── zesto-core.cpp ├── zesto-core.h ├── zesto-decode.cpp ├── zesto-decode.h ├── zesto-dram.cpp ├── zesto-dram.h ├── zesto-dvfs.cpp ├── zesto-dvfs.h ├── zesto-exec.cpp ├── zesto-exec.h ├── zesto-fetch.cpp ├── zesto-fetch.h ├── zesto-memdep.cpp ├── zesto-memdep.h ├── zesto-noc.cpp ├── zesto-noc.h ├── zesto-oracle.cpp ├── zesto-oracle.h ├── zesto-power.cpp ├── zesto-power.h ├── zesto-prefetch.cpp ├── zesto-prefetch.h ├── zesto-repeater.cpp ├── zesto-repeater.h ├── zesto-structs.h ├── zesto-uncore.cpp ├── zesto-uncore.h ├── ztrace.cpp └── ztrace.h /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # BasedOnStyle: LLVM 3 | AccessModifierOffset: -2 4 | ConstructorInitializerIndentWidth: 4 5 | AlignEscapedNewlinesLeft: false 6 | AlignTrailingComments: true 7 | AllowAllParametersOfDeclarationOnNextLine: true 8 | AllowShortIfStatementsOnASingleLine: false 9 | AllowShortLoopsOnASingleLine: false 10 | AlwaysBreakTemplateDeclarations: true 11 | AlwaysBreakBeforeMultilineStrings: false 12 | BreakBeforeBinaryOperators: false 13 | BreakBeforeTernaryOperators: true 14 | BreakConstructorInitializersBeforeComma: true 15 | BinPackParameters: true 16 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 17 | DerivePointerBinding: false 18 | ExperimentalAutoDetectBinPacking: true 19 | IndentCaseLabels: false 20 | MaxEmptyLinesToKeep: 1 21 | NamespaceIndentation: None 22 | PenaltyBreakBeforeFirstCallParameter: 19 23 | PenaltyBreakComment: 1000 24 | PenaltyBreakString: 1000 25 | PenaltyBreakFirstLessLess: 120 26 | PenaltyExcessCharacter: 10000 27 | PenaltyReturnTypeOnItsOwnLine: 10000 28 | PointerBindsToType: true 29 | SpacesBeforeTrailingComments: 2 30 | Cpp11BracedListStyle: false 31 | Standard: Cpp11 32 | IndentWidth: 4 33 | TabWidth: 8 34 | UseTab: Never 35 | BreakBeforeBraces: Attach 36 | IndentFunctionDeclarationAfterType: false 37 | SpacesInParentheses: false 38 | SpacesInAngles: false 39 | SpaceInEmptyParentheses: false 40 | SpacesInCStyleCastParentheses: false 41 | SpaceAfterControlStatementKeyword: true 42 | SpaceBeforeAssignmentOperators: true 43 | ContinuationIndentWidth: 8 44 | ColumnLimit: 100 45 | ... 46 | 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.pyc 3 | *.a 4 | *.swp 5 | *.list 6 | */obj-ia32 7 | *cscope* 8 | bazel-* 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "DRAMSim2"] 2 | path = DRAMSim2 3 | url = https://github.com/s-kanev/DRAMSim2.git 4 | update = merge 5 | fetchRecurseSubmodules = true 6 | [submodule "mem-repeater"] 7 | path = mem-repeater 8 | url = file:///group/brooks/git/librepeater 9 | update = merge 10 | fetchRecurseSubmodules = true 11 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # XIOSim, a detailed x86 microarchitectural simulator. 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | licenses(["notice"]) # BSD 6 | 7 | exports_files(["LICENSE"]) 8 | 9 | filegroup( 10 | name = "xiosim", 11 | srcs = [ 12 | "//third_party/pin:cp_pinbin", 13 | "//xiosim:configs", 14 | "//xiosim/pintool:feeder_zesto.so", 15 | "//xiosim/pintool:harness", 16 | "//xiosim/pintool:timing_sim", 17 | ], 18 | ) 19 | 20 | test_suite( 21 | name = "all_unit", 22 | tags = ["small"], 23 | tests = [ 24 | "//xiosim:unit_tests", 25 | "//xiosim/pintool:unit_tests", 26 | ], 27 | ) 28 | 29 | test_suite( 30 | name = "all_integration", 31 | tags = ["large"], 32 | tests = ["//scripts:integration_tests"], 33 | ) 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Harvard University All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | new_http_archive( 2 | name = "boost", 3 | url = "http://downloads.sourceforge.net/project/boost/boost/1.54.0/boost_1_54_0.tar.gz?r=&ts=1445844477&use_mirror=superb-dca2", 4 | sha256 = "412d003299e72555e1e1f62f51d3b07eca2a1911e27c442ee1c08167826ef9e2", 5 | build_file = "third_party/boost/BUILD.external", 6 | ) 7 | 8 | new_http_archive( 9 | name = "pin", 10 | url = "https://software.intel.com/sites/landingpage/pintool/downloads/pin-2.14-71313-gcc.4.4.7-linux.tar.gz", 11 | sha256 = "1c29f589515772411a699a82fc4a3156cad95863a29741dfa6522865d4d281a1", 12 | build_file = "third_party/pin/BUILD.external", 13 | ) 14 | 15 | new_http_archive( 16 | name = "confuse", 17 | url = "https://github.com/martinh/libconfuse/releases/download/v3.0/confuse-3.0.tar.gz", 18 | sha256 = "f1f326d9443103036d19c32d3f3efec3a85c3b081d99534463668d29992c4648", 19 | build_file = "third_party/confuse/BUILD.external", 20 | ) 21 | 22 | new_http_archive( 23 | name = "catch", 24 | url = "https://github.com/philsquared/Catch/archive/v1.2.1.tar.gz", 25 | sha256 = "24da0b6a6680256607da5ceb28004cb399009eae9f591614d7d22e3532f6980c", 26 | build_file = "third_party/catch/BUILD.external", 27 | ) 28 | -------------------------------------------------------------------------------- /benchmarks.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Configuration file for a XIOSim multiprogrammed benchmark run. 3 | * 4 | * How to define a program: 5 | * 6 | * program PROGRAM_NAME { 7 | * run_path = "working directory for executable" 8 | * exe = "path/to/executable" 9 | * args = "relevant arguments for this program". 10 | * instances = number of instances of this benchmark to run. 11 | * } 12 | * 13 | * Author: Sam Xi 14 | */ 15 | 16 | program { 17 | exe = "tests/k8/fib" 18 | args = "> fib.out 2> fib.err" 19 | instances = 1 20 | } 21 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PIN_PATH=bazel-bin/external/pin 4 | PIN=${PIN_PATH}/pinbin 5 | 6 | BIN_PATH=bazel-bin/xiosim/pintool 7 | PINTOOL=${BIN_PATH}/feeder_zesto.so 8 | TIMING_SIM=${BIN_PATH}/timing_sim 9 | ZESTOCFG=xiosim/config/N.cfg 10 | BENCHMARK_CFG_FILE=benchmarks.cfg 11 | 12 | CMD_LINE="setarch x86_64 -R ${BIN_PATH}/harness \ 13 | -benchmark_cfg $BENCHMARK_CFG_FILE \ 14 | -timing_sim ${TIMING_SIM} \ 15 | -config $ZESTOCFG \ 16 | -pin $PIN \ 17 | -pause_tool 1 \ 18 | -xyzzy \ 19 | -ifeellucky \ 20 | -catch_signals 0 \ 21 | -t \ 22 | $PINTOOL \ 23 | -speculation false" 24 | 25 | echo $CMD_LINE 26 | $CMD_LINE 27 | -------------------------------------------------------------------------------- /scripts/compare_stat.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | 3 | import os 4 | import re 5 | 6 | RUN1 = '/group/brooks/skanev/data_test/ref' 7 | RUN2 = '/group/brooks/skanev/data_test/ref_bkp' 8 | STAT = 'total_IPC' 9 | 10 | 11 | def GetZestoStat(file, stat): 12 | try: 13 | f = open(file) 14 | val = float("NaN") 15 | rx = re.compile(stat) 16 | 17 | for line in f: 18 | m = rx.match(line) 19 | if m: 20 | val = float(line.split()[1]) 21 | break 22 | except IOError: 23 | val = float("NaN") 24 | return val 25 | 26 | def GetRunStats(run, stat): 27 | stats = {} 28 | 29 | res = os.listdir(run) 30 | for f in res: 31 | if not "slice" in f: 32 | continue 33 | 34 | stats[f] = GetZestoStat("%s/%s" % (run, f), stat) 35 | 36 | return stats 37 | 38 | if __name__ == "__main__": 39 | stats1 = GetRunStats(RUN1, STAT) 40 | stats2 = GetRunStats(RUN2, STAT) 41 | 42 | bmks = [] 43 | 44 | for bmk in stats1.keys(): 45 | if bmk in stats2: 46 | bmks.append(bmk) 47 | 48 | bmks.sort() 49 | 50 | for bmk in bmks: 51 | delta = (stats1[bmk] - stats2[bmk]) / stats2[bmk] * 100 52 | print "%s %.2f" % (bmk, delta) 53 | -------------------------------------------------------------------------------- /scripts/counters.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | 3 | #Command lines for different perf counter data gathered 4 | def CountCLK(): 5 | cmd = "en='CPU_CLK_UNHALTED.CORE' " 6 | return cmd 7 | 8 | def CountINST(): 9 | cmd = "en='INST_RETIRED.ANY' " 10 | return cmd 11 | -------------------------------------------------------------------------------- /scripts/molecool.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | import os.path 3 | import re 4 | 5 | from xiosim_driver import * 6 | 7 | ILDJIT_HOME="/group/brooks/xan/Molecool/ildjit" 8 | PIN_HOME="/home/skanev/pin/pin-2.10-45467-gcc.3.4.6-ia32_intel64-linux" 9 | 10 | #envoronment variables are explicitly added to a clean environment 11 | ENVIRONMENT="ILDJIT_HOME=%s ILDJIT_PATH=.:%s/lib/cscc/lib:%s/lib/gcc4cli LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/lib:%s/lib/iljit:%s/ia32/runtime PKG_CONFIG_PATH=%s/lib/pkgconfig PATH=%s/bin:/lib:/usr/lib:/usr/bin ILDJIT_CACHE=/home/skanev HOME=/home/skanev " % (ILDJIT_HOME, ILDJIT_HOME, ILDJIT_HOME, ILDJIT_HOME, PIN_HOME, ILDJIT_HOME, ILDJIT_HOME) 12 | # PARALLELIZER_AUTOMATIC_PARALLELIZATION_SINGLE_THREAD=1" 13 | #PARALLELIZER_AUTOMATIC_PARALLELIZATION=0" 14 | #PARALLELIZER_AUTOMATIC_PARALLELIZATION=1" 15 | #LD_ASSUME_KERNEL=2.4.1" 16 | 17 | PROJROOT="/group/brooks/xan/Molecool" 18 | 19 | PROGRAM="/home/skanev/iljit_regression/test0/test.cil" 20 | ARGS="200000" 21 | #ARGS="2" 22 | 23 | PIN=PIN_HOME + "/ia32/bin/pinbin" 24 | PINTOOL="%s/bin/feeder_zesto.so" % PROJROOT 25 | ZESTOCFG="%s/feeder_zesto/config/A2.cfg" % PROJROOT 26 | MEMCFG="%s/feeder_zesto/dram-config/DDR2-800-5-5-5.cfg" % PROJROOT 27 | 28 | #rm ./test.cil_* 29 | 30 | def RunScalingTest(): 31 | # for ncores in [1, 2, 4, 8, 16]: 32 | for ncores in [16]: 33 | xios = XIOSimDriver(PIN, PINTOOL) 34 | xios.AddCleanArch() 35 | env = ENVIRONMENT + "PARALLELIZER_THREADS=%d " % ncores 36 | xios.AddEnvironment(env) 37 | xios.AddPinOptions() 38 | xios.AddPintoolOptions() 39 | xios.AddMolecoolOptions() 40 | xios.AddZestoOptions(ZESTOCFG, MEMCFG) 41 | xios.AddZestoOut("%d.out" % ncores) 42 | xios.AddZestoCores(ncores) 43 | xios.AddILDJITOptions() 44 | xios.AddApp(PROGRAM, ARGS) 45 | xios.Exec() 46 | 47 | if __name__ == "__main__": 48 | RunScalingTest() 49 | -------------------------------------------------------------------------------- /scripts/parse_res.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | import os.path 3 | 4 | import spec 5 | 6 | experimentDir = '/group/brooks/skanev/data_test1/ref' 7 | 8 | def GetZestoStat(stat, amean): 9 | count = 0 10 | sum = 0 11 | 12 | for run in spec.runs: 13 | file = os.path.join(experimentDir, "%s.zesto" % run.name) 14 | print "%s: " % run.name, 15 | stat_val = "" 16 | for line in open(file): 17 | if stat in line: 18 | # stat_val = line.split()[1] 19 | stat_val = (line.split()[7]).replace(",","") 20 | count += 1 21 | sum += float(stat_val) 22 | break 23 | if stat_val == "": 24 | stat_val = "NOT FOUND!" 25 | print stat_val 26 | 27 | if (amean) and (count > 0): 28 | print "Mean: %f" % (sum / count) 29 | 30 | def GetPinIPC(): 31 | for run in spec.runs: 32 | cpi = 0 33 | pin_cpi = 0 34 | weight = 0 35 | cycles = 0 36 | file = os.path.join(experimentDir, "%s.zesto" % run.name) 37 | print "%s: " % run.name, 38 | stat_val = "" 39 | for line in open(file): 40 | if "n_insn" in line: 41 | stat_val = (line.split()[3]).replace(",","") 42 | weight = float(stat_val) 43 | stat_val = (line.split()[11]) 44 | cycles = float(stat_val) 45 | stat_val = (line.split()[7]).replace(",","") 46 | cpi += cycles * weight / float(stat_val) 47 | stat_val = (line.split()[9]).replace(",","") 48 | pin_cpi += cycles * weight / float(stat_val) 49 | ipc = 1.0 / cpi 50 | pin_ipc = 1.0 / pin_cpi 51 | print "ipc: %f, pin_ipc : %f" % (ipc, pin_ipc) 52 | 53 | if __name__ == "__main__": 54 | # GetZestoStat("sim_inst_rate", True) 55 | GetPinIPC() 56 | 57 | -------------------------------------------------------------------------------- /tests/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # XIOSim ubenchmarks for integration tests 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | licenses(["notice"]) # BSD 7 | 8 | exports_files(["LICENSE"]) 9 | 10 | filegroup( 11 | name = "ubench", 12 | srcs = select({ 13 | ":k8": glob(["k8/*"]), 14 | ":piii": glob(["piii/*"]), 15 | }), 16 | ) 17 | 18 | config_setting( 19 | name = "k8", 20 | values = {"cpu": "k8"}, 21 | ) 22 | 23 | config_setting( 24 | name = "piii", 25 | values = {"cpu": "piii"}, 26 | ) 27 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | all: piii/fib piii/roi piii/repl piii/segf piii/step \ 2 | piii/rep piii/chase piii/prefetch piii/ignore piii/time \ 3 | piii/loop piii/rdtsc \ 4 | k8/fib k8/roi k8/repl k8/segf k8/step k8/rep k8/chase \ 5 | k8/prefetch k8/ignore k8/time k8/loop k8/rdtsc k8/atomics 6 | 7 | 8 | piii/fib: fib.cpp 9 | g++ -m32 -std=c++1y -static -O0 -o $@ $< 10 | piii/roi: roi.cpp 11 | g++ -m32 -std=c++1y -mtune=atom -static -O0 -o $@ $< 12 | piii/repl: repl.cpp 13 | g++ -m32 -std=c++1y -mtune=atom -static -O0 -o $@ $< 14 | piii/segf: segf.cpp 15 | g++ -m32 -std=c++1y -static -O0 -o $@ $< 16 | piii/step: step.cpp 17 | g++ -m32 -std=c++1y -mtune=atom -static -O3 -o $@ $< 18 | piii/rep: rep.cpp 19 | g++ -m32 -std=c++1y -static -O0 -o $@ $< 20 | piii/chase: prefetch.cpp 21 | g++ -m32 -std=c++1y -static -O1 -o $@ $< 22 | piii/prefetch: prefetch.cpp 23 | g++ -m32 -std=c++1y -static -O1 -DPREFETCH -o $@ $< 24 | piii/ignore: ignore.cpp 25 | g++ -m32 -std=c++1y -static -O0 -o $@ $< 26 | piii/time: time.cpp 27 | g++ -m32 -O1 -falign-functions=64 -static -o $@ $< 28 | piii/loop: loop.cpp 29 | g++ -m32 -O0 -static -o $@ $< 30 | piii/rdtsc: rdtsc.cpp 31 | g++ -m32 -O1 -static -falign-functions=16 -o $@ $< 32 | piii/misses: misses.cpp 33 | g++ -m32 -O1 -static -o $@ $< 34 | 35 | k8/fib: fib.cpp 36 | g++ -std=c++1y -static -O0 -o $@ $< 37 | k8/roi: roi.cpp 38 | g++ -std=c++1y -mtune=atom -static -O0 -o $@ $< 39 | k8/repl: repl.cpp 40 | g++ -std=c++1y -mtune=atom -static -O0 -o $@ $< 41 | k8/segf: segf.cpp 42 | g++ -std=c++1y -static -O0 -o $@ $< 43 | k8/step: step.cpp 44 | g++ -std=c++1y -mtune=atom -static -O3 -o $@ $< 45 | k8/rep: rep.cpp 46 | g++ -std=c++1y -static -O0 -o $@ $< 47 | k8/chase: prefetch.cpp 48 | g++ -std=c++1y -static -O1 -o $@ $< 49 | k8/prefetch: prefetch.cpp 50 | g++ -std=c++1y -static -O1 -DPREFETCH -o $@ $< 51 | k8/ignore: ignore.cpp 52 | g++ -std=c++1y -static -O0 -o $@ $< 53 | k8/time: time.cpp 54 | g++ -O1 -falign-functions=64 -static -o $@ $< 55 | k8/time_vdso: time.cpp 56 | g++ -O1 -falign-functions=64 -o $@ $< 57 | k8/loop: loop.cpp 58 | g++ -O0 -static -o $@ $< 59 | k8/rdtsc: rdtsc.cpp 60 | g++ -O1 -static -falign-functions=16 -o $@ $< 61 | k8/atomics: atomics.cpp 62 | g++ -std=c++1y -O1 -static -falign-loops=64 -o $@ $< 63 | k8/misses: misses.cpp 64 | g++ -O1 -static -o $@ $< 65 | -------------------------------------------------------------------------------- /tests/cmpjmp.cpp: -------------------------------------------------------------------------------- 1 | extern "C" void xiosim_roi_begin() __attribute__ ((noinline)); 2 | extern "C" void xiosim_roi_end() __attribute__ ((noinline)); 3 | 4 | void xiosim_roi_begin() { __asm__ __volatile__ ("":::"memory"); } 5 | void xiosim_roi_end() { __asm__ __volatile__ ("":::"memory"); } 6 | 7 | int main(int argc, char* argv[]) { 8 | const int ITER = 1000000; 9 | 10 | xiosim_roi_begin(); 11 | 12 | /* The loop has 7 Mops. On NHM, it is forced to at least 2 cycles / iteration 13 | * (only one jump unit). If we don't fuse, we still have 5 more ops to do 14 | * during the 2 cycles, but only 2 IEUs, so we're forced to 3 cycles / iteration. 15 | * If we fuse, there's 5 fused uops. The cmpjmps use the JEU (so, 2 cycles), 16 | * but there's enough IEUs now to finish 3 adds in 2 cycles / iteration. */ 17 | __asm__ __volatile__ ( 18 | "1:movl $0, %%eax;" 19 | "movl $0, %%ebx;" 20 | "movl $0, %%ecx;" 21 | "loop: cmpl %%ebx, %%ecx;" 22 | "jne 1b;" 23 | "addl $1, %%ebx;" 24 | "addl $1, %%ecx;" 25 | "addl $1, %%eax;" 26 | "cmpl %0, %%eax;" 27 | "jne loop;" 28 | : 29 | :"n"(ITER) 30 | :"%eax","%ebx","%ecx"); 31 | 32 | xiosim_roi_end(); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /tests/fib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fib(int n) 4 | { 5 | if(n<=1) 6 | return 1; 7 | else 8 | return fib(n-1)+fib(n-2); 9 | } 10 | 11 | int main(int argc, char* argv[]) 12 | { 13 | int i; 14 | for(i=0;i<16;i++) 15 | fprintf(stderr,"fib(%d) = %d\n",i,fib(i)); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /tests/ignore.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" void xiosim_roi_begin() __attribute__ ((noinline)); 5 | extern "C" void xiosim_roi_end() __attribute__ ((noinline)); 6 | 7 | void xiosim_roi_begin() { __asm__ __volatile__ ("":::"memory"); } 8 | void xiosim_roi_end() { __asm__ __volatile__ ("":::"memory"); } 9 | 10 | int main(int argc, char* argv[]) { 11 | 12 | const int32_t NUM_ITERS = 10000; 13 | xiosim_roi_begin(); 14 | 15 | /* If we don't ignore the nop, we'll execute 40K instructions. 16 | * If we do -> 30K. */ 17 | __asm__ __volatile ("loop: nop;" 18 | "subl $1, %%eax;" 19 | "cmpl $0, %%eax;" 20 | "jns loop;" 21 | : 22 | : "a"(NUM_ITERS)); 23 | 24 | xiosim_roi_end(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /tests/k8/atomics: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/atomics -------------------------------------------------------------------------------- /tests/k8/chase: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/chase -------------------------------------------------------------------------------- /tests/k8/fib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/fib -------------------------------------------------------------------------------- /tests/k8/fib..pintool.1.pp: -------------------------------------------------------------------------------- 1 | # 2 | # Format: 3 | # A region tag must preceed its start and end tags with no other 4 | # tags in between: 5 | # region 6 | # slice 7 | # start 8 | # end 9 | # 10 | # A markedInstrs tag must preceed the mark tags. There must be 11 | # exactly one markedInstrs tag in the file. 12 | # markedInstrs 13 | # mark 14 | # 15 | # I: 0 16 | 17 | 18 | thread 0 19 | version 3 20 | # C: sum:dummy Command: /home/skanev/pin/2.12/intel64/bin/pinbin -p32 /home/skanev/pin/2.12/ia32/bin/pinbin -waiting_process 22726 -waiting_injector 22733 -sigchld_handler 1 -t /home/skanev/pin/2.12/source/tools/PinPoints/obj-intel64/isimpoint.so -slice_size 30000 -o fib. -- ./fib 21 | 22 | #Pinpoint= 1 Slice= 1 Icount= 30000 Len= 30000 23 | region 1 100.000 1 1 30000 30000 24 | slice 1 0 0.136894 25 | warmup_factor 0 26 | start 1 11 0 27 | end 2 990 0 28 | 29 | markedInstrs 2 30 | mark 1 0x4492dd 1 0 0 31 | mark 2 0x400e2e 0 1 0 32 | 33 | totalIcount 116180 34 | pinpoints 1 35 | endp 36 | -------------------------------------------------------------------------------- /tests/k8/fib..pintool.2.pp: -------------------------------------------------------------------------------- 1 | # 2 | # Format: 3 | # A region tag must preceed its start and end tags with no other 4 | # tags in between: 5 | # region 6 | # slice 7 | # start 8 | # end 9 | # 10 | # A markedInstrs tag must preceed the mark tags. There must be 11 | # exactly one markedInstrs tag in the file. 12 | # markedInstrs 13 | # mark 14 | # 15 | # I: 0 16 | 17 | 18 | thread 0 19 | version 3 20 | # C: sum:dummy Command: /home/skanev/pin/2.12/intel64/bin/pinbin -p32 /home/skanev/pin/2.12/ia32/bin/pinbin -waiting_process 23030 -waiting_injector 23037 -sigchld_handler 1 -t /home/skanev/pin/2.12/source/tools/PinPoints/obj-intel64/isimpoint.so -slice_size 10000 -o fib. -- ./fib 21 | 22 | #Pinpoint= 1 Slice= 1 Icount= 10000 Len= 10000 23 | region 1 16.667 1 1 10000 10000 24 | slice 1 1 0.233842 25 | warmup_factor 0 26 | start 1 1 0 27 | end 2 15 0 28 | 29 | #Pinpoint= 2 Slice= 4 Icount= 40000 Len= 10000 30 | region 2 83.333 1 1 10000 40000 31 | slice 4 0 0.006894 32 | warmup_factor 0 33 | start 3 955 0 34 | end 4 1482 0 35 | 36 | markedInstrs 4 37 | mark 1 0x40108f 1 0 0 38 | mark 2 0x44c404 0 1 0 39 | mark 3 0x400e3b 1 0 0 40 | mark 4 0x400e0e 0 1 0 41 | 42 | totalIcount 116180 43 | pinpoints 2 44 | endp 45 | -------------------------------------------------------------------------------- /tests/k8/ignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/ignore -------------------------------------------------------------------------------- /tests/k8/loop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/loop -------------------------------------------------------------------------------- /tests/k8/misses: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/misses -------------------------------------------------------------------------------- /tests/k8/prefetch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/prefetch -------------------------------------------------------------------------------- /tests/k8/rdtsc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/rdtsc -------------------------------------------------------------------------------- /tests/k8/rep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/rep -------------------------------------------------------------------------------- /tests/k8/repl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/repl -------------------------------------------------------------------------------- /tests/k8/roi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/roi -------------------------------------------------------------------------------- /tests/k8/segf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/segf -------------------------------------------------------------------------------- /tests/k8/step: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/step -------------------------------------------------------------------------------- /tests/k8/time: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/time -------------------------------------------------------------------------------- /tests/k8/time_vdso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/k8/time_vdso -------------------------------------------------------------------------------- /tests/loop.cpp: -------------------------------------------------------------------------------- 1 | int main(int argc, char* argv[]) { 2 | while(1); 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /tests/misses.cpp: -------------------------------------------------------------------------------- 1 | // Repeatedly store/load and flush from a set of memory addresses. 2 | // 3 | // The load PCs should appear in the load_miss_pcs and store_miss_pcs stat. 4 | 5 | #include 6 | #include 7 | 8 | const int ITER = 10000; 9 | const int LOG_CACHELINE_SZ = 6; 10 | // A buffer of this many intergers must be at least twice the size of the L1 dcache. 11 | const int BUF_SZ = 1024 * 1024; 12 | 13 | extern "C" void xiosim_roi_begin() __attribute__ ((noinline)); 14 | extern "C" void xiosim_roi_end() __attribute__ ((noinline)); 15 | 16 | void xiosim_roi_begin() { __asm__ __volatile__ ("":::"memory"); } 17 | void xiosim_roi_end() { __asm__ __volatile__ ("":::"memory"); } 18 | 19 | int main(int args, char** argv) { 20 | int val = 0; 21 | int* src_buf = (int*)malloc(BUF_SZ * sizeof(int)); 22 | // Pseuorandom with fixed seed. 23 | srand(0); 24 | 25 | xiosim_roi_begin(); 26 | for (int i = 0; i < ITER; i++) { 27 | int rand_idx = (rand() % (BUF_SZ >> LOG_CACHELINE_SZ)) << LOG_CACHELINE_SZ; 28 | val = src_buf[rand_idx]; 29 | } 30 | xiosim_roi_end(); 31 | 32 | printf("Last value: %d\n", val); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /tests/piii/chase: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/chase -------------------------------------------------------------------------------- /tests/piii/fib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/fib -------------------------------------------------------------------------------- /tests/piii/fib..pintool.1.pp: -------------------------------------------------------------------------------- 1 | # 2 | # Format: 3 | # A region tag must preceed its start and end tags with no other 4 | # tags in between: 5 | # region 6 | # slice 7 | # start 8 | # end 9 | # 10 | # A markedInstrs tag must preceed the mark tags. There must be 11 | # exactly one markedInstrs tag in the file. 12 | # markedInstrs 13 | # mark 14 | # 15 | # I: 0 16 | 17 | 18 | thread 0 19 | version 3 20 | # C: sum:dummy Command: /home/skanev/pin/2.12/ia32/bin/pinbin -p64 /home/skanev/pin/2.12/intel64/bin/pinbin -t /home/skanev/pin/2.12/source/tools/PinPoints/obj-ia32/isimpoint.so -slice_size 30000 -o fib. -- ./fib 21 | 22 | #Pinpoint= 1 Slice= 1 Icount= 30000 Len= 30000 23 | region 1 100.000 1 1 30000 30000 24 | slice 1 0 0.100336 25 | warmup_factor 0 26 | start 1 514 0 27 | end 2 1004 0 28 | 29 | markedInstrs 2 30 | mark 1 0x8048213 1 0 0 31 | mark 2 0x80481f1 0 1 0 32 | 33 | totalIcount 117923 34 | pinpoints 1 35 | endp 36 | -------------------------------------------------------------------------------- /tests/piii/fib..pintool.2.pp: -------------------------------------------------------------------------------- 1 | # 2 | # Format: 3 | # A region tag must preceed its start and end tags with no other 4 | # tags in between: 5 | # region 6 | # slice 7 | # start 8 | # end 9 | # 10 | # A markedInstrs tag must preceed the mark tags. There must be 11 | # exactly one markedInstrs tag in the file. 12 | # markedInstrs 13 | # mark 14 | # 15 | # I: 0 16 | 17 | 18 | thread 0 19 | version 3 20 | # C: sum:dummy Command: /home/skanev/pin/2.12/ia32/bin/pinbin -p64 /home/skanev/pin/2.12/intel64/bin/pinbin -t /home/skanev/pin/2.12/source/tools/PinPoints/obj-ia32/isimpoint.so -slice_size 10000 -o fib. -- ./fib 21 | 22 | #Pinpoint= 1 Slice= 0 Icount= 0 Len= 10000 23 | region 1 16.667 1 1 10000 0 24 | slice 0 1 0.175846 25 | warmup_factor 0 26 | start 1 1 0 27 | end 2 5 0 28 | 29 | #Pinpoint= 2 Slice= 5 Icount= 50000 Len= 10000 30 | region 2 83.333 1 1 10000 50000 31 | slice 5 0 0.020583 32 | warmup_factor 0 33 | start 3 1506 0 34 | end 3 2000 0 35 | 36 | markedInstrs 3 37 | mark 1 0x80480f0 1 0 0 38 | mark 2 0x8057e0a 0 1 0 39 | mark 3 0x8048213 1 1 0 40 | 41 | totalIcount 117923 42 | pinpoints 2 43 | endp 44 | -------------------------------------------------------------------------------- /tests/piii/ignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/ignore -------------------------------------------------------------------------------- /tests/piii/loop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/loop -------------------------------------------------------------------------------- /tests/piii/misses: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/misses -------------------------------------------------------------------------------- /tests/piii/prefetch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/prefetch -------------------------------------------------------------------------------- /tests/piii/rdtsc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/rdtsc -------------------------------------------------------------------------------- /tests/piii/rep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/rep -------------------------------------------------------------------------------- /tests/piii/repl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/repl -------------------------------------------------------------------------------- /tests/piii/roi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/roi -------------------------------------------------------------------------------- /tests/piii/segf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/segf -------------------------------------------------------------------------------- /tests/piii/step: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/step -------------------------------------------------------------------------------- /tests/piii/time: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/tests/piii/time -------------------------------------------------------------------------------- /tests/prefetch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | extern "C" void xiosim_roi_begin() __attribute__ ((noinline)); 10 | extern "C" void xiosim_roi_end() __attribute__ ((noinline)); 11 | 12 | void xiosim_roi_begin() { __asm__ __volatile__ ("":::"memory"); } 13 | void xiosim_roi_end() { __asm__ __volatile__ ("":::"memory"); } 14 | 15 | struct entry { 16 | int32_t next_ind; 17 | int32_t pf_ind; 18 | char padding[56]; // pad to a cache line to simplify math 19 | }; 20 | const size_t SIZE = 32 * 1024; // 2MB, so in L3 21 | alignas(64) entry arr[SIZE]; 22 | int32_t indices[SIZE]; 23 | 24 | const size_t iterations = 10; 25 | 26 | const int32_t PF_LOOKAHEAD = 16; 27 | 28 | /* without -DPREFETCH: X instructions (X = 1310720, 4 * iterations * SIZE) 29 | * Y load lookups (Y = 327680, iterations * SIZE) 30 | * Y load misses 31 | * IPC: ~0.283 32 | * 33 | * with -DPREFETCH: 2*X instructions (8 * iterations * SIZE) 34 | * 3*Y load lookups 35 | * (curr->next_ind; curr->pf_ind (same line, always hits), prefetch) 36 | * Y load misses (same # as before, but now these are the prefetches -> PROFIT!) 37 | * IPC: ~1.586 38 | */ 39 | int chase() { 40 | size_t ind = 0; 41 | for (size_t i = 0; i < iterations * SIZE; i++) { 42 | entry* curr = &arr[ind]; 43 | ind = curr->next_ind; 44 | #ifdef PREFETCH 45 | __builtin_prefetch(&arr[curr->pf_ind], 0, 0); 46 | #endif 47 | } 48 | return ind > 0; // don't optimize us away 49 | } 50 | 51 | int main(int argc, char* argv[]) { 52 | memset(arr, 0, SIZE * sizeof(entry)); 53 | 54 | /* Generate a permutation of indices */ 55 | for (size_t i = 0; i < SIZE; i++) 56 | indices[i] = i; 57 | // pseudo-random with fixed seed for reproducibility 58 | std::mt19937 rd(1); 59 | std::default_random_engine e1(rd()); 60 | std::shuffle(std::begin(indices), std::end(indices), e1); 61 | 62 | /* Initialize array to hold a pointer chase */ 63 | size_t ind = 0; 64 | for (size_t i = 0; i < SIZE; i++) { 65 | arr[ind].next_ind = indices[i]; 66 | if (i < SIZE - PF_LOOKAHEAD) 67 | arr[ind].pf_ind = indices[i + PF_LOOKAHEAD]; 68 | ind = indices[i]; 69 | } 70 | 71 | /* Aand chase away */ 72 | xiosim_roi_begin(); 73 | int res = chase(); 74 | xiosim_roi_end(); 75 | 76 | if (res) usleep(1); 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /tests/rdtsc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Test for RDTSC timing virtualization. 3 | * 4 | * Compiled on O1, the test should measure around 100k cycles between 5 | * reads of the timestamp counter. 6 | */ 7 | 8 | #include 9 | 10 | extern "C" void xiosim_roi_begin() __attribute__ ((noinline)); 11 | extern "C" void xiosim_roi_end() __attribute__ ((noinline)); 12 | int spin() __attribute__ ((noinline)); 13 | 14 | void xiosim_roi_begin() { __asm__ __volatile__ ("":::"memory"); } 15 | void xiosim_roi_end() { __asm__ __volatile__ ("":::"memory"); } 16 | 17 | int spin() { 18 | int i; 19 | for (i = 0; i < 100000; i++) 20 | ; 21 | return (i < 0); 22 | } 23 | 24 | int main() { 25 | unsigned int init_lo = 0, init_hi = 0; 26 | unsigned int final_lo = 0, final_hi = 0; 27 | 28 | xiosim_roi_begin(); 29 | __asm__ __volatile__ ("rdtsc": "=a"(init_lo), "=d"(init_hi)); 30 | int ret = spin(); 31 | __asm__ __volatile__ ("rdtsc": "=a"(final_lo), "=d"(final_hi)); 32 | xiosim_roi_end(); 33 | 34 | int hi_diff = final_hi - init_hi; 35 | int lo_diff = final_lo - init_lo; 36 | 37 | // So the spin() function doesn't get optimized away. 38 | printf("Some return: %d\n", ret); 39 | printf("High difference: %d\n", hi_diff); 40 | printf("Low difference: %d\n", lo_diff); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /tests/rep.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | const size_t NUM_ITEMS = 256 * 1024; 8 | 9 | int32_t a[NUM_ITEMS]; 10 | int32_t b[NUM_ITEMS]; 11 | 12 | extern "C" void xiosim_roi_begin() __attribute__ ((noinline)); 13 | extern "C" void xiosim_roi_end() __attribute__ ((noinline)); 14 | 15 | void xiosim_roi_begin() { __asm__ __volatile__ ("":::"memory"); } 16 | void xiosim_roi_end() { __asm__ __volatile__ ("":::"memory"); } 17 | 18 | int main(int argc, char* argv[]) 19 | { 20 | /* Time in ROI should be ~3.5x NUM_ITEMS instructions */ 21 | xiosim_roi_begin(); 22 | 23 | /* Copy val to a - NUM_ITEMS unrolled instructions */ 24 | int32_t val = 0xdecafbad; 25 | __asm__ __volatile__ ("cld;" 26 | "rep stosl" 27 | : 28 | :"D"(a), "a"(val), "c"(NUM_ITEMS) 29 | :"memory"); 30 | 31 | /* Copy a to b - NUM_ITEMS unrolled instructions */ 32 | __asm__ __volatile__ ("cld;" 33 | "rep movsl" 34 | : 35 | :"D"(b), "S"(a), "c"(NUM_ITEMS) 36 | :"memory"); 37 | 38 | /* Compare a to b - NUM_ITEMS unrolled instructions */ 39 | __asm__ __volatile__ ("cld;" 40 | "repe cmpsl" 41 | : 42 | :"D"(b), "S"(a), "c"(NUM_ITEMS) 43 | :"memory"); 44 | 45 | a[NUM_ITEMS / 2] = 0; 46 | /* Compare a to b -- finish early - 1/2 NUM_ITEMS unrolled instructions */ 47 | __asm__ __volatile__ ("cld;" 48 | "repe cmpsl" 49 | : 50 | :"D"(b), "S"(a), "c"(NUM_ITEMS) 51 | :"memory"); 52 | xiosim_roi_end(); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /tests/repl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int fib(int n) 5 | { 6 | if(n <= 1) 7 | return 1; 8 | else 9 | return fib(n-1) + fib(n-2); 10 | } 11 | 12 | extern "C" int fib_repl(int n) { return fib(n); } 13 | 14 | int main(int argc, char* argv[]) 15 | { 16 | // If we properly ignored the longer fib_repl call, we should take ~450K instructions. 17 | const int lim = 19; 18 | fib(lim); 19 | fib_repl(lim+2); 20 | fib(lim); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /tests/roi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" void xiosim_roi_begin() __attribute__ ((noinline)); 5 | extern "C" void xiosim_roi_end() __attribute__ ((noinline)); 6 | 7 | void xiosim_roi_begin() { __asm__ __volatile__ ("":::"memory"); } 8 | void xiosim_roi_end() { __asm__ __volatile__ ("":::"memory"); } 9 | 10 | int main(int argc, char* argv[]) 11 | { 12 | const int32_t NUM_ITERS = 30000; 13 | // Time in ROI should be 90K instructions 14 | xiosim_roi_begin(); 15 | __asm__ __volatile ("loop: subl $1, %%eax;" 16 | "cmpl $0, %%eax;" 17 | "jns loop;" 18 | : 19 | : "a"(NUM_ITERS)); 20 | xiosim_roi_end(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /tests/segf.cpp: -------------------------------------------------------------------------------- 1 | // Trigger a segfault on a non-taken path. Should cleanly kill speculative process. 2 | 3 | #define ITER 2000 4 | 5 | #include 6 | 7 | int main(int argc, char** argv) 8 | { 9 | int sum = 0; 10 | for (int i=0; i < ITER; i++) { 11 | if (i >= 0) { 12 | sum += i; 13 | sum *= 5; 14 | } 15 | else { 16 | // Test loads from addr 0 17 | int kaboom = *(int*)NULL; 18 | (void) kaboom; 19 | } 20 | } 21 | 22 | for (int i=0; i < ITER; i++) { 23 | if (i >= 0) { 24 | sum += i; 25 | sum *= 5; 26 | } 27 | else { 28 | // Test indirect jumps to addr 0 29 | __asm__ ("xor %%ecx, %%ecx\n" 30 | "jmp *(%%ecx)" :::"%ecx"); 31 | } 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /tests/step.cpp: -------------------------------------------------------------------------------- 1 | // Step in IPC from high to low 2 | 3 | #define COMPUTE_ITER 12000 4 | #define LOW_ITER 60000 5 | #define RATIO 20 6 | 7 | #include 8 | 9 | int main(int argc, char** argv) 10 | { 11 | int arr[LOW_ITER / RATIO]; 12 | int sum = 0; 13 | 14 | // Init array to throw off predictor 15 | // A.cfg IPC = 0.92 16 | for (int i=0; i < LOW_ITER / RATIO; i++) 17 | arr[i] = rand() % 10; 18 | 19 | // Do some compute 20 | // A.cfg IPC = 0.70 21 | for (int j=0; j < COMPUTE_ITER; j++) { 22 | sum += j; 23 | if (j % 5 == 0) 24 | sum *= 13; 25 | } 26 | 27 | // This should throw off the branch predictor, 28 | // leading to lowish IPC. 29 | // A.cfg IPC = 0.56 30 | for (int k=0; k < LOW_ITER; k++) 31 | if (arr[k % (LOW_ITER / RATIO) < 5]) 32 | sum -= 1; 33 | else { 34 | __asm__("nop; nop; nop;"); 35 | __asm__("nop; nop; nop;"); 36 | __asm__("nop; nop; nop;"); 37 | } 38 | 39 | return (sum <= 0); 40 | } 41 | -------------------------------------------------------------------------------- /tests/time.cpp: -------------------------------------------------------------------------------- 1 | /* Test for various timing-related syscalls (times, gettimeofday). 2 | * 3 | * Simulator should return simulated time instead of host time. 4 | * 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | extern "C" void xiosim_roi_begin() __attribute__ ((noinline)); 13 | extern "C" void xiosim_roi_end() __attribute__ ((noinline)); 14 | 15 | void xiosim_roi_begin() { __asm__ __volatile__ ("":::"memory"); } 16 | void xiosim_roi_end() { __asm__ __volatile__ ("":::"memory"); } 17 | 18 | const int ITER = 1000000; 19 | 20 | double times_test() { 21 | struct tms start, end; 22 | clock_t start_tick, end_tick; 23 | start_tick = times(&start); 24 | printf("starting seconds: %d\n", start.tms_utime); 25 | 26 | unsigned long long counter = 0; 27 | while (counter < ITER) { 28 | counter++; 29 | } 30 | end_tick = times(&end); 31 | 32 | printf("Counter value = %d\n", counter); 33 | printf("Elapsed seconds: %d\n", end.tms_utime); 34 | printf("Elapsed clock ticks: %llu\n", end_tick - start_tick); 35 | return (end.tms_utime - start.tms_utime); 36 | } 37 | 38 | unsigned loop() { 39 | unsigned counter = 0; 40 | __asm__ __volatile ("1: addl $1, %0;" 41 | "cmpl %2, %1;" 42 | "jb 1b;" 43 | : "=a"(counter) 44 | : "0"(counter), "i"(ITER) 45 | : "memory"); 46 | return counter; 47 | } 48 | 49 | double gettimeofday_test() { 50 | struct timeval start, end; 51 | gettimeofday(&start, NULL); 52 | 53 | unsigned counter = loop(); 54 | 55 | gettimeofday(&end, NULL); 56 | 57 | /* 1M iterations of a 3 instruction loop -> 3M instructions. 58 | * With pipelining we get 1 cycles per iteration for a total of 1M cycles. 59 | * Default NHM config is 3.2GHz, so we should expect a time difference 60 | * of around 1M / 3.2GHz = 317us. 61 | */ 62 | printf("Counter value = %d\n", counter); 63 | return (end.tv_sec - start.tv_sec) + 1.0*(end.tv_usec - start.tv_usec)/(1e6); 64 | } 65 | 66 | int main() { 67 | // For now, just test gettimeofday() because we haven't completed times(). 68 | xiosim_roi_begin(); 69 | double elapsed = gettimeofday_test(); 70 | xiosim_roi_end(); 71 | printf("Elapsed: %3.8f sec\n", elapsed); 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /third_party/InstLib/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # InstLib is a library with pin utility functions. 3 | # This is an old version that was distributed with Pin 2.12, because 4 | # we rely on the various controller classes (that Intel removed in favor 5 | # of PinPlay). 6 | 7 | package(default_visibility = ["//visibility:public"]) 8 | 9 | licenses(["notice"]) # Intel Open Source license 10 | 11 | exports_files(["LICENSE"]) 12 | 13 | cc_library( 14 | name = "legacy_instlib", 15 | hdrs = glob([ 16 | "legacy_instlib.H", 17 | # Below should be in srcs, but bazel doesn't like the non-standard header 18 | # extension there. 19 | "*.H" 20 | ]), 21 | ) 22 | -------------------------------------------------------------------------------- /third_party/InstLib/LICENSE: -------------------------------------------------------------------------------- 1 | Intel Open Source License 2 | 3 | Copyright (c) 2002-2012 Intel Corporation. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. Redistributions 11 | in binary form must reproduce the above copyright notice, this list of 12 | conditions and the following disclaimer in the documentation and/or 13 | other materials provided with the distribution. Neither the name of 14 | the Intel Corporation nor the names of its contributors may be used to 15 | endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR 22 | ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /third_party/InstLib/legacy_instlib.H: -------------------------------------------------------------------------------- 1 | /*BEGIN_LEGAL 2 | Intel Open Source License 3 | 4 | Copyright (c) 2002-2012 Intel Corporation. All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. Redistributions 12 | in binary form must reproduce the above copyright notice, this list of 13 | conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. Neither the name of 15 | the Intel Corporation nor the names of its contributors may be used to 16 | endorse or promote products derived from this software without 17 | specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR 23 | ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | END_LEGAL */ 31 | #ifndef INSTLIB_H 32 | #define INSTLIB_H 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #define ISIMPOINT_MAX_THREADS 50 42 | 43 | #include "filter.H" 44 | #include "skipper.H" 45 | #include "icount.H" 46 | #include "alarm.H" 47 | 48 | #include "parse_address_count.H" 49 | 50 | #include "control.H" 51 | #include "control_stats.H" 52 | 53 | #include "follow_child.H" 54 | #endif 55 | -------------------------------------------------------------------------------- /third_party/boost/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Forwarding package, rules should depend on this, so it's easy to 3 | # overwrite if, say, we have the actual package at a different location. 4 | 5 | licenses(["notice"]) 6 | 7 | exports_files(["LICENSE"]) 8 | 9 | cc_library( 10 | name = "accumulators", 11 | visibility = ["//visibility:public"], 12 | deps = ["@boost//:accumulators"], 13 | ) 14 | 15 | cc_library( 16 | name = "interprocess", 17 | visibility = ["//visibility:public"], 18 | deps = ["@boost//:interprocess"], 19 | ) 20 | 21 | cc_library( 22 | name = "tokenizer", 23 | visibility = ["//visibility:public"], 24 | deps = ["@boost//:tokenizer"], 25 | ) 26 | -------------------------------------------------------------------------------- /third_party/catch/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Forwarding package, rules should depend on this, so it's easy to 3 | # overwrite if, say, we have the actual package at a different location. 4 | 5 | licenses(["notice"]) 6 | 7 | exports_files(["LICENSE"]) 8 | 9 | cc_library( 10 | name = "main", 11 | visibility = ["//visibility:public"], 12 | deps = ["@catch//:main"], 13 | ) 14 | -------------------------------------------------------------------------------- /third_party/catch/BUILD.external: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # boost license 2 | 3 | CATCH_PATH = "Catch-1.2.1" 4 | 5 | cc_library( 6 | visibility = ["//visibility:public"], 7 | name = "main", 8 | hdrs = [CATCH_PATH + "/single_include/catch.hpp"], 9 | includes = [CATCH_PATH + "/single_include"], 10 | ) 11 | -------------------------------------------------------------------------------- /third_party/confuse/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Forwarding package, rules should depend on this, so it's easy to 3 | # overwrite if, say, we have the actual package at a different location. 4 | 5 | licenses(["notice"]) 6 | 7 | exports_files(["LICENSE"]) 8 | 9 | package(default_visibility = ["//visibility:public"]) 10 | 11 | cc_library( 12 | name = "confuse", 13 | deps = [":confuse_configed"], 14 | ) 15 | 16 | cc_library( 17 | name = "confuse_configed", 18 | srcs = [ 19 | "@confuse//:srcs", 20 | "config.h", 21 | "lexer.c", 22 | ], 23 | copts = [ 24 | "-DHAVE_CONFIG_H", 25 | "-Ithird_party/confuse", 26 | "-Wno-unused-but-set-parameter", 27 | "-Wno-error", # -Wno-discarded-qualifiers not supported any more 28 | ], 29 | visibility = ["//visibility:private"], 30 | deps = [ 31 | "@confuse//:main", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /third_party/confuse/BUILD.external: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | CONFUSE_PATH = "confuse-3.0" 4 | 5 | cc_library( 6 | visibility = ["//visibility:public"], 7 | name = "main", 8 | includes = [ CONFUSE_PATH + "/src" ], 9 | ) 10 | 11 | # We'll compile these in a wrapper rule in @//third_party, 12 | # because we also want to depend on @//third_party/confuse/config.h 13 | # and bazel doesn't support that yet (coming in 0.2). 14 | filegroup( 15 | visibility = ["//visibility:public"], 16 | name = "srcs", 17 | srcs = [ 18 | CONFUSE_PATH + "/src/compat.h", 19 | CONFUSE_PATH + "/src/confuse.c", 20 | CONFUSE_PATH + "/src/confuse.h", 21 | ], 22 | 23 | ) 24 | 25 | config_setting( 26 | name = "k8", 27 | values = { "cpu" : "k8" } 28 | ) 29 | 30 | config_setting( 31 | name = "piii", 32 | values = { "cpu" : "piii" } 33 | ) 34 | -------------------------------------------------------------------------------- /third_party/ezOptionParser/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # ezOptionParser is a flags parsing library. 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | licenses(["notice"]) # MIT 7 | 8 | exports_files(["LICENSE"]) 9 | 10 | cc_library( 11 | name = "ezOptionParser", 12 | srcs = ["ezOptionParser.hpp"], 13 | hdrs = ["ezOptionParser_clean.hpp"], 14 | includes = ["."], 15 | ) 16 | -------------------------------------------------------------------------------- /third_party/ezOptionParser/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011,2012 Remik Ziemlinski 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /third_party/ezOptionParser/ezOptionParser_clean.hpp: -------------------------------------------------------------------------------- 1 | #pragma GCC diagnostic push 2 | #pragma GCC diagnostic ignored "-Wsign-compare" 3 | #pragma GCC diagnostic ignored "-Wreorder" 4 | #pragma GCC diagnostic ignored "-Wparentheses" 5 | #pragma GCC diagnostic ignored "-Wunused-variable" 6 | #pragma GCC diagnostic ignored "-Wformat-extra-args" 7 | #include "ezOptionParser.hpp" 8 | #pragma GCC diagnostic pop 9 | -------------------------------------------------------------------------------- /third_party/mcpat/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # McPAT is a processor power model. 3 | 4 | licenses(["notice"]) 5 | 6 | exports_files(["LICENSE"]) 7 | 8 | cc_library( 9 | name = "lib", 10 | srcs = glob([ 11 | "XML_Parse.cc", 12 | "array.cc", 13 | "basic_components.cc", 14 | "core.cc", 15 | "interconnect.cc", 16 | "iocontrollers.cc", 17 | "logic.cc", 18 | "slave.cc", 19 | "memoryctrl.cc", 20 | "noc.cc", 21 | "processor.cc", 22 | "sharedcache.cc", 23 | "xmlParser.cc", 24 | "*.h", 25 | ]), 26 | hdrs = [ 27 | "XML_Parse.h", 28 | "mcpat.h", 29 | ], 30 | copts = [ 31 | "-Wno-all", # mcpat is full of warnings, disable 32 | ], 33 | visibility = ["//visibility:public"], 34 | deps = [ 35 | "//third_party/mcpat/cacti:lib", 36 | ], 37 | ) 38 | -------------------------------------------------------------------------------- /third_party/mcpat/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | McPAT 3 | SOFTWARE LICENSE AGREEMENT 4 | Copyright 2012 Hewlett-Packard Development Company, L.P. 5 | All Rights Reserved 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer; 11 | redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution; 14 | neither the name of the copyright holders nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 | -------------------------------------------------------------------------------- /third_party/mcpat/cacti/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Cacti is a cache model distributed with McPAT. 3 | 4 | licenses(["notice"]) 5 | 6 | exports_files(["LICENSE"]) 7 | 8 | cc_library( 9 | name = "lib", 10 | srcs = [ 11 | "Ucache.cc", 12 | "arbiter.cc", 13 | "area.cc", 14 | "bank.cc", 15 | "basic_circuit.cc", 16 | "cacti_interface.cc", 17 | "component.cc", 18 | "crossbar.cc", 19 | "decoder.cc", 20 | "htree2.cc", 21 | "io.cc", 22 | "main.cc", 23 | "mat.cc", 24 | "nuca.cc", 25 | "parameter.cc", 26 | "powergating.cc", 27 | "router.cc", 28 | "subarray.cc", 29 | "technology.cc", 30 | "uca.cc", 31 | "wire.cc", 32 | ], 33 | hdrs = glob(["*.h"]), 34 | copts = [ 35 | "-DPIN", 36 | "-DNTHREADS=1", 37 | "-Wno-all", # mcpat is full of warnings, disable 38 | ], 39 | includes = ["."], 40 | linkopts = [ 41 | "-lm", 42 | "-pthread", 43 | ], 44 | visibility = ["//visibility:public"], 45 | ) 46 | -------------------------------------------------------------------------------- /third_party/mcpat/cacti/area.cc: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * McPAT/CACTI 3 | * SOFTWARE LICENSE AGREEMENT 4 | * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 | * All Rights Reserved 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer; 11 | * redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution; 14 | * neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 | * 30 | ***************************************************************************/ 31 | 32 | 33 | 34 | #include "area.h" 35 | #include "component.h" 36 | #include "decoder.h" 37 | #include "parameter.h" 38 | #include "basic_circuit.h" 39 | #include 40 | #include 41 | #include 42 | 43 | using namespace std; 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /third_party/mcpat/cacti/area.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * McPAT/CACTI 3 | * SOFTWARE LICENSE AGREEMENT 4 | * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 | * All Rights Reserved 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer; 11 | * redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution; 14 | * neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 | * 30 | ***************************************************************************/ 31 | 32 | 33 | 34 | #ifndef __AREA_H__ 35 | #define __AREA_H__ 36 | 37 | #include "cacti_interface.h" 38 | #include "basic_circuit.h" 39 | 40 | using namespace std; 41 | 42 | class Area 43 | { 44 | public: 45 | double w; 46 | double h; 47 | 48 | Area():w(0), h(0), area(0) { } 49 | double get_w() const { return w; } 50 | double get_h() const { return h; } 51 | double get_area() const 52 | { 53 | if (w == 0 && h == 0) 54 | { 55 | return area; 56 | } 57 | else 58 | { 59 | return w*h; 60 | } 61 | } 62 | void set_w(double w_) { w = w_; } 63 | void set_h(double h_) { h = h_; } 64 | void set_area(double a_) { area = a_; } 65 | 66 | private: 67 | double area; 68 | }; 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /third_party/mcpat/cacti/cacti.i: -------------------------------------------------------------------------------- 1 | %module cacti 2 | %{ 3 | /* Includes the header in the wrapper code */ 4 | #include "cacti_interface.h" 5 | %} 6 | 7 | /* Parse the header file to generate wrappers */ 8 | %include "cacti_interface.h" -------------------------------------------------------------------------------- /third_party/mcpat/cacti/globalvar.h: -------------------------------------------------------------------------------- 1 | #include 2 | extern ostream* out_file; 3 | -------------------------------------------------------------------------------- /third_party/mcpat/cacti/io.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * McPAT/CACTI 3 | * SOFTWARE LICENSE AGREEMENT 4 | * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 | * All Rights Reserved 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer; 11 | * redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution; 14 | * neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 | * 30 | ***************************************************************************/ 31 | 32 | 33 | #ifndef __IO_H__ 34 | #define __IO_H__ 35 | 36 | 37 | #include "const.h" 38 | #include "cacti_interface.h" 39 | 40 | 41 | void output_data_csv(const uca_org_t & fin_res); 42 | void output_UCA(uca_org_t * fin_res); 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /third_party/mcpat/cacti/makefile: -------------------------------------------------------------------------------- 1 | TAR = cacti 2 | 3 | .PHONY: dbg opt depend clean clean_dbg clean_opt 4 | 5 | all: opt 6 | 7 | dbg: $(TAR).mk obj_dbg 8 | @$(MAKE) TAG=dbg -C . -f $(TAR).mk 9 | 10 | opt: $(TAR).mk obj_opt 11 | @$(MAKE) TAG=opt -C . -f $(TAR).mk 12 | 13 | obj_dbg: 14 | mkdir $@ 15 | 16 | obj_opt: 17 | mkdir $@ 18 | 19 | clean: clean_dbg clean_opt 20 | 21 | clean_dbg: obj_dbg 22 | @$(MAKE) TAG=dbg -C . -f $(TAR).mk clean 23 | rm -rf $< 24 | 25 | clean_opt: obj_opt 26 | @$(MAKE) TAG=opt -C . -f $(TAR).mk clean 27 | rm -rf $< 28 | 29 | -------------------------------------------------------------------------------- /third_party/mcpat/cacti/subarray.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * McPAT/CACTI 3 | * SOFTWARE LICENSE AGREEMENT 4 | * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 | * All Rights Reserved 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer; 11 | * redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution; 14 | * neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 | * 30 | ***************************************************************************/ 31 | 32 | 33 | 34 | #ifndef __SUBARRAY_H__ 35 | #define __SUBARRAY_H__ 36 | 37 | #include "area.h" 38 | #include "component.h" 39 | #include "parameter.h" 40 | 41 | using namespace std; 42 | 43 | 44 | class Subarray : public Component 45 | { 46 | public: 47 | Subarray(const DynamicParameter & dp, bool is_fa_); 48 | ~Subarray(); 49 | 50 | const DynamicParameter & dp; 51 | double get_total_cell_area(); 52 | unsigned int num_rows; 53 | unsigned int num_cols; 54 | int32_t num_cols_fa_cam; 55 | int32_t num_cols_fa_ram; 56 | Area cell, cam_cell; 57 | 58 | bool is_fa; 59 | double C_wl, C_wl_cam, C_wl_ram; 60 | double R_wl, R_wl_cam, R_wl_ram; 61 | double C_bl, C_bl_cam; 62 | private: 63 | 64 | void compute_C(); // compute bitline and wordline capacitance 65 | }; 66 | 67 | 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /third_party/mcpat/cacti/version_cacti.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * McPAT 3 | * SOFTWARE LICENSE AGREEMENT 4 | * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 | * All Rights Reserved 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer; 11 | * redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution; 14 | * neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 | * 30 | ***************************************************************************/ 31 | 32 | #ifndef VERSION_H_ 33 | #define VERSION_H_ 34 | 35 | #include 36 | 37 | #define VER_MAJOR_CACTI 6 /* CACTI-P and DVS */ 38 | #define VER_MINOR_CACTI 5 39 | const string VER_postfix_CACTI = "-P"; 40 | #define VER_COMMENT_CACTI "CAM and fully associative cache, power gating, and DVS" 41 | #define VER_UPDATE_CACTI "June, 2014" 42 | 43 | #endif /* VERSION_H_ */ 44 | -------------------------------------------------------------------------------- /third_party/mcpat/globalvar.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * McPAT 3 | * SOFTWARE LICENSE AGREEMENT 4 | * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 | * All Rights Reserved 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer; 11 | * redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution; 14 | * neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 | * 30 | ***************************************************************************/ 31 | 32 | 33 | #ifndef GLOBALVAR_H_ 34 | #define GLOBALVAR_H_ 35 | 36 | #include 37 | 38 | #ifdef GLOBALVAR 39 | #define EXTERN 40 | #else 41 | #define EXTERN extern 42 | #endif 43 | 44 | EXTERN bool opt_for_clk; 45 | EXTERN ostream *out_file; 46 | 47 | #endif /* GLOBALVAR_H_ */ 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /third_party/mcpat/makefile: -------------------------------------------------------------------------------- 1 | TAR = mcpat 2 | 3 | .PHONY: dbg opt depend clean clean_dbg clean_opt 4 | 5 | all: lib 6 | 7 | libd: $(TAR).mk obj_dbg_lib 8 | @$(MAKE) TAG=dbg TGT=lib -C . -f $(TAR).mk 9 | 10 | lib: $(TAR).mk obj_opt_lib 11 | @$(MAKE) TAG=opt TGT=lib -C . -f $(TAR).mk 12 | 13 | dbg: $(TAR).mk obj_dbg 14 | @$(MAKE) TAG=dbg TGT=exe -C . -f $(TAR).mk 15 | 16 | opt: $(TAR).mk obj_opt 17 | @$(MAKE) TAG=opt TGT=exe -C . -f $(TAR).mk 18 | 19 | obj_dbg_lib: 20 | mkdir -p obj_dbg 21 | 22 | obj_opt_lib: 23 | mkdir -p obj_opt 24 | 25 | obj_dbg: 26 | mkdir -p $@ 27 | 28 | obj_opt: 29 | mkdir -p $@ 30 | 31 | clean: clean_dbg clean_opt 32 | 33 | clean_dbg: obj_dbg 34 | @$(MAKE) TAG=dbg -C . -f $(TAR).mk clean 35 | rm -rf $< 36 | 37 | clean_opt: obj_opt 38 | @$(MAKE) TAG=opt -C . -f $(TAR).mk clean 39 | rm -rf $< 40 | 41 | -------------------------------------------------------------------------------- /third_party/mcpat/mcpatXeonCore.mk: -------------------------------------------------------------------------------- 1 | TARGET = mcpatXeonCore 2 | SHELL = /bin/sh 3 | .PHONY: all depend clean 4 | .SUFFIXES: .cc .o 5 | 6 | ifndef NTHREADS 7 | NTHREADS = 4 8 | endif 9 | 10 | 11 | LIBS = 12 | INCS = -lm 13 | 14 | ifeq ($(TAG),dbg) 15 | DBG = -Wall 16 | OPT = -ggdb -g -O0 -DNTHREADS=1 -Icacti 17 | else 18 | DBG = 19 | OPT = -O3 -msse2 -mfpmath=sse -DNTHREADS=$(NTHREADS) -Icacti 20 | #OPT = -O0 -DNTHREADS=$(NTHREADS) 21 | endif 22 | 23 | #CXXFLAGS = -Wall -Wno-unknown-pragmas -Winline $(DBG) $(OPT) 24 | CXXFLAGS = -Wno-unknown-pragmas $(DBG) $(OPT) 25 | CXX = g++ -m32 26 | CC = gcc -m32 27 | 28 | VPATH = cacti 29 | 30 | SRCS = \ 31 | Ucache.cc \ 32 | XML_Parse.cc \ 33 | arbiter.cc \ 34 | area.cc \ 35 | array.cc \ 36 | bank.cc \ 37 | basic_circuit.cc \ 38 | basic_components.cc \ 39 | cacti_interface.cc \ 40 | component.cc \ 41 | core.cc \ 42 | crossbar.cc \ 43 | decoder.cc \ 44 | htree2.cc \ 45 | interconnect.cc \ 46 | io.cc \ 47 | iocontrollers.cc \ 48 | logic.cc \ 49 | main.cc \ 50 | mat.cc \ 51 | memoryctrl.cc \ 52 | noc.cc \ 53 | nuca.cc \ 54 | parameter.cc \ 55 | processor.cc \ 56 | router.cc \ 57 | sharedcache.cc \ 58 | subarray.cc \ 59 | technology_xeon_core.cc \ 60 | uca.cc \ 61 | wire.cc \ 62 | xmlParser.cc 63 | 64 | OBJS = $(patsubst %.cc,obj_$(TAG)/%.o,$(SRCS)) 65 | 66 | all: obj_$(TAG)/$(TARGET) 67 | cp -f obj_$(TAG)/$(TARGET) $(TARGET) 68 | 69 | obj_$(TAG)/$(TARGET) : $(OBJS) 70 | $(CXX) $(OBJS) -o $@ $(INCS) $(CXXFLAGS) $(LIBS) -pthread 71 | 72 | #obj_$(TAG)/%.o : %.cc 73 | # $(CXX) -c $(CXXFLAGS) $(INCS) -o $@ $< 74 | 75 | obj_$(TAG)/%.o : %.cc 76 | $(CXX) $(CXXFLAGS) -c $< -o $@ 77 | 78 | clean: 79 | -rm -f *.o $(TARGET) 80 | 81 | 82 | -------------------------------------------------------------------------------- /third_party/mcpat/version.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * McPAT 3 | * SOFTWARE LICENSE AGREEMENT 4 | * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 | * All Rights Reserved 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer; 11 | * redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution; 14 | * neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 | * 30 | ***************************************************************************/ 31 | 32 | #ifndef VERSION_H_ 33 | #define VERSION_H_ 34 | 35 | #define VER_MAJOR 1 36 | #define VER_MINOR 2 37 | 38 | #define VER_UPDATE "June, 2014" 39 | 40 | #endif /* VERSION_H_ */ 41 | -------------------------------------------------------------------------------- /third_party/pin/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Forwarding package, rules should depend on this, so it's easy to 3 | # overwrite if, say, we have the actual package at a different location. 4 | 5 | licenses(["notice"]) 6 | 7 | exports_files(["LICENSE"]) 8 | 9 | cc_library( 10 | name = "pin", 11 | visibility = ["//visibility:public"], 12 | deps = ["@pin//:pin"], 13 | ) 14 | 15 | cc_library( 16 | name = "xed", 17 | visibility = ["//visibility:public"], 18 | deps = ["@pin//:xed"], 19 | ) 20 | 21 | filegroup( 22 | name = "cp_pinbin", 23 | srcs = ["@pin//:cp_pinbin"], 24 | visibility = ["//visibility:public"], 25 | ) 26 | -------------------------------------------------------------------------------- /third_party/pin/weaken.bzl: -------------------------------------------------------------------------------- 1 | # Invoke objcopy to make a list of symbols in an archive weak 2 | 3 | ar_file_type = FileType([".a"]) 4 | 5 | def _impl(ctx): 6 | output = ctx.outputs.out 7 | input = ctx.file.srcs 8 | syms = ctx.attr.symbols 9 | 10 | sym_params = [] 11 | for sym in syms: 12 | sym_params += ["-W", sym] 13 | 14 | ctx.action( 15 | inputs = [input], 16 | outputs = [output], 17 | progress_message = "Running objcopy on %s" % input.short_path, 18 | executable = ctx.fragments.cpp.objcopy_executable, 19 | arguments = sym_params + [input.path, output.path], 20 | ) 21 | 22 | cc_weaken = rule( 23 | implementation = _impl, 24 | fragments = ["cpp"], 25 | attrs = { 26 | "srcs": attr.label(mandatory=True, allow_files=ar_file_type, single_file=True), 27 | "symbols" : attr.string_list(), 28 | }, 29 | outputs = {"out": "%{name}.weak.a"}, 30 | ) 31 | 32 | -------------------------------------------------------------------------------- /tools/bazel.rc: -------------------------------------------------------------------------------- 1 | build --compilation_mode "opt" 2 | build --cpu "k8" 3 | build --dynamic_mode "off" 4 | build --crosstool_top "//tools_local/cpp:toolchain" 5 | test --sandbox_add_path "/dev/shm" 6 | -------------------------------------------------------------------------------- /tools_local/cpp/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "malloc", 5 | ) 6 | 7 | cc_library( 8 | name = "stl", 9 | ) 10 | 11 | filegroup( 12 | name = "empty", 13 | srcs = [], 14 | ) 15 | 16 | # This is the entry point for --crosstool_top. Toolchains are found 17 | # by lopping off the name of --crosstool_top and searching for 18 | # "cc-compiler-${CPU}" in this BUILD file, where CPU is the target CPU 19 | # specified in --cpu. 20 | # 21 | # This file group should include 22 | # * all cc_toolchain targets supported 23 | # * all file groups that said cc_toolchain might refer to, 24 | # including the default_grte_top setting in the CROSSTOOL 25 | # protobuf. 26 | filegroup( 27 | name = "toolchain", 28 | srcs = [ 29 | ":cc-compiler-k8", 30 | ":cc-compiler-local", 31 | ":empty", 32 | ], 33 | ) 34 | 35 | cc_toolchain( 36 | name = "cc-compiler-local", 37 | all_files = ":empty", 38 | compiler_files = ":empty", 39 | cpu = "local", 40 | dwp_files = ":empty", 41 | dynamic_runtime_libs = [":empty"], 42 | linker_files = ":empty", 43 | objcopy_files = ":empty", 44 | static_runtime_libs = [":empty"], 45 | strip_files = ":empty", 46 | supports_param_files = 0, 47 | ) 48 | 49 | cc_toolchain( 50 | name = "cc-compiler-k8", 51 | all_files = ":empty", 52 | compiler_files = ":empty", 53 | cpu = "local", 54 | dwp_files = ":empty", 55 | dynamic_runtime_libs = [":empty"], 56 | linker_files = ":empty", 57 | objcopy_files = ":empty", 58 | static_runtime_libs = [":empty"], 59 | strip_files = ":empty", 60 | supports_param_files = 0, 61 | ) 62 | 63 | filegroup( 64 | name = "srcs", 65 | srcs = glob(["**"]), 66 | ) 67 | -------------------------------------------------------------------------------- /xiosim/2bitc.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------*/ 2 | /* saturating two bit counter implemented with no branching */ 3 | /*----------------------------------------------------------*/ 4 | typedef unsigned char my2bc_t; 5 | 6 | #define _2BC_TABLE 0xD4E8 7 | #define MY2BC_DIR_MASK 0x01 8 | #define MY2BC_HYST_MASK 0x02 9 | #define MY2BC_DIR(ctr) ((ctr)&MY2BC_DIR_MASK) 10 | #define MY2BC_HYST(ctr) ((ctr)&MY2BC_HYST_MASK) 11 | 12 | #define MY2BC_UPDATE(ctr,dir) (ctr)=(_2BC_TABLE>>(((ctr<<1)+(dir))<<1))&3 13 | /* _2BC_table is a bit packed version of the state transition table 14 | for the 2bC: 15 | 16 | The bits are switched in their places (i.e. bit 0 = direction bit 17 | and bit 1 = confidence/hysteresis bit). This allows the extraction 18 | of the direction bit with a simple AND instead of a SHIFT+AND. 19 | 20 | prev 21 | 2bC 22 | LD inc dec 23 | +-------- 24 | 00 | 10 00 (8) 25 | 01 | 11 10 (E) 26 | 10 | 01 00 (4) 27 | 11 | 11 01 (D) 28 | 29 | (LD: 'L'east Signif. Bit of 2bc, 30 | 'D'irection Bit) 31 | 32 | The previous counter value and the branch outcome direction are 33 | used to shift the packed table by the proper amount, and then the 34 | two bits are masked out. 35 | 36 | */ 37 | 38 | /* similar to MY2BC_UPDATE, but these macros inc/dec (saturating) if 39 | the predicate p is true. 40 | 41 | (COND_INC) (COND_DEC) 42 | LD p=1 p=0 LD p=1 p=0 43 | +-------- +-------- 44 | 00 | 10 00 (8) 00 | 00 00 (0) 45 | 01 | 11 01 (D) 01 | 10 01 (9) 46 | 10 | 01 10 (6) 10 | 00 10 (2) 47 | 11 | 11 11 (F) 11 | 01 11 (7) 48 | */ 49 | #define _2BC_CINC_TABLE 0xF6D8 50 | #define _2BC_CDEC_TABLE 0x7290 51 | 52 | #define MY2BC_COND_INC(ctr,p) (ctr)=(_2BC_CINC_TABLE>>(((ctr<<1)+(p))<<1))&3 53 | #define MY2BC_COND_DEC(ctr,p) (ctr)=(_2BC_CDEC_TABLE>>(((ctr<<1)+(p))<<1))&3 54 | 55 | #define MY2BC_STRONG_TAKEN (3) 56 | #define MY2BC_WEAKLY_TAKEN (1) 57 | #define MY2BC_WEAKLY_NT (2) 58 | #define MY2BC_STRONG_NT (0) 59 | -------------------------------------------------------------------------------- /xiosim/LICENSE.zesto: -------------------------------------------------------------------------------- 1 | Copyright © 2009 by Gabriel H. Loh and the Georgia Tech Research Corporation 2 | Atlanta, GA 30332-0415 3 | All Rights Reserved. 4 | 5 | THIS IS A LEGAL DOCUMENT BY DOWNLOADING ZESTO, YOU ARE AGREEING TO THESE 6 | TERMS AND CONDITIONS. 7 | 8 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 9 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 10 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 11 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE 12 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 13 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 14 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 15 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 16 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 17 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 18 | POSSIBILITY OF SUCH DAMAGE. 19 | 20 | Redistribution and use in source and binary forms, with or without 21 | modification, are permitted provided that the following conditions are met: 22 | 23 | 1. Redistributions of source code must retain the above copyright notice, 24 | this list of conditions and the following disclaimer. 25 | 26 | 2. Redistributions in binary form must reproduce the above copyright notice, 27 | this list of conditions and the following disclaimer in the documentation 28 | and/or other materials provided with the distribution. 29 | 30 | 3. Neither the name of the Georgia Tech Research Corporation nor the names of 31 | its contributors may be used to endorse or promote products derived from 32 | this software without specific prior written permission. 33 | 34 | 4. Zesto is distributed freely for commercial and non-commercial use. 35 | 36 | 5. No nonprofit user may place any restrictions on the use of this software, 37 | including as modified by the user, by any other authorized user. 38 | 39 | 6. Noncommercial and nonprofit users may distribute copies of Zesto in 40 | compiled or executable form as set forth in Section 2, provided that either: 41 | (A) it is accompanied by the corresponding machine-readable source code, or 42 | (B) it is accompanied by a written offer, with no time limit, to give anyone 43 | a machine-readable copy of the corresponding source code in return for 44 | reimbursement of the cost of distribution. This written offer must permit 45 | verbatim duplication by anyone, or (C) it is distributed by someone who 46 | received only the executable form, and is accompanied by a copy of the 47 | written offer of source code. 48 | 49 | 7. Zesto was developed by Gabriel H. Loh, Ph.D. US Mail: 266 Ferst Drive, 50 | Georgia Institute of Technology, Atlanta, GA 30332-0765 51 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-MC/MC-ideal.cpp: -------------------------------------------------------------------------------- 1 | /* MC-simple.cpp: Simple memory controller */ 2 | /* 3 | * __COPYRIGHT__ SK 4 | */ 5 | 6 | #ifdef MC_PARSE_ARGS 7 | if(!strcasecmp("ideal",type)) 8 | { 9 | if(sscanf(opt_string,"%*[^:]") != 0) 10 | fatal("bad memory controller options string %s (should be \"simple\")",opt_string); 11 | return std::make_unique(); 12 | } 13 | #else 14 | 15 | /* This implements an ideal memory controller. No latency, no queues, no fun. */ 16 | class MC_ideal_t:public MC_t 17 | { 18 | protected: 19 | 20 | public: 21 | 22 | MC_ideal_t() 23 | { 24 | init(); 25 | } 26 | 27 | ~MC_ideal_t() 28 | { 29 | } 30 | 31 | MC_ENQUEUABLE_HEADER 32 | { 33 | return true; 34 | } 35 | 36 | /* Enqueue a memory command (read/write) to the memory controller. */ 37 | MC_ENQUEUE_HEADER 38 | { 39 | /* fill previous level as appropriate, straight away 40 | XXX: hope that LLC won't trip with 0 latency */ 41 | if(prev_cp) 42 | { 43 | fill_arrived(prev_cp,MSHR_bank,MSHR_index); 44 | bus_use(uncore->fsb.get(),linesize>>uncore->fsb_DDR,cmd==CACHE_PREFETCH); 45 | } 46 | 47 | total_accesses++; 48 | } 49 | 50 | /* This is called each cycle to process the requests in the memory controller queue. */ 51 | MC_STEP_HEADER 52 | { 53 | } 54 | 55 | MC_PRINT_HEADER 56 | { 57 | } 58 | 59 | }; 60 | 61 | 62 | #endif /* MC_PARSE_ARGS */ 63 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-bpred/bpred-2bc.cpp: -------------------------------------------------------------------------------- 1 | /* bpred-2bC.cpp: 2-bit saturating counter [Smith, ISCA 1981] */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "2bC" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | int num_entries; 12 | 13 | if(sscanf(opt_string,"%*[^:]:%[^:]:%d",name,&num_entries) != 2) 14 | fatal("bad bpred options string %s (should be \"2bC:name:num_entries\")",opt_string); 15 | return std::make_unique(core,name,num_entries); 16 | } 17 | #else 18 | 19 | class bpred_2bC_t:public bpred_dir_t 20 | { 21 | class bpred_2bC_sc_t:public bpred_sc_t 22 | { 23 | public: 24 | my2bc_t * current_ctr; 25 | }; 26 | 27 | protected: 28 | 29 | int num_entries; 30 | int entry_mask; 31 | my2bc_t * table; 32 | 33 | public: 34 | 35 | /* CREATE */ 36 | bpred_2bC_t(const core_t * core, 37 | char * const arg_name, 38 | const int arg_num_entries 39 | ) : bpred_dir_t(core) 40 | { 41 | init(); 42 | 43 | /* verify arguments are valid */ 44 | CHECK_PPOW2(arg_num_entries); 45 | 46 | name = arg_name; 47 | type = "2bC"; 48 | 49 | num_entries = arg_num_entries; 50 | entry_mask = arg_num_entries-1; 51 | table = (my2bc_t*) calloc(arg_num_entries,sizeof(my2bc_t)); 52 | if(!table) 53 | fatal("couldn't malloc 2bC table"); 54 | for(int i=0;icurrent_ctr = &table[PC&entry_mask]; 71 | sc->updated = false; 72 | BPRED_STAT(lookups++;) 73 | return MY2BC_DIR(*sc->current_ctr); 74 | } 75 | 76 | /* UPDATE */ 77 | BPRED_UPDATE_HEADER 78 | { 79 | class bpred_2bC_sc_t * sc = (class bpred_2bC_sc_t*) scvp; 80 | if(!sc->updated) 81 | { 82 | BPRED_STAT(num_hits += our_pred == outcome;) 83 | BPRED_STAT(updates++;) 84 | sc->updated = true; 85 | } 86 | MY2BC_UPDATE(*sc->current_ctr,outcome); 87 | } 88 | 89 | /* GET_CACHE */ 90 | BPRED_GET_CACHE_HEADER 91 | { 92 | class bpred_2bC_sc_t * sc = new bpred_2bC_sc_t(); 93 | if(!sc) 94 | fatal("couldn't malloc 2bC State Cache"); 95 | return sc; 96 | } 97 | 98 | }; 99 | 100 | #endif /* BPRED_PARSE_ARGS */ 101 | #undef COMPONENT_NAME 102 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-bpred/bpred-btfnt.cpp: -------------------------------------------------------------------------------- 1 | /* bpred-btfnt.cpp: Static BTFNT (backwards-taken, forward-not-taken) 2 | predictor [Ball and Larus, PPoPP 1993] */ 3 | /* 4 | * __COPYRIGHT__ GT 5 | */ 6 | 7 | #define COMPONENT_NAME "btfnt" 8 | 9 | #ifdef BPRED_PARSE_ARGS 10 | if(!strcasecmp(COMPONENT_NAME,type)) 11 | { 12 | return std::make_unique(core); 13 | } 14 | #else 15 | 16 | class bpred_btfnt_t:public bpred_dir_t 17 | { 18 | public: 19 | 20 | /* CREATE */ 21 | bpred_btfnt_t(const core_t * core) : bpred_dir_t(core) 22 | { 23 | init(); 24 | 25 | name = COMPONENT_NAME; 26 | type = "static btfnt"; 27 | 28 | bits = 0; 29 | } 30 | 31 | /* LOOKUP */ 32 | BPRED_LOOKUP_HEADER 33 | { 34 | BPRED_STAT(lookups++;) 35 | scvp->updated = false; 36 | return (tPC < PC); 37 | } 38 | 39 | }; 40 | 41 | #endif /* BPRED_PARSE_ARGS */ 42 | #undef COMPONENT_NAME 43 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-bpred/bpred-magic.cpp: -------------------------------------------------------------------------------- 1 | /* bpred-magic.cpp: Predictor with a predefined hit rate */ 2 | 3 | #define COMPONENT_NAME "magic" 4 | 5 | #ifdef BPRED_PARSE_ARGS 6 | if(!strcasecmp(COMPONENT_NAME,type)) 7 | { 8 | float hit_rate; 9 | 10 | if(sscanf(opt_string,"%*[^:]:%f",&hit_rate) != 1) 11 | fatal("bad bpred options string %s (should be \"magic:hit_rate\")",opt_string); 12 | return std::make_unique(core, hit_rate); 13 | } 14 | #else 15 | 16 | class bpred_magic_t:public bpred_dir_t 17 | { 18 | protected: 19 | 20 | float hit_rate; 21 | counter_t num_taken; 22 | 23 | public: 24 | 25 | /* CREATE */ 26 | bpred_magic_t(const core_t * core, float _hit_rate) : 27 | bpred_dir_t(core), hit_rate(_hit_rate) 28 | { 29 | init(); 30 | 31 | name = COMPONENT_NAME; 32 | type = "magic hit rate"; 33 | 34 | bits = 0; 35 | } 36 | 37 | /* LOOKUP */ 38 | BPRED_LOOKUP_HEADER 39 | { 40 | int pred; 41 | float prob = random() / float(RAND_MAX); 42 | if (prob < hit_rate) 43 | pred = outcome; 44 | else 45 | pred = !outcome; 46 | BPRED_STAT(lookups++;) 47 | scvp->updated = false; 48 | return pred; 49 | } 50 | 51 | /* UPDATE */ 52 | BPRED_UPDATE_HEADER 53 | { 54 | if(!scvp->updated) 55 | { 56 | if(outcome) 57 | BPRED_STAT(num_taken++;) 58 | BPRED_STAT(updates++;) 59 | BPRED_STAT(num_hits += our_pred == outcome;) 60 | scvp->updated = true; 61 | } 62 | } 63 | 64 | /* REG_STATS */ 65 | BPRED_REG_STATS_HEADER 66 | { 67 | bpred_dir_t::reg_stats(sdb,core); 68 | } 69 | 70 | /* RESET_STATS */ 71 | BPRED_RESET_STATS_HEADER 72 | { 73 | bpred_dir_t::reset_stats(); 74 | } 75 | 76 | }; 77 | 78 | #endif /* BPRED_PARSE_ARGS */ 79 | #undef COMPONENT_NAME 80 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-bpred/bpred-nottaken.cpp: -------------------------------------------------------------------------------- 1 | /* bpred-nottaken.cpp: Static always not-taken predictor */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "nottaken" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | return std::make_unique(core); 12 | } 13 | #else 14 | 15 | class bpred_nottaken_t:public bpred_dir_t 16 | { 17 | public: 18 | 19 | /* CREATE */ 20 | bpred_nottaken_t(const core_t * core) : bpred_dir_t(core) 21 | { 22 | init(); 23 | 24 | name = COMPONENT_NAME; 25 | type = "static not-taken"; 26 | 27 | bits = 0; 28 | } 29 | 30 | /* LOOKUP */ 31 | BPRED_LOOKUP_HEADER 32 | { 33 | BPRED_STAT(lookups++;) 34 | scvp->updated = false; 35 | return 0; 36 | } 37 | }; 38 | #endif /* BPRED_PARSE_ARGS */ 39 | #undef COMPONENT_NAME 40 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-bpred/bpred-perfect.cpp: -------------------------------------------------------------------------------- 1 | /* bpred-perfect.cpp: Oracle/perfect predictor 2 | NOTE: for branch direction only (not target) */ 3 | /* 4 | * __COPYRIGHT__ GT 5 | */ 6 | 7 | #define COMPONENT_NAME "perfect" 8 | 9 | #ifdef BPRED_PARSE_ARGS 10 | if(!strcasecmp(COMPONENT_NAME,type)) 11 | { 12 | return std::make_unique(core); 13 | } 14 | #else 15 | 16 | class bpred_perfect_t:public bpred_dir_t 17 | { 18 | public: 19 | 20 | bpred_perfect_t(const core_t * core) : bpred_dir_t(core) 21 | { 22 | init(); 23 | 24 | name = COMPONENT_NAME; 25 | type = "perfect/oracle"; 26 | 27 | bits = 0; 28 | } 29 | 30 | /* LOOKUP */ 31 | BPRED_LOOKUP_HEADER 32 | { 33 | BPRED_STAT(lookups++;) 34 | scvp->updated = false; 35 | return outcome; 36 | } 37 | 38 | }; 39 | 40 | #endif /* BPRED_PARSE_ARGS */ 41 | #undef COMPONENT_NAME 42 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-bpred/bpred-random.cpp: -------------------------------------------------------------------------------- 1 | /* bpred-random.cpp: Random (50-50) predictor */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "random" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | return std::make_unique(core); 12 | } 13 | #else 14 | 15 | struct bpred_random_t:public bpred_dir_t 16 | { 17 | protected: 18 | 19 | counter_t num_taken; 20 | 21 | public: 22 | 23 | /* CREATE */ 24 | bpred_random_t(const core_t * core) : bpred_dir_t(core) 25 | { 26 | init(); 27 | 28 | name = COMPONENT_NAME; 29 | type = "completely random"; 30 | 31 | bits = 0; 32 | } 33 | 34 | /* LOOKUP */ 35 | BPRED_LOOKUP_HEADER 36 | { 37 | int pred = random()&1; 38 | BPRED_STAT(lookups++;) 39 | scvp->updated = false; 40 | return pred; 41 | } 42 | 43 | /* UPDATE */ 44 | BPRED_UPDATE_HEADER 45 | { 46 | if(!scvp->updated) 47 | { 48 | if(outcome) 49 | BPRED_STAT(num_taken++;) 50 | BPRED_STAT(updates++;) 51 | BPRED_STAT(num_hits += our_pred == outcome;) 52 | scvp->updated = true; 53 | } 54 | } 55 | 56 | /* REG_STATS */ 57 | BPRED_REG_STATS_HEADER 58 | { 59 | bpred_dir_t::reg_stats(sdb,core); 60 | 61 | int id = core?core->id:0; 62 | char buf[256]; 63 | char buf2[256]; 64 | 65 | sprintf(buf,"c%d.%s.num_taken",id,name.c_str()); 66 | sprintf(buf2,"number of taken branch predictions by %s",name.c_str()); 67 | stat_reg_counter(sdb, true, buf, buf2, &num_taken, 0, TRUE, NULL); 68 | } 69 | 70 | /* RESET_STATS */ 71 | BPRED_RESET_STATS_HEADER 72 | { 73 | bpred_dir_t::reset_stats(); 74 | num_taken = 0; 75 | } 76 | 77 | }; 78 | 79 | #endif /* BPRED_PARSE_ARGS */ 80 | #undef COMPONENT_NAME 81 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-bpred/bpred-taken.cpp: -------------------------------------------------------------------------------- 1 | /* bpred-taken.cpp: Static always taken predictor */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "taken" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | return std::make_unique(core); 12 | } 13 | #else 14 | 15 | class bpred_taken_t:public bpred_dir_t 16 | { 17 | public: 18 | 19 | /* CREATE */ 20 | bpred_taken_t(const core_t * core) : bpred_dir_t(core) 21 | { 22 | init(); 23 | 24 | name = COMPONENT_NAME; 25 | type = "static taken"; 26 | 27 | bits = 0; 28 | } 29 | 30 | /* LOOKUP */ 31 | BPRED_LOOKUP_HEADER 32 | { 33 | BPRED_STAT(lookups++;) 34 | scvp->updated = false; 35 | return 1; 36 | } 37 | 38 | }; 39 | 40 | #endif /* BPRED_PARSE_ARGS */ 41 | #undef COMPONENT_NAME 42 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-btb/btb-perfect.cpp: -------------------------------------------------------------------------------- 1 | /* btb-perfect.cpp: Perfect target prediction (not including RAS) */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "perfect" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | return std::make_unique(); 12 | } 13 | #else 14 | 15 | class BTB_perfect_t:public BTB_t 16 | { 17 | public: 18 | /* CREATE */ 19 | BTB_perfect_t(void) 20 | { 21 | init(); 22 | 23 | name = COMPONENT_NAME; 24 | type = COMPONENT_NAME; 25 | } 26 | 27 | /* DESTROY */ 28 | ~BTB_perfect_t() {} 29 | 30 | /* LOOKUP */ 31 | BTB_LOOKUP_HEADER 32 | { 33 | BPRED_STAT(lookups++;) 34 | scvp->updated = false; 35 | if(our_pred && outcome) /* if pred taken, and actually taken */ 36 | return oPC; 37 | else if(our_pred) 38 | return tPC; 39 | else 40 | return 0; 41 | } 42 | 43 | /* UPDATE */ 44 | BTB_UPDATE_HEADER 45 | { 46 | if(!scvp->updated) 47 | { 48 | BPRED_STAT(updates++;) 49 | BPRED_STAT(num_hits += oPC == our_target;) 50 | scvp->updated = true; 51 | } 52 | } 53 | 54 | int get_num_entries(void) { return 0; } 55 | int get_tag_width(void) { return 0; } 56 | int get_num_ways(void) { return 0; } 57 | }; 58 | 59 | #endif /* BTB_PARSE_ARGS */ 60 | #undef COMPONENT_NAME 61 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-dram/dram-simplescalar.cpp: -------------------------------------------------------------------------------- 1 | /* dram-simplescalar.cpp: 2 | Based on SimpleScalar memory model (constant latency DRAM): 3 | Given latency in uncore cycles, or in ns which 4 | we'll convert to uncore cycles for you. 5 | Per-chunk latency computed based on uncore-speed, 6 | fsb-speed, and whether fsb uses DDR. 7 | 8 | This isn't precisely the same as the traditional SimpleScalar 9 | mode, but it's pretty close. 10 | 11 | usage: 12 | -dram simplescalar:LAT:UNITS (UNITS: 0=cycles, 1=ns) 13 | 14 | examples: 15 | -dram simplescalar:160 (160 uncore_cycle's per access) 16 | -dram simplescalar:160:0 (ditto) 17 | -dram simplescalar:120:1 (120 ns per access) */ 18 | /* 19 | * __COPYRIGHT__ GT 20 | */ 21 | 22 | 23 | #define COMPONENT_NAME "simplescalar" 24 | 25 | #ifdef DRAM_PARSE_ARGS 26 | if(!strcasecmp(COMPONENT_NAME,type)) 27 | { 28 | int latency; 29 | int units = 0; /* 0=cycle, 1=ns */ 30 | 31 | if(sscanf(opt_string,"%*[^:]:%d:%d",&latency,&units) != 2) 32 | { 33 | if(sscanf(opt_string,"%*[^:]:%d",&latency) != 1) 34 | fatal("bad dram options string %s (should be \"simplescalar:latency[:units]\")",opt_string); 35 | } 36 | return std::make_unique(latency,units); 37 | } 38 | #else 39 | 40 | class dram_simplescalar_t:public dram_t 41 | { 42 | protected: 43 | int latency; 44 | int chunk_latency; 45 | 46 | public: 47 | 48 | /* CREATE */ 49 | dram_simplescalar_t(int arg_latency, 50 | int arg_units) 51 | { 52 | init(); 53 | 54 | if(arg_units < 0 || arg_units > 1) 55 | fatal("simplescalar dram model's optional units arguments should be 0 (cycles) or 1 (ns)"); 56 | 57 | if(arg_units) 58 | latency = (int)ceil(arg_latency * uncore->fsb_speed/1000.0); 59 | else 60 | latency = arg_latency; 61 | 62 | chunk_latency = 1; 63 | best_latency = INT_MAX; 64 | } 65 | 66 | /* ACCESS */ 67 | DRAM_ACCESS_HEADER 68 | { 69 | int chunks = (bsize + (uncore->fsb_width-1)) >> uncore->fsb_bits; /* burst length, rounded up */ 70 | dram_assert(chunks > 0,latency); 71 | int lat = latency + ((chunk_latency * chunks)>>uncore->fsb_DDR); 72 | 73 | total_accesses++; 74 | total_latency += lat; 75 | total_burst += chunks; 76 | if(lat < best_latency) 77 | best_latency = lat; 78 | if(lat > worst_latency) 79 | worst_latency = lat; 80 | 81 | return lat; 82 | } 83 | }; 84 | 85 | #endif /* DRAM_PARSE_ARGS */ 86 | #undef COMPONENT_NAME 87 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-dvfs/none.cpp: -------------------------------------------------------------------------------- 1 | /* none.cpp - No DVFS, just set frequency to default on create */ 2 | 3 | #ifdef ZESTO_PARSE_ARGS 4 | if(!strcasecmp(opt_string, "none")) 5 | return std::make_unique(core); 6 | #else 7 | 8 | class vf_controller_none_t : public vf_controller_t { 9 | public: 10 | vf_controller_none_t(struct core_t * const _core); 11 | 12 | virtual void change_vf(); 13 | }; 14 | 15 | vf_controller_none_t::vf_controller_none_t(struct core_t * const _core) : vf_controller_t(_core) 16 | { 17 | core->cpu_speed = core->knobs->default_cpu_speed; 18 | } 19 | 20 | void vf_controller_none_t::change_vf() 21 | { 22 | double old_vdd = vdd; 23 | 24 | //XXX: your fancy DVFS algorithm comes here 25 | 26 | // handle bookkeeping 27 | if (vdd != old_vdd) 28 | vf_controller_t::change_vf(); 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-dvfs/sample.cpp: -------------------------------------------------------------------------------- 1 | /* sample.cpp - Simple IPC-based frequency controller */ 2 | 3 | #ifdef ZESTO_PARSE_ARGS 4 | if(!strcasecmp(opt_string, "sample")) 5 | return std::make_unique(core); 6 | #else 7 | 8 | /* This is a simple policy to get the flavor of the DVFS API. 9 | * Not representative of anything realistic. 10 | * Calculate IPC on the fly. If below 0.6, go to half the default frequency. 11 | */ 12 | class vf_controller_sample_t : public vf_controller_t { 13 | public: 14 | vf_controller_sample_t(struct core_t * const _core); 15 | 16 | virtual void change_vf(); 17 | 18 | protected: 19 | tick_t last_cycle; 20 | counter_t last_commit_insn; 21 | float min_freq; 22 | float max_freq; 23 | }; 24 | 25 | vf_controller_sample_t::vf_controller_sample_t(struct core_t * const _core) : vf_controller_t(_core) 26 | { 27 | last_cycle = 0; 28 | last_commit_insn = 0; 29 | max_freq = core->knobs->default_cpu_speed; 30 | min_freq = 0.5 * max_freq; 31 | 32 | core->cpu_speed = core->knobs->default_cpu_speed; 33 | } 34 | 35 | void vf_controller_sample_t::change_vf() 36 | { 37 | counter_t delta_insn = core->stat.commit_insn - last_commit_insn; 38 | tick_t delta_cycles = core->sim_cycle - last_cycle; 39 | float curr_ipc = delta_insn / (float) delta_cycles; 40 | if (curr_ipc < 0.6 ) 41 | core->cpu_speed = min_freq; 42 | else 43 | core->cpu_speed = max_freq; 44 | 45 | ZTRACE_PRINT(core->id, "cycles: %" PRId64" instrs: %" PRId64" IPC: %.3f cpu_speed: %.1f\n", delta_cycles, delta_insn, curr_ipc, core->cpu_speed); 46 | 47 | last_cycle = core->sim_cycle; 48 | last_commit_insn = core->stat.commit_insn; 49 | 50 | /* If you change voltages, update the base controller. */ 51 | /* 52 | if (vdd != previous_vdd) 53 | vf_controller_t::change_vf(); 54 | */ 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-fusion/fusion-mcfarling.cpp: -------------------------------------------------------------------------------- 1 | /* fusion-mcfarling.cpp: McFarling selection table [McFarling, DEC-WRL TN36] 2 | NOTE: number of component predictors must equal two */ 3 | /* 4 | * __COPYRIGHT__ GT 5 | */ 6 | 7 | #define COMPONENT_NAME "mcfarling" 8 | 9 | #ifdef BPRED_PARSE_ARGS 10 | if(!strcasecmp("mcfarling",type)) 11 | { 12 | int num_entries; 13 | 14 | if(sscanf(opt_string,"%*[^:]:%[^:]:%d",name,&num_entries) != 2) 15 | fatal("bad fusion options string %s (should be \"mcfarling:name:num_entries\")",opt_string); 16 | return std::make_unique(name,num_pred,num_entries); 17 | } 18 | #else 19 | 20 | class fusion_mcfarling_t:public fusion_t 21 | { 22 | protected: 23 | int meta_size; 24 | int meta_mask; 25 | my2bc_t * meta; 26 | 27 | public: 28 | 29 | /* CREATE */ 30 | fusion_mcfarling_t(char * const arg_name, 31 | const int arg_num_pred, 32 | const int arg_meta_size 33 | ) 34 | { 35 | init(); 36 | 37 | /* verify arguments are valid */ 38 | CHECK_PPOW2(arg_meta_size); 39 | if(arg_num_pred != 2) 40 | fatal("mcfarling fusion only valid for two component/direction predictors"); 41 | 42 | name = arg_name; 43 | type = "McFarling tournament selection"; 44 | 45 | num_pred = arg_num_pred; 46 | meta_size = arg_meta_size; 47 | meta_mask = meta_size-1; 48 | meta = (my2bc_t*) calloc(meta_size,sizeof(my2bc_t)); 49 | if(!meta) 50 | fatal("couldn't malloc mcfarling meta-table"); 51 | bits = meta_size*2; 52 | } 53 | 54 | /* DESTROY */ 55 | ~fusion_mcfarling_t() 56 | { 57 | free(meta); meta = NULL; 58 | } 59 | 60 | /* LOOKUP */ 61 | FUSION_LOOKUP_HEADER 62 | { 63 | int index = PC&meta_mask; 64 | int meta_direction = MY2BC_DIR(meta[index]); 65 | bool pred = preds[meta_direction]; 66 | BPRED_STAT(lookups++;) 67 | scvp->updated = false; 68 | return pred; 69 | } 70 | 71 | /* UPDATE */ 72 | FUSION_UPDATE_HEADER 73 | { 74 | int index = PC&meta_mask; 75 | 76 | if(!scvp->updated) 77 | { 78 | BPRED_STAT(updates++;) 79 | BPRED_STAT(num_hits += our_pred == outcome;) 80 | scvp->updated = true; 81 | } 82 | 83 | /* meta table only updated when predictors disagree. If both 84 | agree, then either both are right, or both are wrong: in 85 | either case the meta table is not updated. */ 86 | if(preds[0]^preds[1]) 87 | { 88 | MY2BC_UPDATE(meta[index],(preds[1]==outcome)); 89 | } 90 | } 91 | 92 | }; 93 | 94 | #endif /* BPRED_PARSE_ARGS */ 95 | #undef COMPONENT_NAME 96 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-fusion/fusion-oracle.cpp: -------------------------------------------------------------------------------- 1 | /* fusion-oracle.cpp: oracle selection; if the correct prediction 2 | exists among *any* of the component predictors, then this 3 | meta-predictor will select the correct one. This is extremely 4 | optimistic as the only time this will mispredict is when *all* 5 | component predictions are wrong. Obviously using a static 6 | taken predictor and static NT predictor with the fusion_oracle 7 | will result in perfect direction prediction. */ 8 | /* 9 | * __COPYRIGHT__ GT 10 | */ 11 | 12 | #define COMPONENT_NAME "oracle" 13 | 14 | #ifdef BPRED_PARSE_ARGS 15 | if(!strcasecmp("oracle",type) || !strcmp("perfect",type)) 16 | { 17 | return std::make_unique(num_pred); 18 | } 19 | #else 20 | 21 | class fusion_oracle_t:public fusion_t 22 | { 23 | public: 24 | 25 | /* CREATE */ 26 | fusion_oracle_t(const int arg_num_pred) 27 | { 28 | init(); 29 | 30 | name = COMPONENT_NAME; 31 | type = "oracle"; 32 | 33 | num_pred = arg_num_pred; 34 | 35 | bits = 0; 36 | } 37 | 38 | /* LOOKUP */ 39 | FUSION_LOOKUP_HEADER 40 | { 41 | bool pred = !outcome; 42 | 43 | for(int i=0;iupdated = false; 54 | 55 | return pred; 56 | } 57 | 58 | /* UPDATE */ 59 | 60 | /* generic n-component version */ 61 | FUSION_UPDATE_HEADER 62 | { 63 | if(!scvp->updated) 64 | { 65 | BPRED_STAT(updates++;) 66 | BPRED_STAT(num_hits += our_pred == outcome;) 67 | scvp->updated = true; 68 | } 69 | } 70 | 71 | }; 72 | 73 | #endif /* BPRED_PARSE_ARGS */ 74 | #undef COMPONENT_NAME 75 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-fusion/fusion-random.cpp: -------------------------------------------------------------------------------- 1 | /* fusion-random.cpp: randomly choose an outcome from the component predictors */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "random" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp("random",type)) 10 | { 11 | return std::make_unique(num_pred); 12 | } 13 | #else 14 | 15 | class fusion_random_t:public fusion_t 16 | { 17 | public: 18 | 19 | /* CREATE */ 20 | fusion_random_t(const int arg_num_pred) 21 | { 22 | init(); 23 | 24 | name = COMPONENT_NAME; 25 | type = "random Selection"; 26 | 27 | num_pred = arg_num_pred; 28 | 29 | bits = 0; 30 | } 31 | 32 | /* LOOKUP */ 33 | FUSION_LOOKUP_HEADER 34 | { 35 | bool pred = preds[random()%num_pred]; 36 | BPRED_STAT(lookups++;) 37 | scvp->updated = false; 38 | return pred; 39 | } 40 | }; 41 | 42 | #endif /* BPRED_PARSE_ARGS */ 43 | #undef COMPONENT_NAME 44 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-fusion/fusion-singleton.cpp: -------------------------------------------------------------------------------- 1 | /* fusion-singleton.cpp: No-op meta-predictor used when there is only a single component predictor */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "none" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp("none",type)) 10 | { 11 | return std::make_unique(); 12 | } 13 | #else 14 | 15 | class fusion_singleton_t:public fusion_t 16 | { 17 | public: 18 | 19 | fusion_singleton_t(void) 20 | { 21 | init(); 22 | 23 | num_pred = 1; 24 | name = COMPONENT_NAME; 25 | type = "none"; 26 | 27 | bits = 0; 28 | } 29 | 30 | /* LOOKUP */ 31 | FUSION_LOOKUP_HEADER 32 | { 33 | BPRED_STAT(lookups++;) 34 | scvp->updated = false; 35 | return preds[0]; 36 | } 37 | 38 | /* REG_STATS */ 39 | FUSION_REG_STATS_HEADER 40 | { 41 | /* nada: don't bother registering any stats when there's only one 42 | component predictors since the stats will be identical. */ 43 | } 44 | }; 45 | 46 | #endif /* BPRED_PARSE_ARGS */ 47 | #undef COMPONENT_NAME 48 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-memdep/memdep-blind.cpp: -------------------------------------------------------------------------------- 1 | /* memdep-blind.cpp: Always predict that no memory dependencies/conflicts exist */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | #define COMPONENT_NAME "blind" 6 | 7 | #ifdef MEMDEP_PARSE_ARGS 8 | if(!strcasecmp(COMPONENT_NAME,type)) 9 | { 10 | return std::make_unique(core); 11 | } 12 | #else 13 | 14 | class memdep_blind_t: public memdep_t 15 | { 16 | public: 17 | /* CONSTRUCTOR */ 18 | memdep_blind_t(const struct core_t * _core) : memdep_t(_core) 19 | { 20 | init(); 21 | name = COMPONENT_NAME; 22 | type = COMPONENT_NAME; 23 | } 24 | /* LOOKUP */ 25 | MEMDEP_LOOKUP_HEADER 26 | { 27 | MEMDEP_STAT(lookups++;) 28 | return true; 29 | } 30 | }; 31 | 32 | #endif /* MEMDEP_PARSE_ARGS */ 33 | #undef COMPONENT_NAME 34 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-memdep/memdep-lwt.cpp: -------------------------------------------------------------------------------- 1 | /* memdep-lwt.cpp: Load Wait Table [Alpha 21264, R.E. Kessler, IEEE Micro 1999] */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | #define COMPONENT_NAME "lwt" 6 | 7 | #ifdef MEMDEP_PARSE_ARGS 8 | if(!strcasecmp(COMPONENT_NAME,type)) 9 | { 10 | int num_entries; 11 | int reset_interval; 12 | 13 | if(sscanf(opt_string,"%*[^:]:%[^:]:%d:%d",name,&num_entries,&reset_interval) != 3) 14 | fatal("bad memdep options string %s (should be \"lwt:name:num_entries:reset_interval\")",opt_string); 15 | return std::make_unique(core,name,num_entries,reset_interval); 16 | } 17 | #else 18 | 19 | class memdep_lwt_t:public memdep_t 20 | { 21 | protected: 22 | int num_entries; 23 | char * array; 24 | int reset_interval; 25 | tick_t last_reset; 26 | int mask; 27 | 28 | public: 29 | memdep_lwt_t(const struct core_t * _core, 30 | char * arg_name, 31 | int arg_num_entries, 32 | int arg_reset_interval 33 | ) : memdep_t(_core) 34 | { 35 | init(); 36 | 37 | last_reset = 0; 38 | 39 | /* verify arguments are valid */ 40 | CHECK_PPOW2(arg_num_entries); 41 | CHECK_POS(arg_reset_interval); 42 | 43 | name = arg_name; 44 | type = "lwt-memdep"; 45 | 46 | num_entries = arg_num_entries; 47 | reset_interval = arg_reset_interval; 48 | 49 | mask = num_entries-1; 50 | array = (char*) calloc(num_entries,sizeof(array)); 51 | if(!array) 52 | fatal("couldn't malloc lwt-memdep lwt table"); 53 | 54 | bits = num_entries + (int)ceil(log(reset_interval)/log(2.0)); /* plus extra counter to track cycles */ 55 | } 56 | 57 | /* DESTROY */ 58 | ~memdep_lwt_t() 59 | { 60 | free(array); array = NULL; 61 | } 62 | 63 | /* LOOKUP */ 64 | MEMDEP_LOOKUP_HEADER 65 | { 66 | int index = PC&mask; 67 | 68 | MEMDEP_STAT(lookups++;) 69 | 70 | if((core->sim_cycle - last_reset) >= reset_interval) 71 | { 72 | memset(array,0,num_entries*sizeof(*array)); 73 | last_reset = core->sim_cycle - (core->sim_cycle % reset_interval); 74 | } 75 | 76 | if(array[index]) /* predict wait */ 77 | return !sta_unknown; 78 | else 79 | return true; 80 | } 81 | 82 | /* UPDATE */ 83 | MEMDEP_UPDATE_HEADER 84 | { 85 | MEMDEP_STAT(updates++;) 86 | 87 | if((core->sim_cycle - last_reset) >= reset_interval) 88 | { 89 | memset(array,0,num_entries*sizeof(*array)); 90 | last_reset = core->sim_cycle - (core->sim_cycle % reset_interval); 91 | } 92 | 93 | int index = PC&mask; 94 | array[index] = true; 95 | } 96 | }; 97 | 98 | #endif /* MEMDEP_PARSE_ARGS */ 99 | #undef COMPONENT_NAME 100 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-memdep/memdep-none.cpp: -------------------------------------------------------------------------------- 1 | /* memdep-none.cpp: Do not speculate on memory dependences; always wait until 2 | all previous store addresses have been resolved. */ 3 | /* 4 | * __COPYRIGHT__ GT 5 | */ 6 | #define COMPONENT_NAME "none" 7 | 8 | #ifdef MEMDEP_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | return std::make_unique(core); 12 | } 13 | #else 14 | 15 | class memdep_none_t:public memdep_t 16 | { 17 | public: 18 | 19 | /* CONSTRUCTOR */ 20 | memdep_none_t(const struct core_t * _core) : memdep_t(_core) 21 | { 22 | init(); 23 | name = COMPONENT_NAME; 24 | type = COMPONENT_NAME; 25 | } 26 | 27 | /* LOOKUP */ 28 | MEMDEP_LOOKUP_HEADER 29 | { 30 | MEMDEP_STAT(lookups++;) 31 | return !sta_unknown && !partial_match; 32 | } 33 | }; 34 | 35 | #endif /* MEMDEP_PARSE_ARGS */ 36 | #undef COMPONENT_NAME 37 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-memdep/memdep-oracle.cpp: -------------------------------------------------------------------------------- 1 | /* memdep-oracle.cpp: Oracle memory dependence predictor; this handles both 2 | the existance and timing of conflicts (i.e., loads wait until only earlier 3 | matching/conflicting store addresses have been computed, but no longer) */ 4 | /* 5 | * __COPYRIGHT__ GT 6 | */ 7 | #define COMPONENT_NAME "oracle" 8 | 9 | #ifdef MEMDEP_PARSE_ARGS 10 | if(!strcasecmp(COMPONENT_NAME,type)) 11 | { 12 | return std::make_unique(core); 13 | } 14 | #else 15 | 16 | class memdep_oracle_t:public memdep_t 17 | { 18 | public: 19 | /* CONSTRUCTOR */ 20 | memdep_oracle_t(const struct core_t * _core) : memdep_t(core) 21 | { 22 | init(); 23 | name = COMPONENT_NAME; 24 | type = COMPONENT_NAME; 25 | } 26 | /* LOOKUP */ 27 | MEMDEP_LOOKUP_HEADER 28 | { 29 | MEMDEP_STAT(lookups++;) 30 | return (!conflict_exists && !partial_match) || !sta_unknown; 31 | } 32 | }; 33 | 34 | #endif /* MEMDEP_PARSE_ARGS */ 35 | #undef COMPONENT_NAME 36 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-prefetch/prefetch-nextline.cpp: -------------------------------------------------------------------------------- 1 | /* prefetch-nextline.cpp: Simple prefetch the next cacheline based on the physical address. 2 | NOTE: this will cross page boundaries. */ 3 | /* 4 | * __COPYRIGHT__ GT 5 | */ 6 | #define COMPONENT_NAME "nextline" 7 | 8 | #ifdef PREFETCH_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | return std::make_unique(cp); 12 | } 13 | #else 14 | 15 | class prefetch_nextline_t:public prefetch_t 16 | { 17 | public: 18 | /* CREATE */ 19 | prefetch_nextline_t(struct cache_t * arg_cp) 20 | { 21 | init(); 22 | 23 | type = strdup("nextline"); 24 | if(!type) 25 | fatal("couldn't calloc nextline-prefetch type (strdup)"); 26 | 27 | bits = 0; 28 | cp = arg_cp; 29 | } 30 | 31 | /* LOOKUP */ 32 | PREFETCH_LOOKUP_HEADER 33 | { 34 | lookups++; 35 | 36 | /* just return next cache line */ 37 | return (paddr + cp->linesize) & ~(cp->linesize-1); 38 | } 39 | }; 40 | 41 | 42 | #endif /* PREFETCH_PARSE_ARGS */ 43 | #undef COMPONENT_NAME 44 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-ras/ras-perfect.cpp: -------------------------------------------------------------------------------- 1 | /* ras-perfetch.cpp: Oracle return address predictor */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "perfect" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | return std::make_unique(); 12 | } 13 | #else 14 | 15 | class RAS_perfect_t:public RAS_t 16 | { 17 | public: 18 | /* CREATE */ 19 | RAS_perfect_t(void) 20 | { 21 | init(); 22 | 23 | name = "RAS"; 24 | type = COMPONENT_NAME; 25 | } 26 | 27 | /* DESTROY */ 28 | ~RAS_perfect_t() {} 29 | 30 | int get_size(void) 31 | { 32 | return 0; 33 | } 34 | 35 | /* POP */ 36 | RAS_POP_HEADER 37 | { 38 | return oPC; 39 | } 40 | 41 | /* RECOVER */ 42 | RAS_RECOVER_HEADER 43 | { 44 | BPRED_STAT(num_recovers++;) 45 | } 46 | }; 47 | 48 | #endif /* RAS_PARSE_ARGS */ 49 | #undef COMPONENT_NAME 50 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-ras/ras-stack.cpp: -------------------------------------------------------------------------------- 1 | /* ras-stack.cpp: Conventional fixed capacity Return Address Stack predictor */ 2 | /* 3 | * __COPYRIGHT__ GT 4 | */ 5 | 6 | #define COMPONENT_NAME "stack" 7 | 8 | #ifdef BPRED_PARSE_ARGS 9 | if(!strcasecmp(COMPONENT_NAME,type)) 10 | { 11 | int size; 12 | if(sscanf(opt_string,"%*[^:]:%[^:]:%d",name,&size) != 2) 13 | fatal("bad ras options string %s (should be \"stack:name:size\")",opt_string); 14 | return std::make_unique(name,size); 15 | } 16 | #else 17 | 18 | class RAS_stack_t:public RAS_t 19 | { 20 | class RAS_stack_chkpt_t:public RAS_chkpt_t 21 | { 22 | public: 23 | int pos; 24 | }; 25 | 26 | protected: 27 | 28 | md_addr_t *stack; 29 | int size; 30 | int head; 31 | 32 | public: 33 | 34 | /* CREATE */ 35 | RAS_stack_t(char * const arg_name, 36 | const int arg_num_entries 37 | ) 38 | { 39 | init(); 40 | 41 | size = arg_num_entries; 42 | stack = (md_addr_t*) calloc(arg_num_entries,sizeof(md_addr_t)); 43 | if(!stack) 44 | fatal("couldn't malloc stack stack"); 45 | 46 | head = 0; 47 | 48 | name = arg_name; 49 | type = "finite RAS"; 50 | 51 | bits = size*8*sizeof(md_addr_t); 52 | } 53 | 54 | /* DESTROY */ 55 | ~RAS_stack_t() 56 | { 57 | free(stack); stack = NULL; 58 | } 59 | 60 | int get_size(void) 61 | { 62 | return size; 63 | } 64 | 65 | /* PUSH */ 66 | RAS_PUSH_HEADER 67 | { 68 | head = modinc(head,size); //(head + 1) % size; 69 | stack[head] = ftPC; 70 | } 71 | 72 | /* POP */ 73 | RAS_POP_HEADER 74 | { 75 | md_addr_t predPC = stack[head]; 76 | head = moddec(head,size); //(head - 1 + size) % size; 77 | 78 | return predPC; 79 | } 80 | 81 | /* RECOVER */ 82 | RAS_RECOVER_HEADER 83 | { 84 | class RAS_stack_chkpt_t * cp = (class RAS_stack_chkpt_t*) cpvp; 85 | BPRED_STAT(num_recovers++;) 86 | 87 | head = cp->pos; 88 | } 89 | 90 | /* RECOVER INDEX */ 91 | RAS_RECOVER_STATE_HEADER 92 | { 93 | class RAS_stack_chkpt_t * cp = (class RAS_stack_chkpt_t*) cpvp; 94 | cp->pos = head; 95 | } 96 | 97 | /* GET_STATE */ 98 | RAS_GET_STATE_HEADER 99 | { 100 | class RAS_stack_chkpt_t * cp = new RAS_stack_chkpt_t(); 101 | if(!cp) 102 | fatal("couldn't malloc stack recovery state"); 103 | return cp; 104 | } 105 | 106 | /* RET_STATE */ 107 | RAS_RET_STATE_HEADER 108 | { 109 | delete(cpvp); 110 | } 111 | 112 | }; 113 | 114 | #endif /* RAS_PARSE_ARGS */ 115 | #undef COMPONENT_NAME 116 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-repeater/repeater-default.cpp: -------------------------------------------------------------------------------- 1 | /* repeater-default.cpp - Wrapper for default ring cache implementation (librepeater) */ 2 | /* 3 | * Svilen Kanev, 2013 4 | */ 5 | 6 | #include "mem-repeater.h" 7 | 8 | #define COMPONENT_NAME "default" 9 | 10 | #ifdef REPEATER_PARSE_ARGS 11 | if(!strcasecmp(COMPONENT_NAME,type)) 12 | { 13 | auto result = std::unique_ptr(librepeater_create(core, name, next_level)); 14 | result->speed = core->knobs->default_cpu_speed; // Assume repeater runs at core frequency 15 | return result; 16 | } 17 | 18 | #elif defined(REPEATER_INIT) 19 | if(!strcasecmp(COMPONENT_NAME,type)) 20 | { 21 | librepeater_init(opt_string); 22 | return; 23 | } 24 | 25 | #elif defined(REPEATER_SHUTDOWN) 26 | if(!strcasecmp(COMPONENT_NAME,type)) 27 | { 28 | librepeater_shutdown(); 29 | return; 30 | } 31 | 32 | #else 33 | /* repeater_default_t defined in librepeater */ 34 | 35 | #endif 36 | 37 | #undef COMPONENT_NAME 38 | -------------------------------------------------------------------------------- /xiosim/ZCOMPS-repeater/repeater-none.cpp: -------------------------------------------------------------------------------- 1 | /* repeater-none.cpp - Stub for non-existent ring cache */ 2 | /* 3 | * Svilen Kanev, 2013 4 | */ 5 | #define COMPONENT_NAME "none" 6 | 7 | #ifdef REPEATER_PARSE_ARGS 8 | if(!strcasecmp(COMPONENT_NAME,type)) 9 | { 10 | return std::make_unique(core, name, next_level); 11 | } 12 | 13 | #elif defined(REPEATER_INIT) 14 | if(!strcasecmp(COMPONENT_NAME,type)) 15 | { 16 | return; 17 | } 18 | 19 | #elif defined(REPEATER_SHUTDOWN) 20 | if(!strcasecmp(COMPONENT_NAME,type)) 21 | { 22 | return; 23 | } 24 | 25 | #else 26 | 27 | class repeater_none_t: public repeater_t { 28 | public: 29 | repeater_none_t(struct core_t * const _core, const char * const _name, struct cache_t * const _next_level) : 30 | repeater_t (_core, _name, _next_level) 31 | { 32 | // Run at uncore speeds. This is important for correct DFS timing calculations 33 | // in global_step(). 34 | // The real repeater implementation (repeater_default_t) has to run at core 35 | // speeds, so we have to rethink its clock domains if we want DFS to work with it. 36 | speed = uncore_knobs.LLC_speed; 37 | } 38 | virtual void step() { }; 39 | virtual int enqueuable(const enum cache_command cmd, const int asid, const md_addr_t addr) { return true; } 40 | virtual void enqueue(const enum cache_command cmd, 41 | const int asid, 42 | const md_addr_t addr, 43 | void * const op, /* To be passed to callback for identification */ 44 | void (*const cb)(void *, bool is_hit), /* Callback once request is finished */ 45 | seq_t (*const get_action_id)(void* const)) { if (cb) cb(op, true); }; 46 | 47 | virtual void flush(const int asid, void (*const cb)()) { if (cb) cb(); }; 48 | }; 49 | 50 | #endif 51 | 52 | #undef COMPONENT_NAME 53 | -------------------------------------------------------------------------------- /xiosim/ZCORE-power/power-none.cpp: -------------------------------------------------------------------------------- 1 | #ifdef ZESTO_PARSE_ARGS 2 | if(!strcasecmp(power_opt_string,"none")) 3 | return std::make_unique(core); 4 | #else 5 | 6 | class core_power_NONE_t : public core_power_t { 7 | 8 | public: 9 | core_power_NONE_t(struct core_t *_core) : core_power_t(core) { } 10 | ~core_power_NONE_t() {} 11 | 12 | virtual void translate_params(system_core *core_params, system_L2 *L2_params) { } 13 | virtual void translate_stats(xiosim::stats::StatsDatabase* sdb, 14 | system_core* core_stats, 15 | system_L2* L2_stats) {} 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /xiosim/ZPIPE-alloc/alloc-none.cpp: -------------------------------------------------------------------------------- 1 | #ifdef ZESTO_PARSE_ARGS 2 | if(!strcasecmp(alloc_opt_string,"none")) 3 | return std::make_unique(core); 4 | #else 5 | 6 | class core_alloc_NONE_t:public core_alloc_t 7 | { 8 | 9 | public: 10 | 11 | core_alloc_NONE_t(struct core_t * const core) { } 12 | virtual void reg_stats(xiosim::stats::StatsDatabase* sdb) { } 13 | 14 | virtual void step(void) { } 15 | virtual void recover(void) { } 16 | virtual void recover(const struct Mop_t * const Mop) { } 17 | 18 | virtual void RS_deallocate(const struct uop_t * const uop) { } 19 | virtual void start_drain(void) { } /* prevent allocation from proceeding to exec */ 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /xiosim/ZPIPE-decode/decode-none.cpp: -------------------------------------------------------------------------------- 1 | #ifdef ZESTO_PARSE_ARGS 2 | if(!strcasecmp(decode_opt_string,"none")) 3 | return std::make_unique(core); 4 | #else 5 | 6 | class core_decode_NONE_t:public core_decode_t 7 | { 8 | public: 9 | 10 | /* constructor, stats registration */ 11 | core_decode_NONE_t(struct core_t * const core) { } 12 | virtual void reg_stats(xiosim::stats::StatsDatabase* sdb) { } 13 | virtual void update_occupancy(void) { } 14 | 15 | virtual void step(void) { } 16 | virtual void recover(void) { } 17 | virtual void recover(struct Mop_t * const Mop) { } 18 | 19 | /* interface functions for alloc stage */ 20 | virtual bool uop_available(void) { return false; } 21 | virtual struct uop_t * uop_peek(void) { return NULL; } 22 | virtual void uop_consume(void) { } 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /xiosim/ZPIPE-fetch/fetch-none.cpp: -------------------------------------------------------------------------------- 1 | #ifdef ZESTO_PARSE_ARGS 2 | if(!strcasecmp(fetch_opt_string,"none")) 3 | return std::make_unique(core); 4 | #else 5 | 6 | class core_fetch_NONE_t:public core_fetch_t 7 | { 8 | 9 | public: 10 | 11 | /* constructor, stats registration */ 12 | core_fetch_NONE_t(struct core_t * const core) { this->core = core; } 13 | virtual void reg_stats(xiosim::stats::StatsDatabase* sdb) { } 14 | virtual void update_occupancy(void) { } 15 | 16 | /* simulate one cycle */ 17 | virtual void pre_fetch(void) { } 18 | virtual bool do_fetch(void) { 19 | if (core->oracle->is_draining()) 20 | return false; 21 | // Invoke oracle to crack the Mop. 22 | struct Mop_t* Mop = core->oracle->exec(PC); 23 | // Oracle stall (we're looking too far ahead). 24 | if (Mop == nullptr) 25 | return false; 26 | core->oracle->consume(Mop); 27 | PC = Mop->oracle.NextPC; 28 | return false; 29 | } 30 | virtual void post_fetch(void) { } 31 | 32 | /* decode interface */ 33 | virtual bool Mop_available(void) { return false; } 34 | virtual struct Mop_t * Mop_peek(void) { return NULL;} 35 | virtual void Mop_consume(void) { } 36 | 37 | /* enqueue a jeclear event into the jeclear_pipe */ 38 | virtual void jeclear_enqueue(struct Mop_t * const Mop, const md_addr_t New_PC) { } 39 | /* recover the front-end after the recover request actually 40 | reaches the front end. */ 41 | virtual void recover(const md_addr_t new_PC) { } 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /xiosim/boost_statistics.h: -------------------------------------------------------------------------------- 1 | /* Headers needed for statistics library. */ 2 | 3 | #pragma GCC diagnostic push 4 | #pragma GCC diagnostic ignored "-Wunused-local-typedefs" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #pragma GCC diagnostic pop 13 | -------------------------------------------------------------------------------- /xiosim/catch_impl.cpp: -------------------------------------------------------------------------------- 1 | #include "catch.hpp" 2 | -------------------------------------------------------------------------------- /xiosim/components.bzl: -------------------------------------------------------------------------------- 1 | def gen_list(component, dirs, extra_deps=[], extra_srcs=[]): 2 | for dir_ in dirs: 3 | # Generate a filegroup for each cpp in the directory 4 | native.filegroup( 5 | name = "%s" % dir_, 6 | srcs = native.glob( 7 | [ "%s/*.cpp" % dir_], 8 | exclude = [ 9 | "%s/repeater-default.cpp" % dir_, # for now 10 | "%s/MC-dramsim.cpp" % dir_, # for now 11 | ] 12 | ) 13 | ) 14 | 15 | # Generate {DIR}.list.h, which includes each cpp in the directory 16 | native.genrule( 17 | name = "gen-%s-list" % dir_, 18 | srcs = [ ":%s" % dir_ ], 19 | cmd = 'echo -n $(locations :%s) | xargs -d" " -I{} echo \'#include "{}"\' > $@' % dir_, 20 | outs = [ "%s.list.h" % dir_ ], 21 | ) 22 | 23 | hdrs = [ "zesto-%s.h" % component ] 24 | # Add cpp filegroups, se we track them as dependants 25 | # We don't want to add them as srcs, or they'll get compiled individually 26 | for dir_ in dirs: 27 | hdrs += [ ":%s" % dir_ ] 28 | 29 | srcs = [ "zesto-%s.cpp" % component ] 30 | for dir_ in dirs: 31 | srcs += [ "%s.list.h" % dir_ ] 32 | 33 | native.cc_library( 34 | name = "zesto-%s" % component, 35 | hdrs = hdrs, 36 | srcs = srcs + extra_srcs, 37 | deps = [ 38 | ":stats", 39 | ":uarch_headers", 40 | ":x86", 41 | ] + extra_deps, 42 | ) 43 | -------------------------------------------------------------------------------- /xiosim/core-set.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORE_SET__ 2 | #define __CORE_SET__ 3 | 4 | #include "assert.h" 5 | #include 6 | 7 | class CoreSet : public std::set 8 | { 9 | public: 10 | int getPrevCore(int coreId) { 11 | auto curr = this->find(coreId); 12 | assert(curr != this->end()); 13 | curr--; 14 | // This was the first element, start over 15 | if (curr == this->end()) 16 | curr--; 17 | return *curr; 18 | } 19 | 20 | int getNextCore(int coreId) { 21 | auto curr = this->find(coreId); 22 | assert(curr != this->end()); 23 | curr++; 24 | // This was the last element, start over 25 | if (curr == this->end()) 26 | curr = this->begin(); 27 | return *curr; 28 | } 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /xiosim/core_const.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORE_CONST_H__ 2 | #define __CORE_CONST_H__ 3 | 4 | namespace xiosim { 5 | 6 | const int MAX_CORES = 16; 7 | const int INVALID_CORE = -1; 8 | 9 | } // xiosim 10 | 11 | #endif /* __CORE_CONST_H__ */ 12 | -------------------------------------------------------------------------------- /xiosim/decode.h: -------------------------------------------------------------------------------- 1 | #ifndef __DECODE_H__ 2 | #define __DECODE_H__ 3 | 4 | #include 5 | 6 | extern "C" { 7 | #include "xed-interface.h" 8 | } 9 | 10 | struct Mop_t; 11 | struct uop_t; 12 | 13 | namespace xiosim { 14 | namespace x86 { 15 | 16 | const size_t MAX_ILEN = 15; 17 | 18 | void init_decoder(); 19 | void decode(struct Mop_t * Mop); 20 | void decode_flags(struct Mop_t * Mop); 21 | 22 | bool is_trap(const struct Mop_t * Mop); 23 | bool is_ctrl(const struct Mop_t * Mop); 24 | bool is_load(const struct Mop_t * Mop); 25 | bool is_store(const struct Mop_t * Mop); 26 | bool is_nop(const struct Mop_t * Mop); 27 | /* Does Mop execute in FP-like cluster -- x87, SSE, AVX */ 28 | bool is_fp(const struct Mop_t * Mop); 29 | 30 | inline const char * print_uop(const struct uop_t * uop) { return "NYI"; } 31 | 32 | std::string print_Mop(const struct Mop_t * Mop); 33 | 34 | } // xiosim::x86 35 | } // xiosim 36 | 37 | #endif /* __DECODE_H__ */ 38 | -------------------------------------------------------------------------------- /xiosim/expression.h: -------------------------------------------------------------------------------- 1 | #ifndef __EXPRESSION_H__ 2 | #define __EXPRESSION_H__ 3 | 4 | #include 5 | #include 6 | 7 | namespace xiosim { 8 | namespace stats { 9 | 10 | /* All stats get returned as floats. */ 11 | typedef float Result; 12 | 13 | // C++ does not have a standard template operator for exponentiation. 14 | template 15 | class power { 16 | public: 17 | Result operator()(T base, T exp) { 18 | return pow(base, exp); 19 | } 20 | }; 21 | 22 | /* Base interface of an expression tree node. 23 | * 24 | * An equation is broken down into a binary tree of Expression nodes. Calling 25 | * evaluate() on any one of these will recursively evaluate all the nodes below 26 | * it. Leaf nodes are Statistic objects or wrappers around constants, 27 | * and non-leaf nodes represent operations to be performed on 28 | * one or two leaf nodes. 29 | */ 30 | class Expression { 31 | public: 32 | virtual ~Expression() {} 33 | virtual Result evaluate() const = 0; 34 | /* Returns a deep copy of the current expression and all its subexpressions. */ 35 | virtual std::unique_ptr deep_copy() const = 0; 36 | }; 37 | 38 | } // namespace stats 39 | } // namespace xiosim 40 | 41 | #endif /* __EXPRESSION_H__ */ 42 | -------------------------------------------------------------------------------- /xiosim/fu.h: -------------------------------------------------------------------------------- 1 | #ifndef __FU_H__ 2 | #define __FU_H__ 3 | 4 | #include 5 | 6 | /* Forward declaration, zesto-structs.h depends on this file. */ 7 | struct uop_t; 8 | 9 | namespace xiosim { 10 | 11 | /* functional unit classes */ 12 | enum fu_class { 13 | FU_INVALID = -1, 14 | FU_NA = 0, /* inst does not use a functional unit */ 15 | FU_IEU, /* integer ALU */ 16 | FU_JEU, /* jump execution unit */ 17 | FU_IMUL, /* integer multiplier */ 18 | FU_IDIV, /* integer divider */ 19 | FU_SHIFT, /* integer shifter */ 20 | FU_FADD, /* floating point adder */ 21 | FU_FMUL, /* floating point multiplier */ 22 | FU_FDIV, /* floating point divider */ 23 | FU_FCPLX, /* floating point complex (sqrt,transcendentals,...) */ 24 | FU_LD, /* load port/AGU */ 25 | FU_STA, /* store-address port/AGU */ 26 | FU_STD, /* store-data port */ 27 | FU_AGEN, /* AGU used for LEA and int<>float forwarding */ 28 | FU_MAGIC, /* Magic ALU used to model accelerators */ 29 | NUM_FU_CLASSES /* total functional unit classes */ 30 | }; 31 | 32 | std::string fu_name(enum fu_class fu); 33 | 34 | fu_class get_uop_fu(const struct uop_t& uop); 35 | } // xiosim 36 | 37 | #endif /* __FU_H__ */ 38 | -------------------------------------------------------------------------------- /xiosim/helix.h: -------------------------------------------------------------------------------- 1 | #ifndef __HELIX_H__ 2 | #define __HELIX_H__ 3 | 4 | #include "zesto-structs.h" 5 | 6 | // bits 9..0 for the signal id 7 | const unsigned int HELIX_SIGNAL_ID_MASK = 0x3ff; 8 | // bits 14..10 is the first core id 9 | const unsigned int HELIX_SIGNAL_FIRST_CORE_MASK = 0x7c00; 10 | const unsigned int HELIX_SIGNAL_FIRST_CORE_SHIFT = 10; 11 | // bit 15 for light vs. heavy wait 12 | const unsigned int HELIX_LIGHT_WAIT_MASK = 0x8000; 13 | // bit 16 for wait vs. signal 14 | const unsigned int HELIX_WAIT_MASK = 0x10000; 15 | 16 | const unsigned int HELIX_SYNC_SIGNAL_ID = 1020; 17 | const unsigned int HELIX_COLLECT_SIGNAL_ID = 1021; 18 | const unsigned int HELIX_FINISH_SIGNAL_ID = 1022; 19 | 20 | const unsigned int HELIX_FLUSH_SIGNAL_ID = 1023; 21 | const unsigned int HELIX_MAX_SIGNAL_ID = 1023; 22 | 23 | inline bool is_addr_helix_signal(unsigned int addr) 24 | { 25 | return !(addr & HELIX_WAIT_MASK); 26 | } 27 | 28 | inline bool is_uop_helix_signal(const struct uop_t * uop) 29 | { 30 | return (uop->decode.is_sta || uop->decode.is_std) && 31 | uop->oracle.is_sync_op && 32 | is_addr_helix_signal(uop->oracle.virt_addr); 33 | } 34 | 35 | inline unsigned int get_helix_signal_id(unsigned int addr) 36 | { 37 | return (addr & HELIX_SIGNAL_ID_MASK); 38 | } 39 | 40 | inline unsigned int get_helix_signal_first_core(unsigned int addr) 41 | { 42 | return (addr & HELIX_SIGNAL_FIRST_CORE_MASK) >> HELIX_SIGNAL_FIRST_CORE_SHIFT; 43 | } 44 | 45 | inline bool is_helix_signal_collect(unsigned int addr) 46 | { 47 | return (get_helix_signal_id(addr) == HELIX_COLLECT_SIGNAL_ID); 48 | } 49 | 50 | inline bool is_helix_signal_sync(unsigned int addr) 51 | { 52 | return (get_helix_signal_id(addr) == HELIX_SYNC_SIGNAL_ID); 53 | } 54 | 55 | inline bool is_helix_signal_finish(unsigned int addr) 56 | { 57 | return (get_helix_signal_id(addr) == HELIX_FINISH_SIGNAL_ID); 58 | } 59 | 60 | 61 | inline bool is_helix_signal_flush(unsigned int addr) 62 | { 63 | return (get_helix_signal_id(addr) == HELIX_FLUSH_SIGNAL_ID); 64 | } 65 | 66 | inline bool is_helix_wait_light(unsigned int addr) 67 | { 68 | return ((addr & HELIX_LIGHT_WAIT_MASK) == HELIX_LIGHT_WAIT_MASK); 69 | } 70 | 71 | #endif /* __HELIX_H__ */ 72 | -------------------------------------------------------------------------------- /xiosim/host.h: -------------------------------------------------------------------------------- 1 | /* host.h - data-type aliases */ 2 | 3 | #ifndef HOST_H 4 | #define HOST_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /* statistical counter types, use largest counter type available */ 12 | typedef int64_t counter_t; 13 | typedef int64_t tick_t; /* NOTE: unsigned breaks caches */ 14 | const tick_t TICK_T_MAX = std::numeric_limits::max(); 15 | 16 | typedef uint64_t seq_t; 17 | 18 | /* address type definition (depending on build type) */ 19 | #ifdef _LP64 20 | typedef uint64_t md_addr_t; 21 | #else 22 | typedef uint32_t md_addr_t; 23 | #endif 24 | 25 | /* physical address type definition (64-bit) */ 26 | typedef uint64_t md_paddr_t; 27 | 28 | 29 | #endif /* HOST_H */ 30 | -------------------------------------------------------------------------------- /xiosim/libsim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Libsim external API. 3 | * Copyright, Svilen Kanev, 2011 4 | */ 5 | 6 | #ifndef __LIBSIM_H__ 7 | #define __LIBSIM_H__ 8 | 9 | #include 10 | 11 | #include "host.h" 12 | 13 | class handshake_container_t; 14 | 15 | namespace xiosim { 16 | namespace libsim { 17 | 18 | void init(); 19 | void deinit(); 20 | 21 | void simulate_handshake(int coreID, handshake_container_t* handshake); 22 | void simulate_warmup(int asid, md_addr_t addr, bool is_write); 23 | 24 | void activate_core(int coreID); 25 | void deactivate_core(int coreID); 26 | bool is_core_active(int coreID); 27 | 28 | } // xiosim::libsim 29 | } // xiosim 30 | 31 | #endif /*__LIBSIM_H__ */ 32 | -------------------------------------------------------------------------------- /xiosim/misc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/misc.cpp -------------------------------------------------------------------------------- /xiosim/misc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/misc.h -------------------------------------------------------------------------------- /xiosim/misc_test.cpp: -------------------------------------------------------------------------------- 1 | #include "catch.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "misc.h" 8 | 9 | const std::string XIOSIM_PACKAGE_PATH = "xiosim/"; 10 | 11 | TEST_CASE("gzopen", "gz read") { 12 | std::string path = XIOSIM_PACKAGE_PATH + "test_data/gzopen.gz"; 13 | FILE* fd = gzopen(path.c_str(), "r"); 14 | REQUIRE(fd != NULL); 15 | char buff[255]; 16 | char* res = fgets(buff, sizeof(buff), fd); 17 | REQUIRE(res != NULL); 18 | REQUIRE(strncmp(buff, "0xdecafbad\n", sizeof(buff)) == 0); 19 | gzclose(fd); 20 | } 21 | 22 | TEST_CASE("gz overflow", "gz overflow") { 23 | const size_t size = 4 * 1024 * 1024; 24 | char* fname = static_cast(malloc(size)); 25 | memset(fname, 'a', size); 26 | memcpy(fname + size - 4, ".gz", 3); 27 | fname[size - 1] = 0; 28 | FILE* fd = gzopen(fname, "r"); 29 | REQUIRE(fd == NULL); 30 | free(fname); 31 | } 32 | -------------------------------------------------------------------------------- /xiosim/pintool/BufferManager.h: -------------------------------------------------------------------------------- 1 | #ifndef HANDSHAKE_BUFFER_MANAGER 2 | #define HANDSHAKE_BUFFER_MANAGER 3 | 4 | #include 5 | #include 6 | 7 | namespace xiosim { 8 | namespace buffer_management { 9 | /* Handshake buffer interface. The connection between producers of architected 10 | * state (feeders) and consumers (simulated cores). There is a FIFO buffer per 11 | * simulated thread. 12 | 13 | * The overall structure of the buffer is as follows: 14 | * ]-------------] ]-------------------] ]-------------] 15 | * produceBuffer_ fileBuffer consumeBuffer_ 16 | * 17 | 18 | * Feeders write to produceBuffer_ without capturing any locks, 19 | * and conusmers read from consumeBuffers_ without synchronization either. 20 | * When producerBuffer_ gets full, we dump to one entry in fileBuffer, 21 | * which usually lives in /dev/shm. When consumeBuffer_ is empty, it 22 | * waits until an entry in fileBuffer shows up. 23 | */ 24 | 25 | /* Pushing and popping fileBuffer: */ 26 | /* On the producer side, once we have written a fileBuffer entry, make 27 | * it visible to the consumer. */ 28 | extern void NotifyProduced(pid_t tid, std::string filename, size_t n_items); 29 | /* On the consumer side, wait until a file in fileBuffer shows up. 30 | * The thread will sleep on a cv while fileBuffer is empty. 31 | * Returns the filename and number of handshakes to read from the file. */ 32 | extern std::pair WaitForFile(pid_t tid); 33 | /* On the consumer side, notify that we've read @n_items from the head 34 | * of fileBuffer. 35 | * XXX: If thead contention becomes an issue, we can fold this in WaitForFile. */ 36 | extern void NotifyConsumed(pid_t tid, size_t n_items); 37 | 38 | /* Init the shared memory structures. */ 39 | extern void InitBufferManager(pid_t harness_pid); 40 | /* Nada. */ 41 | extern void DeinitBufferManager(); 42 | /* Allocate fileBuffer for a new program thread. */ 43 | extern int AllocateThread(pid_t tid); 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /xiosim/pintool/BufferManagerConsumer.h: -------------------------------------------------------------------------------- 1 | #ifndef __BUFFER_MANAGER_CONSUMER__ 2 | #define __BUFFER_MANAGER_CONSUMER__ 3 | 4 | #include "handshake_container.h" 5 | 6 | namespace xiosim { 7 | namespace buffer_management { 8 | /* Pushing and popping consumeBuffer_: */ 9 | /* Get the number of etnries in consumeBuffer_, so we can process them in bulk. */ 10 | extern int GetConsumerSize(pid_t tid); 11 | /* Get the head of consumeBuffer_. If empty, it will reach out to fileBuffer_, 12 | * where the thread can wait until an entry becomes available. */ 13 | extern handshake_container_t* Front(pid_t tid); 14 | /* Invalidate the head of conusmeBuffer_. Move on to the next entry. */ 15 | extern void Pop(pid_t tid); 16 | 17 | /* Init consumeBuffer_ structures. */ 18 | extern void InitBufferManagerConsumer(pid_t harness_pid); 19 | /* Cleanup. */ 20 | extern void DeinitBufferManagerConsumer(); 21 | /* Allocate consumeBuffer_ for a new program thread. */ 22 | extern void AllocateThreadConsumer(pid_t tid, int buffer_capacity); 23 | } 24 | } 25 | 26 | #endif /* __BUFFER_MANAGER_CONSUMER__ */ 27 | -------------------------------------------------------------------------------- /xiosim/pintool/BufferManagerProducer.h: -------------------------------------------------------------------------------- 1 | #ifndef __BUFFER_MANAGER_PRODUCER__ 2 | #define __BUFFER_MANAGER_PRODUCER__ 3 | 4 | #include 5 | 6 | #include "BufferManager.h" 7 | #include "handshake_container.h" 8 | 9 | namespace xiosim { 10 | namespace buffer_management { 11 | 12 | /* Pushing and popping produceBuffer_: */ 13 | /* The two steps of a push -- get a buffer, do magic with 14 | * it, and call ProducerDone once it can be consumed / flushed. 15 | * GetBuffer() returns the first buffer that doesn't have its valid 16 | * bit set -- either the same as Back(), or a new one, if Back() is 17 | * already done/valid. */ 18 | handshake_container_t* GetBuffer(pid_t tid); 19 | /* By assumption, we call ProducerDone() once we have a completely 20 | * instrumented, valid handshake, so that we don't need to handle 21 | * intermediate cases. 22 | * If produceBuffer_ becomes full, we will flush it out to fileBuffer_. */ 23 | void ProducerDone(pid_t tid, bool keepLock = false); 24 | /* Get a pointer to the last element of produceBuffer_. */ 25 | handshake_container_t* Back(pid_t tid); 26 | 27 | /* Flush everything in produceBuffer_ to fileBuffer_ so it can 28 | * be consumed straight away. */ 29 | void FlushBuffers(pid_t tid); 30 | 31 | /* Any elements in the current produceBuffer_? */ 32 | bool ProducerEmpty(pid_t tid); 33 | 34 | /* Init producerBuffer_ structures. */ 35 | void InitBufferManagerProducer(pid_t harness_pid, bool skip_space_check, std::string bridge_dirs); 36 | /* Cleanup. */ 37 | void DeinitBufferManagerProducer(void); 38 | /* Allocate produceBuffer_ for a new program thread. */ 39 | void AllocateThreadProducer(pid_t tid); 40 | } 41 | } 42 | 43 | #endif /* __BUFFER_MANAGER_PRODUCER__ */ 44 | -------------------------------------------------------------------------------- /xiosim/pintool/base_allocator.cpp: -------------------------------------------------------------------------------- 1 | /* Implementation of common interface functions for core allocators. 2 | * 3 | * Author: Sam Xi 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #include "xiosim/synchronization.h" 10 | 11 | #include "multiprocess_shared.h" 12 | #include "speedup_models.h" 13 | 14 | #include "base_allocator.h" 15 | 16 | namespace xiosim { 17 | 18 | BaseAllocator::BaseAllocator(OptimizationTarget target, 19 | SpeedupModelType speedup_model_type, 20 | double core_power, 21 | double uncore_power, 22 | int ncores) { 23 | num_cores = ncores; 24 | switch (speedup_model_type) { 25 | case SpeedupModelType::LINEAR: 26 | speedup_model = new LinearSpeedupModel(core_power, uncore_power, num_cores, target); 27 | break; 28 | case SpeedupModelType::LOGARITHMIC: 29 | speedup_model = new LogSpeedupModel(core_power, uncore_power, num_cores, target); 30 | break; 31 | } 32 | } 33 | 34 | void BaseAllocator::ResetState() { core_allocs.clear(); } 35 | 36 | BaseAllocator::~BaseAllocator() { delete speedup_model; } 37 | 38 | void BaseAllocator::DeallocateCoresForProcess(int asid) { 39 | lk_lock(&allocator_lock, 1); 40 | if (core_allocs.find(asid) != core_allocs.end()) 41 | core_allocs[asid] = 1; 42 | lk_unlock(&allocator_lock); 43 | } 44 | 45 | int BaseAllocator::get_cores_for_asid(int asid) { 46 | int res = 0; 47 | lk_lock(&allocator_lock, 1); 48 | if (core_allocs.find(asid) != core_allocs.end()) 49 | res = core_allocs[asid]; 50 | lk_unlock(&allocator_lock); 51 | return res; 52 | } 53 | 54 | void BaseAllocator::UpdateSHMAllocation(int asid, int allocated_cores) const { 55 | UpdateProcessCoreAllocation(asid, allocated_cores); 56 | } 57 | 58 | std::vector BaseAllocator::get_processes_to_unblock(int asid) { 59 | lk_lock(&allocator_lock, 1); 60 | auto it = processes_to_unblock.find(asid); 61 | if (it != processes_to_unblock.end()) { 62 | lk_unlock(&allocator_lock); 63 | return it->second; 64 | } 65 | lk_unlock(&allocator_lock); 66 | return std::vector(); 67 | } 68 | 69 | } // namespace xiosim 70 | -------------------------------------------------------------------------------- /xiosim/pintool/boost_interprocess.h: -------------------------------------------------------------------------------- 1 | /* Headers needed for multiprocess communication through boost interprocess. */ 2 | 3 | #pragma GCC diagnostic push 4 | #pragma GCC diagnostic ignored "-Wnarrowing" 5 | #pragma GCC diagnostic ignored "-Wunused-local-typedefs" 6 | #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 7 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #pragma GCC diagnostic pop 26 | 27 | #include "shared_map.h" 28 | #include "shared_unordered_map.h" 29 | -------------------------------------------------------------------------------- /xiosim/pintool/buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef BUF_FER_H 2 | #define BUF_FER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* Buffer is a pre-allocated circular queue. 9 | * T must be default-constructible, and have a void Invalidate(void) method. */ 10 | template 11 | class Buffer { 12 | public: 13 | Buffer(int size) 14 | : numPool_(size) 15 | , pool_(new T[numPool_]) 16 | , head_(0) 17 | , tail_(0) 18 | , size_(0) {} 19 | 20 | // Push is split in two phases: (i) a non-destructive get_buffer(), 21 | // which returns a pointer to an internal storage element and (ii) 22 | // push_done(), which markes the element as unavailable and occupying 23 | // space. 24 | T* get_buffer() { 25 | assert(!full()); 26 | return &(pool_[head_]); 27 | } 28 | 29 | void push_done() { 30 | assert(!full()); 31 | 32 | head_++; 33 | if (head_ == numPool_) { 34 | head_ = 0; 35 | } 36 | size_++; 37 | assert(size_ <= numPool_); 38 | } 39 | 40 | void pop() { 41 | T* head = front(); 42 | head->Invalidate(); 43 | 44 | tail_++; 45 | if (tail_ == numPool_) { 46 | tail_ = 0; 47 | } 48 | size_--; 49 | } 50 | 51 | void pop_back() { 52 | T* head = back(); 53 | head->Invalidate(); 54 | 55 | head_--; 56 | if (head_ == -1) { 57 | head_ = numPool_ - 1; 58 | } 59 | size_--; 60 | } 61 | 62 | T* front() { 63 | assert(size_ > 0); 64 | return &(pool_[tail_]); 65 | } 66 | 67 | T* back() { 68 | assert(size_ > 0); 69 | 70 | int dex = (head_ - 1); 71 | if (dex == -1) { 72 | dex = numPool_ - 1; 73 | } 74 | return &(pool_[dex]); 75 | } 76 | 77 | // [0] corresponds to front(), [size_ - 1] to back() 78 | // does not bounds check 79 | T* get_item(int index) { 80 | int dex = (tail_ + index); 81 | if (dex >= numPool_) 82 | dex -= numPool_; 83 | return &(pool_[dex]); 84 | } 85 | T* operator[](int index) { return get_item(index); } 86 | 87 | bool empty() const { return size_ == 0; } 88 | bool full() const { return size_ == numPool_; } 89 | 90 | int size() const { return size_; } 91 | int capacity() const { return numPool_; } 92 | 93 | private: 94 | int numPool_; 95 | std::unique_ptr pool_; 96 | int head_; 97 | int tail_; 98 | 99 | int size_; 100 | }; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /xiosim/pintool/gang_allocator.cpp: -------------------------------------------------------------------------------- 1 | #include "allocators_impl.h" 2 | 3 | namespace xiosim { 4 | 5 | GangAllocator::GangAllocator(OptimizationTarget opt_target, 6 | SpeedupModelType speedup_model, 7 | double core_power, 8 | double uncore_power, 9 | int num_cores) 10 | : BaseAllocator(opt_target, speedup_model, core_power, uncore_power, num_cores) {} 11 | 12 | GangAllocator::~GangAllocator() {} 13 | 14 | int GangAllocator::AllocateCoresForProcess(int asid, 15 | std::vector scaling, 16 | double serial_runtime) { 17 | (void)scaling; 18 | (void)asid; 19 | 20 | lk_lock(&allocator_lock, 1); 21 | core_allocs[asid] = num_cores; 22 | std::vector unblock_list; 23 | unblock_list.push_back(asid); 24 | processes_to_unblock[asid] = unblock_list; 25 | lk_unlock(&allocator_lock); 26 | 27 | UpdateSHMAllocation(asid, num_cores); 28 | return num_cores; 29 | } 30 | 31 | } // namespace xiosim 32 | -------------------------------------------------------------------------------- /xiosim/pintool/ignore_ins.h: -------------------------------------------------------------------------------- 1 | #ifndef __IGNORE_INS__ 2 | #define __IGNORE_INS__ 3 | 4 | #include 5 | 6 | #include "feeder.h" 7 | 8 | /* Ignore calls and @num_insn (including the call) to the routine at @addr. 9 | * Looks for @num_insn-1 stack writes. 10 | * if @replacement_pc != -1, it is used to properly set NPC for the last 11 | * non-ignored instruction in case the routine is replaced in analysis. 12 | * XXX: We only ignore direct calls. 13 | */ 14 | VOID IgnoreCallsTo(ADDRINT addr, UINT32 num_insn, ADDRINT replacement_pc); 15 | 16 | /* Ignore instances of instruction at address @pc. Will set the NPC to the 17 | * fallthrough, so be careful if you ignore things like often taken branches 18 | */ 19 | VOID IgnorePC(ADDRINT pc); 20 | 21 | /* Add the absolute addresses of ignored instructions. If the PCs are specified 22 | * through symbols and offsets, then resolve the absolute address. 23 | */ 24 | VOID AddIgnoredInstructionPCs(IMG img, std::vector& ignored_pcs); 25 | 26 | /* Used at analysis time to properly set NPCs of instructions, taking into 27 | * account ignored ones. 28 | */ 29 | ADDRINT NextUnignoredPC(ADDRINT pc); 30 | 31 | /* Trace-level instrumentation that looks for calls to ignored routines and 32 | * sets up the static instructions to ignore. 33 | */ 34 | VOID InstrumentInsIgnoring(TRACE trace, VOID* v); 35 | 36 | /* At analysis time, check whether the instruction at @pc should be ignored. 37 | */ 38 | bool IsInstructionIgnored(ADDRINT pc); 39 | 40 | 41 | extern KNOB KnobIgnorePCs; 42 | 43 | #endif /* __IGNORE_INS__ */ 44 | -------------------------------------------------------------------------------- /xiosim/pintool/ildjit.h: -------------------------------------------------------------------------------- 1 | #ifndef __MOLECOOL_PIN__ 2 | #define __MOLECOOL_PIN__ 3 | 4 | /* 5 | * ILDJIT-specific functions for zesto feeder 6 | * Copyright, Svilen Kanev, 2012 7 | */ 8 | 9 | VOID MOLECOOL_Init(); 10 | VOID AddILDJITCallbacks(IMG img); 11 | BOOL ILDJIT_IsExecuting(); 12 | BOOL ILDJIT_IsCreatingExecutor(); 13 | BOOL ILDJIT_GetExecutingTID(); 14 | BOOL ILDJIT_IsDoneFastForwarding(); 15 | 16 | VOID printMemoryUsage(THREADID tid); 17 | /* Insert additional fake instructions to end the loop properly (flush RC, etc.). */ 18 | VOID InsertHELIXPauseCode(THREADID tid, bool first_thread); 19 | 20 | class loop_state_t { 21 | public: 22 | int simmed_iteration_count; 23 | bool use_ring_cache; 24 | ADDRINT current_loop; 25 | UINT32 invocationCount; 26 | UINT32 iterationCount; 27 | }; 28 | 29 | #endif /* __MOLECOOL_PIN__ */ 30 | -------------------------------------------------------------------------------- /xiosim/pintool/ipc_queues.cpp: -------------------------------------------------------------------------------- 1 | #include "ipc_queues.h" 2 | 3 | SHARED_VAR_DEFINE(MessageQueue, ipcMessageQueue) 4 | SHARED_VAR_DEFINE(MessageQueue, ipcEarlyMessageQueue) 5 | SHARED_VAR_DEFINE(AckMessageMap, ackMessages) 6 | SHARED_VAR_DEFINE(XIOSIM_LOCK, lk_ipcMessageQueue) 7 | 8 | static ipc_message_allocator_t* ipc_queue_allocator; 9 | 10 | void InitIPCQueues(void) { 11 | ipc_queue_allocator = new ipc_message_allocator_t(global_shm->get_segment_manager()); 12 | 13 | SHARED_VAR_INIT(MessageQueue, ipcMessageQueue, *ipc_queue_allocator); 14 | SHARED_VAR_INIT(MessageQueue, ipcEarlyMessageQueue, *ipc_queue_allocator); 15 | SHARED_VAR_INIT(XIOSIM_LOCK, lk_ipcMessageQueue); 16 | 17 | SHARED_VAR_CONSTRUCT(AckMessageMap, ackMessages); 18 | } 19 | 20 | void DeinitIPCQueues(void) { 21 | delete ipc_queue_allocator; 22 | } 23 | 24 | void SendIPCMessage(ipc_message_t msg, bool blocking) { 25 | MessageQueue* q = msg.ConsumableEarly() ? ipcEarlyMessageQueue : ipcMessageQueue; 26 | msg.blocking = blocking; 27 | 28 | #ifdef IPC_DEBUG 29 | lk_lock(printing_lock, 1); 30 | std::cerr << "[SEND] IPC message, ID: " << msg.id << std::endl; 31 | lk_unlock(printing_lock); 32 | #endif 33 | 34 | lk_lock(lk_ipcMessageQueue, 1); 35 | q->push_back(msg); 36 | 37 | if (blocking) 38 | ackMessages->operator[](msg) = false; 39 | lk_unlock(lk_ipcMessageQueue); 40 | 41 | if (blocking) { 42 | lk_lock(lk_ipcMessageQueue, 1); 43 | while (ackMessages->at(msg) == false) { 44 | lk_unlock(lk_ipcMessageQueue); 45 | xio_sleep(10); 46 | lk_lock(lk_ipcMessageQueue, 1); 47 | } 48 | lk_unlock(lk_ipcMessageQueue); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /xiosim/pintool/linreg.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | file linreg.cpp 3 | */ 4 | #include 5 | #include 6 | #include "linreg.h" 7 | 8 | LinearRegression::LinearRegression(Point2D* p, long size) { 9 | long i; 10 | a = b = sumX = sumY = sumXsquared = sumYsquared = sumXY = 0.0; 11 | n = 0L; 12 | 13 | if (size > 0L) // if size greater than zero there are data arrays 14 | for (n = 0, i = 0L; i < size; i++) 15 | addPoint(p[i]); 16 | } 17 | 18 | LinearRegression::LinearRegression(double* x, double* y, long size) { 19 | long i; 20 | a = b = sumX = sumY = sumXsquared = sumYsquared = sumXY = 0.0; 21 | n = 0L; 22 | 23 | if (size > 0L) // if size greater than zero there are data arrays 24 | for (n = 0, i = 0L; i < size; i++) 25 | addXY(x[i], y[i]); 26 | } 27 | 28 | void LinearRegression::addXY(const double& x, const double& y) { 29 | n++; 30 | sumX += x; 31 | sumY += y; 32 | sumXsquared += x * x; 33 | sumYsquared += y * y; 34 | sumXY += x * y; 35 | Calculate(); 36 | } 37 | 38 | void LinearRegression::Calculate() { 39 | if (haveData()) { 40 | if (fabs(double(n) * sumXsquared - sumX * sumX) > DBL_EPSILON) { 41 | b = (double(n) * sumXY - sumY * sumX) / (double(n) * sumXsquared - sumX * sumX); 42 | a = (sumY - b * sumX) / double(n); 43 | 44 | double sx = b * (sumXY - sumX * sumY / double(n)); 45 | double sy2 = sumYsquared - sumY * sumY / double(n); 46 | double sy = sy2 - sx; 47 | coefD = sx / sy2; 48 | coefC = sqrt(coefD); 49 | stdError = sqrt(sy / double(n - 2)); 50 | } else { 51 | a = b = coefD = coefC = stdError = 0.0; 52 | } 53 | } 54 | } 55 | 56 | void LinearRegressionIntercept::Calculate() { 57 | if (haveData()) { 58 | if (fabs(double(n) * sumXsquared - sumX * sumX) > DBL_EPSILON) { 59 | b = (sumXY - sumX) / sumXsquared; 60 | a = 1.0; 61 | 62 | double sx = b * (sumXY - sumX * sumY / double(n)); 63 | double sy2 = sumYsquared - sumY * sumY / double(n); 64 | double sy = sy2 - sx; 65 | coefD = sx / sy2; 66 | coefC = sqrt(coefD); 67 | stdError = sqrt(sy / double(n - 2)); 68 | } else { 69 | a = b = coefD = coefC = stdError = 0.0; 70 | } 71 | } 72 | } 73 | 74 | std::ostream& operator<<(std::ostream& out, LinearRegression& lr) { 75 | if (lr.haveData()) 76 | out << "f(x) = " << lr.getA() << " + ( " << lr.getB() << " * x )"; 77 | return out; 78 | } 79 | -------------------------------------------------------------------------------- /xiosim/pintool/mpkeys.h: -------------------------------------------------------------------------------- 1 | // Keys for locating variables in shared memory via the boost interprocess 2 | // module. Used for multiprogramming support in XIOSim. 3 | // 4 | // Author: Sam Xi 5 | 6 | #ifndef MP_KEYS_H 7 | #define MP_KEYS_H 8 | 9 | #include 10 | 11 | namespace xiosim { 12 | namespace shared { 13 | 14 | // Global shared memory key names. 15 | extern const char* XIOSIM_SHARED_MEMORY_KEY; 16 | extern const char* XIOSIM_INIT_SHARED_LOCK; 17 | extern const char* XIOSIM_INIT_COUNTER_KEY; 18 | 19 | // Shared memory default sizes 20 | extern const std::size_t DEFAULT_SHARED_MEMORY_SIZE; 21 | 22 | } // namespace shared 23 | } // namespace xiosim 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /xiosim/pintool/mpkeys_impl.cpp: -------------------------------------------------------------------------------- 1 | #include "mpkeys.h" 2 | 3 | namespace xiosim { 4 | namespace shared { 5 | 6 | const char* XIOSIM_SHARED_MEMORY_KEY = "xiosim_shared_memory"; 7 | const char* XIOSIM_INIT_SHARED_LOCK = "xiosim_init_shared_lock"; 8 | const char* XIOSIM_INIT_COUNTER_KEY = "xiosim_init_counter"; 9 | 10 | // Shared memory default sizes 11 | const size_t DEFAULT_SHARED_MEMORY_SIZE = 10 * 1024 * 1024; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /xiosim/pintool/optimization_targets.h: -------------------------------------------------------------------------------- 1 | /* Different core allocation functions for different optimization targets. 2 | * Currently, we support optimizing for throughput and energy. 3 | * 4 | * Author: Sam Xi 5 | */ 6 | 7 | namespace xiosim { 8 | 9 | /* Searches for the core allocation that provides the most system throughput 10 | * across n processes. 11 | * 12 | * Arguments: 13 | * core_allocs: Map of address space ids (asids), or process identifiers, to 14 | * the number of cores it is allocated. 15 | * scaling: Vector of doubles containing scaling data vs. cores. 16 | * num_cores: total number of cores in the system. 17 | * TODO: Why do we need num_cores? We should just use scaling.length. 18 | */ 19 | void OptimizeThroughput(std::map& core_allocs, 20 | std::vector*> process_scaling, 21 | int num_cores); 22 | 23 | void OptimizeEnergyForLinearScaling(std::map& core_allocs, 24 | std::vector& process_linear_scaling, 25 | std::vector& process_serial_runtime, 26 | int num_cores); 27 | 28 | } // namespace xiosim 29 | -------------------------------------------------------------------------------- /xiosim/pintool/paravirt.h: -------------------------------------------------------------------------------- 1 | #ifndef __FEEDER_PARAVIRT__ 2 | #define __FEEDER_PARAVIRT__ 3 | 4 | /* Utilities to virtualize timing system calls. 5 | * So we can lie to the application and return simulated time instead of 6 | * elapsed on the simulation host. 7 | */ 8 | 9 | #include "feeder.h" 10 | 11 | VOID InstrumentParavirt(TRACE trace, VOID* v); 12 | 13 | /* Hook for the entrypoint of gettimeofday(). 14 | * Called either at the syscall site or when entering the VDSO version. */ 15 | void BeforeGettimeofday(THREADID tid, ADDRINT arg1); 16 | 17 | /* Hook for the exit point of gettimeofday(). Actually modifies the returned value. 18 | * Called either at the syscall return, or the ret instruction of the VDSO version. */ 19 | void AfterGettimeofday(THREADID tid, ADDRINT retval); 20 | 21 | #endif /* __FEEDER_PARAVIRT__ */ 22 | -------------------------------------------------------------------------------- /xiosim/pintool/parse_speedup.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARSE_SPEEDUP_H__ 2 | #define __PARSE_SPEEDUP_H__ 3 | /* Related to reading IR model speedup predictions. */ 4 | 5 | #include 6 | #include 7 | 8 | // Describes loop scaling behavior in terms of its scaling across cores and its 9 | // serial runtime. 10 | struct loop_data { 11 | double* speedup; 12 | double serial_runtime; // This is an ESTIMATE. 13 | double serial_runtime_variance; 14 | }; 15 | 16 | /* Parses a comma separated value file that contains predicted speedups for 17 | * each loop when run on 2, 4, 8, and 16 cores, as well as the mean serial 18 | * runtime and variance over all invocations. Stores this data in a map. 19 | */ 20 | void LoadHelixSpeedupModelData(const std::string filepath); 21 | 22 | /* Returns parsed scaling data for a cerain loop. */ 23 | std::vector GetHelixLoopScaling(const std::string& loop_name); 24 | 25 | /* Returns the full loop scaling attributes of a loop: core scaling, serial 26 | * runtime, and serial runtime variance across invocations. 27 | */ 28 | loop_data* GetHelixFullLoopData(const std::string& loop_name); 29 | 30 | #endif /* __PARSE_SPEEDUP_H__ */ 31 | -------------------------------------------------------------------------------- /xiosim/pintool/profiling.h: -------------------------------------------------------------------------------- 1 | #ifndef __FEEDER_PROFILING_H__ 2 | #define __FEEDER_PROFILING_H__ 3 | 4 | /* Add profiling routines for @img. */ 5 | void AddProfilingCallbacks(IMG img); 6 | 7 | #endif /* __FEEDER_PROFILING_H__ */ 8 | -------------------------------------------------------------------------------- /xiosim/pintool/replace_function.h: -------------------------------------------------------------------------------- 1 | #ifndef __REPLACE_FUNCTION__ 2 | #define __REPLACE_FUNCTION__ 3 | 4 | #include 5 | #include 6 | 7 | #include "feeder.h" 8 | #include "handshake_container.h" 9 | 10 | /* Replace @function_name with the xed-encoded instructions supplied in @replacement. 11 | * @num_params is used to ignore the stack-pushing instructions before the actual 12 | * calls to @function_name that setup parameters (they will be ignored *after* the 13 | * first call). 14 | * The instructions inserted instead of @function_name will have flags.real == false, 15 | * so that the timing simulator can treat them differently, if it sp choses. 16 | * 17 | * Here's a sample use-case that replaces a function with just one nop: 18 | xed_encoder_instruction_t nop; 19 | xed_inst0(&nop, dstate, XED_ICLASS_NOP, 0); 20 | list insts = {nop}; 21 | AddReplacement("fib_repl", 1, insts); 22 | 23 | * TODO(skanev): This is abstracted from the helix use-case in ildjit.cpp. 24 | * Port the helix case to actually use this API. 25 | */ 26 | 27 | void AddReplacement(std::string function_name, 28 | size_t num_params, 29 | std::list replacement); 30 | 31 | /* Default case for AddReplacement that simply replaces @function_name and 32 | * 0 parameters with a single nop. Useful for testing. */ 33 | void IgnoreFunction(std::string function_name); 34 | extern KNOB KnobIgnoreFunctions; 35 | 36 | #endif /* __REPLACE_FUNCTION__ */ 37 | -------------------------------------------------------------------------------- /xiosim/pintool/roi.h: -------------------------------------------------------------------------------- 1 | #ifndef __FEEDER_ROI__ 2 | #define __FEEDER_ROI__ 3 | 4 | /* Check whether ROI support is needed. */ 5 | extern KNOB KnobROI; 6 | 7 | /* Add instrumentation looking for ROI callbacks. 8 | * Will look for xiosim_roi_begin and xiosim_roi_end calls in 9 | * the simulated application to deliniate the region-of-interest. 10 | */ 11 | void AddROICallbacks(IMG img); 12 | 13 | #endif /* __FEEDER_ROI__ */ 14 | -------------------------------------------------------------------------------- /xiosim/pintool/scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Scheduling interface between app threads and cores 3 | * Copyright, Svilen Kanev, 2013 4 | */ 5 | 6 | #ifndef __SCHEDULER_H__ 7 | #define __SCHEDULER_H__ 8 | 9 | namespace xiosim { 10 | 11 | const pid_t INVALID_THREADID = -1; 12 | 13 | void InitScheduler(int num_cores); 14 | 15 | /* Notify the scheduler a new thread is created. 16 | * It will be immediately marked for scheduling on a core. 17 | * Returns the scheduled coreID, or INVALID_CORE. 18 | */ 19 | int ScheduleNewThread(pid_t tid, bool check_reschedule = true); 20 | 21 | void ScheduleProcessThreads(int asid, std::list threads); 22 | 23 | /* Notify the scheduler that thread @tid will only 24 | * run on core @coreID. 25 | */ 26 | void SetThreadAffinity(pid_t tid, int coreID); 27 | 28 | /* Get the current running thread on core @coreID. 29 | * returns INVALID_THREADID if core is not active. 30 | */ 31 | pid_t GetCoreThread(int coreID); 32 | 33 | /* Remove a thread from the scheduler once it exits, 34 | * and we are done simulating it. This will free the 35 | * thread state and deactivate the core, if needed. 36 | */ 37 | void DescheduleActiveThread(int coreID); 38 | 39 | /* Let another thread (if any) scheduled on core 40 | * @coreID take over. 41 | * Assumes it is only called from the core sim thread */ 42 | void GiveUpCore(int coreID, bool reschedule_thread); 43 | 44 | /* A check whether anything is running on core 45 | * @coreID. This serves the same purpose as is_core_active(), 46 | * but is thread-safe and can be called from any thread. 47 | */ 48 | bool IsCoreBusy(int coreID); 49 | 50 | /* Ask scheduler if it's time give up core @coreID. 51 | * Assumes it is only called from the core sim thread 52 | */ 53 | bool NeedsReschedule(int coreID); 54 | 55 | /* Have thread @tid, currently running on @coreID, give the 56 | * core up, and block until thread @blocked_on exits. */ 57 | void BlockThread(int coreID, pid_t tid, pid_t blocked_on); 58 | 59 | /* Remove thread @tid from the head of the queue at @coreID, 60 | * and reschedule it (potentially on a different core). 61 | * Different from GiveUpCore(@tid, true), which will always reschedule on the same core */ 62 | void MigrateThread(pid_t tid, int coreID); 63 | 64 | } // namespace xiosim 65 | 66 | #endif /* __SCHEDULER_H__ */ 67 | -------------------------------------------------------------------------------- /xiosim/pintool/speculation.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPECULATION_H__ 2 | #define __SPECULATION_H__ 3 | 4 | #include "pin.H" 5 | 6 | /* This speculative process is done producing handshakes. Exits. 7 | * This can (and should) be called from various places in the feeder 8 | * (e.g. syscalls), where continuing on the speculative path would cause 9 | * irreversible global state changes. 10 | */ 11 | void FinishSpeculation(thread_state_t* tstate); 12 | 13 | /* Add speculation-specific instrumentation. */ 14 | VOID InstrumentSpeculation(INS ins, VOID* v); 15 | 16 | /* Is this a throwaway process on a speculative execution path. */ 17 | extern bool speculation_mode; 18 | 19 | #endif /* __SPECULATION_H__ */ 20 | -------------------------------------------------------------------------------- /xiosim/pintool/sync_pthreads.h: -------------------------------------------------------------------------------- 1 | #ifndef __FEEDER_SYNC_PTHREADS__ 2 | #define __FEEDER_SYNC_PTHREADS__ 3 | 4 | extern KNOB KnobPthreads; 5 | 6 | extern VOID AddPthreadsCallbacks(IMG img); 7 | 8 | #endif /* __FEEDER_SYNC_PTHREADS__ */ 9 | -------------------------------------------------------------------------------- /xiosim/pintool/syscall_handling.h: -------------------------------------------------------------------------------- 1 | extern XIOSIM_LOCK syscall_lock; 2 | 3 | VOID InitSyscallHandling(); 4 | -------------------------------------------------------------------------------- /xiosim/pintool/test_data/loop_speedup_data.csv: -------------------------------------------------------------------------------- 1 | // These are for unit testing. Do not change without changing the unit tests 2 | // too. Speedup numbers are absolute speedups over single core execution. 3 | // Format: , <2 core speedup>, <4>, <8>, <16>, , 4 | // . 5 | loop_1,0.9,1.6,2.19,2.39,1111,0.111 6 | loop_2,0.6,1.1,1.4,1.65,22222,0.5 7 | loop_3,0.8,1.4,1.7,1.8,33333,1 8 | "a weird, weird loop name and speedup. $#$",1.5,1.5,1.5,1.5,5555555555,0.9 9 | art_loop_1,1.58,2.75,3.73,6.58,1.5,0.1 10 | art_loop_2,1.99,3.99,7.99,15.99,2.01,0.2 11 | art_loop_3,1.99,3.33,4.99,9.99,1.75,0.15 12 | -------------------------------------------------------------------------------- /xiosim/pintool/test_handshake_serialization.cpp: -------------------------------------------------------------------------------- 1 | #include "catch.hpp" 2 | //#define SERIAlIZATION_DEBUG 3 | #include "handshake_container.h" 4 | 5 | struct test_context { 6 | handshake_container_t producer_handshake; 7 | handshake_container_t consumer_handshake; 8 | static const size_t buffer_size = 4096; 9 | char buffer[buffer_size]; 10 | 11 | void perform_serialization() { 12 | memset(buffer, 0, buffer_size); 13 | 14 | producer_handshake.Serialize(buffer, buffer_size); 15 | 16 | size_t bytes_written; 17 | memcpy(&bytes_written, buffer, sizeof(size_t)); 18 | bytes_written -= sizeof(size_t); 19 | 20 | consumer_handshake.Deserialize(buffer + sizeof(size_t), bytes_written); 21 | 22 | REQUIRE(producer_handshake == consumer_handshake); 23 | } 24 | }; 25 | 26 | TEST_CASE("Serialize-deserialize test", "handshakes") { 27 | test_context ctxt; 28 | 29 | SECTION("Empty") { ctxt.perform_serialization(); } 30 | 31 | SECTION("PCs") { 32 | auto& start = ctxt.producer_handshake; 33 | start.pc = 0xdeadbeef; 34 | start.npc = 0xfeedface; 35 | start.tpc = 0xdecafbad; 36 | start.rSP = 0x12345678; 37 | 38 | ctxt.perform_serialization(); 39 | } 40 | 41 | SECTION("Memory") { 42 | auto& start = ctxt.producer_handshake; 43 | start.mem_buffer.push_back(std::make_pair(0xdeadbeef, 4)); 44 | start.mem_buffer.push_back(std::make_pair(0xfeedface, 4)); 45 | 46 | ctxt.perform_serialization(); 47 | } 48 | 49 | SECTION("Flags") { 50 | auto& start = ctxt.producer_handshake; 51 | start.flags.speculative = true; 52 | start.flags.valid = true; 53 | start.flags.real = true; 54 | 55 | ctxt.perform_serialization(); 56 | } 57 | 58 | SECTION("Instruction") { 59 | auto& start = ctxt.producer_handshake; 60 | start.flags.valid = true; 61 | start.flags.real = true; 62 | 63 | start.pc = 0xdeadbeef; 64 | start.npc = 0xfeedface; 65 | start.tpc = 0xdecafbad; 66 | start.rSP = 0x12345678; 67 | 68 | start.mem_buffer.push_back(std::make_pair(0xdeadbeef, 4)); 69 | 70 | start.ins[0] = 0x90; 71 | 72 | ctxt.perform_serialization(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /xiosim/pintool/test_parse_speedup.cpp: -------------------------------------------------------------------------------- 1 | /* Unit tests for the speedup data parser. */ 2 | 3 | #include 4 | #include 5 | 6 | #include "catch.hpp" 7 | #include "parse_speedup.h" 8 | 9 | const std::string XIOSIM_PACKAGE_PATH = "xiosim/"; 10 | 11 | TEST_CASE("Complete front-to-end test of the speedup data parser", "parser") { 12 | using namespace std; 13 | using std::string; 14 | string filepath = XIOSIM_PACKAGE_PATH + "pintool/test_data/loop_speedup_data.csv"; 15 | LoadHelixSpeedupModelData(filepath); 16 | // Data has four points, and GetHelixLoopScaling() adds a fifth for 1 core. 17 | const int NUM_POINTS = 4; 18 | 19 | SECTION("test data for loop_1") { 20 | string loop_name = "loop_1"; 21 | vector loop_scaling = GetHelixLoopScaling(loop_name); 22 | REQUIRE(loop_scaling.size() == NUM_POINTS + 1); 23 | REQUIRE(loop_scaling.at(0) == Approx(1.0)); 24 | REQUIRE(loop_scaling.at(1) == Approx(0.9)); 25 | REQUIRE(loop_scaling.at(2) == Approx(1.6)); 26 | REQUIRE(loop_scaling.at(3) == Approx(2.19)); 27 | REQUIRE(loop_scaling.at(4) == Approx(2.39)); 28 | } 29 | 30 | SECTION("test the weird loop name with weird speedup") { 31 | string loop_name = "a weird, weird loop name and speedup. $#$"; 32 | vector loop_scaling = GetHelixLoopScaling(loop_name); 33 | // The first three elements will be 0, 0.5, and 0.25 due to linear 34 | // interpolation but all the others should be 0.5. 35 | REQUIRE(loop_scaling.size() == NUM_POINTS + 1); 36 | REQUIRE(loop_scaling.at(0) == Approx(1)); 37 | REQUIRE(loop_scaling.at(1) == Approx(1.5)); 38 | REQUIRE(loop_scaling.at(2) == Approx(1.5)); 39 | REQUIRE(loop_scaling.at(3) == Approx(1.5)); 40 | REQUIRE(loop_scaling.at(4) == Approx(1.5)); 41 | } 42 | 43 | SECTION("Test parsing of serial runtime and variance.") { 44 | string loop_name = "loop_1"; 45 | loop_data* data = GetHelixFullLoopData(loop_name); 46 | REQUIRE(data->serial_runtime == 1111); 47 | REQUIRE(data->serial_runtime_variance == Approx(0.111)); 48 | 49 | loop_name = "loop_2"; 50 | data = GetHelixFullLoopData(loop_name); 51 | REQUIRE(data->serial_runtime == 22222); 52 | REQUIRE(data->serial_runtime_variance == Approx(0.5)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /xiosim/pintool/timing_sim.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMING_SIM__ 2 | #define __TIMING_SIM__ 3 | 4 | /* ========================================================================== */ 5 | class sim_thread_state_t { 6 | public: 7 | sim_thread_state_t() { 8 | 9 | is_running = true; 10 | // Will get cleared on first simulated instruction 11 | sim_stopped = true; 12 | 13 | lk_init(&lock); 14 | } 15 | 16 | XIOSIM_LOCK lock; 17 | // XXX: SHARED -- lock protects those 18 | // Signal to the simulator thread to die 19 | bool is_running; 20 | // Set by simulator thread once it dies 21 | bool sim_stopped; 22 | // XXX: END SHARED 23 | }; 24 | sim_thread_state_t* get_sim_tls(int coreID); 25 | 26 | #endif /* __TIMING_SIM__ */ 27 | -------------------------------------------------------------------------------- /xiosim/pintool/utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "feeder.h" 5 | #include "utils.h" 6 | 7 | time_t last_time; 8 | 9 | bool parse_sym(std::string sym_off, symbol_off_t& result) { 10 | auto re = std::regex("([^\\+]*)(?:\\+)?((?:0x)?[A-Fa-f0-9]+)?"); 11 | std::smatch re_match; 12 | 13 | if (!std::regex_match(sym_off, re_match, re)) { 14 | std::cerr << "Couldn't parse symbol " << sym_off << std::endl; 15 | return false; 16 | } 17 | 18 | if (re_match.size() - 1 != 2) { 19 | std::cerr << "Knob parse RE has the wrong number of groups." << std::endl; 20 | return false; 21 | } 22 | 23 | ADDRINT off = 0; 24 | if (re_match[2].length() > 0) 25 | off = std::stol(re_match[2], nullptr, 0); 26 | result.symbol_name = re_match[1]; 27 | result.offset = off; 28 | return true; 29 | } 30 | 31 | VOID printElapsedTime() { 32 | time_t elapsed_time = time(NULL) - last_time; 33 | time_t hours = elapsed_time / 3600; 34 | time_t minutes = (elapsed_time % 3600) / 60; 35 | time_t seconds = ((elapsed_time % 3600) % 60); 36 | cerr << hours << "h" << minutes << "m" << seconds << "s" << endl; 37 | last_time = time(NULL); 38 | } 39 | 40 | VOID printMemoryUsage(THREADID tid) { 41 | lk_lock(printing_lock, tid + 1); 42 | int myPid = getpid(); 43 | char str[50]; 44 | sprintf(str, "%d", myPid); 45 | 46 | ifstream fin; 47 | fin.open(("/proc/" + string(str) + "/status").c_str()); 48 | string line; 49 | while (getline(fin, line)) { 50 | if (line.find("VmSize") != string::npos) { 51 | cerr << tid << ":" << line << endl; 52 | break; 53 | } 54 | } 55 | fin.close(); 56 | lk_unlock(printing_lock); 57 | } 58 | -------------------------------------------------------------------------------- /xiosim/pintool/utils.h: -------------------------------------------------------------------------------- 1 | extern time_t last_time; 2 | #ifndef _UTILS_H_ 3 | #define _UTILS_H_ 4 | 5 | #include 6 | 7 | /* Instruction address, specified by a symbol name and its offset from that 8 | * symbol's address. 9 | */ 10 | struct symbol_off_t { 11 | std::string symbol_name; 12 | ADDRINT offset; 13 | }; 14 | 15 | /* Parse a start/stop point definition of symbol(+offset) and stores the 16 | * parsed symbol in result. Returns true on success, false otherwise. 17 | */ 18 | bool parse_sym(std::string sym_off, symbol_off_t& result); 19 | 20 | VOID printMemoryUsage(THREADID tid); 21 | VOID printElapsedTime(); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /xiosim/pintool/vdso.h: -------------------------------------------------------------------------------- 1 | #ifndef __FEEDER_VDSO_H__ 2 | #define __FEEDER_VDSO_H__ 3 | 4 | /* Utilities to parse VDSO symbols. Taken from the kernel docs. */ 5 | 6 | #include 7 | 8 | /* Get VDSO base address from the auxv. */ 9 | uintptr_t vdso_addr(); 10 | #ifdef WE_DONT_NEED_NO_STINKING_LIBC 11 | extern uintptr_t auxv_start; 12 | #endif 13 | 14 | /* Parse VDSO ELF dynamic symbol tables. Not thread-safe. */ 15 | void vdso_init_from_sysinfo_ehdr(uintptr_t base); 16 | 17 | /* Search for a VDSO symbol. Returns (addr, length). */ 18 | std::pair vdso_sym(const char* name); 19 | 20 | #endif /* __FEEDER_VDSO_H__ */ 21 | -------------------------------------------------------------------------------- /xiosim/regs.h: -------------------------------------------------------------------------------- 1 | /* regs.h - register helper functions */ 2 | 3 | #ifndef REGS_H 4 | #define REGS_H 5 | 6 | extern "C" { 7 | #include "xed-interface.h" 8 | } 9 | 10 | namespace xiosim { 11 | namespace x86 { 12 | 13 | inline bool is_ireg(xed_reg_enum_t reg) { 14 | auto reg_class = xed_reg_class(reg); 15 | return reg_class == XED_REG_CLASS_GPR; 16 | } 17 | 18 | inline bool is_freg(xed_reg_enum_t reg) { 19 | auto reg_class = xed_reg_class(reg); 20 | return reg_class == XED_REG_CLASS_X87 || 21 | reg_class == XED_REG_CLASS_XMM || 22 | reg_class == XED_REG_CLASS_YMM; 23 | } 24 | 25 | inline bool is_xmmreg(xed_reg_enum_t reg) { 26 | auto reg_class = xed_reg_class(reg); 27 | return reg_class == XED_REG_CLASS_XMM; 28 | } 29 | 30 | inline bool is_creg(xed_reg_enum_t reg) { 31 | auto reg_class = xed_reg_class(reg); 32 | return reg_class == XED_REG_CLASS_FLAGS || 33 | reg_class == XED_REG_CLASS_XCR; 34 | } 35 | 36 | inline bool is_sreg(xed_reg_enum_t reg) { 37 | auto reg_class = xed_reg_class(reg); 38 | return reg_class == XED_REG_CLASS_SR; 39 | } 40 | 41 | /* Get the largest architectural register covering @reg. 42 | * This is different based on 32/64-bit mode: 43 | * - in 32b, largest_reg(XED_REG_EAX) == XED_REG_EAX 44 | * - in 64b, largest_reg(XED_REG_EAX) == XED_REG_RAX 45 | * All explicit register name mentions should be wrapped in this function, 46 | * so we don't miss dependences due to distinguishing, say EAX/RAX. 47 | */ 48 | inline xed_reg_enum_t largest_reg(const xed_reg_enum_t reg) { 49 | #ifdef _LP64 50 | return xed_get_largest_enclosing_register(reg); 51 | #else 52 | return xed_get_largest_enclosing_register32(reg); 53 | #endif 54 | } 55 | 56 | } 57 | } 58 | 59 | #endif /* REGS_H */ 60 | -------------------------------------------------------------------------------- /xiosim/shadow_MopQ.cpp: -------------------------------------------------------------------------------- 1 | #include "misc.h" 2 | 3 | #include "zesto-core.h" 4 | #include "zesto-oracle.h" 5 | #include "zesto-structs.h" 6 | #include "shadow_MopQ.h" 7 | 8 | /* Get the shadow MopQ entry corresponding to Mop in the oracle MopQ. 9 | * The oracle calls this with a fresh new Mop that it needs to decode and process. 10 | */ 11 | handshake_container_t const& shadow_MopQ_t::get_shadow_Mop(const struct Mop_t* Mop) { 12 | struct core_t* core = Mop->core; 13 | core_oracle_t* oracle = core->oracle.get(); 14 | 15 | int Mop_ind = oracle->get_index(Mop); 16 | int from_head = (Mop_ind - oracle->MopQ_head) & (oracle->MopQ_size - 1); 17 | 18 | /* Non-spec Mops are always in sync with the MopQ. So, we just need the same position 19 | * in this buffer. */ 20 | if (!Mop->oracle.spec_mode) { 21 | handshake_container_t& res = buffer_.get_item(from_head)->Mop; 22 | zesto_assert(res.flags.valid, nullptr); 23 | return res; 24 | } else { 25 | /* Speculative Mops in the MopQ are always on the tail end (newest) -- when we recover 26 | * from speculation, we blow them away. */ 27 | 28 | /* So, to get to a speculative entry, we first find the youngest non-spec Mop 29 | * in the MopQ (the one that triggered speculation. */ 30 | zesto_assert(oracle->MopQ_num - oracle->MopQ_spec_num > 0, nullptr); 31 | int last_non_spec_Mop = moddec(oracle->MopQ_non_spec_tail, oracle->MopQ_size); 32 | int non_spec_from_head = (last_non_spec_Mop - oracle->MopQ_head) & (oracle->MopQ_size - 1); 33 | /* Because non-spec Mops are always in sync, it's business as usual. */ 34 | auto shadow_entry = buffer_.get_item(non_spec_from_head); 35 | 36 | /* We need to check diff # Mops deep in the speculation queue. */ 37 | int diff = from_head - non_spec_from_head - 1; 38 | zesto_assert(diff >= 0, nullptr); 39 | 40 | /* Feeder didn't give us enough speculative handshakes. And we don't have fake 41 | * NOPs manufactured. 42 | * The only time this can happen is when we encounter new (unseen before) speculation 43 | * on a nuke recovery path. So, just get new fake NOPs. */ 44 | while (diff >= (int)shadow_entry->speculated.size()) { 45 | zesto_assert(oracle->on_nuke_recovery_path(), nullptr); 46 | shadow_entry->speculated.push_back(oracle->get_fake_spec_handshake()); 47 | size_++; 48 | } 49 | 50 | /* We have a spec entry in place. Just return it. */ 51 | handshake_container_t& res = shadow_entry->speculated[diff]; 52 | zesto_assert(res.flags.valid, nullptr); 53 | return res; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /xiosim/sim-loop.h: -------------------------------------------------------------------------------- 1 | namespace xiosim { 2 | namespace libsim { 3 | 4 | void sim_loop_init(void); 5 | 6 | } // xiosim::libsim 7 | } // xiosim 8 | -------------------------------------------------------------------------------- /xiosim/sim.h: -------------------------------------------------------------------------------- 1 | #ifndef SIM_H 2 | #define SIM_H 3 | 4 | namespace xiosim { 5 | 6 | namespace stats { 7 | class StatsDatabase; // fwd 8 | } 9 | 10 | namespace libsim { 11 | 12 | /* register simulation statistics */ 13 | void sim_reg_stats(xiosim::stats::StatsDatabase* sdb); 14 | void compute_rtp_power(void); 15 | 16 | } // xiosim::libsim 17 | } // xiosim 18 | 19 | extern struct core_t ** cores; 20 | 21 | #endif /* SIM_H */ 22 | -------------------------------------------------------------------------------- /xiosim/slices.h: -------------------------------------------------------------------------------- 1 | #ifndef __SLICES_H__ 2 | #define __SLICES_H__ 3 | 4 | void start_slice(unsigned int slice_num); 5 | 6 | void end_slice(unsigned int slice_num, 7 | unsigned long long slice_length, 8 | unsigned long long slice_weight_times_1000); 9 | 10 | void scale_all_slices(void); 11 | 12 | #endif /* __SLICES_H__ */ 13 | -------------------------------------------------------------------------------- /xiosim/test_data/gzopen.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/test_data/gzopen.gz -------------------------------------------------------------------------------- /xiosim/test_data/test_stat.database.out: -------------------------------------------------------------------------------- 1 | integer_stat 100 # integer description 2 | double_stat 50.1230 # double description 3 | long_long_stat 1233445 # int64_t description 4 | string_stat string # string description 5 | dist # dist description 6 | dist.count = 50 7 | dist.total = 0 8 | dist.average = 0.0000 9 | dist.std_dev = 0.0000 10 | dist.overflows = 1 11 | # pdf = prob. dist. fn. cdf = cumulative dist. fn. 12 | # index count pdf cdf 13 | dist.start_dist 14 | 0 50 100.00 100.00 15 | 1 0 0.00 100.00 16 | 2 0 0.00 100.00 17 | 3 0 0.00 100.00 18 | dist.end_dist 19 | hist # hist description 20 | hist.total = 12 21 | # label count pdf cdf 22 | hist.start_hist 23 | 0 5 41.67 41.67 24 | 10 7 58.33 100.00 25 | hist.end_hist 26 | -------------------------------------------------------------------------------- /xiosim/test_data/test_stat.distribution.labeled.out: -------------------------------------------------------------------------------- 1 | labeled_dist # Distribution description 2 | labeled_dist.count = 44 3 | labeled_dist.total = 151 4 | labeled_dist.average = 3.4318 5 | labeled_dist.std_dev = 2.5172 6 | labeled_dist.overflows = 0 7 | # pdf = prob. dist. fn. cdf = cumulative dist. fn. 8 | # index count pdf cdf 9 | labeled_dist.start_dist 10 | label_1 10 22.7 22.7 11 | label_2 0 0.0 22.7 12 | label_3 13 29.5 52.3 13 | label_4 0 0.0 52.3 14 | label_5 0 0.0 52.3 15 | label_6 1 2.3 54.5 16 | label_7 20 45.5 100.0 17 | label_8 0 0.0 100.0 18 | label_9 0 0.0 100.0 19 | label_10 0 0.0 100.0 20 | labeled_dist.end_dist 21 | -------------------------------------------------------------------------------- /xiosim/test_data/test_stat.distribution.unlabeled.out: -------------------------------------------------------------------------------- 1 | dist # Distribution description. 2 | dist.count = 100 3 | dist.total = 450 4 | dist.average = 4.5000 5 | dist.std_dev = 2.8723 6 | dist.overflows = 10 7 | # pdf = prob. dist. fn. cdf = cumulative dist. fn. 8 | # index count pdf cdf 9 | dist.start_dist 10 | 0 10 10.00 10.00 11 | 1 10 10.00 20.00 12 | 2 10 10.00 30.00 13 | 3 10 10.00 40.00 14 | 4 10 10.00 50.00 15 | 5 10 10.00 60.00 16 | 6 10 10.00 70.00 17 | 7 10 10.00 80.00 18 | 8 10 10.00 90.00 19 | 9 10 10.00 100.00 20 | dist.end_dist 21 | -------------------------------------------------------------------------------- /xiosim/test_data/test_stat.histogram.out: -------------------------------------------------------------------------------- 1 | histogram # A histogram 2 | histogram.total = 24 3 | # label count pdf cdf 4 | histogram.start_hist 5 | 0 16 66.67 66.67 6 | 1 4 16.67 83.33 7 | 3 2 8.33 91.67 8 | 50 2 8.33 100.00 9 | histogram.end_hist 10 | -------------------------------------------------------------------------------- /xiosim/test_data/test_stat.histogram_scaled.out: -------------------------------------------------------------------------------- 1 | histogram # A histogram 2 | histogram.total = 12 3 | # label count pdf cdf 4 | histogram.start_hist 5 | 0 8 66.67 66.67 6 | 1 2 16.67 83.33 7 | 3 1 8.33 91.67 8 | 50 1 8.33 100.00 9 | histogram.end_hist 10 | -------------------------------------------------------------------------------- /xiosim/test_data/test_stat.reg_api.out: -------------------------------------------------------------------------------- 1 | integer_stat 1 # integer description 2 | double_stat 7.2500 # double description 3 | formula 8.2500 # A formula 4 | ratio 0.0001 # A ratio 5 | -------------------------------------------------------------------------------- /xiosim/test_data/test_stat.singlevalue_int.out: -------------------------------------------------------------------------------- 1 | test_stat 1000 # Description of a test statistic. 2 | -------------------------------------------------------------------------------- /xiosim/test_xed_context.h: -------------------------------------------------------------------------------- 1 | #ifndef __TEST_XED_CONTEXT_H__ 2 | #define __TEST_XED_CONTEXT_H__ 3 | 4 | #ifdef DECODE_DEBUG 5 | #include 6 | #endif 7 | 8 | extern "C" { 9 | #include "xed-interface.h" 10 | } 11 | 12 | #include "decode.h" 13 | #include "misc.h" 14 | #include "uop_cracker.h" 15 | #include "zesto-structs.h" 16 | 17 | class xed_context { 18 | public: 19 | xed_encoder_instruction_t x; 20 | xed_encoder_request_t enc_req; 21 | xed_state_t dstate; 22 | 23 | struct Mop_t Mop; 24 | 25 | xed_context() { 26 | xed_tables_init(); 27 | #ifdef _LP64 28 | xed_state_init2(&dstate, XED_MACHINE_MODE_LONG_64, XED_ADDRESS_WIDTH_64b); 29 | #else 30 | xed_state_init2(&dstate, XED_MACHINE_MODE_LONG_COMPAT_32, XED_ADDRESS_WIDTH_32b); 31 | #endif 32 | 33 | init_decoder(); 34 | } 35 | 36 | #ifdef _LP64 37 | // In 64-bit mode, we need to explicitly specify 64-bit operand width 38 | // for some encodings (like indirect jmps) 39 | const unsigned int op_width = 64; 40 | const unsigned int mem_op_width = 64; 41 | #else 42 | const unsigned int op_width = 0; 43 | const unsigned int mem_op_width = 32; 44 | #endif 45 | 46 | void encode(void) { 47 | xed_encoder_request_zero_set_mode(&enc_req, &dstate); 48 | 49 | bool convert_ok = xed_convert_to_encoder_request(&enc_req, &x); 50 | if (!convert_ok) { 51 | fatal("conversion to encode request failed\n"); 52 | } 53 | unsigned int inst_len; 54 | auto err = xed_encode(&enc_req, Mop.fetch.code, MAX_ILEN, &inst_len); 55 | if (err != XED_ERROR_NONE) { 56 | fatal("xed_encode failed %s\n", xed_error_enum_t2str(err)); 57 | } 58 | } 59 | 60 | void decode(void) { 61 | xiosim::x86::decode(&Mop); 62 | xiosim::x86::decode_flags(&Mop); 63 | 64 | #ifdef DECODE_DEBUG 65 | std::cerr << print_Mop(&Mop) << std::endl; 66 | #endif 67 | } 68 | 69 | void decode_and_crack(void) { 70 | decode(); 71 | xiosim::x86::crack(&Mop); 72 | } 73 | }; 74 | 75 | #endif /* __TEST_XED_CONTEXT_H__ */ 76 | -------------------------------------------------------------------------------- /xiosim/uop_cracker.h: -------------------------------------------------------------------------------- 1 | #ifndef __UOP_CRACKER_H__ 2 | #define __UOP_CRACKER_H__ 3 | 4 | struct Mop_t; 5 | struct uop_t; 6 | 7 | namespace xiosim { 8 | namespace x86 { 9 | 10 | /* Takes a decoded Mop and fills in the uop flow. */ 11 | void crack(struct Mop_t * Mop); 12 | 13 | /* Allocate a (properly aligned) array of uops. */ 14 | struct uop_t* get_uop_array(const size_t num_uops); 15 | 16 | /* Deallocates the uops for a Mop */ 17 | void return_uop_array(struct uop_t* p, const size_t num_uops); 18 | 19 | /* Max number of uops per Mop */ 20 | const size_t MAX_NUM_UOPS = 64; 21 | const size_t UOP_SEQ_SHIFT = 6; // log2(MAX_NUM_UOPS) 22 | 23 | /* Max number of input registers per uop. */ 24 | const size_t MAX_IDEPS = 3; 25 | /* Max numbder of output registers per uop (1+flags). */ 26 | const size_t MAX_ODEPS = 2; 27 | 28 | /* Flags for allowing different types of uop fusion. */ 29 | struct fusion_flags_t { 30 | bool LOAD_OP:1; 31 | bool STA_STD:1; 32 | bool LOAD_OP_ST:1; /* for atomic Mop execution */ 33 | bool FP_LOAD_OP:1; /* same as load op, but for fp ops */ 34 | 35 | bool matches(fusion_flags_t& rhs) { 36 | return (LOAD_OP && rhs.LOAD_OP) || (STA_STD && rhs.STA_STD) || 37 | (LOAD_OP_ST && rhs.LOAD_OP_ST) || (FP_LOAD_OP && rhs.FP_LOAD_OP); 38 | } 39 | }; 40 | 41 | } // xiosim::x86 42 | } // xiosim 43 | 44 | #endif /* __UOP_CRACKER_H__ */ 45 | -------------------------------------------------------------------------------- /xiosim/valcheck.h: -------------------------------------------------------------------------------- 1 | #ifndef VALCHECK_H 2 | #define VALCHECK_H 3 | 4 | /* macros for checking arguments */ 5 | 6 | /* true is x is a power of two */ 7 | #define IS_POW2(x) (!(((x)-1)&(x))) 8 | 9 | /* is power of two? */ 10 | #define CHECK_POW2(x) if(!IS_POW2(x)) fatal("%s %s must be a power of two.",COMPONENT_NAME,#x) 11 | /* is positive power of two? */ 12 | #define CHECK_PPOW2(x) if(!IS_POW2(x) || ((x) < 1)) fatal("%s %s must be a positive power of two.",COMPONENT_NAME,#x) 13 | /* is not negative? (i.e. >= 0) */ 14 | #define CHECK_NNEG(x) if(((x) < 0)) fatal("%s %s must be non-negative.",COMPONENT_NAME,#x) 15 | /* is positive? (i.e. > 0) */ 16 | #define CHECK_POS(x) if(((x) <= 0)) fatal("%s %s must be positive.",COMPONENT_NAME,#x) 17 | /* is not negative and <= y? */ 18 | #define CHECK_NNEG_LEQ(x,y) if(((x) < 0) || ((x)>(y))) fatal("%s %s must be non-negative and less than or equal to %lf.",COMPONENT_NAME,#x,(double)(y)) 19 | /* is positive and <= y? */ 20 | #define CHECK_POS_LEQ(x,y) if(((x) <= 0) || ((x)>(y))) fatal("%s %s must be positive and less than or equal to %lf.",COMPONENT_NAME,#x,(double)(y)) 21 | /* is not negative and < y? */ 22 | #define CHECK_NNEG_LT(x,y) if(((x) < 0) || ((x)>=(y))) fatal("%s %s must be non-negative and less than or equal to %lf.",COMPONENT_NAME,#x,(double)(y)) 23 | /* is positive and < y? */ 24 | #define CHECK_POS_LT(x,y) if(((x) <= 0) || ((x)>=(y))) fatal("%s %s must be positive and less than or equal to %lf.",COMPONENT_NAME,#x,(double)(y)) 25 | /* is positive and > y? */ 26 | #define CHECK_POS_GT(x,y) if(((x) <= 0) || ((x)<=(y))) fatal("%s %s must be positive and greater than %lf.",COMPONENT_NAME,#x,(double)(y)) 27 | /* is boolean? */ 28 | #define CHECK_BOOL(x) if(((x) != 0) && ((x) != 1)) fatal("%s %s must be boolean (0 or 1).",COMPONENT_NAME,#x) 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /xiosim/zesto-MC.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-MC.cpp -------------------------------------------------------------------------------- /xiosim/zesto-MC.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-MC.h -------------------------------------------------------------------------------- /xiosim/zesto-alloc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-alloc.cpp -------------------------------------------------------------------------------- /xiosim/zesto-alloc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-alloc.h -------------------------------------------------------------------------------- /xiosim/zesto-bpred.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-bpred.cpp -------------------------------------------------------------------------------- /xiosim/zesto-bpred.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-bpred.h -------------------------------------------------------------------------------- /xiosim/zesto-cache.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-cache.cpp -------------------------------------------------------------------------------- /xiosim/zesto-cache.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-cache.h -------------------------------------------------------------------------------- /xiosim/zesto-coherence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "memory.h" 5 | #include "misc.h" 6 | #include "stats.h" 7 | #include "synchronization.h" 8 | 9 | #include "zesto-cache.h" 10 | #include "zesto-coherence.h" 11 | #include "zesto-core.h" 12 | #include "zesto-uncore.h" 13 | #include "zesto-noc.h" 14 | #include "zesto-MC.h" 15 | 16 | using namespace xiosim; 17 | 18 | /* load in all definitions */ 19 | #include "xiosim/ZCOMPS-coherence.list.h" 20 | 21 | cache_controller_t::cache_controller_t(struct core_t * const _core, struct cache_t * const _cache) : 22 | cache(_cache), core(_core) 23 | {} 24 | 25 | std::unique_ptr controller_create(const char * controller_opt_string, struct core_t * core, struct cache_t * cache) 26 | { 27 | #define ZESTO_PARSE_ARGS 28 | #include "xiosim/ZCOMPS-coherence.list.h" 29 | 30 | fatal("unknown cache controller type \"%s\"", controller_opt_string); 31 | #undef ZESTO_PARSE_ARGS 32 | } 33 | -------------------------------------------------------------------------------- /xiosim/zesto-coherence.h: -------------------------------------------------------------------------------- 1 | #ifndef ZESTO_COHERENCE_INCLUDED 2 | #define ZESTO_COHERENCE_INCLUDED 3 | 4 | #include 5 | 6 | enum controller_response_t { MSHR_CHECK_ARRAY, MSHR_STALL }; 7 | enum controller_array_response_t { ARRAY_HIT, ARRAY_MISS }; 8 | 9 | class cache_controller_t { 10 | public: 11 | cache_controller_t ( 12 | struct core_t * const core, 13 | struct cache_t * const cache); 14 | virtual ~cache_controller_t() {} 15 | 16 | virtual controller_array_response_t check_array(struct cache_line_t * line) = 0; 17 | virtual controller_response_t check_MSHR(struct cache_action_t * MSHR_item) = 0; 18 | 19 | virtual bool can_schedule_upstream() = 0; 20 | virtual bool can_schedule_downstream(struct cache_t * const prev_cache) = 0; 21 | virtual bool send_request_upstream(int bank, int MSHR_index, struct cache_action_t * MSHR) = 0; 22 | virtual void send_response_downstream(struct cache_action_t * const MSHR) = 0; 23 | 24 | virtual void reg_stats(xiosim::stats::StatsDatabase* sdb) { } 25 | 26 | protected: 27 | struct cache_t * const cache; 28 | struct core_t * const core; 29 | 30 | }; 31 | 32 | class LLC_controller_t { 33 | 34 | }; 35 | 36 | std::unique_ptr controller_create(const char * controller_opt_string, struct core_t * core, struct cache_t * cache); 37 | 38 | #endif /*ZESTO_COHERENCE*/ 39 | -------------------------------------------------------------------------------- /xiosim/zesto-commit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-commit.cpp -------------------------------------------------------------------------------- /xiosim/zesto-commit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-commit.h -------------------------------------------------------------------------------- /xiosim/zesto-config.h: -------------------------------------------------------------------------------- 1 | /* Read Zesto configuration file and store settings in the knobs structure. 2 | * 3 | * Cache, TLB, and prefetcher configurations are identical from an attributes 4 | * perspective. However, they differ in their default values. Therefore, each 5 | * such structure has its own specification. 6 | * 7 | * Author: Sam Xi 8 | */ 9 | 10 | #ifndef __ZESTO_CONFIG_H__ 11 | #define __ZESTO_CONFIG_H__ 12 | 13 | #include 14 | 15 | #include "knobs.h" 16 | 17 | /* Entry point for parsing configuration file. Options are stored in the knobs structs. */ 18 | void read_config_file(std::string cfg_file, core_knobs_t* knobs, uncore_knobs_t* uncore_knobs, 19 | system_knobs_t* system_knobs); 20 | 21 | /* Print the parsed configuration for to file descriptor @fd. */ 22 | void print_config(FILE* fd); 23 | 24 | /* Free all memory associated with the configs. */ 25 | void free_config(); 26 | 27 | #endif /* __ZESTO_CONFIG_H__ */ 28 | -------------------------------------------------------------------------------- /xiosim/zesto-core.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-core.cpp -------------------------------------------------------------------------------- /xiosim/zesto-core.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-core.h -------------------------------------------------------------------------------- /xiosim/zesto-decode.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-decode.cpp -------------------------------------------------------------------------------- /xiosim/zesto-decode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-decode.h -------------------------------------------------------------------------------- /xiosim/zesto-dram.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-dram.cpp -------------------------------------------------------------------------------- /xiosim/zesto-dram.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-dram.h -------------------------------------------------------------------------------- /xiosim/zesto-dvfs.cpp: -------------------------------------------------------------------------------- 1 | #include "misc.h" 2 | #include "ztrace.h" 3 | 4 | #include "zesto-structs.h" 5 | #include "zesto-core.h" 6 | #include "zesto-dvfs.h" 7 | 8 | using namespace std; 9 | 10 | /* load in all definitions */ 11 | #include "xiosim/ZCOMPS-dvfs.list.h" 12 | 13 | std::unique_ptr vf_controller_create(const char * opt_string, struct core_t * core) 14 | { 15 | #define ZESTO_PARSE_ARGS 16 | #include "xiosim/ZCOMPS-dvfs.list.h" 17 | #undef ZESTO_PARSE_ARGS 18 | 19 | fatal("unknown dvfs controller type (%s)", opt_string); 20 | } 21 | 22 | double vf_controller_t::get_average_vdd() 23 | { 24 | pair curr, next; 25 | double sum; 26 | 27 | if (voltages.empty()) { 28 | last_power_computation = core->sim_cycle; 29 | return vdd; 30 | } 31 | 32 | if (last_power_computation == core->sim_cycle) { 33 | return vdd; 34 | } 35 | 36 | curr = voltages.front(); 37 | sum = (curr.first - last_power_computation) * curr.second; 38 | 39 | while(voltages.size() > 1) { 40 | voltages.pop(); 41 | next = voltages.front(); 42 | 43 | sum += (next.first - curr.first) * curr.second; 44 | curr = next; 45 | } 46 | 47 | curr = voltages.front(); 48 | sum += (core->sim_cycle - curr.first) * curr.second; 49 | sum /= (core->sim_cycle - last_power_computation); 50 | last_power_computation = core->sim_cycle; 51 | return sum; 52 | } 53 | 54 | void vf_controller_t::change_vf() 55 | { 56 | voltages.push(pair(core->sim_cycle, vdd)); 57 | } 58 | -------------------------------------------------------------------------------- /xiosim/zesto-dvfs.h: -------------------------------------------------------------------------------- 1 | #ifndef __ZESTO_DVFS__ 2 | #define __ZESTO_DVFS__ 3 | 4 | #include 5 | #include 6 | 7 | class vf_controller_t { 8 | public: 9 | vf_controller_t (struct core_t * const _core) : next_invocation(0), core(_core) { } 10 | virtual ~vf_controller_t() { } 11 | 12 | virtual void change_vf(); 13 | virtual double get_average_vdd(); 14 | 15 | tick_t next_invocation; 16 | 17 | double vdd; 18 | 19 | protected: 20 | struct core_t * const core; 21 | tick_t last_power_computation; 22 | std::queue > voltages; 23 | }; 24 | 25 | std::unique_ptr vf_controller_create(const char * opt_string, struct core_t * core); 26 | 27 | #endif /* __ZESTO_DVFS__ */ 28 | -------------------------------------------------------------------------------- /xiosim/zesto-exec.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-exec.cpp -------------------------------------------------------------------------------- /xiosim/zesto-exec.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-exec.h -------------------------------------------------------------------------------- /xiosim/zesto-fetch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-fetch.cpp -------------------------------------------------------------------------------- /xiosim/zesto-fetch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-fetch.h -------------------------------------------------------------------------------- /xiosim/zesto-memdep.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-memdep.cpp -------------------------------------------------------------------------------- /xiosim/zesto-memdep.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-memdep.h -------------------------------------------------------------------------------- /xiosim/zesto-noc.h: -------------------------------------------------------------------------------- 1 | #ifndef ZESTO_NOC_INCLUDED 2 | #define ZESTO_NOC_INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | struct bus_t { 8 | std::string name; 9 | int width; /* in bytes tranferrable per cycle */ 10 | const tick_t * clock; /* The sim_cycle used to drive this bus */ 11 | int ratio; /* number of ^ clock cycles per bus cycle */ 12 | tick_t when_available; 13 | 14 | struct { 15 | counter_t accesses; 16 | double utilization; /* cumulative cycles in use */ 17 | double prefetch_utilization; /* cumulative prefetch cycles in use */ 18 | } stat; 19 | }; 20 | 21 | std::unique_ptr bus_create( 22 | const char * const name, 23 | const int width, 24 | const tick_t * clock, 25 | const int ratio); 26 | 27 | void bus_reg_stats( 28 | xiosim::stats::StatsDatabase* sdb, 29 | struct core_t * const core, 30 | struct bus_t * const bus); 31 | 32 | int bus_free(const struct bus_t * const bus); 33 | 34 | void bus_use( 35 | struct bus_t * const bus, 36 | const int transfer_size, 37 | const int prefetch); 38 | 39 | #endif /* ZESTO_NOC */ 40 | -------------------------------------------------------------------------------- /xiosim/zesto-oracle.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-oracle.cpp -------------------------------------------------------------------------------- /xiosim/zesto-oracle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-oracle.h -------------------------------------------------------------------------------- /xiosim/zesto-power.h: -------------------------------------------------------------------------------- 1 | #ifndef ZESTO_POWER_INCLUDED 2 | #define ZESTO_POWER_INCLUDED 3 | 4 | #include 5 | 6 | /* McPAT interface fwd */ 7 | struct system_core; 8 | struct system_L2; 9 | 10 | void init_power(void); 11 | void deinit_power(void); 12 | void compute_power(xiosim::stats::StatsDatabase* sdb, bool print_power); 13 | 14 | class core_power_t { 15 | 16 | public: 17 | core_power_t(struct core_t * _core); 18 | virtual ~core_power_t(void) {} 19 | 20 | double rt_power; 21 | double leakage_power; 22 | static double default_vdd; 23 | 24 | virtual void translate_params(system_core *core_params, system_L2 *L2_params); 25 | virtual void translate_stats(xiosim::stats::StatsDatabase* sdb, 26 | system_core* core_stats, 27 | system_L2* L2_stats); 28 | 29 | protected: 30 | struct core_t *core; 31 | }; 32 | 33 | std::unique_ptr power_create(const char * power_opt_string, struct core_t * core); 34 | 35 | #endif /*ZESTO_POWER*/ 36 | -------------------------------------------------------------------------------- /xiosim/zesto-prefetch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-prefetch.cpp -------------------------------------------------------------------------------- /xiosim/zesto-prefetch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-prefetch.h -------------------------------------------------------------------------------- /xiosim/zesto-repeater.cpp: -------------------------------------------------------------------------------- 1 | /* zesto-repeater.cpp - Ring cache code base classes */ 2 | /* 3 | * Svilen Kanev, 2013 4 | */ 5 | 6 | #include 7 | 8 | #include "misc.h" 9 | 10 | #include "zesto-core.h" 11 | #include "zesto-cache.h" 12 | #include "zesto-structs.h" 13 | #include "zesto-repeater.h" 14 | 15 | /* Load in definitions */ 16 | #include "xiosim/ZCOMPS-repeater.list.h" 17 | 18 | #define REPEATER_PARSE_ARGS 19 | std::unique_ptr repeater_create( 20 | const char * const opt_string, 21 | struct core_t * const core, 22 | const char * const name, 23 | struct cache_t * const next_level) 24 | { 25 | char type[255]; 26 | /* the format string "%[^:]" for scanf reads a string consisting of non-':' characters */ 27 | if(sscanf(opt_string,"%[^:]",type) != 1) 28 | fatal("malformed repeater option string: %s",opt_string); 29 | #include "xiosim/ZCOMPS-repeater.list.h" 30 | 31 | fatal("Unknown memory repeater type (%s)", opt_string); 32 | } 33 | 34 | #undef REPEATER_PARSE_ARGS 35 | 36 | #define REPEATER_INIT 37 | void repeater_init(const char * const opt_string) 38 | { 39 | char type[255]; 40 | if(sscanf(opt_string,"%[^:]",type) != 1) 41 | fatal("malformed repeater option string: %s",opt_string); 42 | 43 | #include "xiosim/ZCOMPS-repeater.list.h" 44 | 45 | fatal("Unknown memory repeater type (%s)", opt_string); 46 | } 47 | 48 | #undef REPEATER_INIT 49 | 50 | #define REPEATER_SHUTDOWN 51 | void repeater_shutdown(const char * const opt_string) 52 | { 53 | char type[255]; 54 | if(sscanf(opt_string,"%[^:]",type) != 1) 55 | fatal("malformed repeater option string: %s",opt_string); 56 | #include "xiosim/ZCOMPS-repeater.list.h" 57 | 58 | fatal("Unknown memory repeater type (%s)", opt_string); 59 | } 60 | 61 | #undef REPEATER_SHUTDOWN 62 | -------------------------------------------------------------------------------- /xiosim/zesto-repeater.h: -------------------------------------------------------------------------------- 1 | /* zesto-repeater.h - Ring cache code base classes */ 2 | /* 3 | * Svilen Kanev, 2013 4 | */ 5 | 6 | #ifndef __ZESTO_REPEATER_H 7 | #define __ZESTO_REPEATER_H 8 | 9 | #include 10 | 11 | class repeater_t { 12 | public: 13 | struct core_t * core; 14 | const char * const name; 15 | struct cache_t * nextLevel; 16 | double speed; 17 | 18 | repeater_t(struct core_t * const _core, const char * const _name, struct cache_t * const _next_level) : 19 | core(_core), name(_name), nextLevel(_next_level) { } 20 | virtual ~repeater_t() { } 21 | 22 | /* Called every cycle. Repeater processing happens here. */ 23 | virtual void step() = 0; 24 | 25 | /* Checks if we can insert request in repeater. Returns 1 if possible */ 26 | virtual int enqueuable(const enum cache_command cmd, const int asid, const md_addr_t addr) = 0; 27 | 28 | /* Send a request to the repeater. 29 | Assumes repeater_enqueuable() has been called in the same cycle. 30 | cb is called with op once request is not blocking any more. */ 31 | virtual void enqueue(const enum cache_command cmd, 32 | const int asid, 33 | const md_addr_t addr, 34 | void * const op, /* To be passed to callback for identification */ 35 | void (*const cb)(void *, bool is_hit), /* Callback once request is finished */ 36 | seq_t (*const get_action_id)(void* const)) = 0; 37 | 38 | /* Flushes all of repeater contents for process @asid. 39 | Some addresses are propagated to next level cache. 40 | cb is called once flush is finished. */ 41 | virtual void flush(const int asid, void (*const cb)()) = 0; 42 | }; 43 | 44 | /* Initialize the repeater. */ 45 | std::unique_ptr repeater_create( 46 | const char * const opt_string, 47 | struct core_t * const core, 48 | const char * const name, 49 | struct cache_t * const next_level); 50 | 51 | void repeater_init(const char * const opt_string); 52 | void repeater_shutdown(const char * const opt_string); 53 | 54 | #endif /*__ZESTO_REPEATER_H */ 55 | -------------------------------------------------------------------------------- /xiosim/zesto-structs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-structs.h -------------------------------------------------------------------------------- /xiosim/zesto-uncore.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-uncore.cpp -------------------------------------------------------------------------------- /xiosim/zesto-uncore.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s-kanev/XIOSim/9673bbd15ba72c9cce15243a462bffb5d9ded9ae/xiosim/zesto-uncore.h -------------------------------------------------------------------------------- /xiosim/ztrace.h: -------------------------------------------------------------------------------- 1 | #ifndef __ZTRACE_H__ 2 | #define __ZTRACE_H__ 3 | 4 | /* Ztrace keeps a circular trace buffer of the last several thousand microarchitectural 5 | * events. It is extremeley useful when debugging simulator bugs that happen further 6 | * along in the execution, when the full trace won't fit on hard drives. 7 | * There is one circular buffer per core and one for the uncore. 8 | */ 9 | 10 | #ifdef ZTRACE 11 | /* Opens ztrace files */ 12 | extern void ztrace_init(); 13 | /* Flushes the in-memory traces to files */ 14 | extern void ztrace_flush(); 15 | 16 | /* Generic tracing functions. 17 | * @coreID == INVALID_CORE prints to the uncore trace. 18 | */ 19 | extern void vtrace(const int coreID, const char *fmt, va_list v); 20 | extern void trace(const int coreID, const char *fmt, ...) 21 | __attribute__ ((format (printf, 2, 3))); 22 | 23 | #define ZTRACE_PRINT(coreID, fmt, ...) trace(coreID, fmt, ## __VA_ARGS__) 24 | #define ZTRACE_VPRINT(coreID, fmt, v) vtrace(coreID, fmt, v) 25 | 26 | /* Convenience functions for tracing Mops and uops respectively. */ 27 | void ztrace_print(const struct Mop_t * Mop); 28 | void ztrace_Mop_timing(const struct Mop_t * Mop); 29 | void ztrace_print(const struct Mop_t * Mop, const char * fmt, ... ); 30 | void ztrace_print(const struct uop_t * uop, const char * fmt, ... ); 31 | void ztrace_print(const int coreID, const char * fmt, ... ); 32 | 33 | void ztrace_print_start(const struct uop_t * uop, const char * fmt, ... ); 34 | void ztrace_print_cont(const int coreID, const char * fmt, ... ); 35 | void ztrace_print_finish(const int coreID, const char * fmt, ... ); 36 | 37 | void ztrace_uop_ID(const struct uop_t * uop); 38 | void ztrace_uop_alloc(const struct uop_t * uop); 39 | void ztrace_uop_timing(const struct uop_t * uop); 40 | 41 | #else 42 | 43 | inline void ztrace_init() {} 44 | /* Assert macros rely that this is defined. */ 45 | inline void ztrace_flush() {} 46 | 47 | #define ZTRACE_PRINT(coreID, fmt, ...) 48 | #define ZTRACE_VPRINT(coreID, fmt, v) 49 | 50 | #endif 51 | 52 | #endif /* __ZTRACE_H__ */ 53 | --------------------------------------------------------------------------------