├── .clang-format ├── .github ├── ISSUE_TEMPLATE │ ├── ask-a-question.md │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── build-checkpoint-creator-loader.yml │ ├── test-clang-format.yml │ └── test-make-release.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── bin ├── checkpoint │ ├── README.md │ ├── convert_checkpoints_to_traces.py │ ├── create_checkpoints.py │ └── prepare_spec_checkpoints_directory.py ├── power │ ├── README.md │ ├── cacti.patch │ ├── mcpat.patch │ ├── power_intf.pl │ └── power_intf.py ├── requirements.txt ├── run_clang_format_on_all.sh ├── scarab_batch.py ├── scarab_globals │ ├── __init__.py │ ├── batch_manager.py │ ├── command.py │ ├── object_manager.py │ ├── progress.py │ ├── scarab_batch_types.py │ ├── scarab_paths.py │ ├── scarab_snapshot.py │ ├── scarab_stats.py │ └── scarab_utils.py └── scarab_launch.py ├── docs ├── .gitignore ├── Makefile ├── common-problems.md ├── compiling-scarab.md ├── figures │ └── scarab_bm_uml.png ├── memtrace.md ├── pin-frontend.md ├── qsort-example-docs │ ├── Makefile │ ├── conf.py │ ├── index.rst │ └── make.bat ├── run_spec17.md ├── running-scarab.md ├── system_requirements.md └── verification.md ├── src ├── BUGS ├── CMakeLists.txt ├── Doxyfile ├── Makefile ├── PARAMS.kaby_lake ├── addr_trans.c ├── addr_trans.h ├── bp │ ├── bp.c │ ├── bp.h │ ├── bp.param.def │ ├── bp.param.h │ ├── bp.stat.def │ ├── bp_conf.c │ ├── bp_conf.h │ ├── bp_table.def │ ├── bp_targ_mech.c │ ├── bp_targ_mech.h │ ├── cbp_table.def │ ├── cbp_to_scarab.cc │ ├── cbp_to_scarab.h │ ├── gshare.cc │ ├── gshare.h │ ├── hybridgp.cc │ ├── hybridgp.h │ ├── mtage_unlimited.cc │ ├── mtage_unlimited.h │ ├── tagescl.cc │ ├── tagescl.h │ └── template_lib │ │ ├── loop_predictor.h │ │ ├── statistical_corrector.h │ │ ├── tage.h │ │ ├── tagescl.h │ │ ├── tagescl_configs.h │ │ └── utils.h ├── cmp_model.c ├── cmp_model.h ├── cmp_model_support.c ├── cmp_model_support.h ├── core.param.def ├── core.param.h ├── core.stat.def ├── ctype_pin_inst.h ├── dcache_stage.c ├── dcache_stage.h ├── debug │ ├── debug.param.def │ ├── debug.param.h │ ├── debug_macros.h │ ├── debug_print.c │ ├── debug_print.h │ ├── memview.c │ ├── memview.h │ ├── pipeview.c │ └── pipeview.h ├── decode_stage.c ├── decode_stage.h ├── deps │ └── CMakeLists.txt ├── dram_sched_table.def ├── dumb_model.c ├── dumb_model.h ├── dvfs │ ├── dvfs.c │ ├── dvfs.h │ ├── dvfs.param.def │ ├── dvfs.param.h │ ├── perf_pred.c │ ├── perf_pred.h │ ├── power_pred.c │ └── power_pred.h ├── exec_ports.c ├── exec_ports.h ├── exec_stage.c ├── exec_stage.h ├── fetch.stat.def ├── freq.c ├── freq.h ├── frontend │ ├── frontend.c │ ├── frontend.h │ ├── frontend_intf.c │ ├── frontend_intf.h │ ├── frontend_table.def │ ├── memtrace │ │ ├── memtrace_fe.cc │ │ ├── memtrace_fe.h │ │ ├── memtrace_trace_reader.cc │ │ ├── memtrace_trace_reader.h │ │ ├── memtrace_trace_reader_memtrace.cc │ │ └── memtrace_trace_reader_memtrace.h │ ├── pin_exec_driven_fe.cc │ ├── pin_exec_driven_fe.h │ ├── pin_trace_fe.c │ ├── pin_trace_fe.h │ ├── pin_trace_read.cc │ └── pin_trace_read.h ├── general.param.def ├── general.param.h ├── globals │ ├── assert.h │ ├── enum.c │ ├── enum.h │ ├── global_defs.h │ ├── global_types.h │ ├── global_vars.h │ ├── param_enum_headers.h │ ├── utils.c │ └── utils.h ├── icache_stage.c ├── icache_stage.h ├── inst.param.h ├── inst.stat.def ├── inst_info.h ├── isa │ ├── isa.c │ ├── isa.h │ ├── isa_macros.h │ └── x86_regs.def ├── libs │ ├── cache_lib.c │ ├── cache_lib.h │ ├── hash_lib.c │ ├── hash_lib.h │ ├── list_lib.c │ ├── list_lib.h │ ├── malloc_lib.c │ ├── malloc_lib.h │ ├── port_lib.c │ └── port_lib.h ├── main.c ├── map.c ├── map.h ├── map_stage.c ├── map_stage.h ├── memory │ ├── cache_part.c │ ├── cache_part.h │ ├── mem_req.c │ ├── mem_req.h │ ├── memory.c │ ├── memory.h │ ├── memory.param.def │ ├── memory.param.h │ └── memory.stat.def ├── model.h ├── model_table.def ├── node_stage.c ├── node_stage.h ├── op.h ├── op_info.h ├── op_pool.c ├── op_pool.h ├── optimizer2.c ├── optimizer2.h ├── packet_build.c ├── packet_build.h ├── packet_build.param.def ├── packet_build.param.h ├── param_files.def ├── param_parser.c ├── param_parser.h ├── pin │ ├── pin_exec │ │ ├── .gitignore │ │ ├── analysis_functions.cc │ │ ├── analysis_functions.h │ │ ├── exception_handling.cc │ │ ├── exception_handling.h │ │ ├── globals.cc │ │ ├── globals.h │ │ ├── main_loop.cc │ │ ├── main_loop.h │ │ ├── makefile │ │ ├── makefile.rules │ │ ├── pin_exec.cpp │ │ ├── read_mem_map.h │ │ ├── scarab_interface.cc │ │ ├── scarab_interface.h │ │ ├── testing │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── c_program_with_ud2.c │ │ │ ├── exception_tests.cc │ │ │ ├── execution_tests.cc │ │ │ ├── fake_scarab.cc │ │ │ ├── fake_scarab.h │ │ │ ├── jump_near_boundary.s │ │ │ ├── main.cc │ │ │ ├── nop_mode_bad_store.s │ │ │ ├── nop_mode_nonret_direct.s │ │ │ ├── nop_mode_nonret_indirect.s │ │ │ ├── nop_mode_not_taken.s │ │ │ ├── nop_mode_ret.s │ │ │ ├── nop_mode_tests.cc │ │ │ ├── simple_c_program.c │ │ │ ├── simple_loop.s │ │ │ ├── utils.cc │ │ │ ├── utils.h │ │ │ └── wrong_path_exception.s │ │ └── utils.h │ ├── pin_lib │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── decoder.cc │ │ ├── decoder.h │ │ ├── gather_scatter_addresses.cc │ │ ├── gather_scatter_addresses.h │ │ ├── message_queue_interface_lib.cc │ │ ├── message_queue_interface_lib.h │ │ ├── pin_api_to_xed.h │ │ ├── pin_scarab_common_lib.cc │ │ ├── pin_scarab_common_lib.h │ │ ├── uop_generator.c │ │ ├── uop_generator.h │ │ ├── x86_decoder.cc │ │ ├── x86_decoder.h │ │ ├── x87_stack_delta.cc │ │ └── x87_stack_delta.h │ └── pin_trace │ │ ├── .gitignore │ │ ├── gen_trace.cc │ │ ├── makefile │ │ ├── makefile.rules │ │ └── read_trace.cc ├── power │ ├── power.param.def │ ├── power.param.h │ ├── power.stat.def │ ├── power_intf.c │ ├── power_intf.h │ ├── power_scarab_config.cc │ └── power_scarab_config.h ├── prefetcher │ ├── l2l1pref.c │ ├── l2l1pref.h │ ├── l2l1pref.param.def │ ├── l2l1pref.param.h │ ├── l2l1pref.stat.def │ ├── l2markv_pref.c │ ├── l2markv_pref.h │ ├── l2way_pref.c │ ├── l2way_pref.h │ ├── pref.param.def │ ├── pref.param.h │ ├── pref.stat.def │ ├── pref_2dc.c │ ├── pref_2dc.h │ ├── pref_2dc.param.def │ ├── pref_2dc.param.h │ ├── pref_common.c │ ├── pref_common.h │ ├── pref_ghb.c │ ├── pref_ghb.h │ ├── pref_ghb.param.def │ ├── pref_ghb.param.h │ ├── pref_markov.c │ ├── pref_markov.h │ ├── pref_markov.param.def │ ├── pref_markov.param.h │ ├── pref_phase.c │ ├── pref_phase.h │ ├── pref_phase.param.def │ ├── pref_phase.param.h │ ├── pref_stream.c │ ├── pref_stream.h │ ├── pref_stride.c │ ├── pref_stride.h │ ├── pref_stride.param.def │ ├── pref_stride.param.h │ ├── pref_stridepc.c │ ├── pref_stridepc.h │ ├── pref_stridepc.param.def │ ├── pref_stridepc.param.h │ ├── pref_table.def │ ├── pref_type.h │ ├── stream.param.def │ ├── stream.param.h │ ├── stream.stat.def │ ├── stream_pref.c │ └── stream_pref.h ├── ramulator.cc ├── ramulator.h ├── ramulator.param.def ├── ramulator.param.h ├── ramulator │ ├── .gitignore │ ├── ALDRAM.cpp │ ├── ALDRAM.h │ ├── CMakeLists.txt │ ├── Cache.cpp │ ├── Cache.h │ ├── Config.cpp │ ├── Config.h │ ├── Controller.cpp │ ├── Controller.h │ ├── DDR3.cpp │ ├── DDR3.h │ ├── DDR4.cpp │ ├── DDR4.h │ ├── DRAM.h │ ├── DSARP.cpp │ ├── DSARP.h │ ├── GDDR5.cpp │ ├── GDDR5.h │ ├── HBM.cpp │ ├── HBM.h │ ├── LPDDR3.cpp │ ├── LPDDR3.h │ ├── LPDDR4.cpp │ ├── LPDDR4.h │ ├── Memory.h │ ├── MemoryFactory.cpp │ ├── MemoryFactory.h │ ├── Processor.cpp │ ├── Processor.h │ ├── README.md │ ├── Refresh.cpp │ ├── Refresh.h │ ├── Request.h │ ├── SALP.cpp │ ├── SALP.h │ ├── ScarabWrapper.cpp │ ├── ScarabWrapper.h │ ├── Scheduler.h │ ├── SpeedyController.h │ ├── StatType.cpp │ ├── StatType.h │ ├── Statistics.h │ ├── TLDRAM.cpp │ ├── TLDRAM.h │ ├── WideIO.cpp │ ├── WideIO.h │ ├── WideIO2.cpp │ └── WideIO2.h ├── sim.c ├── sim.h ├── stage_data.h ├── stat_files.def ├── stat_mon.c ├── stat_mon.h ├── stat_trace.c ├── stat_trace.h ├── statistics.c ├── statistics.h ├── table_info.h ├── test │ ├── .gitignore │ ├── Makefile │ ├── different_scatter_types.s │ ├── dummy_globals.c │ ├── exception_custom_handler.c │ ├── exception_not_taken.c │ ├── exception_taken.c │ ├── gather_not_kmask.s │ ├── gather_scatter.out │ ├── gather_scatter.s │ ├── gather_scatter_wrongpath.s │ ├── inst_with_two_loads.out │ ├── inst_with_two_loads.s │ ├── isa_test.s │ ├── loop_gather_scatter.s │ ├── message_queue_interface_lib_test.cc │ ├── message_test_case.h │ ├── scalar_mov_port_binding_test.s │ ├── scarab_dummy_client_test.cc │ ├── server_client_socket_test.cc │ ├── simple_loop.out │ ├── simple_loop.s │ ├── simple_loop.trace.bz2 │ ├── simple_loop.trace.golden │ ├── test_main.cc │ └── vector_mov_port_binding_test.s ├── thread.c ├── thread.h ├── trigger.c ├── trigger.h ├── valgrind.supp ├── version.c └── version.h └── utils ├── checkpoint ├── README.md ├── creator │ ├── create_checkpoint.cpp │ ├── makefile │ └── makefile.rules └── loader │ ├── .gitignore │ ├── CMakeLists.txt │ ├── Makefile │ ├── checkpoint_loader.cc │ ├── checkpoint_reader.cc │ ├── checkpoint_reader.h │ ├── cpuinfo.h │ ├── gtree.c │ ├── gtree.h │ ├── hconfig.c │ ├── hconfig.h │ ├── ptrace_interface.cc │ ├── ptrace_interface.h │ ├── read_mem_map.cc │ ├── read_mem_map.h │ ├── test_memcpy.cc │ ├── utils.cc │ └── utils.h ├── diff_scarab_ops.py ├── memtrace ├── portabilize_trace.py ├── run_portabilize_trace.sh ├── run_update_trace.sh └── updateTraceModulePaths.py ├── qsort ├── Makefile ├── PARAMS.qsort ├── __init__.py ├── example_checkpoint_descriptor.def ├── example_scarab_batch_jobfile.py ├── libc_qsort.c ├── libc_qsort.h ├── ref_stats │ ├── PARAMS.out │ ├── bp.stat.0.out │ ├── core.stat.0.out │ ├── fetch.stat.0.out │ ├── inst.stat.0.out │ ├── l2l1pref.stat.0.out │ ├── memory.stat.0.out │ ├── power.stat.0.out │ ├── pref.stat.0.out │ ├── ramulator.stat.out │ └── stream.stat.0.out ├── scarab_batch_descriptor.def ├── scarab_test_qsort.py └── test_qsort.c └── scarab_markers.h /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | AccessModifierOffset: -1 3 | AlignAfterOpenBracket: Align 4 | AlignConsecutiveAssignments: true 5 | AlignConsecutiveDeclarations: true 6 | AlignEscapedNewlines: Left 7 | AlignOperands: true 8 | AlignTrailingComments: true 9 | AllowAllParametersOfDeclarationOnNextLine: false 10 | AllowShortBlocksOnASingleLine: true 11 | AllowShortCaseLabelsOnASingleLine: false 12 | AllowShortFunctionsOnASingleLine: Inline 13 | AllowShortIfStatementsOnASingleLine: false 14 | AllowShortLoopsOnASingleLine: false 15 | AlwaysBreakAfterReturnType: None 16 | AlwaysBreakBeforeMultilineStrings: false 17 | AlwaysBreakTemplateDeclarations: true 18 | BinPackArguments: true 19 | BinPackParameters: true 20 | 21 | BreakBeforeBraces: Custom 22 | BraceWrapping: 23 | AfterClass: false 24 | AfterControlStatement: false 25 | AfterEnum: false 26 | AfterFunction: false 27 | AfterNamespace: false 28 | AfterStruct: false 29 | AfterUnion: false 30 | BeforeCatch: false 31 | BeforeElse: false 32 | IndentBraces: false 33 | 34 | BreakBeforeBinaryOperators: None 35 | BreakBeforeInheritanceComma: false 36 | BreakBeforeTernaryOperators: false 37 | BreakConstructorInitializers: AfterColon 38 | BreakStringLiterals: true 39 | ColumnLimit: 80 40 | CompactNamespaces: false 41 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 42 | ConstructorInitializerIndentWidth: 4 43 | ContinuationIndentWidth: 2 44 | Cpp11BracedListStyle: true 45 | DerivePointerBinding: false 46 | FixNamespaceComments: true 47 | IncludeCategories: 48 | - Regex: '^<.*>' 49 | Priority: 1 50 | - Regex: '.*' 51 | Priority: 2 52 | IndentCaseLabels: true 53 | IndentWidth: 2 54 | IndentWrappedFunctionNames: true 55 | KeepEmptyLinesAtTheStartOfBlocks: false 56 | MaxEmptyLinesToKeep: 2 57 | NamespaceIndentation: None 58 | PenaltyBreakAssignment: 120 59 | PenaltyBreakBeforeFirstCallParameter: 1 60 | PenaltyBreakComment: 60 61 | PenaltyBreakFirstLessLess: 120 62 | PenaltyBreakString: 1000 63 | PenaltyExcessCharacter: 1000000 64 | PenaltyReturnTypeOnItsOwnLine: 400 65 | PointerAlignment: Left 66 | ReflowComments: true 67 | SortIncludes: true 68 | SortUsingDeclarations: true 69 | SpaceAfterCStyleCast: false 70 | SpaceAfterTemplateKeyword: true 71 | SpaceBeforeAssignmentOperators: true 72 | SpaceBeforeParens: Never 73 | SpaceInEmptyParentheses: false 74 | SpacesBeforeTrailingComments: 2 75 | SpacesInAngles: false 76 | SpacesInCStyleCastParentheses: false 77 | SpacesInParentheses: false 78 | SpacesInSquareBrackets: false 79 | Standard: Cpp11 80 | TabWidth: 2 81 | UseTab: Never 82 | ... 83 | 84 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/ask-a-question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Ask a Question 3 | about: Having trouble with Scarab? Ask us anything! 4 | title: "[Question]" 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | 10 | Asking a question on the Scarab Issues page allows the entire Scarab community to benefit from the discussion. It also decreases response time as any of the Scarab administrators can answer these questions. 11 | 12 | Please type your questions here! 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/build-checkpoint-creator-loader.yml: -------------------------------------------------------------------------------- 1 | name: Build Checkpoint Creator and Loader 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build-checkpoint-creator: 11 | 12 | runs-on: ${{ matrix.os }} 13 | 14 | strategy: 15 | matrix: 16 | #os: [ubuntu-16.04, ubuntu-18.04, ubuntu-20.04] 17 | os: [ubuntu-18.04, ubuntu-20.04] 18 | gcc: [9] 19 | 20 | steps: 21 | - name: Install Scarab Dependencies 22 | id: install-scarab 23 | if: steps.cache-scarab-dep.outputs.cache-hit != 'true' 24 | uses: actions/checkout@v2 25 | with: 26 | path: scarab-dependencies 27 | repository: hpsresearchgroup/scarab-dependencies 28 | token: ${{ secrets.HPS_ACCESS_TOKEN }} 29 | env: 30 | PIN_ROOT: $(pwd)/scarab-dependencies/pinplay-drdebug-3.5-pin-3.5-97503-gac534ca30-gcc-linux 31 | 32 | # Check out scarab repo 33 | - uses: actions/checkout@v2 34 | with: 35 | path: scarab 36 | 37 | - name: Build Checkpoint Creator 38 | env: 39 | PIN_ROOT: ${{ github.workspace }}/scarab-dependencies/pinplay-drdebug-3.5-pin-3.5-97503-gac534ca30-gcc-linux 40 | run: | 41 | CC="gcc-${{ matrix.gcc }}" 42 | CXX="g++-${{ matrix.gcc }}" 43 | ${CC} --version 44 | ${CXX} --version 45 | CC=${CC} CXX=${CXX} make -C scarab/utils/checkpoint/creator/ 46 | 47 | - name: Build Checkpoint Loader 48 | run: | 49 | CC="gcc-${{ matrix.gcc }}" 50 | CXX="g++-${{ matrix.gcc }}" 51 | ${CC} --version 52 | ${CXX} --version 53 | make CC=${CC} CCC=${CXX} -C scarab/utils/checkpoint/loader/ 54 | -------------------------------------------------------------------------------- /.github/workflows/test-clang-format.yml: -------------------------------------------------------------------------------- 1 | name: test-clang-format 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | push: 8 | branches: 9 | - master 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v1 16 | - uses: DoozyX/clang-format-lint-action@v0.5 17 | with: 18 | source: '.' 19 | exclude: './src/ramulator' 20 | extensions: 'h,cpp,cc,c' 21 | clangFormatVersion: 5 22 | -------------------------------------------------------------------------------- /.github/workflows/test-make-release.yml: -------------------------------------------------------------------------------- 1 | name: make-release 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | push: 8 | branches: 9 | - master 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Check Cache for Scarab Dependencies 16 | id: cache-scarab-dep 17 | uses: actions/cache@v1 18 | env: 19 | cache-name: cache-scarab-dep 20 | with: 21 | path: scarab-dependencies 22 | key: scarab-dep-key 23 | 24 | - name: Install Scarab Dependencies 25 | id: install-scarab 26 | if: steps.cache-scarab-dep.outputs.cache-hit != 'true' 27 | uses: actions/checkout@v2 28 | with: 29 | path: scarab-dependencies 30 | repository: hpsresearchgroup/scarab-dependencies 31 | token: ${{ secrets.HPS_ACCESS_TOKEN }} 32 | env: 33 | PIN_ROOT: $(pwd)/scarab-dependencies/pinplay-drdebug-3.5-pin-3.5-97503-gac534ca30-gcc-linux 34 | 35 | - uses: actions/checkout@v2 36 | with: 37 | path: scarab 38 | - name: make release 39 | run: | 40 | make clean -C scarab/src 41 | make dbg -j -C scarab/src 42 | make opt -j -C scarab/src 43 | env: 44 | PIN_ROOT: ${{ github.workspace }}/scarab-dependencies/pinplay-drdebug-3.5-pin-3.5-97503-gac534ca30-gcc-linux 45 | 46 | # - name: test qsort 47 | # run: | 48 | # pip install -r scarab/bin/requirements.txt 49 | # cd scarab/utils/qsort; make; python3 scarab_test_qsort.py tmp 50 | # env: 51 | # PIN_ROOT: ${{ github.workspace }}/scarab-dependencies/pinplay-drdebug-3.5-pin-3.5-97503-gac534ca30-gcc-linux 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | syntax: regexp 2 | 3 | # Files matching these patterns will be ignored by hg 4 | # if they are not tracked already 5 | 6 | # experiment result directories 7 | out/ 8 | results/ 9 | rollups/ 10 | 11 | # intermediate compilation files 12 | *.o 13 | *.so 14 | *.a 15 | *.d 16 | *.dd 17 | *.aux 18 | *.bbl 19 | *.blg 20 | *.brf 21 | *.dvi 22 | *.log 23 | 24 | # Doxygen output 25 | ^doc/doxygen 26 | 27 | # binaries/compilation results 28 | build/ 29 | *.pdf 30 | *.ps 31 | *.pyc 32 | bin/Linux 33 | src/bin 34 | src/obj 35 | src/libcbp_inst/libcbp_inst.a 36 | src/libcbp_inst/predictor 37 | src/scarab 38 | src/gitrev 39 | src/ramulator/lib_opt 40 | src/ramulator/lib_dbg 41 | src/ramulator/lib_gpf 42 | utils/qsort/test_qsort 43 | 44 | # Emacs backup files 45 | *.~ 46 | 47 | # tags files 48 | TAGS 49 | 50 | # Hidden files usually should not be tracked 51 | ^\. 52 | .*.swp 53 | 54 | PARAMS.in 55 | src/pin/pin_trace/read 56 | src/test/PARAMS.in 57 | test_mem 58 | test_mem.c 59 | test_simd 60 | test_simd.c 61 | test_simd.dump 62 | test_simd_pinball/ 63 | test_string 64 | test_string.c 65 | test_string.dump 66 | test_string_pinball/ 67 | 68 | .vscode/* 69 | *.code-workspace 70 | .env 71 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/deps/mbuild"] 2 | path = src/deps/mbuild 3 | url = https://github.com/intelxed/mbuild.git 4 | [submodule "src/deps/xed"] 5 | path = src/deps/xed 6 | url = https://github.com/intelxed/xed.git 7 | [submodule "src/deps/dynamorio"] 8 | path = src/deps/dynamorio 9 | url = https://github.com/DynamoRIO/dynamorio.git 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 HPS/SAFARI Research Groups 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 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, 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, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /bin/power/README.md: -------------------------------------------------------------------------------- 1 | # Scarab Power Model 2 | 3 | ## Enabling Scarab Power Model 4 | ### 1. Download McPAT 5 | The scarab power model relies on McPAT. Scarab has been tested and works with McPAT v1.0, which 6 | can be found [here](http://www.hpl.hp.com/research/mcpat/). 7 | 8 | ### 2. Download CACTI 9 | The scarab power model relies on CACTI. Scarab has been tested and works with CACTI 6.5, which 10 | can be found [here](http://www.hpl.hp.com/research/cacti/). 11 | 12 | ### 3. Environment Variables 13 | Scarab uses ```MCPAT_BIN``` and ```CACTI_BIN``` to find McPat and CACTI binaries. You can use the following commands: 14 | >$ export MCPAT\_BIN=/mcpat 15 | >$ export CACTI\_BIN=/cacti 16 | 17 | By default, Scarab looks for McPat and CACTI binaries in the paths specified by ```__mcpat_bin__``` and ```__cacti_bin__```, which are defined in ```/bin/scarab_globals/scarab_paths.py```. Changing these variables is another way you can set the paths to the power tools. 18 | 19 | ### 4. Enabling Power Simulation 20 | ```power_intf_on``` enables the power simulation and it can be enabled in the PARAM file or in the command-line arguments when launching Scarab. 21 | 22 | 23 | ### 6. Enabling Dynamic Voltage-and-Frequency Scaling (DVFS): 24 | Scarab supports DVFS with the following changes to McPAT and CACTI. These changes are supplied in two patch files, mcpat.patch and cacti.patch. To apply the patches, first download McPAT and CACTI (follow the directions above), then apply the patches using as below. 25 | 26 | * McPat: 27 | 28 | >$ cd 29 | >$ patch -s -p2 < /bin/power/mcpat.patch 30 | >$ make -j 31 | 32 | * Cacti: 33 | 34 | >$ cd 35 | >$ patch -s -p2 < /bin/power/cacti.patch 36 | >$ make -j 37 | 38 | ## Power Model Flow 39 | Important power model files can be found under two directories: 40 | 1. ```/bin/power/``` 41 | 2. ```/src/power/``` 42 | -------------------------------------------------------------------------------- /bin/power/cacti.patch: -------------------------------------------------------------------------------- 1 | diff -ruN cacti65/io.cc ../cacti65/io.cc 2 | --- cacti65/io.cc 2009-12-25 10:16:58.000000000 -0600 3 | +++ ../cacti65/io.cc 2019-02-21 13:50:33.804812785 -0600 4 | @@ -1190,7 +1190,9 @@ 5 | cout << " Write ports: " << 6 | g_ip->num_wr_ports << endl;; 7 | cout << " Technology size (nm): " << 8 | - g_ip->F_sz_nm << endl << endl; 9 | + g_ip->F_sz_nm << endl; 10 | + cout << " Voltage (V): " << 11 | + g_tp.dram_cell_Vdd << endl << endl; 12 | 13 | cout << " Access time (ns): " << fr->access_time*1e9 << endl; 14 | cout << " Cycle time (ns): " << fr->cycle_time*1e9 << endl; 15 | -------------------------------------------------------------------------------- /bin/power/mcpat.patch: -------------------------------------------------------------------------------- 1 | diff -ruN mcpat/processor.cc ../mcpat_v1.0/processor.cc 2 | --- mcpat/processor.cc 2013-09-03 14:56:02.000000000 -0500 3 | +++ ../mcpat_v1.0/processor.cc 2019-02-21 13:14:39.358458138 -0600 4 | @@ -493,6 +493,8 @@ 5 | cout <=1.16.6 2 | scipy>=1.4.1 3 | pandas>=1.0.3 4 | pylint>=2.5.2 5 | pyparsing>=2.4.7 6 | python-dateutil>=2.8.1 7 | PyYAML>=5.4 8 | statistics>=1.0.3.5 9 | -------------------------------------------------------------------------------- /bin/run_clang_format_on_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCARAB_PATH="$(realpath $(dirname "${0}")/..)" 4 | 5 | echo $SCARAB_PATH 6 | for src_file in `find $SCARAB_PATH -regextype posix-extended -regex "$SCARAB_PATH/src/(deps|ramulator|build)" -prune -o -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h'`; do 7 | clang-format -i $src_file 8 | done 9 | -------------------------------------------------------------------------------- /bin/scarab_globals/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 HPS/SAFARI Research Groups 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 7 | # of the Software, and to permit persons to whom the Software is furnished to do 8 | # so, 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, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | from os.path import dirname, basename, isfile, join 22 | import glob 23 | modules = glob.glob(join(dirname(__file__), "*.py")) 24 | __all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')] 25 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | autogen-* 2 | doxygen 3 | _build 4 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | ROOT := .. 2 | 3 | .PHONY: all scarab-src qsort-example 4 | 5 | all: scarab-src qsort-example 6 | 7 | scarab-src: 8 | make docs -C $(ROOT)/src 9 | 10 | qsort-example: 11 | make html -C qsort-example-docs 12 | 13 | -------------------------------------------------------------------------------- /docs/common-problems.md: -------------------------------------------------------------------------------- 1 | # Common Problems 2 | ## MAPPING NEW INSTRUCTIONS 3 | 4 | Scarab was tested on a subset of the SPEC 2017 benchmarks. It is possible (and 5 | probably likely) that running on a new machine, using a different compiler, 6 | running a different region of a program, or running new programs will uncover 7 | unmapped instructions. 8 | 9 | Please see the [directions](../src/pin/pin_lib/README.md) to map new instructions. 10 | 11 | ## USING POWER MODEL 12 | > python ./bin/scarab_launch.py --program /bin/ls --scarab_args='--power_intf_on 1' 13 | 14 | Power and energy stats will be in the power.stat.out file. 15 | -------------------------------------------------------------------------------- /docs/compiling-scarab.md: -------------------------------------------------------------------------------- 1 | # Compiling Scarab 2 | 3 | Before compiling Scarab, the environment variable PIN_ROOT should be set to the 4 | path to your Intel PIN 3.5 directory. 5 | 6 | > export PIN_ROOT=/absolute/path/to/pin-3.5 7 | 8 | All of the Scarab source code is located in the src directory. 9 | 10 | To compile Scarab, use the following commands: 11 | > cd src 12 | 13 | > make 14 | 15 | This will make the optimized binary for Scarab. 16 | 17 | Alternatively, if you would like to generate the debugging binary for Scarab, 18 | use the following commands: 19 | > make dbg 20 | 21 | ## Other relevant pages 22 | 23 | For more information, please see our auto-generated 24 | [Makefile documentation.](autogen-scarab-makefile-docs.md) 25 | 26 | * Please run this command in the root directory to auto-generate documentation. 27 | > make -C docs 28 | -------------------------------------------------------------------------------- /docs/figures/scarab_bm_uml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hpsresearchgroup/scarab/5c58dea0766f9db9e17283760d017d70d7d07b37/docs/figures/scarab_bm_uml.png -------------------------------------------------------------------------------- /docs/memtrace.md: -------------------------------------------------------------------------------- 1 | # Memtrace Frontend 2 | 3 | Scarab supports simulating instruction and memory address traces in the memtrace format, 4 | obtained with dynamorio. Memtraces contain basic block (BBL) PC addresses of all executed 5 | BBLs and memory addresses of all instructions accessing main memory. To simulate a 6 | memtrace, scarab needs to be provided with the trace and a module.log file that contains 7 | the absolute paths to the traced binary and all referenced libraries. 8 | 9 | ##### Compiling the Memtrace Frontend 10 | 1. Install additional dependencies: snappy, dl, config++, z, rt, pthread 11 | 2. $ export SCARAB_ENABLE_MEMTRACE=1 12 | 3. $ make (from the main scarab directory) 13 | 14 | ##### Capturing Memtraces 15 | 1. Trace a workload 16 | $ /deps/dynamorio/bin64/drrun -c deps/dynamorio/clients/lib64/release/libdrmemtrace.so -offline -trace_after_instrs 1M -exit_after_tracing 1G -- 17 | 2. Copy binaries and shared libs and convert trace 18 | $ sh run_portabilize_trace.sh (run from the directory that contains the drmemtrace.* directory). 19 | 3. Fix absolute paths in modules.log (needs to be performed whenever the bin directory is moved) 20 | $ sh run_update_trace.sh 21 | 22 | ##### Simulating Memtraces with Scarab 23 | $ scarab 24 | --frontend memtrace --fetch_off_path_ops 0 25 | --cbp_trace_r0= 26 | --memtrace_modules_log= 27 | -------------------------------------------------------------------------------- /docs/pin-frontend.md: -------------------------------------------------------------------------------- 1 | 2 | Scarab is an execute-at-fetch model simulator. That is to say, a functional 3 | model executes each instruction before it is fetched. We refer to the function 4 | simulator model as the 'frontend'. PIN serves as the frontend functional 5 | simulator for Scarab. 6 | 7 | Once instructions have been fetched and processed by the frontend functional 8 | model, they are passed to Scarab to simulate timing. 9 | 10 | Due to limitations with PIN, we chose to seperate PIN and Scarab in 11 | seperate processes, so that they can be compiled completely independently from 12 | one another. For each core in Scarab, a new PIN process is created in addition 13 | to the scarab process. In other words, if a 4-core simulation is run, the 4 PIN 14 | processes will be created, in addition to a single Scarab process, making there 15 | 5 processes total. 16 | 17 | The easiest way to launch scarab is though the scarab_launch.py script, 18 | provided in the bin directory. 19 | 20 | 21 | ## 5.0 EXECUTION-DRIVEN FRONTEND 22 | 23 | The execution-driven frontend supports wrong-path execution, making it Scarabs 24 | most detailed simulation mode. It is, however, much slower than the trace 25 | frontend. 26 | 27 | Using the script scarab_launch.py, located in the bin directory, is the 28 | simplest way to run the execution-driven frontend. Please see the directions 29 | above. 30 | 31 | ## 6.0 TRACE FRONTEND 32 | 33 | The trace frontend is run in two phases. 34 | 35 | During the first phase, PIN is used to generate a trace of the program. During 36 | the second phase, Scarab reads and processes the trace. 37 | 38 | The trace frontend is not currently supported by the scarab_launch.py script. 39 | Both the trace creation and Scarab phases must be run by-hand. 40 | -------------------------------------------------------------------------------- /docs/qsort-example-docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | clean: 16 | -rm -r _build 17 | 18 | .PHONY: help Makefile 19 | 20 | # Catch-all target: route all unknown targets to Sphinx using the new 21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 22 | %: Makefile 23 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 24 | -------------------------------------------------------------------------------- /docs/qsort-example-docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | import os 14 | import sys 15 | sys.path.insert(0, os.path.abspath('../../utils')) 16 | 17 | 18 | # -- Project information ----------------------------------------------------- 19 | 20 | project = 'Quick Sort Example' 21 | copyright = '2020, HPS/SAFARI' 22 | author = 'HPS/SAFARI' 23 | 24 | 25 | # -- General configuration --------------------------------------------------- 26 | 27 | # Add any Sphinx extension module names here, as strings. They can be 28 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 29 | # ones. 30 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.napoleon'] 31 | 32 | # Add any paths that contain templates here, relative to this directory. 33 | templates_path = ['_templates'] 34 | 35 | # List of patterns, relative to source directory, that match files and 36 | # directories to ignore when looking for source files. 37 | # This pattern also affects html_static_path and html_extra_path. 38 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 39 | 40 | 41 | # -- Options for HTML output ------------------------------------------------- 42 | 43 | # The theme to use for HTML and HTML Help pages. See the documentation for 44 | # a list of builtin themes. 45 | # 46 | html_theme = 'alabaster' 47 | 48 | # Add any paths that contain custom static files (such as style sheets) here, 49 | # relative to this directory. They are copied after the builtin static files, 50 | # so a file named "default.css" will overwrite the builtin "default.css". 51 | html_static_path = [] 52 | -------------------------------------------------------------------------------- /docs/qsort-example-docs/index.rst: -------------------------------------------------------------------------------- 1 | Quick Sort Example 2 | ================== 3 | 4 | .. automodule:: qsort.scarab_test_qsort 5 | :members: 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | :caption: Contents: 10 | 11 | 12 | 13 | Indices and tables 14 | ================== 15 | 16 | * :ref:`genindex` 17 | * :ref:`modindex` 18 | * :ref:`search` 19 | -------------------------------------------------------------------------------- /docs/qsort-example-docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/running-scarab.md: -------------------------------------------------------------------------------- 1 | # Running A Single Program on Scarab 2 | 3 | ## Running QSORT 4 | 5 | > Note: before running Scarab, please ensure that you have installed all 6 | required software packed shown on the [system requirements](system_requirements.md) page. 7 | 8 | We will start off by running the ```qsort``` example on Scarab. 9 | 10 | 11 | 12 | ### Running a complete program 13 | > python ./bin/scarab_launch.py --program /bin/ls --param src/PARAMS.in 14 | 15 | ### Fast forwarding to a simpoint 16 | > python ./bin/scarab_launch.py --program /bin/ls --pintool_args='-hyper_fast_forward_count 100000' 17 | 18 | ### Starting from a checkpoint of a simpoint 19 | 20 | This feature is not yet supported. 21 | 22 | ### Running with an instruction limit 23 | > python ./bin/scarab_launch.py --program /bin/ls --pintool_args='-hyper_fast_forward_count 100000' --scarab_args='--inst_limit 1000' 24 | 25 | ## The Params File 26 | 27 | In order to run scarab, the user must specify a param file that configures all 28 | of the parameters in Scarab. 29 | 30 | Scarab parameters are specified in 1 of 3 ways. The first, by the default value 31 | specified in the parameter definition files (src/*.param.def). The second, by 32 | speficing a PARAMS.in file, which must be located in the same directory Scarab 33 | is running. The third, by any command line arguements passed to Scarab. 34 | 35 | -------------------------------------------------------------------------------- /docs/system_requirements.md: -------------------------------------------------------------------------------- 1 | # SYSTEM REQUIREMENTS 2 | 3 | Please be sure that your system meets these minimum software prerequisits 4 | before running Scarab. Below are the packages that we use to run Scarab. 5 | Other versions of the same software may work, but have not been tested. 6 | 7 | Scarab relies on the following software packages: 8 | 9 | ## Required Packages 10 | * [Intel PIN (see below)](#tested-intel-pin-versions) 11 | * g++ 7.3.1 12 | * gcc 7.3.1 13 | * Clang 5.0.1 14 | * Python 3.6.3 15 | * [Intel XED 12.01](https://github.com/intelxed/xed/releases) (included as a git submodule) 16 | 17 | ## Tested Intel PIN versions: 18 | * [PIN-Play 3.5](https://software.intel.com/en-us/articles/program-recordreplay-toolkit) 19 | * [PIN 3.15](https://www.intel.com/content/www/us/en/developer/articles/tool/pin-a-binary-instrumentation-tool-downloads.html) 20 | 21 | Note: Our checkpoint creater scripts only work with PIN-Play currently (due to a despendency with their simpoint scripts). 22 | 23 | ## Required Python Packages 24 | See `$SCARAB_ROOT/bin/requirements.txt` 25 | 26 | ##### E.g. Install with pip: 27 | ``` 28 | cd $SCARAB_ROOT/bin 29 | pip3 install -r requirements.txt 30 | ``` 31 | 32 | # Other Useful Packages 33 | 34 | ## If Running GTest 35 | * GTest 1.6 36 | 37 | ## If Using Power Model 38 | * Perl 5 v5.16.3 39 | * [McPAT v1.0](http://www.hpl.hp.com/research/mcpat/) 40 | * [CACTI 6.5](http://www.hpl.hp.com/research/cacti/) 41 | 42 | Note: Lower or higher versions of the above software may work, but have not been tested. 43 | -------------------------------------------------------------------------------- /docs/verification.md: -------------------------------------------------------------------------------- 1 | # Verification Tools 2 | 3 | Below are a set of resources intended to let you know that Scarab has been installed properly on your system. 4 | 5 | In addition, as you modify Scarab for your own research, you may be able to use these tests to verify that Scarab's base functionality has remained unchaged. 6 | 7 | # Sanity Checks 8 | 9 | ### **Run QSORT to verify Scarab produces stats similar to golden stat files** 10 | 11 | ./utils/qsort includes a small test program for running libc's qsort() on 12 | random data that we use for sanity checks. To run it, use: 13 | 14 | > python ./bin/scarab_test_qsort.py path_to_results_directory 15 | gg 16 | ./utils/qsort/ref_stats includes sample stats that you can use for sanity 17 | checks. The exact statistics are unlikely to match with the reference stats 18 | because the produced binary is compiler-dependent. 19 | 20 | # Automatic Verification Tools 21 | 22 | Coming Soon! -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | 3 | project(scarab C CXX ASM) 4 | 5 | set(CMAKE_C_STANDARD 99) 6 | set(CMAKE_CXX_STANDARD 14) 7 | set(CMAKE_C_STANDARD_REQUIRED ON) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | 10 | set(enable_memtrace 0) 11 | set(flags_enable_memtrace "") 12 | 13 | if(DEFINED ENV{SCARAB_ENABLE_MEMTRACE}) 14 | set(flags_enable_memtrace "-DENABLE_MEMTRACE") 15 | endif() 16 | 17 | set(CMAKE_C_FLAGS_SCARABOPT "-O3 -DNO_DEBUG -DLINUX -DX86_64 ${flags_enable_memtrace}") 18 | set(CMAKE_CXX_FLAGS_SCARABOPT "-O3 -DNO_DEBUG -DLINUX -DX86_64 ${flags_enable_memtrace}") 19 | set(CMAKE_C_FLAGS_VALGRIND "-O0 -g3 -DLINUX -DX86_64 ${flags_enable_memtrace}") 20 | set(CMAKE_CXX_FLAGS_VALGRIND "-O0 -g3 -DLINUX -DX86_64 ${flags_enable_memtrace}") 21 | set(CMAKE_C_FLAGS_GPROF "${CMAKE_CXX_FLAGS_SCARABOPT} -pg -g3 ${flags_enable_memtrace}") 22 | set(CMAKE_CXX_FLAGS_GPROF "${CMAKE_CXX_FLAGS_SCARABOPT} -pg -g3 ${flags_enable_memtrace}") 23 | 24 | #build dependencies with default warn flags, otherwise dynamorio will not build 25 | add_subdirectory(deps) 26 | 27 | set(warn_flags -Wall -Wunused -Wno-long-long 28 | -Wpointer-arith 29 | -Werror) 30 | set(warn_c_flags ${warn_flags} 31 | -Wmissing-declarations 32 | -Wmissing-prototypes 33 | -Wimplicit -Wno-unused-but-set-variable -Wno-maybe-uninitialized) 34 | set(warn_cxx_flags ${warn_flags}) 35 | 36 | add_compile_options( 37 | "$<$:${warn_c_flags}>" 38 | "$<$:${warn_cxx_flags}>" 39 | ) 40 | 41 | add_subdirectory(ramulator) 42 | add_subdirectory(pin/pin_lib) 43 | add_subdirectory(pin/pin_exec/testing) 44 | 45 | set(scarab_dirs bp debug bp/template_lib dvfs frontend globals isa libs memory power prefetcher .) 46 | if(DEFINED ENV{SCARAB_ENABLE_MEMTRACE}) 47 | set(scarab_dirs ${scarab_dirs} frontend/memtrace) 48 | endif() 49 | 50 | set(srcs) 51 | foreach(dir IN LISTS scarab_dirs) 52 | file(GLOB dir_srcs 53 | ${dir}/*.h 54 | ${dir}/*.cc 55 | ${dir}/*.c 56 | ) 57 | set(srcs ${srcs} ${dir_srcs}) 58 | endforeach() 59 | 60 | add_executable(scarab 61 | ${srcs} 62 | ) 63 | 64 | target_include_directories(scarab PRIVATE .) 65 | 66 | target_link_libraries(scarab 67 | PRIVATE 68 | ramulator 69 | pin_lib_for_scarab 70 | ) 71 | if(DEFINED ENV{SCARAB_ENABLE_MEMTRACE}) 72 | target_link_libraries(scarab PRIVATE dynamorio memtrace) 73 | endif() 74 | -------------------------------------------------------------------------------- /src/addr_trans.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : addr_trans.h 24 | * Author : HPS Research Group 25 | * Date : 10/28/2012 26 | * Description : "Fake" virtual to physical address translation. Uses a hash 27 | *function, and does not maintain page tables. Used to randomize DRAM bank 28 | *mappings. 29 | ***************************************************************************************/ 30 | 31 | #ifndef __ADDR_TRANS_H__ 32 | #define __ADDR_TRANS_H__ 33 | 34 | #include "globals/enum.h" 35 | #include "globals/global_types.h" 36 | 37 | /**************************************************************************************/ 38 | /* Types */ 39 | 40 | #define ADDR_TRANSLATION_LIST(elem) \ 41 | elem(NONE) elem(FLIP) elem(RANDOM) elem(PRESERVE_BLP) elem(PRESERVE_STREAM) 42 | 43 | DECLARE_ENUM(Addr_Translation, ADDR_TRANSLATION_LIST, ADDR_TRANS_); 44 | 45 | /**************************************************************************************/ 46 | /* Prototypes */ 47 | 48 | Addr addr_translate(Addr virt_addr); 49 | 50 | #endif // __ADDR_TRANS_H__ 51 | -------------------------------------------------------------------------------- /src/bp/bp.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : bp/bp.param.h 24 | * Author : HPS Research Group 25 | * Date : 12/10/1998 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __BP_PARAM_H__ 30 | #define __BP_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in core.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "bp/bp.param.def" 41 | #undef DEF_PARAM 42 | 43 | extern Flag USE_LATE_BP; 44 | 45 | /**************************************************************************************/ 46 | 47 | #endif /* #ifndef __BP.PARAM_H__ */ 48 | -------------------------------------------------------------------------------- /src/bp/cbp_table.def: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cbp_table.def 3 | * @author Stephen Pruett (stephen.pruett@utexas.edu) 4 | * @brief 5 | * @version 0.1 6 | * @date 2021-01-12 7 | * 8 | * Usage: 9 | * Add your CBP predictor below, as indicated by the example. 10 | * 11 | * Example: 12 | * DEF_CBP("predictor_name", PREDICTOR_CLASS) 13 | */ 14 | 15 | DEF_CBP("mtage", MTAGE) -------------------------------------------------------------------------------- /src/bp/gshare.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __GSHARE_H__ 23 | #define __GSHARE_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include "bp/bp.h" 30 | 31 | /*************Interface to Scarab***************/ 32 | void bp_gshare_init(void); 33 | void bp_gshare_timestamp(Op*); 34 | uns8 bp_gshare_pred(Op*); 35 | void bp_gshare_spec_update(Op*); 36 | void bp_gshare_update(Op*); 37 | void bp_gshare_retire(Op*); 38 | void bp_gshare_recover(Recovery_Info*); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | 45 | #endif // __GSHARE_H__ 46 | -------------------------------------------------------------------------------- /src/bp/hybridgp.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __HYBRIDGP_H__ 23 | #define __HYBRIDGP_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include "bp/bp.h" 30 | 31 | /*************Interface to Scarab***************/ 32 | void bp_hybridgp_init(void); 33 | void bp_hybridgp_timestamp(Op*); 34 | uns8 bp_hybridgp_pred(Op*); 35 | void bp_hybridgp_spec_update(Op*); 36 | void bp_hybridgp_update(Op*); 37 | void bp_hybridgp_retire(Op*); 38 | void bp_hybridgp_recover(Recovery_Info*); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif // __HYBRIDGP_H__ 45 | -------------------------------------------------------------------------------- /src/bp/tagescl.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __TAGESCL_H_ 23 | #define __TAGESCL_H_ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include "bp/bp.h" 30 | 31 | /*************Interface to Scarab***************/ 32 | void bp_tagescl_init(); 33 | void bp_tagescl_timestamp(Op* op); 34 | uns8 bp_tagescl_pred(Op*); 35 | void bp_tagescl_spec_update(Op* op); 36 | void bp_tagescl_update(Op* op); 37 | void bp_tagescl_retire(Op* op); 38 | void bp_tagescl_recover(Recovery_Info*); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/cmp_model_support.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : cmp_model_support.h 24 | * Author : HPS Research Group 25 | * Date : 11/27/2006 26 | * Description : CMP with runahead 27 | ***************************************************************************************/ 28 | 29 | 30 | #ifndef __CMP_MODEL_SUPPORT_H__ 31 | #define __CMP_MODEL_SUPPORT_H__ 32 | 33 | #include "globals/global_types.h" 34 | 35 | /**************************************************************************************/ 36 | /* Prototypes */ 37 | 38 | void cmp_init_cmp_model(void); 39 | void cmp_init_thread_data(uns8); 40 | void cmp_set_all_stages(uns8); 41 | void cmp_init_bogus_sim(uns8); 42 | /**************************************************************************************/ 43 | /* External variables */ 44 | 45 | #endif /* #ifndef __CMP_MODEL_SUPPORT_H__ */ 46 | -------------------------------------------------------------------------------- /src/core.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : core.param.h 24 | * Author : HPS Research Group 25 | * Date : 9/18/1998 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __CORE_PARAM_H__ 30 | #define __CORE_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in core.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "core.param.def" 41 | #undef DEF_PARAM 42 | 43 | /* The values of these parameters are computed from other parameters*/ 44 | extern uns NUM_FUS; 45 | extern uns NUM_RS; 46 | extern uns POWER_TOTAL_RS_SIZE; 47 | extern uns POWER_TOTAL_INT_RS_SIZE; 48 | extern uns POWER_TOTAL_FP_RS_SIZE; 49 | extern uns POWER_NUM_ALUS; 50 | extern uns POWER_NUM_MULS_AND_DIVS; 51 | extern uns POWER_NUM_FPUS; 52 | 53 | /**************************************************************************************/ 54 | 55 | #endif /* #ifndef __CORE_PARAM_H__ */ 56 | -------------------------------------------------------------------------------- /src/debug/debug.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : debug/debug.param.h 24 | * Author : HPS Research Group 25 | * Date : 9/22/1998 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __DEBUG_PARAM_H__ 30 | #define __DEBUG_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in core_param_def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "debug/debug.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __DEBUG_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/debug/pipeview.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : debug/pipeview.h 24 | * Author : HPS Research Group 25 | * Date : 4/24/2012 26 | * Description : Pipeline visualization tracing. 27 | ***************************************************************************************/ 28 | 29 | #ifndef __PIPEVIEW_H__ 30 | #define __PIPEVIEW_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | /**************************************************************************************/ 35 | /* Forward declarations */ 36 | 37 | struct Op_struct; 38 | 39 | /**************************************************************************************/ 40 | /* Prototypes */ 41 | 42 | /* Initialize pipeline visualization */ 43 | void pipeview_init(void); 44 | 45 | /* Print an op (when it's freed) */ 46 | void pipeview_print_op(struct Op_struct* op); 47 | 48 | /* Clean up pipeline visualization */ 49 | void pipeview_done(void); 50 | 51 | /*************************************************************/ 52 | 53 | #endif /* __PIPEVIEW_H__*/ 54 | -------------------------------------------------------------------------------- /src/deps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Git) 2 | if(GIT_FOUND) 3 | execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive 4 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/.. 5 | RESULT_VARIABLE GIT_SUBMOD_RESULT) 6 | if(NOT GIT_SUBMOD_RESULT EQUAL "0") 7 | message(FATAL_ERROR "Updating git submodules failed: ${GIT_SUBMOD_RESULT}") 8 | endif() 9 | else() 10 | message(FATAL_ERROR "Could not find git binary in the system") 11 | endif() 12 | 13 | find_package(Python3) 14 | if(Python3_FOUND) 15 | execute_process( 16 | COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/xed/mfile.py 17 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/xed" 18 | COMMAND_ECHO STDOUT 19 | ) 20 | else() 21 | message(FATAL_ERROR "Could not find python3 in the system") 22 | endif() 23 | 24 | set($ENV{TARGET} ia32) 25 | add_library(xed INTERFACE) 26 | target_include_directories(xed INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/xed/include/public/xed/) 27 | target_include_directories(xed INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/xed/obj/) 28 | target_link_libraries(xed INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/xed/obj/libxed.a) 29 | 30 | if(DEFINED ENV{SCARAB_ENABLE_MEMTRACE}) 31 | add_subdirectory(dynamorio) 32 | add_library(memtrace INTERFACE) 33 | 34 | target_include_directories(memtrace 35 | INTERFACE 36 | ${CMAKE_BINARY_DIR}/deps/dynamorio/include/ 37 | ${CMAKE_CURRENT_SOURCE_DIR}/dynamorio/ext/drcovlib/ 38 | ${CMAKE_CURRENT_SOURCE_DIR}/dynamorio/ext/drmgr/ 39 | ${CMAKE_CURRENT_SOURCE_DIR}/dynamorio/ext/drcontainers/ 40 | ${CMAKE_CURRENT_SOURCE_DIR}/dynamorio/core/lib/ 41 | ${CMAKE_CURRENT_SOURCE_DIR}/dynamorio/clients/drcachesim/reader/ 42 | ${CMAKE_CURRENT_SOURCE_DIR}/dynamorio/clients/drcachesim/common/ 43 | ${CMAKE_CURRENT_SOURCE_DIR}/dynamorio/clients/drcachesim/tracer/ 44 | ${CMAKE_CURRENT_SOURCE_DIR}/dynamorio/clients/drcachesim/ 45 | ) 46 | 47 | target_link_libraries(memtrace 48 | INTERFACE 49 | drmemtrace_raw2trace 50 | directory_iterator 51 | drfrontendlib 52 | drutil_static 53 | drmgr_static 54 | drmemfuncs 55 | dynamorio_static 56 | drlibc 57 | drcovlib_static 58 | drx_static 59 | drreg_static 60 | drcontainers 61 | drmemtrace_analyzer 62 | xed 63 | snappy 64 | dl 65 | config++ 66 | z 67 | rt 68 | pthread 69 | ) 70 | endif() 71 | -------------------------------------------------------------------------------- /src/dram_sched_table.def: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 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 7 | * of the Software, and to permit persons to whom the Software is furnished to do 8 | * so, 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : dram_sched_table.def 24 | * Author : HPS Research Group 25 | * Date : 10/25/2012 26 | * Description : Dram schedulers table. 27 | ***************************************************************************************/ 28 | 29 | // Format: enum name, text name, function name prefix 30 | DRAM_SCHED_IMPL(ATLAS, "atlas", atlas) 31 | DRAM_SCHED_IMPL(BATCH, "batch", batch_sched) 32 | DRAM_SCHED_IMPL(BW, "bw", bw_sched) 33 | DRAM_SCHED_IMPL(BW_PART, "bw_part", dram_bw_part) 34 | DRAM_SCHED_IMPL(EQUAL_USE, "equal_use", equal_use) 35 | DRAM_SCHED_IMPL(MP_PERF_PRED, "mp_perf_pred", dram_mp_perf_pred) 36 | DRAM_SCHED_IMPL(PRIORITY, "priority", pri_dram_sched) 37 | DRAM_SCHED_IMPL(SHARING, "sharing", dram_mp_sharing) 38 | DRAM_SCHED_IMPL(TCM, "tcm", tcm_sched) 39 | DRAM_SCHED_IMPL(PROB_PRIORITY, "prob_priority", prob_pri_sched) 40 | DRAM_SCHED_IMPL(FAIR_QUEUING, "fair_queuing", fair_queuing) 41 | DRAM_SCHED_IMPL(FAIR_QUEUING_2LEVEL, "fair_queuing_2level", fair_queuing_2level) 42 | -------------------------------------------------------------------------------- /src/dumb_model.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : dumb_model.h 24 | * Author : HPS Research Group 25 | * Date : 7/23/2013 26 | * Description : Model that drives the memory system with randomly 27 | * generated memory requests (no core modeling) 28 | ***************************************************************************************/ 29 | 30 | #ifndef __DUMB_MODEL_H__ 31 | #define __DUMB_MODEL_H__ 32 | 33 | #include "memory/memory.h" 34 | 35 | /**************************************************************************************/ 36 | /* dumb model data */ 37 | 38 | typedef struct Dumb_Model_struct { 39 | Memory memory; 40 | } Dumb_Model; 41 | 42 | /**************************************************************************************/ 43 | /* Global vars */ 44 | 45 | Dumb_Model dumb_model; 46 | extern Dumb_Model dumb_model; 47 | 48 | /**************************************************************************************/ 49 | /* Prototypes */ 50 | 51 | void dumb_init(uns mode); 52 | void dumb_reset(void); 53 | void dumb_cycle(void); 54 | void dumb_debug(void); 55 | void dumb_done(void); 56 | 57 | 58 | /**************************************************************************************/ 59 | 60 | #endif /* #ifndef __DUMB_MODEL_H__ */ 61 | -------------------------------------------------------------------------------- /src/dvfs/dvfs.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : dvfs.h 24 | * Author : HPS Research Group 25 | * Date : 3/28/2012 26 | * Description : DVFS controller 27 | ***************************************************************************************/ 28 | 29 | #ifndef __DVFS_H__ 30 | #define __DVFS_H__ 31 | 32 | #include "globals/enum.h" 33 | 34 | /**************************************************************************************/ 35 | /* Enumerations */ 36 | 37 | #define DVFS_METRIC_LIST(elem) elem(DELAY) elem(ENERGY) elem(EDP) elem(ED2) 38 | 39 | DECLARE_ENUM(DVFS_Metric, DVFS_METRIC_LIST, DVFS_METRIC_); 40 | 41 | /**************************************************************************************/ 42 | /* Prototypes */ 43 | 44 | /* Initialization */ 45 | void dvfs_init(void); 46 | 47 | /* Call at the end of every cycle to make DVFS controller work */ 48 | void dvfs_cycle(void); 49 | 50 | /* Done */ 51 | void dvfs_done(void); 52 | 53 | #endif /* #ifndef __DVFS_H__ */ 54 | -------------------------------------------------------------------------------- /src/dvfs/dvfs.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : dvfs/dvfs.param.h 24 | * Author : HPS Research Group 25 | * Date : 3/29/2012 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __DVFS_PARAM_H__ 30 | #define __DVFS_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in dvfs/dvfs.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "dvfs/dvfs.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __DVFS_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/dvfs/power_pred.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : dvfs/power_pred.h 24 | * Author : HPS Research Group 25 | * Date : 05/19/2012 26 | * Description : Power prediction for DVFS 27 | ***************************************************************************************/ 28 | 29 | #ifndef __POWER_PRED_H__ 30 | #define __POWER_PRED_H__ 31 | 32 | #include "globals/global_defs.h" 33 | #include "globals/global_types.h" 34 | 35 | /**************************************************************************************/ 36 | /* Prototypes */ 37 | 38 | /* Return predicted normalized power for the provided core and memory 39 | cycle times, memory access fractions, and the predicted slowdown of each core 40 | */ 41 | double power_pred_norm_power(uns* core_cycle_times, uns memory_cycle_time, 42 | double* memory_access_fracs, double* slowdowns); 43 | 44 | #endif // __POWER_PRED_H__ 45 | -------------------------------------------------------------------------------- /src/exec_ports.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : exec_ports.h 24 | * Author : HPS Research Group 25 | * Date : 1/9/18 26 | * Description : Defines the macros used in the exec_ports.def file 27 | ***************************************************************************************/ 28 | 29 | #ifndef __EXEC_PORTS_H__ 30 | #define __EXEC_PORTS_H__ 31 | 32 | #include "table_info.h" 33 | 34 | /**************************************************************************************/ 35 | /* Type Declarations */ 36 | void init_exec_ports(uns8, const char*); 37 | 38 | typedef enum Power_FU_Type_enum { 39 | POWER_FU_ALU, 40 | POWER_FU_MUL_DIV, 41 | POWER_FU_FPU 42 | } Power_FU_Type; 43 | 44 | Power_FU_Type power_get_fu_type(Op_Type op_type, Flag is_simd); 45 | uns64 get_fu_type(Op_Type op_type, Flag is_simd); 46 | 47 | #endif /* #ifndef __EXEC_PORTS_H__ */ 48 | -------------------------------------------------------------------------------- /src/frontend/frontend_intf.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : frontend/frontend_intf.c 24 | * Author : HPS Research Group 25 | * Date : 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #include "frontend/frontend_intf.h" 30 | #include "general.param.h" 31 | #include "globals/global_defs.h" 32 | 33 | /* Include headers of all the implementations here */ 34 | #include "frontend/pin_exec_driven_fe.h" 35 | #include "frontend/pin_trace_fe.h" 36 | 37 | #ifdef ENABLE_MEMTRACE 38 | #include "frontend/memtrace/memtrace_fe.h" 39 | #endif 40 | 41 | Frontend_Impl frontend_table[] = { 42 | #define FRONTEND_IMPL(id, name, prefix) \ 43 | {name, \ 44 | prefix##_next_fetch_addr, \ 45 | prefix##_can_fetch_op, \ 46 | prefix##_fetch_op, \ 47 | prefix##_redirect, \ 48 | prefix##_recover, \ 49 | prefix##_retire}, 50 | #include "frontend/frontend_table.def" 51 | #undef FRONTEND_IMPL 52 | }; 53 | 54 | Frontend_Impl* frontend = NULL; 55 | 56 | void frontend_intf_init() { 57 | frontend = &frontend_table[FRONTEND]; 58 | } 59 | -------------------------------------------------------------------------------- /src/frontend/frontend_table.def: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 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 7 | * of the Software, and to permit persons to whom the Software is furnished to do 8 | * so, 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : frontend/frontend_table.def 24 | * Author : HPS Research Group 25 | * Date : 12/12/2011 26 | * Description : Frontend implementations. 27 | ***************************************************************************************/ 28 | 29 | // Format: enum name, text name, function name prefix 30 | FRONTEND_IMPL(PIN_EXEC_DRIVEN, "pin_exec_driven", pin_exec_driven) 31 | FRONTEND_IMPL(TRACE, "trace", trace) 32 | #ifdef ENABLE_MEMTRACE 33 | FRONTEND_IMPL(MEMTRACE, "memtrace", memtrace) 34 | #endif -------------------------------------------------------------------------------- /src/frontend/pin_trace_fe.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : frontend/pin_trace_fe.h 24 | * Author : HSP Research Group 25 | * Date : 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __PIN_TRACE_FE_H__ 30 | #define __PIN_TRACE_FE_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | /**************************************************************************************/ 35 | /* Forward Declarations */ 36 | 37 | struct Trace_Uop_struct; 38 | typedef struct Trace_Uop_struct Trace_Uop; 39 | struct Op_struct; 40 | 41 | /**************************************************************************************/ 42 | /* Prototypes */ 43 | 44 | void trace_init(void); 45 | 46 | /* Implementing the frontend interface */ 47 | Addr trace_next_fetch_addr(uns proc_id); 48 | Flag trace_can_fetch_op(uns proc_id); 49 | void trace_fetch_op(uns proc_id, Op* op); 50 | void trace_redirect(uns proc_id, uns64 inst_uid, Addr fetch_addr); 51 | void trace_recover(uns proc_id, uns64 inst_uid); 52 | void trace_retire(uns proc_id, uns64 inst_uid); 53 | 54 | /* For restarting of traces */ 55 | void trace_done(void); 56 | void trace_close_trace_file(uns proc_id); 57 | void trace_setup(uns proc_id); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/frontend/pin_trace_read.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : frontend/pin_trace_read.h 24 | * Author : HPS Research Group 25 | * Date : 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __PIN_TRACE_READ_H__ 30 | #define __PIN_TRACE_READ_H__ 31 | 32 | #include "ctype_pin_inst.h" 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void pin_trace_file_pointer_init(unsigned char); 39 | int pin_trace_read(unsigned char, ctype_pin_inst*); 40 | void pin_trace_open(unsigned char, const char*); 41 | void pin_trace_close(unsigned char); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/general.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : general.param.h 24 | * Author : HPS Research Group 25 | * Date : 9/18/1998 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __GENERAL_PARAM_H__ 30 | #define __GENERAL_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in core.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "general.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __GENERAL_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/globals/param_enum_headers.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : param_globals/enum.headers.h 24 | * Author : HPS Research Group 25 | * Date : 4/11/2012 26 | * Description : Combined file that declares all enums used as parameter types. 27 | ***************************************************************************************/ 28 | 29 | /* To use an enum as a parameter type, you must include the header 30 | file declaring that enum in this file */ 31 | 32 | #ifndef __PARAM_ENUM_HEADERS_H__ 33 | #define __PARAM_ENUM_HEADERS_H__ 34 | 35 | #include "addr_trans.h" 36 | #include "dvfs/dvfs.h" 37 | #include "dvfs/perf_pred.h" 38 | #include "frontend/frontend_intf.h" 39 | #include "memory/cache_part.h" 40 | 41 | #endif // __PARAM_ENUM_HEADERS_H__ 42 | -------------------------------------------------------------------------------- /src/inst.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : inst.param.h 24 | * Author : HPS Research Group 25 | * Date : 3/28/2000 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __INST_PARAM_H__ 30 | #define __INST_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in inst.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "inst.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __INST_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/isa/isa.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : isa/isa.c 24 | * Author : HPS Research Group 25 | * Date : 3/20/2012 26 | * Description : ISA definitions (currently just registers) 27 | ***************************************************************************************/ 28 | 29 | //#include "globals/assert.h" 30 | #include "isa/isa.h" 31 | #include 32 | 33 | #define REG(x) #x, 34 | static char* reg_names[NUM_REGS] = { 35 | #include "isa/x86_regs.def" 36 | }; 37 | #undef REG 38 | 39 | char* disasm_reg(Reg_Id reg_id) { 40 | assert(reg_id < NUM_REGS); 41 | return reg_names[reg_id]; 42 | } 43 | -------------------------------------------------------------------------------- /src/isa/isa.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : isa/isa.h 24 | * Author : HPS Research Group 25 | * Date : 3/20/2012 26 | * Description : ISA definitions (currently just registers) 27 | ***************************************************************************************/ 28 | 29 | #ifndef __ISA_H__ 30 | #define __ISA_H__ 31 | 32 | #define REG(x) REG_##x, 33 | typedef enum Reg_Id_struct { 34 | #include "isa/x86_regs.def" 35 | NUM_REGS 36 | } Reg_Id; 37 | #undef REG 38 | 39 | char* disasm_reg(Reg_Id reg_id); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/libs/malloc_lib.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : libs/malloc_lib.h 24 | * Author : HPS Research Group 25 | * Date : 3/14/2000 26 | * Description : A faster malloc for small repetitive allocations 27 | ***************************************************************************************/ 28 | 29 | #ifndef __MALLOC_LIB_H__ 30 | #define __MALLOC_LIB_H__ 31 | 32 | typedef struct SMalloc_Raw_struct { 33 | char* ptr; 34 | int cur_size; 35 | } SMalloc_Raw; 36 | 37 | typedef struct SMalloc_Entry_struct { 38 | void* data; 39 | struct SMalloc_Entry_struct* next; 40 | } SMalloc_Entry; 41 | 42 | void* smalloc(int nbytes); 43 | void sfree(int nbytes, void* item); 44 | 45 | #endif /* #ifndef __MALLOC_LIB_H__ */ 46 | -------------------------------------------------------------------------------- /src/memory/memory.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : memory/memory.param.h 24 | * Author : HPS Research Group 25 | * Date : 9/18/1998 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __MEMORY_PARAM_H__ 30 | #define __MEMORY_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in memory.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "memory.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __MEMORY_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/op_pool.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : op_pool.h 24 | * Author : HPS Research Group 25 | * Date : 1/28/1998 26 | * Description : Header for op_pool.c 27 | ***************************************************************************************/ 28 | 29 | #ifndef __OP_POOL_H__ 30 | #define __OP_POOL_H__ 31 | 32 | 33 | /**************************************************************************************/ 34 | /* Global Variables */ 35 | 36 | extern Op invalid_op; 37 | extern uns op_pool_entries; 38 | extern uns op_pool_active_ops; 39 | 40 | 41 | /**************************************************************************************/ 42 | /* Prototypes */ 43 | 44 | void init_op_pool(void); 45 | void reset_op_pool(void); 46 | Op* alloc_op(uns proc_id); 47 | void free_op(Op*); 48 | void op_pool_init_op(Op*); 49 | void op_pool_setup_op(uns proc_id, Op* op); 50 | 51 | /**************************************************************************************/ 52 | 53 | #endif /* #ifndef __OP_POOL_H__ */ 54 | -------------------------------------------------------------------------------- /src/packet_build.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : packet_build.param.h 24 | * Author : HPS Research Group 25 | * Date : 2/28/01 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __PACKET_BUILD_PARAM_H__ 30 | #define __PACKET_BUILD_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in packet_build.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "packet_build.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __PACKET_BUILD_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/param_files.def: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 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 7 | * of the Software, and to permit persons to whom the Software is furnished to do 8 | * so, 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /* -*- Mode: c -*- */ 23 | /*************************************************************************************** 24 | * File : param_files.def 25 | * Author : HPS Research Group 26 | * Date : 2/15/1998 27 | * Description : This file should contains only the includes for the various 28 | ".param.def" files. 29 | ***************************************************************************************/ 30 | 31 | #include "general.param.def" 32 | #include "memory/memory.param.def" 33 | #include "ramulator.param.def" 34 | #include "dvfs/dvfs.param.def" 35 | #include "core.param.def" 36 | #include "debug/debug.param.def" 37 | #include "bp/bp.param.def" 38 | #include "packet_build.param.def" 39 | #include "power/power.param.def" 40 | #include "prefetcher//stream.param.def" 41 | #include "prefetcher/pref.param.def" 42 | #include "prefetcher/l2l1pref.param.def" 43 | #include "prefetcher/pref_ghb.param.def" 44 | #include "prefetcher/pref_stride.param.def" 45 | #include "prefetcher/pref_stridepc.param.def" 46 | #include "prefetcher/pref_phase.param.def" 47 | #include "prefetcher/pref_2dc.param.def" 48 | #include "prefetcher/pref_markov.param.def" 49 | -------------------------------------------------------------------------------- /src/pin/pin_exec/.gitignore: -------------------------------------------------------------------------------- 1 | obj-intel64/* 2 | -------------------------------------------------------------------------------- /src/pin/pin_exec/exception_handling.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef PIN_EXEC_EXCEPTION_HANDLING_H__ 23 | #define PIN_EXEC_EXCEPTION_HANDLING_H__ 24 | 25 | #include "globals.h" 26 | 27 | void register_signal_handlers(); 28 | 29 | bool dummy_handler(THREADID tid, INT32 sig, CONTEXT* ctxt, bool hasHandler, 30 | const EXCEPTION_INFO* pExceptInfo, void* v); 31 | 32 | bool signal_handler(THREADID tid, INT32 sig, CONTEXT* ctxt, bool hasHandler, 33 | const EXCEPTION_INFO* pExceptInfo, void* v); 34 | 35 | // Main loop for rightpath execptions: any context change is delayed until we 36 | // reach the execption handler 37 | bool excp_main_loop(int sig); 38 | 39 | #endif // PIN_EXEC_EXCEPTION_HANDLING_H__ -------------------------------------------------------------------------------- /src/pin/pin_exec/main_loop.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef PIN_EXEC_MAIN_LOOP_H__ 23 | #define PIN_EXEC_MAIN_LOOP_H__ 24 | 25 | #include "globals.h" 26 | 27 | // Communicates with scarab, and performs the requested actions 28 | void main_loop(CONTEXT* ctxt); 29 | 30 | bool do_fe_retire(Scarab_To_Pin_Msg& cmd); 31 | 32 | void do_fe_fetch_op(bool& syscall_has_been_sent_to_scarab); 33 | 34 | void do_fe_null(bool& have_consumed_op); 35 | 36 | #endif // PIN_EXEC_MAIN_LOOP_H__ -------------------------------------------------------------------------------- /src/pin/pin_exec/makefile: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # 3 | # DO NOT EDIT THIS FILE! 4 | # 5 | ############################################################## 6 | 7 | # If the tool is built out of the kit, PIN_ROOT must be specified in the make invocation and point to the kit root. 8 | ifdef PIN_ROOT 9 | CONFIG_ROOT := $(PIN_ROOT)/source/tools/Config 10 | else 11 | CONFIG_ROOT := ../Config 12 | endif 13 | include $(CONFIG_ROOT)/makefile.config 14 | include makefile.rules 15 | include $(TOOLS_ROOT)/Config/makefile.default.rules 16 | 17 | ############################################################## 18 | # 19 | # DO NOT EDIT THIS FILE! 20 | # 21 | ############################################################## 22 | -------------------------------------------------------------------------------- /src/pin/pin_exec/scarab_interface.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef PIN_EXEC_SCARAB_INTERFACE_H 23 | #define PIN_EXEC_SCARAB_INTERFACE_H 24 | 25 | #include "globals.h" 26 | 27 | #include "../pin_lib/pin_scarab_common_lib.h" 28 | 29 | Scarab_To_Pin_Msg get_scarab_cmd(); 30 | void insert_scarab_op_in_buffer(compressed_op& cop); 31 | bool scarab_buffer_full(); 32 | void scarab_send_buffer(); 33 | void scarab_clear_all_buffers(); 34 | 35 | #endif // PIN_EXEC_SCARAB_INTERFACE_H -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hpsresearchgroup/scarab/5c58dea0766f9db9e17283760d017d70d7d07b37/src/pin/pin_exec/testing/.gitignore -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/c_program_with_ud2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | jmp_buf buffer; 5 | 6 | void handle_sig(int sig); 7 | void handle_sig(int sig) { 8 | longjmp(buffer, 1); 9 | } 10 | 11 | int main() { 12 | signal(SIGILL, handle_sig); 13 | int x = setjmp(buffer); 14 | if(x == 0) { 15 | __asm__("ud2\n"); 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/exception_tests.cc: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * File : simple_loop_test.cc 3 | * Author : HPS Research Group 4 | * Date : 4/22/2020 5 | * Description : 6 | ***************************************************************************************/ 7 | 8 | #include 9 | 10 | #include "gtest/gtest.h" 11 | 12 | #include "fake_scarab.h" 13 | #include "utils.h" 14 | 15 | #ifndef WRONG_PATH_EXCEPTION_BINARY 16 | #define WRONG_PATH_EXCEPTION_BINARY "./wrong_path_exception" 17 | #endif 18 | 19 | #ifndef C_PROGRAM_WITH_UD2_BINARY 20 | #define C_PROGRAM_WITH_UD2_BINARY "./c_program_with_ud2" 21 | #endif 22 | 23 | using namespace scarab::pin::testing; 24 | 25 | class Wrong_Path_Exception_Binary_Info : public Binary_Info { 26 | public: 27 | Wrong_Path_Exception_Binary_Info() : 28 | Binary_Info(WRONG_PATH_EXCEPTION_BINARY), 29 | bad_store_addr(find_addr("movq")), 30 | illegal_instruction_addr(find_addr("ud2")) {} 31 | 32 | const uint64_t bad_store_addr; 33 | const uint64_t illegal_instruction_addr; 34 | }; 35 | 36 | TEST(Exception_Test, WrongPathDoesNotExcuteExceptions) { 37 | Wrong_Path_Exception_Binary_Info binary_info; 38 | 39 | Fake_Scarab fake_scarab(WRONG_PATH_EXCEPTION_BINARY); 40 | 41 | ASSERT_NO_FATAL_FAILURE(fake_scarab.fetch_until_first_control_flow()); 42 | 43 | const auto redirect_uid = fake_scarab.get_latest_inst_uid(); 44 | const auto store_addr = binary_info.bad_store_addr; 45 | const auto illegal_inst_addr = binary_info.illegal_instruction_addr; 46 | 47 | ASSERT_NO_FATAL_FAILURE(fake_scarab.redirect(store_addr)); 48 | ASSERT_NO_FATAL_FAILURE( 49 | fake_scarab.fetch_instructions({store_addr, illegal_inst_addr})); 50 | ASSERT_TRUE(fake_scarab.has_fetched_ifetch_barrier()); 51 | 52 | ASSERT_NO_FATAL_FAILURE(fake_scarab.recover(redirect_uid)); 53 | ASSERT_NO_FATAL_FAILURE(fake_scarab.fetch_until_completion()); 54 | ASSERT_TRUE(fake_scarab.has_reached_end()); 55 | ASSERT_NO_FATAL_FAILURE(fake_scarab.retire_all()); 56 | } 57 | 58 | TEST(Exception_Test, CanExecuteCustomHandler) { 59 | Fake_Scarab fake_scarab(C_PROGRAM_WITH_UD2_BINARY); 60 | fake_scarab.fetch_retire_until_completion(); 61 | ASSERT_TRUE(fake_scarab.has_reached_end()); 62 | } -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/fake_scarab.h: -------------------------------------------------------------------------------- 1 | #ifndef __PIN_PIN_EXEC_TESTING_FAKE_SCARAB_H__ 2 | #define __PIN_PIN_EXEC_TESTING_FAKE_SCARAB_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "gtest/gtest.h" 12 | #include "utils.h" 13 | 14 | #include "../../pin_lib/message_queue_interface_lib.h" 15 | #include "../../pin_lib/pin_scarab_common_lib.h" 16 | 17 | namespace scarab { 18 | namespace pin { 19 | namespace testing { 20 | 21 | class Fake_Scarab { 22 | public: 23 | Fake_Scarab(const char* binary_path); 24 | ~Fake_Scarab(); 25 | 26 | void fetch_instructions(const std::vector& addresses); 27 | 28 | void fetch_instructions_in_wrongpath_nop_mode( 29 | uint64_t next_fetch_addr, int num_instructions, 30 | Wrongpath_Nop_Mode_Reason expected_reason); 31 | 32 | void fetch_retire_until_completion(); 33 | 34 | void fetch_until_completion(); 35 | 36 | void fetch_until_first_control_flow(); 37 | 38 | void fetch_until_first_wrongpath_nop_mode( 39 | int max_num_instructions, Wrongpath_Nop_Mode_Reason expected_reason); 40 | 41 | uint64_t get_latest_inst_uid(); 42 | 43 | bool has_fetched_ifetch_barrier(); 44 | 45 | bool has_reached_end(); 46 | 47 | void recover(uint64_t inst_uid); 48 | 49 | void redirect(uint64_t fetch_addr); 50 | 51 | void retire_all(); 52 | 53 | 54 | private: 55 | void fetch_new_ops(); 56 | void fetch_next_instruction(); 57 | void flush_cops_after_uid(uint64_t inst_uid); 58 | void refill_op_buffer(); 59 | void retire(uint64_t inst_uid); 60 | 61 | std::string tmpdir_path_; 62 | Process_Runner pintool_process_; 63 | std::unique_ptr server_communicator_; 64 | 65 | ScarabOpBuffer_type op_buffer_; 66 | std::deque fetched_ops_; 67 | }; 68 | 69 | } // namespace testing 70 | } // namespace pin 71 | } // namespace scarab 72 | 73 | #endif //__PIN_PIN_EXEC_TESTING_FAKE_SCARAB_H__ -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/jump_near_boundary.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | jmp done 6 | done: 7 | xor %rdi, %rdi 8 | mov $231, %rax 9 | syscall 10 | 11 | .rept 0x550 12 | nopl (%rax) 13 | .endr 14 | .byte 0x0f 15 | .byte 0x1f 16 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/main.cc: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include "utils.h" 4 | 5 | int main(int argc, char** argv) { 6 | ::testing::InitGoogleTest(&argc, argv); 7 | return RUN_ALL_TESTS(); 8 | } 9 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/nop_mode_bad_store.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | lea gvar, %rax 6 | movq $1, (%rax) 7 | mov %rsp, %rax # since we do not write anything to the stack in this 8 | # program, writing to the stack on the wrong path should 9 | # trigger wrong path nop mode 10 | sub $8, %rsp 11 | jmp done # redirect this to the first mov 12 | done: 13 | xor %rdi, %rdi 14 | mov $231, %rax 15 | syscall 16 | 17 | .section .data 18 | gvar: .skip 8, 0 19 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/nop_mode_nonret_direct.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | xor %rax, %rax 6 | redirect_target: 7 | test %rax, %rax 8 | mispredicting_branch: 9 | jnz far_target 10 | mov $1, %rax 11 | jmp done # test should redirect this jmp to redirect_target 12 | done: 13 | xor %rdi, %rdi 14 | mov $231, %rax 15 | syscall 16 | 17 | gap: 18 | .skip 4096, 0 19 | far_target: 20 | jmp far_target 21 | 22 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/nop_mode_nonret_indirect.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | xor %rax, %rax 6 | lea next_instruction, %rbx 7 | redirect_target: 8 | jmpq *%rbx 9 | next_instruction: 10 | lea far_target, %rbx 11 | jmp done # test should redirect this jmp to redirect_target 12 | done: 13 | xor %rdi, %rdi 14 | mov $231, %rax 15 | syscall 16 | 17 | gap: 18 | .skip 4096, 0 19 | far_target: 20 | jmp far_target 21 | 22 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/nop_mode_not_taken.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | mov $2, %rax 6 | loop: 7 | sub $1, %rax 8 | jne skip 9 | xor %rdi, %rdi 10 | mov $231, %rax 11 | syscall 12 | skip: 13 | jne loop # this branch should be redirected to fall thrugh, then 14 | # eventually the process reaches non-instrumented instructions 15 | # on the wrongpath. 16 | sub $1, %rax 17 | jne skip 18 | jne skip 19 | jne skip 20 | jne skip 21 | jne skip 22 | jne skip 23 | jne skip 24 | loop2: 25 | jmp loop2 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/nop_mode_ret.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | lea done, %rax 6 | lea ret_inst, %rbx 7 | sub $0x10000, %rbx 8 | pushq %rbx # Pushing nonsense address on the stack. If an extra retq 9 | # is executed on the wrongpath, we expect to go into 10 | # wronpath nop mode. 11 | pushq %rax 12 | ret_inst: 13 | retq 14 | done: 15 | xor %rdi, %rdi 16 | mov $231, %rax 17 | syscall 18 | 19 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/simple_c_program.c: -------------------------------------------------------------------------------- 1 | int main() {} -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/simple_loop.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | # rax: loop variable 5 | # rax: counts of odd loop variables 6 | _start: 7 | xor %rax, %rax 8 | xor %rcx, %rcx 9 | 10 | loop: 11 | # first, test if loop variable is odd 12 | mov %rax, %rbx 13 | and $1, %rbx 14 | 15 | # only increment rax if rax is odd 16 | je end_loop 17 | add $1, %rcx 18 | 19 | end_loop: 20 | # loop for 10 iterations 21 | add $1, %rax 22 | cmp $10, %rax 23 | jl loop 24 | 25 | # exit the program 26 | xor %rdi, %rdi 27 | mov $231, %rax 28 | syscall 29 | 30 | wrongpath_loop: 31 | mov $99999, %rax 32 | mov $99999, %rax 33 | jmp wrongpath_loop 34 | -------------------------------------------------------------------------------- /src/pin/pin_exec/testing/wrong_path_exception.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | xor %rax, %rax 6 | je done # redirect this to fall-through for testing 7 | # wrong-path exceptions 8 | 9 | movq $0, done # code region is not writable, so this should cause an 10 | # exception, however, since it is on the wrongpath, 11 | # the pintool should just skip executing it and continue 12 | 13 | ud2 # illegal instruction should stop fetch (ifetch_barrier) 14 | done: 15 | xor %rdi, %rdi 16 | mov $231, %rax 17 | syscall 18 | 19 | -------------------------------------------------------------------------------- /src/pin/pin_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(pin_lib_for_scarab 2 | STATIC 3 | message_queue_interface_lib.cc 4 | message_queue_interface_lib.h 5 | pin_scarab_common_lib.cc 6 | pin_scarab_common_lib.h 7 | uop_generator.c 8 | uop_generator.h 9 | x86_decoder.cc 10 | x86_decoder.h 11 | x87_stack_delta.h 12 | x87_stack_delta.cc 13 | gather_scatter_addresses.h 14 | gather_scatter_addresses.cc 15 | ) 16 | target_include_directories(pin_lib_for_scarab PRIVATE ../..) 17 | target_link_libraries(pin_lib_for_scarab PUBLIC xed) 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/pin/pin_lib/decoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __DECODER_H__ 23 | #define __DECODER_H__ 24 | 25 | #undef UNUSED // there is a name conflict between PIN and Scarab 26 | #undef WARNING // there is a name conflict between PIN and Scarab 27 | 28 | #include "pin.H" 29 | 30 | #undef UNUSED // there is a name conflict between PIN and Scarab 31 | #undef WARNING // there is a name conflict between PIN and Scarab 32 | #include 33 | #include "../../ctype_pin_inst.h" 34 | #include "../../table_info.h" 35 | #include "x86_decoder.h" 36 | 37 | using namespace std; 38 | 39 | void pin_decoder_init(bool translate_x87_regs, std::ostream* err_ostream); 40 | 41 | void pin_decoder_insert_analysis_functions(const INS& ins); 42 | void insert_analysis_functions(ctype_pin_inst* info, const INS& ins); 43 | ctype_pin_inst* pin_decoder_get_latest_inst(); 44 | 45 | void pin_decoder_print_unknown_opcodes(); 46 | 47 | vector 48 | get_gather_scatter_mem_access_infos_from_gather_scatter_info( 49 | const CONTEXT* ctxt, const PIN_MULTI_MEM_ACCESS_INFO* infos_from_pin); 50 | 51 | ctype_pin_inst create_sentinel(); 52 | ctype_pin_inst create_dummy_jump(uint64_t eip, uint64_t tgt); 53 | ctype_pin_inst create_dummy_nop(uint64_t eip, Wrongpath_Nop_Mode_Reason reason); 54 | 55 | #endif // __DECODER_H__ 56 | -------------------------------------------------------------------------------- /src/pin/pin_lib/pin_scarab_common_lib.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : pin_scarab_common_lib.cc 24 | * Author : HPS Research Group 25 | * Date : 10/30/2018 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #include "pin_scarab_common_lib.h" 30 | 31 | /********************************************************** 32 | * compressed_op interface 33 | **********************************************************/ 34 | 35 | // pin skips (fast_forward_count - 1) instructions 36 | uint64_t fast_forward_count = 0; 37 | 38 | Flag is_sentinal_op(compressed_op* cop) { 39 | return cop->is_sentinel == 1; 40 | } 41 | -------------------------------------------------------------------------------- /src/pin/pin_lib/pin_scarab_common_lib.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : pin_scarab_common_lib.h 24 | * Author : HPS Research Group 25 | * Date : 10/30/2018 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | /* Interface to use PIN Execution Driven frontend as a functional frontend */ 30 | 31 | #ifndef __PIN_SCARAB_COMMON_LIB_H__ 32 | #define __PIN_SCARAB_COMMON_LIB_H__ 33 | 34 | #include 35 | #include "../../ctype_pin_inst.h" 36 | #include "../../op_info.h" 37 | #include "stdint.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | typedef enum Scarab_To_Pin_Cmd_enum { 44 | FE_NULL, 45 | FE_FETCH_OP, 46 | FE_REDIRECT, 47 | FE_RECOVER_BEFORE, 48 | FE_RECOVER_AFTER, 49 | FE_RETIRE, 50 | FE_NUM_COMMANDS 51 | } Scarab_To_Pin_Cmd; 52 | 53 | struct Scarab_To_Pin_Msg { 54 | Scarab_To_Pin_Cmd type; 55 | uint64_t inst_uid; 56 | Addr inst_addr; 57 | } __attribute__((packed)); 58 | 59 | typedef std::deque ScarabOpBuffer_type; 60 | 61 | Flag is_sentinal_op(compressed_op* op); 62 | 63 | extern uint64_t fast_forward_count; 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/pin/pin_lib/uop_generator.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | ** File : uop_generator.h 24 | ** Author : HPS Research Group 25 | ** Date : 1/3/2018 26 | ** Description : API to extract uops out of ctype_pin_inst_struct instances. 27 | ****************************************************************************************/ 28 | 29 | #ifndef __UOP_GENERATOR_H__ 30 | #define __UOP_GENERATOR_H__ 31 | 32 | #include "../../globals/global_types.h" 33 | 34 | /**************************************************************************************/ 35 | /* Prototypes */ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | void uop_generator_init(uint32_t num_cores); 42 | Flag uop_generator_extract_op(uns proc_id, Op* op, compressed_op* cop); 43 | 44 | void uop_generator_get_uop(uns proc_id, Op* op, compressed_op* inst); 45 | Flag uop_generator_get_bom(uns proc_id); // Called before 46 | // uop_generator_get_uop. 47 | Flag uop_generator_get_eom(uns proc_id); // Called after uop_generator_get_uop. 48 | void uop_generator_recover(uns8 proc_id); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif //__UOP_GENERATOR_H__ 55 | -------------------------------------------------------------------------------- /src/pin/pin_lib/x87_stack_delta.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef X87_STACK_DELTA_H 23 | #define X87_STACK_DELTA_H 24 | 25 | /* Initialize (call before calling the other function) */ 26 | void init_x87_stack_delta(); 27 | 28 | /* Translate the relative reg given to its absolute name */ 29 | int absolute_reg(int reg, int opcode, bool write); 30 | 31 | /* Update x87 stack state. Once this is called, absolute_reg() 32 | traslates for the *next* instruction */ 33 | void update_x87_stack_state(int opcode); 34 | 35 | /* Check whether the given opcode pops the x87 stack */ 36 | int pops_x87_stack(int opcode); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/pin/pin_trace/.gitignore: -------------------------------------------------------------------------------- 1 | obj-intel64 2 | -------------------------------------------------------------------------------- /src/pin/pin_trace/makefile: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # 3 | # DO NOT EDIT THIS FILE! 4 | # 5 | ############################################################## 6 | 7 | # If the tool is built out of the kit, PIN_ROOT must be specified in the make invocation and point to the kit root. 8 | PIN_ROOT?=$(shell pwd | sed '/extras.*/s///g') 9 | ifdef PIN_ROOT 10 | CONFIG_ROOT := $(PIN_ROOT)/source/tools/Config 11 | else 12 | CONFIG_ROOT := ../Config 13 | endif 14 | include $(CONFIG_ROOT)/makefile.config 15 | include makefile.rules 16 | include $(TOOLS_ROOT)/Config/makefile.default.rules 17 | 18 | ############################################################## 19 | # 20 | # DO NOT EDIT THIS FILE! 21 | # 22 | ############################################################## 23 | -------------------------------------------------------------------------------- /src/power/power.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : power.param.h 24 | * Author : HPS Research Group 25 | * Date : 2/28/01 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __POWER_PARAM_H__ 30 | #define __POWER_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in power.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "power.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __POWER_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/prefetcher/l2l1pref.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : l2l1pref.param.h 24 | * Author : HPS Research Group 25 | * Date : 03.17.2004 26 | * Description : l2l1 prefetcher 27 | ***************************************************************************************/ 28 | 29 | #ifndef __L2L1PREF_PARAM_H__ 30 | #define __L2L1PREF_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in l2l1pref.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "l2l1pref.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __L2L1PREF_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/prefetcher/l2markv_pref.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : l2markv_pref.h 24 | * Author : HPS Research Group 25 | * Date : 03/17/2004 26 | * Description : 27 | ***************************************************************************************/ 28 | #ifndef __L2MARKV_PREF_H__ 29 | #define __L2MARKV_PREF_H__ 30 | 31 | #include "pref_type.h" 32 | 33 | typedef struct L2markv_Rec_Struct { 34 | Addr last_addr; 35 | Addr next_addr; 36 | Counter time_diff; 37 | int next_addr_counter; 38 | int last_addr_counter; 39 | Counter last_access_time; 40 | } L2markv_Rec; 41 | 42 | void l2markv_init(void); 43 | void l2markv_pref(Mem_Req_Info* req, int* train_hit, int* pref_req, 44 | Addr* req_addr); 45 | int l2markv_pref_train(Mem_Req_Info* req); 46 | int l2markv_pref_pred(Mem_Req_Info* req, Addr* req_addr); 47 | void insert_l2markv_pref_req(Addr va, Counter time); 48 | void update_l2markv_pref_req_queue(void); 49 | 50 | void l2next_pref(Mem_Req_Info* req); 51 | 52 | #endif /* #ifnde __L2MARKV_PREF_H__ */ 53 | -------------------------------------------------------------------------------- /src/prefetcher/l2way_pref.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : l2way_pref.h 24 | * Author : HPS Research Group 25 | * Date : 03/11/2004 26 | * Description : 27 | ***************************************************************************************/ 28 | #ifndef __L2WAY_PREF_H__ 29 | #define __L2WAY_PREF_H__ 30 | 31 | #include "globals/global_types.h" 32 | #include "pref_type.h" 33 | 34 | // way predictor training structure 35 | typedef struct L2way_Rec_Struct { 36 | uns last_way; 37 | uns pred_way; 38 | uns counter; 39 | Counter last_access_time; 40 | } L2way_Rec; 41 | 42 | typedef struct L2set_Rec_Struct { 43 | Addr last_addr; 44 | Addr pred_addr; 45 | } L2set_Rec; 46 | 47 | typedef struct L1pref_Req_Struct { 48 | Flag valid; 49 | Addr va; 50 | Counter time; 51 | Counter rdy_cycle; 52 | } L1pref_Req; 53 | 54 | 55 | void l2way_init(void); 56 | void l2way_pref(Mem_Req_Info* req); 57 | void l2way_pref_train(Mem_Req_Info* req); 58 | void l2way_pref_pred(Mem_Req_Info* req); 59 | void insert_l2way_pref_req(Addr va, Counter time); 60 | void update_l2way_pref_req_queue(void); 61 | #endif /* #ifndef __L2WAY_PREF_H__ */ 62 | -------------------------------------------------------------------------------- /src/prefetcher/pref.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __PREF_PARAM_H__ 23 | #define __PREF_PARAM_H__ 24 | 25 | #include "globals/global_types.h" 26 | 27 | /**************************************************************************************/ 28 | /* extern all of the variables defined in core.param.def */ 29 | 30 | #define DEF_PARAM(name, variable, type, func, def, const) \ 31 | extern const type variable; 32 | #include "pref.param.def" 33 | #undef DEF_PARAM 34 | 35 | /**************************************************************************************/ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/prefetcher/pref_2dc.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : pref_2dc.param.h 24 | * Author : HPS Research Group 25 | * Date : 26 | * Description : 27 | ****************************************************************************************/ 28 | #ifndef __PREF_2DC_PARAM_H__ 29 | #define __PREF_2DC_PARAM_H__ 30 | 31 | #include "globals/global_types.h" 32 | 33 | /**************************************************************************************/ 34 | /* extern all of the variables defined in core.param.def */ 35 | 36 | #define DEF_PARAM(name, variable, type, func, def, const) \ 37 | extern const type variable; 38 | #include "pref_2dc.param.def" 39 | #undef DEF_PARAM 40 | 41 | /**************************************************************************************/ 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/prefetcher/pref_ghb.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : pref_ghb.param.h 24 | * Author : HPS Research Group 25 | * Date : 26 | * Description : 27 | ****************************************************************************************/ 28 | 29 | #ifndef __PREF_GHB_PARAM_H__ 30 | #define __PREF_GHB_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | /**************************************************************************************/ 35 | /* extern all of the variables defined in core.param.def */ 36 | 37 | #define DEF_PARAM(name, variable, type, func, def, const) \ 38 | extern const type variable; 39 | #include "pref_ghb.param.def" 40 | #undef DEF_PARAM 41 | 42 | /**************************************************************************************/ 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/prefetcher/pref_markov.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : pref_markov.param.h 24 | * Author : HPS Research Group 25 | * Date : 26 | * Description : 27 | ****************************************************************************************/ 28 | 29 | #ifndef __PREF_MARKOV_PARAM_H__ 30 | #define __PREF_MARKOV_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | /**************************************************************************************/ 35 | /* extern all of the variables defined in core.param.def */ 36 | 37 | #define DEF_PARAM(name, variable, type, func, def, const) \ 38 | extern const type variable; 39 | #include "pref_markov.param.def" 40 | #undef DEF_PARAM 41 | 42 | /**************************************************************************************/ 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/prefetcher/pref_phase.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __PREF_PHASE_PARAM_H__ 23 | #define __PREF_PHASE_PARAM_H__ 24 | 25 | #include "globals/global_types.h" 26 | 27 | /**************************************************************************************/ 28 | /* extern all of the variables defined in core.param.def */ 29 | 30 | #define DEF_PARAM(name, variable, type, func, def, const) \ 31 | extern const type variable; 32 | #include "pref_phase.param.def" 33 | #undef DEF_PARAM 34 | 35 | /**************************************************************************************/ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/prefetcher/pref_stride.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __PREF_STRIDE_PARAM_H__ 23 | #define __PREF_STRIDE_PARAM_H__ 24 | 25 | #include "globals/global_types.h" 26 | 27 | /**************************************************************************************/ 28 | /* extern all of the variables defined in core.param.def */ 29 | 30 | #define DEF_PARAM(name, variable, type, func, def, const) \ 31 | extern const type variable; 32 | #include "pref_stride.param.def" 33 | #undef DEF_PARAM 34 | 35 | /**************************************************************************************/ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/prefetcher/pref_stridepc.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __PREF_STRIDEPC_PARAM_H__ 23 | #define __PREF_STRIDEPC_PARAM_H__ 24 | 25 | #include "globals/global_types.h" 26 | 27 | /**************************************************************************************/ 28 | /* extern all of the variables defined in core.param.def */ 29 | 30 | #define DEF_PARAM(name, variable, type, func, def, const) \ 31 | extern const type variable; 32 | #include "pref_stridepc.param.def" 33 | #undef DEF_PARAM 34 | 35 | /**************************************************************************************/ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/prefetcher/pref_type.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : pref_type.h 24 | * Author : HPS Research Group 25 | * Date : 04/04/2004 26 | * Description : Prefetcher Request variable 27 | ***************************************************************************************/ 28 | 29 | #ifndef __PREF_TYPE_H__ 30 | #define __PREF_TYPE_H__ 31 | 32 | #include "memory/mem_req.h" 33 | 34 | typedef struct Mem_Req_Info_Struct { 35 | uns8 proc_id; 36 | Addr addr; 37 | Mem_Req_Type type; 38 | Counter oldest_op_unique_num; 39 | Addr oldest_op_inst_addr; 40 | } Mem_Req_Info; 41 | 42 | 43 | #endif // #ifndef __PREF_TYPE_H__ 44 | -------------------------------------------------------------------------------- /src/prefetcher/stream.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __STREAM_PARAM_H__ 23 | #define __STREAM_PARAM_H__ 24 | 25 | #include "globals/global_types.h" 26 | 27 | /**************************************************************************************/ 28 | /* extern all of the variables defined in core.param.def */ 29 | 30 | #define DEF_PARAM(name, variable, type, func, def, const) \ 31 | extern const type variable; 32 | #include "stream.param.def" 33 | #undef DEF_PARAM 34 | 35 | /**************************************************************************************/ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/ramulator.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : ramulator.h 24 | * Author : SAFARI research group 25 | * Date : 6/12/2018 26 | * Description : Header file defining an interface to Ramulator 27 | ***************************************************************************************/ 28 | 29 | #ifndef __RAMULATOR_H__ 30 | #define __RAMULATOR_H__ 31 | 32 | #include "globals/global_types.h" 33 | #include "memory/memory.h" 34 | 35 | #ifdef __cplusplus 36 | #define EXTERNC extern "C" 37 | #else 38 | #define EXTERNC 39 | #endif 40 | 41 | EXTERNC void ramulator_init(); 42 | EXTERNC void ramulator_finish(); 43 | 44 | EXTERNC int ramulator_send(Mem_Req* scarab_req); 45 | EXTERNC void ramulator_tick(); 46 | 47 | EXTERNC int ramulator_get_chip_width(); 48 | EXTERNC int ramulator_get_chip_size(); 49 | EXTERNC int ramulator_get_num_chips(); 50 | EXTERNC int ramulator_get_chip_row_buffer_size(); 51 | 52 | EXTERNC Mem_Req* ramulator_search_queue(long phys_addr, Mem_Req_Type type); 53 | #undef EXTERNC 54 | 55 | #endif // __RAMULATOR_H__ 56 | -------------------------------------------------------------------------------- /src/ramulator.param.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : ramulator.param.h 24 | * Author : SAFARI research group 25 | * Date : 6/12/2018 26 | * Description : 27 | ***************************************************************************************/ 28 | 29 | #ifndef __RAMULATOR_PARAM_H__ 30 | #define __RAMULATOR_PARAM_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | 35 | /**************************************************************************************/ 36 | /* extern all of the variables defined in ramulator.param.def */ 37 | 38 | #define DEF_PARAM(name, variable, type, func, def, const) \ 39 | extern const type variable; 40 | #include "ramulator.param.def" 41 | #undef DEF_PARAM 42 | 43 | 44 | /**************************************************************************************/ 45 | 46 | #endif /* #ifndef __RAMULATOR_PARAM_H__ */ 47 | -------------------------------------------------------------------------------- /src/ramulator/.gitignore: -------------------------------------------------------------------------------- 1 | obj/* 2 | obj_dbg/* 3 | obj_*/* 4 | -------------------------------------------------------------------------------- /src/ramulator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB srcs *.cpp *.h) 2 | add_library(ramulator STATIC ${srcs}) 3 | target_compile_definitions(ramulator PRIVATE RAMULATOR) 4 | target_compile_options(ramulator PRIVATE ${ramulator_warnings}) -------------------------------------------------------------------------------- /src/ramulator/ScarabWrapper.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 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 7 | * of the Software, and to permit persons to whom the Software is furnished to do 8 | * so, 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __SCARAB_WRAPPER_H 23 | #define __SCARAB_WRAPPER_H 24 | 25 | #include 26 | 27 | #include "Config.h" 28 | 29 | using namespace std; 30 | 31 | namespace ramulator 32 | { 33 | 34 | class Request; 35 | class MemoryBase; 36 | 37 | class ScarabWrapper 38 | { 39 | private: 40 | MemoryBase *mem; 41 | public: 42 | //double tCK; 43 | ScarabWrapper(const Config& configs, const unsigned int cacheline, void (* stats_callback)(int, int)); 44 | ~ScarabWrapper(); 45 | void tick(); 46 | bool send(Request req); 47 | void finish(void); 48 | 49 | int get_chip_width() const; 50 | int get_chip_size() const; 51 | int get_num_chips() const; 52 | int get_chip_row_buffer_size() const; 53 | }; 54 | 55 | } /*namespace ramulator*/ 56 | 57 | #endif /*__SCARAB_WRAPPER_H*/ 58 | -------------------------------------------------------------------------------- /src/stat_files.def: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 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 7 | * of the Software, and to permit persons to whom the Software is furnished to do 8 | * so, 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /* -*- Mode: c -*- */ 23 | /*************************************************************************************** 24 | * File : stat_files.def 25 | * Author : HPS Research Group 26 | * Date : 2/15/1998 27 | * Description : This file should contains only the includes for the various 28 | ".stat.def" files. 29 | ***************************************************************************************/ 30 | 31 | #include "fetch.stat.def" 32 | #include "bp/bp.stat.def" 33 | #include "memory/memory.stat.def" 34 | #include "core.stat.def" 35 | #include "inst.stat.def" 36 | #include "prefetcher/stream.stat.def" 37 | #include "prefetcher/l2l1pref.stat.def" 38 | #include "power/power.stat.def" 39 | #include "prefetcher/pref.stat.def" 40 | 41 | -------------------------------------------------------------------------------- /src/stat_trace.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : stat_trace.h 24 | * Author : HPS Research Group 25 | * Date : 04/21/2012 26 | * Description : Statistic trace 27 | ***************************************************************************************/ 28 | 29 | #ifndef __STAT_TRACE_H__ 30 | #define __STAT_TRACE_H__ 31 | 32 | #include "globals/global_types.h" 33 | 34 | /**************************************************************************************/ 35 | /* Prototypes */ 36 | 37 | /* Initialize stat trace */ 38 | void stat_trace_init(void); 39 | 40 | /* Call every cycle */ 41 | void stat_trace_cycle(void); 42 | 43 | /* Clean up */ 44 | void stat_trace_done(void); 45 | 46 | /* Useful functions */ 47 | uns num_tokens(const char*, const char*); 48 | 49 | 50 | /**************************************************************************************/ 51 | /* Global Variables */ 52 | extern const char* DELIMITERS; 53 | 54 | #endif // __STAT_TRACE_H__ 55 | -------------------------------------------------------------------------------- /src/test/.gitignore: -------------------------------------------------------------------------------- 1 | client_test 2 | message_test 3 | server_test 4 | obj 5 | -------------------------------------------------------------------------------- /src/test/dummy_globals.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "../globals/global_types.h" 23 | #include "../table_info.h" 24 | #include "stdio.h" 25 | 26 | FILE* mystdout = stdout; 27 | FILE* mystderr = stderr; 28 | FILE* mystatus = stdout; 29 | 30 | Counter cycle_count = 0; 31 | Counter unique_count = 0; 32 | Counter* op_count; 33 | Counter* inst_count; 34 | Counter* unique_count_per_core; 35 | Flag* trace_read_done; 36 | 37 | // const char* PIN_EXEC_DRIVEN_FE_SOCKET = "./temp.socket"; 38 | const char* FILE_TAG = ""; 39 | uns INST_HASH_TABLE_SIZE = 500021; 40 | int op_type_delays[NUM_OP_TYPES]; 41 | -------------------------------------------------------------------------------- /src/test/exception_custom_handler.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | int* global = 0; 28 | int temp = 1; 29 | jmp_buf bufferA, bufferB; 30 | 31 | void handle_sig(int sig) { 32 | printf("Exception\n"); 33 | longjmp(bufferA, 10001); 34 | } 35 | 36 | int main() { 37 | signal(SIGSEGV, handle_sig); 38 | signal(SIGILL, handle_sig); 39 | 40 | setbuf(stdout, NULL); 41 | printf("Here 1\n"); 42 | printf("Here 2\n"); 43 | int k = 0; 44 | k = setjmp(bufferA); 45 | printf("%d\n", k); 46 | if(k == 0) { 47 | __asm__("ud2;"); 48 | // int a = *global; 49 | } 50 | printf("Here 3\n"); 51 | 52 | return 1; 53 | } 54 | -------------------------------------------------------------------------------- /src/test/exception_not_taken.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | int* global = 0; 28 | int temp = 1; 29 | jmp_buf bufferA, bufferB; 30 | 31 | void handle_sig(int sig) { 32 | printf("Exception\n"); 33 | longjmp(bufferA, 10001); 34 | } 35 | 36 | int main() { 37 | signal(SIGSEGV, handle_sig); 38 | // signal(SIGILL, handle_sig); 39 | 40 | setbuf(stdout, NULL); 41 | printf("Here 1\n"); 42 | printf("Here 2\n"); 43 | int k = 0; 44 | int j = 0; 45 | k = setjmp(bufferA); 46 | printf("%d\n", k); 47 | if(j != 0) { 48 | __asm__("ud2;"); 49 | // int a = *global; 50 | } 51 | printf("Here 3\n"); 52 | 53 | return 1; 54 | } 55 | -------------------------------------------------------------------------------- /src/test/exception_taken.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | int* global = 0; 28 | int temp = 1; 29 | jmp_buf bufferA, bufferB; 30 | 31 | void handle_sig(int sig) { 32 | printf("Exception\n"); 33 | longjmp(bufferA, 10001); 34 | } 35 | 36 | int main() { 37 | signal(SIGSEGV, handle_sig); 38 | // signal(SIGILL, handle_sig); 39 | 40 | setbuf(stdout, NULL); 41 | printf("Here 1\n"); 42 | printf("Here 2\n"); 43 | int k = 0; 44 | int j = 0; 45 | k = setjmp(bufferA); 46 | printf("%d\n", k); 47 | __asm__("ud2;"); 48 | // int a = *global; 49 | printf("Here 3\n"); 50 | 51 | return 1; 52 | } 53 | -------------------------------------------------------------------------------- /src/test/gather_not_kmask.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | // mov $-32, %ebx 6 | // vmovdqa int_indices,%ymm0 7 | // vmovdqa mask1_2,%ymm2 8 | // vpgatherdd %ymm2,output_ints(%ebx,%ymm0,4),%ymm3 9 | // vmovdqa %ymm3, output_ints 10 | 11 | // vmovdqa int_indices,%ymm0 12 | // vmovdqa mask3_4,%ymm7 13 | // vpgatherdq %ymm7,input_ints(,%xmm0,8),%ymm4 14 | // vmovdqa %ymm4, output_ints 15 | 16 | // vmovdqa quad_indices_for_ints,%ymm0 17 | // vmovdqa mask5_6,%ymm5 18 | // vpgatherqd %xmm5,input_ints(,%ymm0,4),%xmm6 19 | // vmovdqa %xmm6, output_ints 20 | 21 | vmovdqa quad_indices_for_quads,%ymm0 22 | vmovdqa mask7_8,%ymm5 23 | vpgatherqq %ymm5,input_ints(,%ymm0,8),%ymm6 24 | vmovdqa %ymm6, output_ints 25 | 26 | xor %edi, %edi 27 | xor %rax, %rax 28 | LOOP: add output_ints(, %rax, 4), %edi 29 | add $1, %rax 30 | cmp $7, %rax 31 | jle LOOP 32 | 33 | mov $231, %eax 34 | syscall 35 | 36 | .data 37 | .align 32 38 | mask1_2: .int 0x80000000,0x80000000,0,0,0,0,0,0 39 | .align 32 40 | mask3_4: .quad 0,0x8000000000000000,0,0 41 | .align 32 42 | mask5_6: .int 0x80000000,0x80000000,0,0 43 | .align 32 44 | mask7_8: .quad 0,0,0,0x8000000000000000 45 | .align 32 46 | int_indices: .int 0,1,2,3,4,5,6,7 47 | .align 32 48 | quad_indices_for_ints: .quad 4,5,6,7 49 | .align 32 50 | quad_indices_for_quads: .quad 0,1,2,3 51 | .align 32 52 | input_ints: .int 1,2,3,4,5,6,7,8 53 | .align 32 54 | output_ints: .fill 8, 4, 0 55 | -------------------------------------------------------------------------------- /src/test/gather_scatter.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hpsresearchgroup/scarab/5c58dea0766f9db9e17283760d017d70d7d07b37/src/test/gather_scatter.out -------------------------------------------------------------------------------- /src/test/gather_scatter.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | kmovw mask, %k1 6 | lea input_ints, %rbx 7 | lea output_ints, %rcx 8 | vmovdqa64 indices,%zmm0 9 | vpgatherdd (%rbx,%zmm0,4),%zmm1{%k1} 10 | kmovw mask, %k1 11 | vpscatterdd %zmm1,(%rcx,%zmm0,4){%k1} 12 | 13 | xor %edi, %edi 14 | xor %rax, %rax 15 | LOOP: add (%rcx, %rax, 4), %edi 16 | add $1, %rax 17 | cmp $15, %rax 18 | jle LOOP 19 | 20 | mov $231, %eax 21 | syscall 22 | 23 | .data 24 | mask: .word 0x8001 25 | .align 64 26 | indices: .int 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 27 | input_ints: .int 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 28 | output_ints: .fill 16, 4, 0 29 | -------------------------------------------------------------------------------- /src/test/gather_scatter_wrongpath.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | kmovw full_mask, %k1 6 | vmovdqa64 neg_indices,%zmm0 7 | vpgatherdd output_ints(,%zmm0,4),%zmm1{%k1} 8 | kmovw full_mask, %k1 9 | lea output_ints, %rcx 10 | vmovdqa64 pos_indices,%zmm0 11 | vpscatterdd %zmm1,(%rcx,%zmm0,4){%k1} 12 | 13 | vmovdqa64 input_ints_2,%zmm1 14 | kmovw missing_one_mask, %k1 15 | 16 | cmp $0, %rcx 17 | jne skip 18 | vpscatterdd %zmm1,(%rcx,%zmm0,4){%k1} 19 | movl $3, output_ints 20 | 21 | skip: 22 | xor %edi, %edi 23 | xor %rax, %rax 24 | LOOP: add (%rcx, %rax, 4), %edi 25 | add $1, %rax 26 | cmp $15, %rax 27 | jle LOOP 28 | 29 | mov %edi, %ebx 30 | LOOP2: 31 | cmp $0, %ebx 32 | je EXIT 33 | add $-1, %ebx 34 | jmp LOOP2 35 | 36 | EXIT: mov $231, %eax 37 | syscall 38 | 39 | .data 40 | full_mask: .word 0xFFFF 41 | missing_one_mask: .word 0xFFFE 42 | .align 64 43 | pos_indices: .int 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 44 | neg_indices: .int -1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16 45 | input_ints_2: .fill 16, 4, 2 46 | input_ints_1: .fill 16, 4, 1 47 | output_ints: .fill 16, 4, 0 48 | -------------------------------------------------------------------------------- /src/test/inst_with_two_loads.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hpsresearchgroup/scarab/5c58dea0766f9db9e17283760d017d70d7d07b37/src/test/inst_with_two_loads.out -------------------------------------------------------------------------------- /src/test/inst_with_two_loads.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | cld 6 | lea my_str1(,1), %rsi 7 | lea my_str2(,1), %rdi 8 | LOOP: cmpsb 9 | je LOOP 10 | xor %edi, %edi 11 | mov $231, %eax 12 | syscall 13 | 14 | .data 15 | .align 32 16 | my_str1: .string "12345678a" 17 | my_str2: .string "12345678b" 18 | -------------------------------------------------------------------------------- /src/test/isa_test.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | mov $0, %rax 6 | mov $0, %rbx 7 | add %rax, %rbx 8 | mov var(,1), %rcx 9 | add $1, var(,1) 10 | add %eax, var(,1) 11 | add var(,1), %rdx 12 | lea var(,1), %rbx 13 | mov (%rbx, %rax), %rbp 14 | mov (%rbx, %rax, 1), %rsp 15 | mov var(, %rax, 4), %rdi 16 | mov %ebp, (%rbx, %rax) 17 | mov %esp, (%rbx, %rax, 4) 18 | mov %di, var(, %rax, 4) 19 | 20 | addpd %xmm0, %xmm1 21 | vaddpd %ymm2, %ymm3, %ymm4 22 | vaddps %ymm5, %ymm6, %ymm7 23 | addss %xmm8, %xmm9 # <====== 24 | addsd var(,1), %xmm11 # <====== 25 | 26 | addsd var(, %rax, 1), %xmm12 # <====== 27 | addsd (%rbx, %rax, 1), %xmm12 # <====== 28 | 29 | bsf %rsi, %r8 # <====== 30 | bsf var(, %rax, 1), %r9 # <====== 31 | bswap %r10 32 | 33 | btc %rax, var(, %rax, 1) 34 | lea stack2, %rsp 35 | lea stack2, %rbp 36 | push %r13 37 | push %r14 38 | call func1 39 | 40 | 41 | 42 | xor %edi, %edi 43 | mov $231, %eax 44 | syscall 45 | 46 | func1: ret 47 | 48 | .data 49 | .align 32 50 | var: .long 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 51 | stack: .long 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 52 | stack2: .long 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 53 | -------------------------------------------------------------------------------- /src/test/loop_gather_scatter.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | kmovw mask, %k1 6 | kmovw mask, %k2 7 | kmovw mask, %k3 8 | lea input_ints, %rbx 9 | lea output_ints, %rcx 10 | 11 | xor %rax, %rax 12 | 13 | again: 14 | vmovdqa64 indices,%zmm0 15 | vpgatherdd (%rbx,%zmm0,4),%zmm1{%k1} 16 | vpscatterdd %zmm1,(%rcx,%zmm0,4){%k2} 17 | knotw %k3, %k1 18 | knotw %k3, %k2 19 | add $1, %rax 20 | cmp $1, %rax 21 | jle again 22 | 23 | xor %edi, %edi 24 | xor %rax, %rax 25 | LOOP: add (%rcx, %rax, 4), %edi 26 | add $1, %rax 27 | cmp $15, %rax 28 | jle LOOP 29 | 30 | mov $231, %eax 31 | syscall 32 | 33 | .data 34 | mask: .word 0x8001 35 | .align 64 36 | indices: .int 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 37 | input_ints: .int 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 38 | output_ints: .fill 16, 4, 0 39 | -------------------------------------------------------------------------------- /src/test/simple_loop.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hpsresearchgroup/scarab/5c58dea0766f9db9e17283760d017d70d7d07b37/src/test/simple_loop.out -------------------------------------------------------------------------------- /src/test/simple_loop.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .globl _start 3 | 4 | _start: 5 | xor %eax, %eax 6 | LOOP: add $1, %eax 7 | cmp $10, %eax 8 | jle LOOP 9 | xor %edi, %edi 10 | mov $231, %eax 11 | syscall 12 | -------------------------------------------------------------------------------- /src/test/simple_loop.trace.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hpsresearchgroup/scarab/5c58dea0766f9db9e17283760d017d70d7d07b37/src/test/simple_loop.trace.bz2 -------------------------------------------------------------------------------- /src/test/test_main.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "gtest/gtest.h" 23 | 24 | int main(int argc, char** argv) { 25 | ::testing::InitGoogleTest(&argc, argv); 26 | return RUN_ALL_TESTS(); 27 | } 28 | -------------------------------------------------------------------------------- /src/trigger.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : trigger.h 24 | * Author : HPS Research Group 25 | * Date : 10/31/2012 26 | * Description : Generates a trigger from a text specification. For example, to 27 | *generate a trigger that fires after 1M instructions, use specification 28 | *'inst:1000000' 29 | ***************************************************************************************/ 30 | 31 | #ifndef __TRIGGER_H__ 32 | #define __TRIGGER_H__ 33 | 34 | #include "globals/global_types.h" 35 | 36 | /**************************************************************************************/ 37 | /* Types */ 38 | 39 | typedef enum Trigger_Type_enum { 40 | TRIGGER_ONCE, 41 | TRIGGER_REPEAT, 42 | TRIGGER_NUM_ELEMS 43 | } Trigger_Type; 44 | 45 | struct Trigger_struct; 46 | typedef struct Trigger_struct Trigger; 47 | 48 | /**************************************************************************************/ 49 | /* Prototypes */ 50 | 51 | Trigger* trigger_create(const char* name, const char* spec, Trigger_Type type); 52 | 53 | Flag trigger_fired(Trigger* trigger); 54 | 55 | Flag trigger_on(Trigger* trigger); 56 | 57 | double trigger_progress(Trigger* trigger); 58 | 59 | void trigger_free(Trigger* trigger); 60 | 61 | #endif // __TRIGGER_H__ 62 | -------------------------------------------------------------------------------- /src/version.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : version.c 24 | * Author : HPS Research Group 25 | * Date : 3/26/2012 26 | * Description : Keeping track of Scarab version 27 | ***************************************************************************************/ 28 | 29 | #include "version.h" 30 | 31 | /**************************************************************************************/ 32 | /* version */ 33 | const char* version(void) { 34 | return 35 | #include "gitrev" 36 | ; 37 | } 38 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*************************************************************************************** 23 | * File : version.h 24 | * Author : HPS Research Group 25 | * Date : 3/26/2012 26 | * Description : Keeping track of Scarab version 27 | ***************************************************************************************/ 28 | 29 | #ifndef __VERSION_H__ 30 | #define __VERSION_H__ 31 | 32 | /**************************************************************************************/ 33 | /* Functions */ 34 | 35 | const char* version(void); 36 | 37 | /**************************************************************************************/ 38 | 39 | #endif /* #ifndef __VERSION_H__ */ 40 | -------------------------------------------------------------------------------- /utils/checkpoint/README.md: -------------------------------------------------------------------------------- 1 | # Checkpoint Tool 2 | 3 | We provide a tool for checkpointing single-threaded Linux processes for 4 | re-executing programs from deterministic starting states. Loading checkpoint 5 | is a faster alternative to fast-forwarding with Scarab. Checkpoints are not 6 | portable and cannot be moved once created. Thus, we provide scripts for 7 | creating new checkpoints for programs. 8 | 9 | ## Requirements 10 | 11 | * Only works in Linux. 12 | * The checkpointed program must be linked statically. 13 | * The checkpointed program must be single-threaded. 14 | * The checkpointed program cannot use sockets. 15 | * The checkpoint restores the absolute and relative paths of the files in use. 16 | Thus, all files that the checkpointed program use must not move after the 17 | checkpoint is created. 18 | * The checkpointed program should not overwrite input files. 19 | 20 | ## Creating a new checkpoint. 21 | 22 | Put all program files (binary and optional input files) in a directory. We 23 | refer to the absolute path of this directory as *run_dir*. Prepare the command to 24 | run the program from within the run directory (*run_command*). To create a 25 | checkpoint at a given instruction count (*icount*), use the makefile in 26 | utils/checkpoint/creator to create a new checkpoint in the desired absolute 27 | path *checkpoint_path*. 28 | 29 | > ICOUNT=icount RUN_DIR=run_dir PIN_APP_COMMAND="run_command" CHECKPOINT_PATH=checkpoint_path make checkpoint 30 | -------------------------------------------------------------------------------- /utils/checkpoint/creator/makefile: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # 3 | # DO NOT EDIT THIS FILE! 4 | # 5 | ############################################################## 6 | 7 | # If the tool is built out of the kit, PIN_ROOT must be specified in the make invocation and point to the kit root. 8 | ifdef PIN_ROOT 9 | CONFIG_ROOT := $(PIN_ROOT)/source/tools/Config 10 | else 11 | CONFIG_ROOT := ../Config 12 | endif 13 | include $(CONFIG_ROOT)/makefile.config 14 | include makefile.rules 15 | include $(TOOLS_ROOT)/Config/makefile.default.rules 16 | 17 | ############################################################## 18 | # 19 | # DO NOT EDIT THIS FILE! 20 | # 21 | ############################################################## 22 | -------------------------------------------------------------------------------- /utils/checkpoint/loader/.gitignore: -------------------------------------------------------------------------------- 1 | obj 2 | checkpoint_loader 3 | loader 4 | build 5 | build_dbg 6 | -------------------------------------------------------------------------------- /utils/checkpoint/loader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5.0) 2 | 3 | project(scarab_checkpoint_loader CXX C) 4 | 5 | set(CMAKE_C_STANDARD 99) 6 | set(CMAKE_CXX_STANDARD 17) 7 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 8 | 9 | set(warn_flags -Wall -Wunused -Wmissing-declarations -Wno-long-long -Wpointer-arith -Werror) 10 | set(warn_c_flags ${warn_flags} -Wmissing-prototypes -Wimplicit -Wno-unused-but-set-variable -Wno-maybe-uninitialized) 11 | set(warn_cxx_flags ${warn_flags}) 12 | 13 | 14 | add_library(loader_lib 15 | ptrace_interface.cc ptrace_interface.h 16 | checkpoint_reader.cc checkpoint_reader.h 17 | gtree.c gtree.h 18 | hconfig.c hconfig.h 19 | read_mem_map.cc read_mem_map.h 20 | utils.cc utils.h 21 | ) 22 | target_compile_options(loader_lib 23 | PUBLIC 24 | "$<$:${warn_c_flags}>" 25 | "$<$:${warn_cxx_flags}>" 26 | ) 27 | target_compile_definitions(loader_lib 28 | PUBLIC 29 | "$<$:DEBUG_EN=0>" 30 | "$<$>:DEBUG_EN=1>" 31 | ) 32 | 33 | add_executable(checkpoint_loader 34 | checkpoint_loader.cc 35 | ) 36 | target_link_libraries(checkpoint_loader PUBLIC loader_lib) 37 | 38 | 39 | option(BUILD_TESTS "Build or not build the test binary for memcpy" OFF) 40 | 41 | if (BUILD_TESTS) 42 | add_executable(test_memcpy 43 | test_memcpy.cc 44 | ) 45 | target_link_libraries(test_memcpy PUBLIC loader_lib -static) 46 | endif() 47 | -------------------------------------------------------------------------------- /utils/checkpoint/loader/Makefile: -------------------------------------------------------------------------------- 1 | CMAKE=$(shell if which cmake3 ; then echo "cmake"; else echo "cmake"; fi) 2 | 3 | all: opt 4 | 5 | .PHONY: opt 6 | opt: build/Makefile 7 | make -j --no-print-directory -C build 8 | ln -sf build/checkpoint_loader checkpoint_loader 9 | 10 | .PHONY: dbg 11 | dbg: build_dbg/Makefile 12 | make -j --no-print-directory -C build_dbg 13 | ln -sf build_dbg/checkpoint_loader checkpoint_loader 14 | 15 | build/Makefile: 16 | mkdir -p build 17 | cd build; $(CMAKE) .. -DCMAKE_BUILD_TYPE=Release 18 | 19 | build_dbg/Makefile: 20 | mkdir -p build_dbg 21 | cd build_dbg; $(CMAKE) .. -DCMAKE_BUILD_TYPE=Debug 22 | 23 | clean: 24 | rm -rf build/ build_dbg/ 25 | rm -f checkpoint_loader 26 | -------------------------------------------------------------------------------- /utils/checkpoint/loader/checkpoint_reader.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __CHECKPOINT_READER_H__ 23 | #define __CHECKPOINT_READER_H__ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | extern "C" { 36 | #include "hconfig.h" 37 | } 38 | 39 | #include "utils.h" 40 | 41 | static const int FPSTATE_SIZE = 2688; 42 | extern char fpstate_buffer[FPSTATE_SIZE]; 43 | 44 | void read_checkpoint(const char* checkpoint_dir); 45 | 46 | void set_child_pid(pid_t pid); 47 | 48 | void open_file_descriptors(); 49 | 50 | void change_working_directory(); 51 | 52 | uint64_t get_checkpoint_start_rip(); 53 | 54 | const char* get_checkpoint_exe_path(); 55 | 56 | void allocate_new_regions(pid_t child_pid); 57 | 58 | void write_data_to_regions(pid_t child_pid); 59 | 60 | void update_region_protections(pid_t child_pid); 61 | 62 | void load_registers(pid_t child_id); 63 | 64 | std::vector get_checkpoint_envp_vector(); 65 | 66 | std::vector get_checkpoint_argv_vector(); 67 | 68 | bool get_checkpoint_os_info(std::string& kernel_release, 69 | std::string& os_version); 70 | 71 | bool get_checkpoint_cpuinfo(std::string& flags); 72 | #endif 73 | -------------------------------------------------------------------------------- /utils/checkpoint/loader/gtree.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef GTREE_H 23 | #define GTREE_H 24 | 25 | /** \file 26 | 27 | An implementation of a "growing tree," a simple general tree data 28 | structure which allows only one kind of modification: adding 29 | children to a tree node. */ 30 | 31 | /** A type representing both a specific node of a tree, and the tree 32 | for which this node is the root node.*/ 33 | struct gtree_node; 34 | 35 | /** Add a child containing \p data to the (sub)tree rooted in \p 36 | parent. If \p parent is NULL, a root node for a new tree is 37 | created. 38 | 39 | @returns Pointer to the newly created tree node. */ 40 | struct gtree_node* gtree_add_child(struct gtree_node* parent, void* data); 41 | 42 | /** @returns An array of pointers to children of \p parent. The array 43 | size is given by gtree_num_children(). */ 44 | struct gtree_node** gtree_children(struct gtree_node* parent); 45 | 46 | /** @returns Number of children \p parent has. */ 47 | unsigned int gtree_num_children(struct gtree_node* parent); 48 | 49 | /** @returns Pointer to data associated with \p node. */ 50 | void* gtree_data(struct gtree_node* node); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /utils/checkpoint/loader/read_mem_map.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /*4/23/19*/ 23 | 24 | #ifndef __READ_MEM_MAP_H__ 25 | #define __READ_MEM_MAP_H__ 26 | 27 | #include 28 | #include 29 | #include "utils.h" 30 | 31 | std::vector read_proc_maps_file(pid_t pid); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /utils/checkpoint/loader/test_memcpy.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "ptrace_interface.h" 9 | 10 | namespace { 11 | 12 | char data[] = "Test Failed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; 13 | char repl_data[] = "Test Succeeded !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; 14 | 15 | void execute_tracer(pid_t child_pid) { 16 | int status; 17 | waitpid(child_pid, &status, 0); 18 | if(!WIFSTOPPED(status)) { 19 | std::cerr << "Child process did not stop" << std::endl; 20 | std::exit(1); 21 | } 22 | 23 | 24 | auto[tracer_addr, tracee_addr] = allocate_shared_memory(child_pid); 25 | 26 | shared_memory_memcpy(child_pid, &data[0], &repl_data[0], 27 | (sizeof(data) / 8) * 8, tracer_addr, tracee_addr); 28 | // execute_memcpy(child_pid, &data[0], &repl_data[0], (sizeof(data) / 8) * 8); 29 | 30 | if(ptrace(PTRACE_DETACH, child_pid, NULL, NULL)) { 31 | perror("PTRACE_DETACH"); 32 | } 33 | 34 | waitpid(child_pid, &status, 0); 35 | if(!WIFEXITED(status)) { 36 | std::cerr << "Child process did not terminate normally" << std::endl; 37 | std::exit(1); 38 | } 39 | } 40 | 41 | void execute_tracee_wrapper(char* argv0) { 42 | ptrace(PTRACE_TRACEME, 0, 0, 0); 43 | char dummy_arg[] = "dummy"; 44 | char* argv[] = {argv0, dummy_arg, nullptr}; 45 | execv(argv0, argv); 46 | } 47 | 48 | void execute_tracee() { 49 | std::cout << data << std::endl; 50 | } 51 | 52 | } // namespace 53 | 54 | int main(int argc, char** argv) { 55 | if(argc > 1) { 56 | execute_tracee(); 57 | 58 | } else { 59 | auto fork_pid = fork(); 60 | if(fork_pid == 0) { 61 | execute_tracee_wrapper(argv[0]); 62 | } else { 63 | execute_tracer(fork_pid); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /utils/memtrace/portabilize_trace.py: -------------------------------------------------------------------------------- 1 | # Portabilize trace by copying binary dependencies to a local directory 2 | # Usage: python portabilize_trace.py [trace directory, e.g. ~/drmemtrace.trace1.1234.2134.dir/] 3 | # 4 | 5 | from shutil import copy 6 | from os import mkdir 7 | from os import path 8 | import sys 9 | 10 | 11 | if len(sys.argv) < 2: 12 | print('Usage: python portabilize_trace.py [trace directory, e.g. ~/drmemtrace.trace1.1234.2134.dir/]') 13 | exit(); 14 | 15 | traceDir = sys.argv[1] 16 | 17 | binPath = traceDir + '/bin/' 18 | if not path.exists(binPath): 19 | mkdir(binPath) 20 | 21 | data = [] 22 | with open(traceDir + '/bin/modules.log', 'r') as infile : 23 | separator = ', ' 24 | first = 1 25 | col = 99 26 | for line in infile: 27 | s = line.split(separator) 28 | if first: 29 | ss = s[0].split(' ') 30 | 31 | first = 0 32 | if ss[2] != 'version': 33 | print('Corrupt file format'+s[2]) 34 | exit() 35 | else: 36 | #version == 5 37 | if ss[3] == '5': 38 | col = 8 39 | #earlier versions 40 | elif ss[3] < 5: 41 | col = 7 42 | else: 43 | print('new file format, please add support') 44 | exit() 45 | 46 | # Skip over but preserve lines that don't describe libraries 47 | if len(s) < col+1 or s[col][0] != '/': 48 | data.append(line); 49 | continue; 50 | libPath = s[col].strip() 51 | copy(libPath, binPath) 52 | # Modify the path to the library to point to new, relative path 53 | libName = path.basename(libPath) 54 | newLibPath = path.abspath(binPath + libName) 55 | s[col] = newLibPath + '\n' 56 | 57 | data.append(separator.join(s)) 58 | 59 | with open(traceDir + '/raw/modules.log', 'w') as outfile: 60 | for wline in data: 61 | outfile.write(wline) 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /utils/memtrace/run_portabilize_trace.sh: -------------------------------------------------------------------------------- 1 | SCRIPT=$(readlink -f "$0") 2 | SCRIPTDIR=$(dirname "$SCRIPT") 3 | 4 | DRIO_BUILD_DIR=${SCRIPTDIR}/../../src/build/opt/deps/dynamorio 5 | 6 | for dir in */; do 7 | echo "$dir" 8 | cd $dir 9 | mkdir -p bin 10 | cp raw/modules.log bin/modules.log 11 | python2 $SCRIPTDIR/portabilize_trace.py . 12 | cp bin/modules.log raw/modules.log 13 | ${DRIO_BUILD_DIR}/clients/bin64/drraw2trace -indir ./raw/ & 14 | cd - 15 | done 16 | -------------------------------------------------------------------------------- /utils/memtrace/run_update_trace.sh: -------------------------------------------------------------------------------- 1 | SCRIPT=$(readlink -f "$0") 2 | SCRIPTDIR=$(dirname "$SCRIPT") 3 | 4 | DRIO_BUILD_DIR=${SCRIPTDIR}/../../src/build/opt/deps/dynamorio 5 | 6 | for dir in */; do 7 | echo "$dir" 8 | cd $dir 9 | python2 $SCRIPTDIR/updateTraceModulePaths.py . 10 | cd - 11 | done 12 | -------------------------------------------------------------------------------- /utils/memtrace/updateTraceModulePaths.py: -------------------------------------------------------------------------------- 1 | # Update paths in modules.log to the new absolute paths. 2 | # Required step whenever trace is moved to a new location. 3 | # Usage: python updateTraceModulePaths.py [trace directory, e.g. ~/drmemtrace.trace1.1234.2134.dir/] 4 | # 5 | 6 | from os import mkdir 7 | from os import path 8 | import sys 9 | 10 | print (len(sys.argv)) 11 | 12 | if len(sys.argv) < 2: 13 | print ('Usage: python updateTraceModulePaths.py [trace directory, e.g. ~/drmemtrace.trace1.1234.2134.dir/]') 14 | exit(); 15 | 16 | traceDir = sys.argv[1] 17 | 18 | binPath = traceDir + '/bin/' 19 | if not path.exists(binPath): 20 | print ('Error: first portabilize trace') 21 | exit(); 22 | 23 | 24 | 25 | data = [] 26 | with open(traceDir + '/bin/modules.log', 'r') as infile: 27 | separator = ', ' 28 | first = 1 29 | col = 99 30 | for line in infile: 31 | s = line.split(separator) 32 | if first: 33 | ss = s[0].split(' ') 34 | 35 | first = 0 36 | if ss[2] != 'version': 37 | print('Corrupt file format'+s[2]) 38 | exit() 39 | else: 40 | #version == 5 41 | if ss[3] == '5': 42 | col = 8 43 | #earlier versions 44 | elif ss[3] < 5: 45 | col = 7 46 | else: 47 | print('new file format, please add support') 48 | exit() 49 | 50 | # Skip over but preserve lines that don't describe libraries 51 | if len(s) < col+1 or s[col][0] != '/': 52 | data.append(line); 53 | continue; 54 | libPath = s[col].strip() 55 | # Modify the path to the library to point to new, relative path 56 | libName = path.basename(libPath) 57 | newLibPath = path.abspath(traceDir + '/bin/' + libName) 58 | s[col] = newLibPath + '\n' 59 | 60 | print (s) 61 | 62 | data.append(separator.join(s)) 63 | 64 | with open(traceDir + '/bin/modules.log', 'w') as outfile: 65 | for wline in data: 66 | outfile.write(wline) 67 | 68 | -------------------------------------------------------------------------------- /utils/qsort/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | 3 | test_qsort: test_qsort.c ../scarab_markers.h libc_qsort.h libc_qsort.c 4 | $(CC) -o test_qsort test_qsort.c libc_qsort.c -O2 -static 5 | 6 | clean: 7 | rm -f test_qsort 8 | 9 | 10 | -------------------------------------------------------------------------------- /utils/qsort/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 HPS/SAFARI 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from os.path import dirname, basename, isfile, join 15 | import glob 16 | modules = glob.glob(join(dirname(__file__), "*.py")) 17 | __all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')] 18 | -------------------------------------------------------------------------------- /utils/qsort/example_checkpoint_descriptor.def: -------------------------------------------------------------------------------- 1 | # Copyright 2020 HPS/SAFARI Research Groups 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 7 | # of the Software, and to permit persons to whom the Software is furnished to do 8 | # so, 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, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | import os 22 | 23 | qsort = Program("qsort", "./test_qsort", path=scarab_paths.utils_dir + "/qsort", copy=True) 24 | -------------------------------------------------------------------------------- /utils/qsort/example_scarab_batch_jobfile.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 HPS/SAFARI Research Groups 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 7 | # of the Software, and to permit persons to whom the Software is furnished to do 8 | # so, 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, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | import os 22 | import sys 23 | 24 | from scarab_globals import * 25 | from scarab_globals.scarab_batch_types import * 26 | 27 | import_descriptor(scarab_paths.utils_dir + "/qsort/scarab_batch_descriptor.def") 28 | 29 | #SystemConfig.submission_system = command.SubmissionSystems.PBS 30 | 31 | baseline_params = ScarabParams(params_file=scarab_paths.sim_dir + "/src/PARAMS.kaby_lake") 32 | baseline_params += "--heartbeat 1000" 33 | perfect_bp_params="--perfect_bp 1" 34 | perfect_params = baseline_params + perfect_bp_params 35 | 36 | ScarabRun("Baseline", suite1, baseline_params, results_dir="./results") 37 | ScarabRun("Perfect", suite1, perfect_params, results_dir="./results") 38 | 39 | BatchManager() -------------------------------------------------------------------------------- /utils/qsort/libc_qsort.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1991-2018 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | Written by Douglas C. Schmidt (schmidt@ics.uci.edu). 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | The GNU C Library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with the GNU C Library; if not, see 14 | . */ 15 | 16 | /* If you consider tuning this algorithm, you should consult first: 17 | Engineering a sort function; Jon Bentley and M. Douglas McIlroy; 18 | Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993. */ 19 | 20 | #include 21 | 22 | typedef int cmp_t(const void*, const void*, const void*); 23 | 24 | void libc_qsort(void* const pbase, size_t total_elems, size_t size, cmp_t cmp, 25 | void* arg); 26 | -------------------------------------------------------------------------------- /utils/qsort/scarab_batch_descriptor.def: -------------------------------------------------------------------------------- 1 | # Copyright 2020 HPS/SAFARI Research Groups 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 7 | # of the Software, and to permit persons to whom the Software is furnished to do 8 | # so, 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, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | import os 22 | 23 | 24 | qsort = Program("qsort", "./test_qsort", path=scarab_paths.utils_dir + "/qsort", scarab_args="--inst_limit 300000", pintool_args="-fast_forward_to_start_inst 1", copy=True, weight=0.3) 25 | qsort2 = Program("qsort2", "./test_qsort", path=scarab_paths.utils_dir + "/qsort", scarab_args="--inst_limit 1000000", pintool_args="-fast_forward_to_start_inst 1", copy=True, weight=1.0) 26 | ls_l = Program("ls_l", "/usr/bin/ls -l") 27 | mix1 = Mix("mix1", [qsort, ls_l], scarab_args="--inst_limit 300000") 28 | benchmark = Benchmark("benchmark", [qsort, qsort2]) 29 | suite1 = Suite("suite1", [qsort, ls_l, mix1, benchmark]) 30 | -------------------------------------------------------------------------------- /utils/qsort/test_qsort.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "../scarab_markers.h" 23 | #include "libc_qsort.h" 24 | 25 | int32_t* A; 26 | int32_t N = 1000000; 27 | int32_t elt_size = sizeof(int32_t); 28 | 29 | #define DEBUG 30 | 31 | int int32_compare(const void* A, const void* B, const void* arg) { 32 | const int32_t* A_ptr = A; 33 | const int32_t* B_ptr = B; 34 | int32_t A_data = *A_ptr; 35 | int32_t B_data = *B_ptr; 36 | return A_data < B_data ? -1 : (A_data == B_data) ? 0 : 1; 37 | } 38 | 39 | int main(void) { 40 | printf("Starting Main\n"); 41 | 42 | srand(42); 43 | A = malloc(elt_size * N); 44 | 45 | for(uint32_t i = 0; i < N; ++i) { 46 | A[i] = (uint32_t)rand(); 47 | } 48 | fflush(stdout); 49 | 50 | scarab_begin(); 51 | libc_qsort(A, N, elt_size, int32_compare, NULL); 52 | scarab_end(); 53 | } 54 | -------------------------------------------------------------------------------- /utils/scarab_markers.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 HPS/SAFARI Research Groups 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all 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, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #ifndef __SCARAB_MARKERS_H__ 23 | #define __SCARAB_MARKERS_H__ 24 | 25 | #include 26 | #include 27 | 28 | #define COMPILER_BARRIER() \ 29 | { __asm__ __volatile__("" ::: "memory"); } 30 | 31 | /* Note: If these values change, must update 32 | * the macros in src/pin/pin_exec/* as well. */ 33 | #define SCARAB_MARKERS_PIN_BEGIN (1) 34 | #define SCARAB_MARKERS_PIN_END (2) 35 | 36 | static inline void scarab_marker(uint64_t op) { 37 | COMPILER_BARRIER(); 38 | __asm__ __volatile__("xchg %%rcx, %%rcx;" : : "c"(op)); 39 | COMPILER_BARRIER(); 40 | } 41 | 42 | static inline void scarab_begin() { 43 | printf("Scarab: Starting Simulation\n"); 44 | scarab_marker(SCARAB_MARKERS_PIN_BEGIN); 45 | } 46 | 47 | static inline void scarab_end() { 48 | scarab_marker(SCARAB_MARKERS_PIN_END); 49 | printf("Scarab: Ending simulation\n"); 50 | } 51 | 52 | #endif 53 | --------------------------------------------------------------------------------