├── .gitattributes ├── .gitignore ├── .gitmodules ├── Makefile ├── Makefile-defs.mk ├── Makefile-template.mk ├── README-Install.md ├── README-License.txt ├── README-notes-history.md ├── README-notes.md ├── README.md ├── benchmarks ├── Makefile └── README.md ├── bin-anlys ├── Makefile ├── README-Install.md ├── README-License.txt ├── README-notes.md ├── README.md ├── README │ ├── MIAMI-ACKNOWLEDGEMENTS │ ├── MIAMI-LICENSE │ └── miami-README ├── doc │ ├── MIAMI-Framework-ISPASS14.pdf │ ├── Main_Metrics.txt │ ├── README.txt │ ├── Reuse_Metrics.txt │ └── Units_Metrics.txt ├── machines │ ├── README-architecture.txt │ ├── README-format.txt │ ├── doc │ │ ├── 0-amd-X86-64.pdf │ │ ├── 0-ibm-POWER9.pdf │ │ ├── 0-intel-xeon-phi-knl-Colfax_KNL_Clustering_Modes_Guide.pdf │ │ ├── 0-intel-xeon-phi-knl-Colfax_KNL_MCDRAM_Guide.pdf │ │ ├── 0-intel-xeon-phi-knl.pdf │ │ ├── intel-xeon-x86-64-core-gen2-sandybridge-1.pdf │ │ ├── intel-xeon-x86-64-core-gen2-sandybridge-1a.pdf │ │ ├── intel-xeon-x86-64-core-gen2-sandybridge-2.pages │ │ ├── intel-xeon-x86-64-core-gen2-sandybridge-3.pages │ │ ├── intel-xeon-x86-64-core-gen3-ivybridge-1.pdf │ │ ├── intel-xeon-x86-64-core-gen3-ivybridge-1a.pdf │ │ ├── intel-xeon-x86-64-core-gen3-ivybridge-2.pages │ │ ├── intel-xeon-x86-64-core-gen4-haswell-1.pdf │ │ ├── intel-xeon-x86-64-core-gen4-haswell-1a.pdf │ │ ├── intel-xeon-x86-64-core-gen4-haswell-2.pages │ │ ├── intel-xeon-x86-64-core-gen5-broadwell-1.pdf │ │ ├── intel-xeon-x86-64-core-gen5-broadwell-1a.pdf │ │ ├── intel-xeon-x86-64-core-gen5-broadwell-2.pages │ │ ├── intel-xeon-x86-64-core-gen6-skylake-1.pdf │ │ ├── intel-xeon-x86-64-core-gen6-skylake-1a.pdf │ │ └── intel-xeon-x86-64-core-gen6-skylake-2.pdf │ ├── x86_IvyBridge_EP.mdf │ ├── x86_SandyBridge_1.mdf │ └── x86_SandyBridge_EP.mdf ├── miami.config ├── src │ ├── Makefile │ ├── OAUtils │ │ ├── BaseGraph.C │ │ ├── BaseGraph.h │ │ ├── DGraph.C │ │ ├── DGraph.h │ │ ├── DomTree.C │ │ ├── DomTree.h │ │ ├── Exception.h │ │ ├── Graph.C │ │ ├── Graph.h │ │ ├── Iterator.h │ │ ├── Makefile │ │ ├── Tree.C │ │ ├── Tree.h │ │ ├── grtest.C │ │ └── trtest.C │ ├── Scheduler │ │ ├── BitSet.C │ │ ├── BitSet.h │ │ ├── BypassRule.C │ │ ├── BypassRule.h │ │ ├── CFG.C │ │ ├── CFG.h │ │ ├── CFGDominator.h │ │ ├── Clique.C │ │ ├── Clique.h │ │ ├── CycleSetDAG.C │ │ ├── CycleSetDAG.h │ │ ├── DGBuilder.C │ │ ├── DGBuilder.h │ │ ├── DGDominator.h │ │ ├── FindCliques.C │ │ ├── FindCliques.h │ │ ├── GenericInstruction.h │ │ ├── InstTemplate.C │ │ ├── InstTemplate.h │ │ ├── Instruction.C │ │ ├── Instruction.h │ │ ├── Machine.C │ │ ├── Machine.h │ │ ├── MachineExecutionUnit.h │ │ ├── Makefile │ │ ├── MemoryHierarchyLevel.C │ │ ├── MemoryHierarchyLevel.h │ │ ├── MiamiDriver.C │ │ ├── MiamiDriver.h │ │ ├── PathInfo.C │ │ ├── PathInfo.h │ │ ├── PatternGraph.C │ │ ├── PatternGraph.h │ │ ├── ReplacementRule.h │ │ ├── SchedDG.C │ │ ├── SchedDG.h │ │ ├── StringAssocTable.C │ │ ├── StringAssocTable.h │ │ ├── TemplateExecutionUnit.C │ │ ├── TemplateExecutionUnit.h │ │ ├── TemplateInstantiate.C │ │ ├── TimeAccount.C │ │ ├── TimeAccount.h │ │ ├── UnitRestriction.C │ │ ├── UnitRestriction.h │ │ ├── XML_output.C │ │ ├── block_path.C │ │ ├── block_path.h │ │ ├── debug_scheduler.C │ │ ├── debug_scheduler.h │ │ ├── dependency_type.C │ │ ├── dependency_type.h │ │ ├── imix_clustering.C │ │ ├── imix_clustering.h │ │ ├── imix_histograms.C │ │ ├── imix_width_clustering.C │ │ ├── imix_width_clustering.h │ │ ├── load_module.C │ │ ├── load_module.h │ │ ├── machdesc.lex.c │ │ ├── machdesc.tab.c │ │ ├── machdesc.tab.h │ │ ├── machine_description.l │ │ ├── machine_description.y │ │ ├── memory_coverage.C │ │ ├── memory_coverage.h │ │ ├── memory_latency_histograms.C │ │ ├── memory_latency_histograms.h │ │ ├── memory_reuse_histograms.C │ │ ├── memory_reuse_histograms.h │ │ ├── miami_options.h │ │ ├── mrd_file_info.h │ │ ├── path_id.C │ │ ├── path_id.h │ │ ├── position.h │ │ ├── reg_sched_info.h │ │ ├── reuse_group.C │ │ ├── reuse_group.h │ │ ├── routine.C │ │ ├── routine.h │ │ ├── schedtool.C │ │ ├── schedule_time.C │ │ ├── schedule_time.h │ │ ├── scope_implementation.h │ │ ├── scope_reuse_data.h │ │ ├── stream_reuse_histograms.C │ │ └── stream_reuse_histograms.h │ ├── common │ │ ├── Assertion.C │ │ ├── Assertion.h │ │ ├── BaseDominator.C │ │ ├── BaseDominator.h │ │ ├── CRCHash.h │ │ ├── Dominator.C │ │ ├── Dominator.h │ │ ├── InstructionDecoder-dyninst.cpp │ │ ├── InstructionDecoder-dyninst.hpp │ │ ├── InstructionDecoder-xed-iclass.h │ │ ├── InstructionDecoder-xed.cpp │ │ ├── InstructionDecoder.cpp │ │ ├── InstructionDecoder.hpp │ │ ├── PrivateCFG.C │ │ ├── PrivateCFG.h │ │ ├── base_slice.C │ │ ├── base_slice.h │ │ ├── block_mapper.h │ │ ├── bucket_hashmap.h │ │ ├── cache_sim.C │ │ ├── cache_sim.h │ │ ├── canonical_ops.C │ │ ├── canonical_ops.h │ │ ├── charless.h │ │ ├── code_scope.C │ │ ├── code_scope.h │ │ ├── config.h │ │ ├── debug_miami.C │ │ ├── debug_miami.h │ │ ├── default_values.C │ │ ├── dense_container.h │ │ ├── fast_hashmap.h │ │ ├── file_utilities.C │ │ ├── file_utilities.h │ │ ├── general_formula.h │ │ ├── generic_math_expression.h │ │ ├── generic_pair.h │ │ ├── generic_trio.h │ │ ├── gnu_demangle.h │ │ ├── hashmaps.h │ │ ├── instr_bins.C │ │ ├── instr_bins.H │ │ ├── instr_info.C │ │ ├── instr_info.H │ │ ├── instruction_class.C │ │ ├── instruction_class.h │ │ ├── loadable_class.C │ │ ├── loadable_class.h │ │ ├── math_routines.C │ │ ├── math_routines.h │ │ ├── miami_allocator.h │ │ ├── miami_containers.h │ │ ├── miami_data_sections.h │ │ ├── miami_globals.C │ │ ├── miami_growvector.h │ │ ├── miami_stack.h │ │ ├── miami_types.h │ │ ├── miami_utils.C │ │ ├── miami_utils.h │ │ ├── mrd_splay_tree.h │ │ ├── printable_class.C │ │ ├── printable_class.h │ │ ├── private_load_module.C │ │ ├── private_load_module.h │ │ ├── private_routine.C │ │ ├── private_routine.h │ │ ├── prog_scope.C │ │ ├── prog_scope.h │ │ ├── ranged_set.H │ │ ├── register_class.C │ │ ├── register_class.h │ │ ├── report_time.C │ │ ├── report_time.h │ │ ├── self_sorted_list.h │ │ ├── slice_references.C │ │ ├── slice_references.h │ │ ├── source_file_mapping.h │ │ ├── source_file_mapping_binutils.C │ │ ├── static_branch_analysis.C │ │ ├── static_branch_analysis.h │ │ ├── static_memory_analysis.C │ │ ├── static_memory_analysis.h │ │ ├── uipair.h │ │ ├── unionfind.h │ │ ├── uop_code_cache.C │ │ ├── uop_code_cache.h │ │ ├── xml.C │ │ └── xml.h │ ├── tarjans │ │ ├── EdgeDirection.h │ │ ├── ForwardBackward.h │ │ ├── MiamiRIFG.C │ │ ├── MiamiRIFG.h │ │ ├── RIFG.h │ │ ├── TarjanIntervals.C │ │ ├── TarjanIntervals.h │ │ ├── UnionFindUniverse.C │ │ └── UnionFindUniverse.h │ └── tools │ │ ├── get_path.sh │ │ ├── run_static.in │ │ └── run_tool.in ├── test │ ├── Makefile │ ├── Makefile_randomAccess │ ├── petsc-matmult-new.memprof │ ├── petsc-matmult-seqbaij_1_0_0.rb │ ├── petsc-matmult-seqbaij_1_0_called_0.cfg.svg │ ├── petsc-matmult.memprof │ ├── petsc.blkprof │ ├── petsc.x86_64-linux.x │ ├── test1.memprof │ ├── test1.x86_64-linux.x │ ├── test2.memprof │ └── test2.x86_64-linux.x ├── x-ExtractSourceFiles │ ├── canonicalize │ ├── collectSourceFiles.sh │ ├── commonPrefix │ ├── copySourceFiles.sh │ └── getAllFileNames.sh └── x-Viewer │ └── hpcviewer.jar ├── mem-anlys ├── .gitignore ├── Access.hpp ├── AccessTime.hpp ├── Address.hpp ├── CPU.hpp ├── Function.cpp ├── Function.hpp ├── Instruction.hpp ├── Makefile ├── MemgazeSource-example-old.cpp ├── MemgazeSource-example.cpp ├── MemgazeSource.cpp ├── MemgazeSource.hpp ├── README-notes.md ├── Trace.hpp ├── Window.cpp ├── Window.hpp ├── check │ ├── Makefile │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part1 │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part1.binanlys │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part1.callpath │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part1.gold │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part1.gold-oe │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part1.hpcstruct │ │ └── minivite-v1-O3-n300k-buf8k-p10000000-part1.trace │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part2 │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part2.binanlys │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part2.callpath │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part2.gold │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part2.gold-oe │ │ ├── minivite-v1-O3-n300k-buf8k-p10000000-part2.hpcstruct │ │ └── minivite-v1-O3-n300k-buf8k-p10000000-part2.trace │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part1 │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part1.binanlys │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part1.callpath │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part1.gold │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part1.gold-oe │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part1.hpcstruct │ │ └── minivite-v3-O3-n300k-buf8k-p10000000-part1.trace │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part2 │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part2.binanlys │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part2.callpath │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part2.gold │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part2.gold-oe │ │ ├── minivite-v3-O3-n300k-buf8k-p10000000-part2.hpcstruct │ │ └── minivite-v3-O3-n300k-buf8k-p10000000-part2.trace │ └── ubench-O3-n500k-buf8k-p100000 │ │ ├── ubench-O3-n500k-buf8k-p100000.binanlys │ │ ├── ubench-O3-n500k-buf8k-p100000.callpath │ │ ├── ubench-O3-n500k-buf8k-p100000.gold │ │ ├── ubench-O3-n500k-buf8k-p100000.gold-oe │ │ ├── ubench-O3-n500k-buf8k-p100000.hpcstruct │ │ └── ubench-O3-n500k-buf8k-p100000.trace ├── loc-anlys │ ├── Makefile │ ├── README.md │ ├── aux_scripts │ │ ├── add_hotlines_affinity.py │ │ ├── buildZoomTree.py │ │ ├── composite-bar-plot.py │ │ ├── composite-metric-plot.py │ │ ├── copy_heatmap_plot.sh │ │ ├── fileToDataframe.py │ │ ├── getRUDInsnMap.py │ │ ├── get_perf_match.py │ │ ├── groupRUDInsn.py │ │ ├── inter-region_heatmap.py │ │ ├── plot_variants_avg.py │ │ ├── sa-si-sd-agg_combined_hm.py │ │ ├── sd_agg_heatmap.py │ │ ├── sp-si-agg_combined_hm.py │ │ ├── sp-si-sd_agg_plot.py │ │ ├── sp-si_agg_plot.py │ │ └── verifyRUDInsnMap.py │ └── src │ │ ├── BlockInfo.cpp │ │ ├── BlockInfo.hpp │ │ ├── SpatialRUD.cpp │ │ ├── SpatialRUD.hpp │ │ ├── TraceLine.hpp │ │ ├── hyperloglog.hpp │ │ ├── main.cpp │ │ ├── memoryanalysis.cpp │ │ ├── memoryanalysis.h │ │ ├── memorymodeling.h │ │ ├── murmur3.h │ │ ├── structure.cpp │ │ └── structure.h ├── main.cpp └── metrics.hpp ├── mem-trace ├── Makefile ├── amd-ibs-select ├── check │ ├── README.md │ └── amd-ibs-select-t1 │ │ ├── ibs_annotated_op-10.csv │ │ └── ibs_annotated_op-1k.csv ├── memgaze-analyze ├── memgaze-analyze-loc ├── memgaze-inst ├── memgaze-inst-cat ├── memgaze-run ├── memgaze-xtrace ├── memgaze-xtrace-normalize ├── perf-script-intel-ldlat.py └── perf-script-intel-pt.py ├── memfriend ├── README-License.txt └── README.md └── xlib ├── Makefile ├── README.md ├── config-lib ├── config.yaml ├── dyninst.patch ├── dyninst.py ├── hpctk-dev-pkgs.yaml ├── hpctk-pkgs.yaml └── hpctk.py └── config-perf ├── perf-python.patch └── perf-script.patch /.gitattributes: -------------------------------------------------------------------------------- 1 | *.md ident 2 | *.txt ident 3 | [mM]ake* ident 4 | *.mk ident 5 | *.sh ident 6 | *.rb ident 7 | *.py ident 8 | *.cpp ident 9 | *.hpp ident 10 | *.C ident 11 | *.[ch] ident 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | */*~ 3 | */*.[oa] 4 | */*/*/*.[oa] 5 | bin-anlys/install/ 6 | bin-anlys/objs/ 7 | tags 8 | */tags 9 | *.swp 10 | */*.swp 11 | cscope.out 12 | */cscope.out 13 | bin-anlys/x-ExtractSourceFiles 14 | bin-anlys/x-Viewer 15 | bin-anlys/test 16 | xlib/lib/ 17 | install/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "benchmarks/gapbs"] 2 | path = benchmarks/gapbs 3 | url = https://github.com/sbeamer/gapbs 4 | [submodule "benchmarks/minivite-x"] 5 | path = benchmarks/minivite-x 6 | url = https://gitlab.pnnl.gov/perf-lab/minivite-x 7 | [submodule "benchmarks/darknet"] 8 | path = benchmarks/darknet 9 | url = https://github.com/pjreddie/darknet 10 | [submodule "benchmarks/sw4lite"] 11 | path = benchmarks/sw4lite 12 | url = https://github.com/geodynamics/sw4lite 13 | [submodule "benchmarks/amg"] 14 | path = benchmarks/amg 15 | url = https://github.com/LLNL/AMG.git -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # -*-Mode: makefile;-*- 2 | 3 | #*BeginPNNLCopyright********************************************************* 4 | # 5 | # $HeadURL$ 6 | # $Id: b3a9434b0207745daf99726c43f05688ac1e068f $ 7 | # 8 | #***********************************************************EndPNNLCopyright* 9 | 10 | #**************************************************************************** 11 | # Package defs 12 | #**************************************************************************** 13 | 14 | include Makefile-defs.mk 15 | 16 | #**************************************************************************** 17 | # Recursion 18 | #**************************************************************************** 19 | 20 | MK_SUBDIRS = \ 21 | bin-anlys \ 22 | mem-anlys \ 23 | mem-trace 24 | 25 | 26 | #**************************************************************************** 27 | # Template Rules 28 | #**************************************************************************** 29 | 30 | include Makefile-template.mk 31 | 32 | 33 | #**************************************************************************** 34 | # Local Rules 35 | #**************************************************************************** 36 | 37 | info.local : 38 | @$(PRINTF) $(msg_info) 39 | 40 | install.local : 41 | 42 | check.local : 43 | 44 | -------------------------------------------------------------------------------- /benchmarks/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS := $(wildcard */.) 2 | 3 | all: $(SUBDIRS) 4 | $(SUBDIRS): 5 | $(MAKE) -C $@ 6 | 7 | .PHONY: all $(SUBDIRS) -------------------------------------------------------------------------------- /benchmarks/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | - [Gapbs](https://github.com/sbeamer/gapbs) 4 | - cc (-g 22) 5 | - 1 thread 6 | - g=22 -> 0.15 s 7 | - g=24 -> 0.72 s 8 | - 8 threads 9 | - g=22 -> 0.02 s 10 | - g=24 -> 0.1 s 11 | - pr (-g 22) 12 | - [minivite](https://gitlab.pnnl.gov/perf-lab/minivite-x) (v2 or v3) 13 | - need to add -lm in Makefile in line 28 14 | - add -n 300000 (specify rank) 15 | - 1 thread 16 | - n=300000 -> 1.4 s 17 | - 8 threads 18 | - n=300000 -> 0.25 s 19 | - n=600000 -> 0.5 s 20 | - [darknet](https://github.com/pjreddie/darknet) 21 | - resnet152 22 | - alexnet 23 | - [AMG](https://github.com/LLNL/AMG) 24 | - make sure that Makefile.include has the -fopenmp option 25 | - omp = 8 26 | - 256 -> 26 s 27 | - 512 -> 3.7 m 28 | - 1024 -> mem overflow 29 | - [sw4lite](https://github.com/geodynamics/sw4lite) 30 | - need to use the line: make ckernel=yes openmp=yes 31 | - 1 thread 32 | - n=1 poinsource.in -> 17.5419 s 33 | - 8 threads 34 | - n=1 poinsource.in -> 8.6982 s 35 | 36 | # Pipeline Steps 37 | 38 | 1. inst 39 | 2. run 40 | 3. xtrace 41 | 4. analyze or analyze-loc 42 | 43 | # Dependencies 44 | 45 | - gcc 46 | - g++ 47 | - make 48 | - openMP 49 | - CUDA toolkit 50 | - openCV 51 | - ar 52 | - cuDNN 53 | - pthread 54 | 55 | # Notes 56 | 57 | - knobs 58 | - affinity 59 | - threads (8 <= n <= 16) 60 | - use only 1 hw thread per p-core 61 | - problem size (start w/ moderate size) 62 | 63 | - metrics 64 | - time 65 | - \time -f "overview: elapsed %es, user %Us, system %Ss, cpu %P, ctxt-switch %c, waits %w, exit %x\nmemory: res-set-max %MK, res-set-avg %tK, mem-avg %KK, unshared-data-avg %DK, unshared-stack-avg %pK, shared-txt-avg %XK, major-faults %F, minor-faults %R, swaps %W\nio: inputs %I, outputs %O, sckt-rcv %r, sckt-snd %s, signals %k" 66 | 67 | - first order statistics: compute means and stardard deviations of all experiments (-> to catch outliars) -------------------------------------------------------------------------------- /bin-anlys/Makefile: -------------------------------------------------------------------------------- 1 | # -*-Mode: makefile;-*- 2 | 3 | #*BeginPNNLCopyright********************************************************* 4 | # 5 | # $HeadURL$ 6 | # $Id: a85cf6340db0967f1e8e20cba3a2da5a38270a1a $ 7 | # 8 | #***********************************************************EndPNNLCopyright* 9 | 10 | #**************************************************************************** 11 | # Package defs 12 | #**************************************************************************** 13 | 14 | include ../Makefile-defs.mk 15 | ##include miami.config 16 | 17 | #**************************************************************************** 18 | 19 | MIAMI_TARGET ?= $(MEMGAZE_MIAMI_ROOT) 20 | 21 | VAR_FILES = $(wildcard $(MIAMI_TARGET)/etc/vars/vars_*) 22 | 23 | 24 | #**************************************************************************** 25 | # Template Rules 26 | #**************************************************************************** 27 | 28 | include ../Makefile-template.mk 29 | 30 | #**************************************************************************** 31 | # Local Rules 32 | #**************************************************************************** 33 | 34 | all: 35 | ifneq ($(VAR_FILES),) 36 | rm $(VAR_FILES) 37 | endif 38 | cd src && $(MAKE) $@ MIAMI_KIT=1 39 | # @echo "Installing out of tree" 40 | mkdir -p $(MIAMI_TARGET) 41 | 42 | clean cleanall info: 43 | cd src && $(MAKE) $@ MIAMI_KIT=1 44 | 45 | distclean: cleanall 46 | 47 | install.local : 48 | 49 | -------------------------------------------------------------------------------- /bin-anlys/README-Install.md: -------------------------------------------------------------------------------- 1 | -*-Mode: markdown;-*- 2 | 3 | $Id: b67c7d5191b4f21578f181442752541afc58c9fb $ 4 | 5 | 6 | Prerequisites 7 | ============================================================================= 8 | 9 | Environment 10 | - GCC 4+ 11 | - DynInstAPI 9.3.2 (Palm externals) 12 | - Xed (Palm externals) 13 | - binutils 2.26+ (Palm externals) 14 | 15 | 16 | 17 | Building & Installing 18 | ============================================================================= 19 | 20 | 1. Build Palm Externals package: 21 | https://gitlab.pnnl.gov/perf-lab/palm/palm-externals 22 | 23 | 2. 24 | 25 | 26 | Using 27 | ============================================================================= 28 | 29 | -------------------------------------------------------------------------------- /bin-anlys/README.md: -------------------------------------------------------------------------------- 1 | -*-Mode: markdown;-*- 2 | 3 | $Id: 81ee58b1c073bc00642ebe4b0682bba3b5459a7f $ 4 | 5 | Palm Memory 6 | ============================================================================= 7 | 8 | **Home**: 9 | - https://gitlab.pnnl.gov/perf-lab/palm/palm-memory 10 | 11 | 12 | **About**: Palm/Memory: The Performance and Architecture Lab Modeling 13 | tool, or Palm, is a modeling tool designed to make application 14 | modeling easier. 15 | 16 | 17 | **Palm/FastFootprints**: The new FastFootprints is a tool for 18 | low-overhead analysis of memory footprint access diagnostics. 19 | (MIAMI-NW computes footprints, but has overheads of at least ~200x.) 20 | FastFootprints has two methods. The whole-program method reduces the 21 | overhead to 10% by computing upper bounds, but still yields 22 | inter-procedural insight through a call path profile. The precise 23 | method uses additional static analysis and profiling to refine the 24 | upper bounds for intra-procedural loop nests. 25 | 26 | 27 | **Contributors**: 28 | - Ozgur Kilic (PNNL) 29 | - Nathan R. Tallent (PNNL) 30 | 31 | 32 | Acknowledgements 33 | ----------------------------------------------------------------------------- 34 | 35 | This work was supported by the U.S. Department of Energy's Office of 36 | Advanced Scientific Computing Research: 37 | - Integrated End-to-end Performance Prediction and Diagnosis 38 | - PNNL DMC Fallacy... 39 | 40 | Portions of Palm Memory utilize functionality heavily adapted from MIAMI-NW (https://gitlab.pnnl.gov/perf-lab/palm/miami-nw), an updated version of MIAMI. 41 | The original MIAMI READMEs and license are located in directory. 42 | 43 | -------------------------------------------------------------------------------- /bin-anlys/README/MIAMI-ACKNOWLEDGEMENTS: -------------------------------------------------------------------------------- 1 | ACKNOWLEDGEMENTS: 2 | 3 | Funding for this work has been provided by: 4 | 2013-2014: University of Tennessee, Knoxville 5 | 2011-2012: Oak Ridge National Laboratory 6 | before 2008: Rice University 7 | 8 | MIAMI includes code developed at Rice University as part of the HPCToolkit 9 | and DSystem frameworks. In particular, the Tarjan interval analysis 10 | and the Java XML viewer were taken from HPCToolkit. 11 | A collection of basic graph classes were taken from an early release 12 | of the OpenAnalysis library. 13 | 14 | An initial implmentation based on analysis of Sparc binaries using the EEL 15 | binary analysis framework has been developped at Rice University before 2008. 16 | The current implementation based on analysis of x86 binaries has been under 17 | development since 2011. Some functionality could be ported over from the 18 | Sparc version, however, a majority of the code is completely new, or heavily 19 | modified. 20 | 21 | Authors: 22 | * Gabriel Marin 23 | 24 | -------------------------------------------------------------------------------- /bin-anlys/README/MIAMI-LICENSE: -------------------------------------------------------------------------------- 1 | 2 | MIAMI is licensed under the following BSD license: 3 | 4 | Copyright (c) 2013-2014 University of Tennessee 5 | Copyright (c) 2011-2012 UT-Battelle, LLC 6 | All other rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | * Neither the names of the copyright holders, nor the names of its 19 | contributors may be used to endorse or promote products derived from this 20 | software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | 34 | -------------------------------------------------------------------------------- /bin-anlys/README/miami-README: -------------------------------------------------------------------------------- 1 | ABOUT MIAMI: 2 | 3 | MIAMI (Machine Independent Application Models for performance Insight) is a 4 | collection of tools for automatic construction of application centric, 5 | thread-level, performance models, focused on facilitating performance 6 | prediction and micro-architecture level performance diagnosis. At its lowest 7 | level, MIAMI uses static and dynamic analysis of fully optimized x86-64 8 | application binaries. 9 | 10 | 11 | MOTIVATION: 12 | 13 | Performance diagnosis is by and large a manual process. While performance 14 | measurement is well supported by existing tools, analysis of performance 15 | results to understand performance inefficiencies and to identify 16 | opportunities for tuning is left to the users. The difficulty of this task 17 | is compounded by the fact that most performance tools measure performance 18 | effects, the result of interactions between code and a target architecture. 19 | Such measurements are useful to identify hotspots in applications, places 20 | where execution time is spent or where cache misses are incurred. However, 21 | a process of deconvolution through which we can attribute parts of the 22 | observed effects to specific application and architectural factors is needed 23 | to perform root cause analysis from hardware counter measurements. While 24 | certain correlations between application or architectural factors and the 25 | observed performance effects can be established, this process is based on 26 | human intuition, and many times results in a trial and error tuning approach. 27 | 28 | In contrast, MIAMI uses a bottom-up approach. Instead of measuring 29 | performance effects, MIAMI collects profiles of application characteristics 30 | that are largely architecture independent. MIAMI uses detailed static 31 | analysis and performance modeling based on first order principles to reason 32 | about the performance of a code on a target architecture, to understand 33 | performance inefficiencies, and to identify opportunities for tuning. MIAMI 34 | computes a large number of performance metrics that correlate well with 35 | several types of common performance inefficiencies. Experienced users that 36 | can interpret this data would get the most benefit from the provided 37 | insight. While manual interpretation of performance results is still needed 38 | for now, our experience shows that MIAMI drastically reduces the amount of 39 | guesswork traditionally involved in uncovering tuning opportunities. 40 | 41 | 42 | INSTALLATION: 43 | 44 | For building instructions, see the INSTALL file in this folder. 45 | 46 | 47 | USE INSTRUCTIONS: 48 | 49 | For information on using the tools, see the README file and associated 50 | documentation in the doc/ subfolder. 51 | 52 | 53 | CONTACT INFORMATION: 54 | 55 | For other questions, contact Gabriel Marin . 56 | -------------------------------------------------------------------------------- /bin-anlys/doc/MIAMI-Framework-ISPASS14.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/doc/MIAMI-Framework-ISPASS14.pdf -------------------------------------------------------------------------------- /bin-anlys/doc/Reuse_Metrics.txt: -------------------------------------------------------------------------------- 1 | Description of data reuse metrics: 2 | 3 | Reuse_L1D : Long reused locations for level L1D 4 | IrregReuse_L1D : Irregular long reused locations for level L1D 5 | Reuse_L2D : Long reused locations for level L2D 6 | IrregReuse_L2D : Irregular long reused locations for level L2D 7 | Reuse_L3D : Long reused locations for level L3D 8 | 9 | - lists individual memory access patterns grouped by source and destination 10 | of the reuse, and their contribution to misses at various memory levels. 11 | "IrregReuse_*" accounts only for misses caused by patterns that were 12 | determined to be irregular or indirect, while "Reuse_*" accounts for 13 | misses from all memory access patterns. 14 | 15 | For each pattern group you can further see the carrying scopes of 16 | individual access patterns and how many misses each pattern produces. 17 | See my ISPASS'08 paper for an explanation of data access patterns, and 18 | definition of source, destination, carrier scopes. 19 | -------------------------------------------------------------------------------- /bin-anlys/doc/Units_Metrics.txt: -------------------------------------------------------------------------------- 1 | Description of unit usage metrics: 2 | 3 | CPU_Time : Total scheduling time 4 | - estimate of instruction schedule cost; same value as in the main xml file. 5 | 6 | InUse_U_ALU[0] : Cycles unit U_ALU[0] was in use 7 | InUse_U_ALU[1] : Cycles unit U_ALU[1] was in use 8 | InUse_U_ALU[2] : Cycles unit U_ALU[2] was in use 9 | InUse_U_Load[0] : Cycles unit U_Load[0] was in use 10 | InUse_U_Load[1] : Cycles unit U_Load[1] was in use 11 | InUse_U_StAddr[0] : Cycles unit U_StAddr[0] was in use 12 | InUse_U_StAddr[1] : Cycles unit U_StAddr[1] was in use 13 | InUse_U_STD[0] : Cycles unit U_STD[0] was in use 14 | InUse_U_VMul[0] : Cycles unit U_VMul[0] was in use 15 | InUse_U_VAdd[0] : Cycles unit U_VAdd[0] was in use 16 | InUse_U_JMP[0] : Cycles unit U_JMP[0] was in use 17 | InUse_U_VShuffle[0] : Cycles unit U_VShuffle[0] was in use 18 | InUse_U_VShuffle[1] : Cycles unit U_VShuffle[1] was in use 19 | InUse_U_FDiv[0] : Cycles unit U_FDiv[0] was in use 20 | InUse_U_FpAdd[0] : Cycles unit U_FpAdd[0] was in use 21 | InUse_U_FpMul[0] : Cycles unit U_FpMul[0] was in use 22 | InUse_U_FpShuf[0] : Cycles unit U_FpShuf[0] was in use 23 | InUse_U_FpBool[0] : Cycles unit U_FpBool[0] was in use 24 | InUse_U_FpBlend[0] : Cycles unit U_FpBlend[0] was in use 25 | InUse_U_FpBlend[1] : Cycles unit U_FpBlend[1] was in use 26 | InUse_U_Carry[0] : Cycles unit U_Carry[0] was in use 27 | InUse_I_Port[0] : Cycles unit I_Port[0] was in use 28 | InUse_I_Port[1] : Cycles unit I_Port[1] was in use 29 | InUse_I_Port[2] : Cycles unit I_Port[2] was in use 30 | InUse_I_Port[3] : Cycles unit I_Port[3] was in use 31 | InUse_I_Port[4] : Cycles unit I_Port[4] was in use 32 | InUse_I_Port[5] : Cycles unit I_Port[5] was in use 33 | InUse_L1_WrTrans : Usage of async resource L1_WrTrans 34 | - reports how many cycles each execution units has been in use during the 35 | execution of a loop / routine. 36 | 37 | -------------------------------------------------------------------------------- /bin-anlys/machines/doc/0-amd-X86-64.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/0-amd-X86-64.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/0-ibm-POWER9.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/0-ibm-POWER9.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/0-intel-xeon-phi-knl-Colfax_KNL_Clustering_Modes_Guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/0-intel-xeon-phi-knl-Colfax_KNL_Clustering_Modes_Guide.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/0-intel-xeon-phi-knl-Colfax_KNL_MCDRAM_Guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/0-intel-xeon-phi-knl-Colfax_KNL_MCDRAM_Guide.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/0-intel-xeon-phi-knl.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/0-intel-xeon-phi-knl.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen2-sandybridge-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen2-sandybridge-1.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen2-sandybridge-1a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen2-sandybridge-1a.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen2-sandybridge-2.pages: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen2-sandybridge-2.pages -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen2-sandybridge-3.pages: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen2-sandybridge-3.pages -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen3-ivybridge-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen3-ivybridge-1.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen3-ivybridge-1a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen3-ivybridge-1a.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen3-ivybridge-2.pages: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen3-ivybridge-2.pages -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen4-haswell-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen4-haswell-1.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen4-haswell-1a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen4-haswell-1a.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen4-haswell-2.pages: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen4-haswell-2.pages -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen5-broadwell-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen5-broadwell-1.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen5-broadwell-1a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen5-broadwell-1a.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen5-broadwell-2.pages: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen5-broadwell-2.pages -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen6-skylake-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen6-skylake-1.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen6-skylake-1a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen6-skylake-1a.pdf -------------------------------------------------------------------------------- /bin-anlys/machines/doc/intel-xeon-x86-64-core-gen6-skylake-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/machines/doc/intel-xeon-x86-64-core-gen6-skylake-2.pdf -------------------------------------------------------------------------------- /bin-anlys/miami.config: -------------------------------------------------------------------------------- 1 | # -*-Mode: makefile;-*- 2 | #**************************************************************************** 3 | #include ../Makefile-defs.mk 4 | 5 | CC = g++ 6 | CXX = g++ -std=gnu++11 -Wno-deprecated-declarations #-std=c++11, -std=c++0x 7 | 8 | LINKER = $(CXX) #-v 9 | 10 | #**************************************************************************** 11 | 12 | # Auto-discover root directory (may need make 3.81+) 13 | #mkfile_defs_mia := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) 14 | #mkfile_defs ?= $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) 15 | 16 | #mkfile_defs_mia_root := $(abspath $(dir $(mkfile_defs_mia))) 17 | #mkfile_defs_root ?= $(abspath $(dir $(mkfile_defs))) 18 | 19 | #**************************************************************************** 20 | 21 | #MEMGAZE_ROOT ?= $(mkfile_defs_root)/../.. 22 | 23 | #MEMGAZE_MIAMI_ROOT := $(abspath $(dir $(mkfile_defs_mia))) 24 | #MEMGAZE_MIAMI_ROOT := $(abspath $(dir $(mkfile_defs))) 25 | #MEMGAZE_MIAMI_ROOT := $(MEMGAZE_ROOT)/bin-anlys/ 26 | 27 | #MEMGAZE_EXT_ROOT ?= $(MEMGAZE_ROOT)/palm-externals/ 28 | 29 | #MEMGAZE_EXT_HPCTKEXT_ROOT ?= $(MEMGAZE_EXT_ROOT)/hpctoolkit-externals/ 30 | 31 | #DYNINST_ROOT = $(MEMGAZE_EXT_HPCTKEXT_ROOT)/symtabAPI 32 | #DYNINST_ROOT ?= /home/kili337/src/DYNINST_Xaozhu/dyninst/install 33 | #DYNINST_ROOT ?= /files0/kili337/TestBed/memgaze/palm-externals/dyninst/install 34 | #DYNINST_INC = $(DYNINST_ROOT)/include 35 | #DYNINST_LIB = $(DYNINST_ROOT)/lib 36 | 37 | #XED_ROOT ?= $(MEMGAZE_EXT_HPCTKEXT_ROOT)/xed2 38 | #XED_ROOT ?= /files0/kili337/TestBed/memgaze/palm-externals/hpctoolkit-externals/xed2/kits/xed-install-base-2015-09-10-lin-x86-64/ 39 | #XED_INC = $(XED_ROOT)/include 40 | #XED_LIB = $(XED_ROOT)/lib 41 | 42 | #BINUTILS_ROOT ?= $(MEMGAZE_EXT_HPCTKEXT_ROOT)/binutils 43 | #BINUTILS_INC = $(BINUTILS_ROOT)/include 44 | 45 | #BOOST_ROOT ?= $(MEMGAZE_EXT_HPCTKEXT_ROOT)/boost 46 | #BOOST_INC = $(BOOST_ROOT)/include 47 | #BOOST_LIB = $(BOOST_ROOT)/lib 48 | 49 | #TBB_ROOT ?= $(MEMGAZE_EXT_HPCTKEXT_ROOT)/boost 50 | #TBB_INC = $(TBB_ROOT)/include 51 | #TBB_LIB = $(TBB_ROOT)/lib 52 | 53 | 54 | #**************************************************************************** 55 | 56 | #MIAMI_TARGET = $(MEMGAZE_MIAMI_ROOT)/install 57 | -------------------------------------------------------------------------------- /bin-anlys/src/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS = Scheduler 2 | 3 | all clean cleanall distclean info: 4 | @for dir in $(SUBDIRS); \ 5 | do \ 6 | echo "Running \"make $@\" in $$dir"; \ 7 | (cd $$dir && $(MAKE) $@ MIAMI_KIT=1); \ 8 | done 9 | -------------------------------------------------------------------------------- /bin-anlys/src/OAUtils/Exception.h: -------------------------------------------------------------------------------- 1 | // $Id: 120735fc6dc04ff1b9a98d372082afd2f065843d $ 2 | // -*-C++-*- 3 | // * BeginRiceCopyright ***************************************************** 4 | // 5 | // Copyright ((c)) 2002, Rice University 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 15 | // * Redistributions in binary form must reproduce the above copyright 16 | // notice, this list of conditions and the following disclaimer in the 17 | // documentation and/or other materials provided with the distribution. 18 | // 19 | // * Neither the name of Rice University (RICE) nor the names of its 20 | // contributors may be used to endorse or promote products derived from 21 | // this software without specific prior written permission. 22 | // 23 | // This software is provided by RICE and contributors "as is" and any 24 | // express or implied warranties, including, but not limited to, the 25 | // implied warranties of merchantability and fitness for a particular 26 | // purpose are disclaimed. In no event shall RICE or contributors be 27 | // liable for any direct, indirect, incidental, special, exemplary, or 28 | // consequential damages (including, but not limited to, procurement of 29 | // substitute goods or services; loss of use, data, or profits; or 30 | // business interruption) however caused and on any theory of liability, 31 | // whether in contract, strict liability, or tort (including negligence 32 | // or otherwise) arising in any way out of the use of this software, even 33 | // if advised of the possibility of such damage. 34 | // 35 | // ******************************************************* EndRiceCopyright * 36 | 37 | // Best seen in 120-column wide window (or print in landscape mode). 38 | //-------------------------------------------------------------------------------------------------------------------- 39 | // This file is part of Mint. 40 | // Arun Chauhan (achauhan@cs.rice.edu), Dept of Computer Science, Rice University, 2001. 41 | //-------------------------------------------------------------------------------------------------------------------- 42 | 43 | #ifndef Exception_H 44 | #define Exception_H 45 | 46 | #include 47 | 48 | /** Exception is the abstract base class for all exceptions that can be thrown by Mint programs. */ 49 | class Exception { 50 | public: 51 | Exception () {} 52 | virtual ~Exception () {} 53 | virtual void report (std::ostream&) const = 0; 54 | }; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /bin-anlys/src/OAUtils/Iterator.h: -------------------------------------------------------------------------------- 1 | // $Id: 4a18e2bd2190f34eafacf6ea95c729385fb83cbf $ 2 | // -*-C++-*- 3 | // * BeginRiceCopyright ***************************************************** 4 | // 5 | // Copyright ((c)) 2002, Rice University 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 15 | // * Redistributions in binary form must reproduce the above copyright 16 | // notice, this list of conditions and the following disclaimer in the 17 | // documentation and/or other materials provided with the distribution. 18 | // 19 | // * Neither the name of Rice University (RICE) nor the names of its 20 | // contributors may be used to endorse or promote products derived from 21 | // this software without specific prior written permission. 22 | // 23 | // This software is provided by RICE and contributors "as is" and any 24 | // express or implied warranties, including, but not limited to, the 25 | // implied warranties of merchantability and fitness for a particular 26 | // purpose are disclaimed. In no event shall RICE or contributors be 27 | // liable for any direct, indirect, incidental, special, exemplary, or 28 | // consequential damages (including, but not limited to, procurement of 29 | // substitute goods or services; loss of use, data, or profits; or 30 | // business interruption) however caused and on any theory of liability, 31 | // whether in contract, strict liability, or tort (including negligence 32 | // or otherwise) arising in any way out of the use of this software, even 33 | // if advised of the possibility of such damage. 34 | // 35 | // ******************************************************* EndRiceCopyright * 36 | 37 | // Best seen in 120-column wide window (or print in landscape mode). 38 | //-------------------------------------------------------------------------------------------------------------------- 39 | // This file is part of Mint. 40 | // Arun Chauhan (achauhan@cs.rice.edu), Dept of Computer Science, Rice University, 2001. 41 | //-------------------------------------------------------------------------------------------------------------------- 42 | 43 | #ifndef Iterator_H 44 | #define Iterator_H 45 | 46 | //-------------------------------------------------------------------------------------------------------------------- 47 | /** The Iterator abstract base class defines the basic properties of an iterator. */ 48 | class Iterator { 49 | public: 50 | Iterator () {} 51 | virtual ~Iterator () {} 52 | virtual operator bool () const = 0; 53 | virtual void operator++ () = 0; 54 | void operator++ (int) { operator++(); } // postfix, only forward iterator is defined 55 | }; 56 | //-------------------------------------------------------------------------------------------------------------------- 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/BypassRule.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: BypassRule.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Implements a data structure to hold MDL (machine description language) 10 | * bypass rules. 11 | */ 12 | 13 | #include "BypassRule.h" 14 | #include "instr_bins.H" 15 | #include "dependency_type.h" 16 | 17 | using namespace MIAMI; 18 | 19 | BypassRule::BypassRule (ICSet* _source, BitSet* _edge, ICSet* _sink, 20 | unsigned int _latency, Position& _pos) : 21 | sourceType(_source), edgeType(_edge), sinkType(_sink), 22 | latency(_latency) 23 | { 24 | pos = _pos; 25 | } 26 | 27 | BypassRule::~BypassRule () 28 | { 29 | delete (sourceType); 30 | delete (edgeType); 31 | delete (sinkType); 32 | } 33 | 34 | bool 35 | BypassRule::matchesRule(const InstructionClass& _source, int _edge, const InstructionClass& _sink) 36 | { 37 | /** search in ICSet. Should I include the width in the search? 38 | ** I may need to change the Comparator clas 39 | ** TODO 40 | */ 41 | return ((*edgeType)[_edge] && (*sourceType)[_source] && (*sinkType)[_sink]); 42 | } 43 | 44 | void 45 | BypassRule::print (FILE* fd) 46 | { 47 | BitSet::BitSetIterator bsit(*edgeType); 48 | fprintf (fd, "A dependency of type {%s", dependencyTypeToString (bsit)); 49 | ++ bsit; 50 | while ((bool)bsit) 51 | { 52 | fprintf (fd, "|%s", dependencyTypeToString (bsit) ); 53 | ++ bsit; 54 | } 55 | 56 | ICSet::iterator icit = sourceType->begin(); 57 | if (icit != sourceType->end()) // I should not have empty sets, but check nevertheless 58 | { 59 | fprintf (fd, "} from an instruction of one of the types {%s-%s-%s-%" PRIwidth, 60 | Convert_InstrBin_to_string(icit->type), ExecUnitToString(icit->eu_style), 61 | ExecUnitTypeToString(icit->eu_type), icit->width ); 62 | ++ icit; 63 | } 64 | for ( ; icit!=sourceType->end() ; ++icit) 65 | { 66 | fprintf (fd, " | %s-%s-%s-%" PRIwidth, 67 | Convert_InstrBin_to_string(icit->type), ExecUnitToString(icit->eu_style), 68 | ExecUnitTypeToString(icit->eu_type), icit->width ); 69 | } 70 | 71 | icit = sinkType->begin(); 72 | if (icit != sinkType->end()) // I should not have empty sets, but check nevertheless 73 | { 74 | fprintf (fd, "} to an instruction of type {%s-%s-%s-%" PRIwidth, 75 | Convert_InstrBin_to_string(icit->type), ExecUnitToString(icit->eu_style), 76 | ExecUnitTypeToString(icit->eu_type), icit->width ); 77 | ++ icit; 78 | } 79 | for ( ; icit!=sinkType->end() ; ++icit) 80 | { 81 | fprintf (fd, " | %s-%s-%s-%" PRIwidth, 82 | Convert_InstrBin_to_string(icit->type), ExecUnitToString(icit->eu_style), 83 | ExecUnitTypeToString(icit->eu_type), icit->width ); 84 | } 85 | fprintf (fd, "} has %u cycles latency.\n", latency); 86 | } 87 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/BypassRule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: BypassRule.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines a data structure to hold MDL (machine description language) 10 | * bypass rules. 11 | */ 12 | 13 | #ifndef _BYPASS_RULE 14 | #define _BYPASS_RULE 15 | 16 | #include 17 | #include 18 | #include "BitSet.h" 19 | #include "position.h" 20 | #include "instruction_class.h" 21 | 22 | namespace MIAMI 23 | { 24 | 25 | class BypassRule 26 | { 27 | public: 28 | BypassRule (ICSet* _source, BitSet* _edge, ICSet* _sink, 29 | unsigned int _latency, Position& _pos); 30 | ~BypassRule (); 31 | bool matchesRule(const InstructionClass& _source, int _edge, const InstructionClass& _sink); 32 | unsigned int bypassLatency() { return (latency); } 33 | void print (FILE* fd); 34 | 35 | private: 36 | ICSet* sourceType; 37 | BitSet* edgeType; 38 | ICSet* sinkType; 39 | unsigned int latency; 40 | Position pos; 41 | }; 42 | 43 | typedef std::list BypassList; 44 | 45 | } /* namespace MIAMI */ 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/CFGDominator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: CFGDominator.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Extends the base Dominator class to implement a dominator algorithm for the 10 | * the Scheduler CFG implementation. 11 | */ 12 | 13 | #ifndef _MIAMI_CFG_DOMINATOR_H 14 | #define _MIAMI_CFG_DOMINATOR_H 15 | 16 | #include "Dominator.h" 17 | #include "CFG.h" 18 | 19 | namespace MIAMI 20 | { 21 | 22 | template 23 | class CFGDominator : public Dominator 24 | { 25 | public: 26 | CFGDominator (CFG *_g, SNodeList &root_nodes, bool _incl_struct=false, 27 | const char *prefix = "") 28 | : Dominator(_g, root_nodes, _incl_struct, prefix) 29 | { } 30 | 31 | CFGDominator (CFG *_g, SNode* rootN, bool _incl_struct=false, 32 | const char *prefix = "") 33 | : Dominator(_g, rootN, _incl_struct, prefix) 34 | { } 35 | 36 | virtual CFG::Node* iDominator (SNode *node) { 37 | return (dynamic_cast((this->nodeDom)[node->getId()])); 38 | } 39 | 40 | /* cannot dynamic cast to **. Use the implementation from the base class which 41 | * returns an array of base pointers. Dynamic cast each individual pointer 42 | * when needed. 43 | */ 44 | /* 45 | CFG::Node** getDomTree () const { 46 | return (dynamic_cast(this->nodeDom)); 47 | } 48 | */ 49 | private: 50 | 51 | }; 52 | 53 | } // namespace MIAMI 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/Clique.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: Clique.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Implements a data structure to hold cliques of nodes. 10 | */ 11 | 12 | #include "Clique.h" 13 | #include 14 | 15 | using namespace MIAMI; 16 | 17 | Clique::Clique (int _num_nodes, unsigned int *_vertices) 18 | { 19 | num_nodes = _num_nodes; 20 | vertices = new unsigned int [num_nodes]; 21 | memcpy (vertices, _vertices, num_nodes*sizeof(unsigned int)); 22 | } 23 | 24 | Clique::~Clique () 25 | { 26 | delete[] vertices; 27 | } 28 | 29 | Clique::Clique (const Clique &cq) 30 | { 31 | num_nodes = cq.num_nodes; 32 | vertices = new unsigned int [num_nodes]; 33 | memcpy (vertices, cq.vertices, num_nodes*sizeof(unsigned int)); 34 | } 35 | 36 | Clique& 37 | Clique::operator= (const Clique &cq) 38 | { 39 | num_nodes = cq.num_nodes; 40 | vertices = new unsigned int [num_nodes]; 41 | memcpy (vertices, cq.vertices, num_nodes*sizeof(unsigned int)); 42 | return (*this); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/Clique.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: Clique.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines a data structure to hold cliques of nodes. 10 | */ 11 | 12 | #ifndef _CLIQUE_H 13 | #define _CLIQUE_H 14 | 15 | #include 16 | #include 17 | 18 | namespace MIAMI 19 | { 20 | 21 | class Clique 22 | { 23 | public: 24 | Clique () { num_nodes = 0; vertices = NULL; } 25 | Clique (int _num_nodes, unsigned int *_vertices); 26 | Clique (const Clique &cq); 27 | ~Clique (); 28 | 29 | Clique& operator= (const Clique &cq); 30 | 31 | int num_nodes; 32 | unsigned int *vertices; 33 | }; 34 | 35 | typedef std::list CliqueList; 36 | 37 | } /* namespace MIAMI */ 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/DGDominator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: DGDominator.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Extends the base Dominator class to implement a dominator algorithm for the 10 | * the Scheduler dependence graph implementation. 11 | */ 12 | 13 | #ifndef _MIAMI_DG_DOMINATOR_H 14 | #define _MIAMI_DG_DOMINATOR_H 15 | 16 | #include "Dominator.h" 17 | #include "SchedDG.h" 18 | 19 | namespace MIAMI_DG 20 | { 21 | 22 | template 23 | class DGDominator : public MIAMI::Dominator 24 | { 25 | public: 26 | DGDominator (SchedDG *_g, MIAMI::SNodeList &root_nodes, bool _incl_struct=false, 27 | const char *prefix = "") 28 | : Dominator(_g, root_nodes, _incl_struct, prefix) 29 | { } 30 | 31 | DGDominator (SchedDG *_g, MIAMI::SNode* rootN, bool _incl_struct=false, 32 | const char *prefix = "") 33 | : Dominator(_g, rootN, _incl_struct, prefix) 34 | { } 35 | 36 | virtual SchedDG::Node* iDominator (MIAMI::SNode *node) { 37 | return (dynamic_cast((this->nodeDom)[node->getId()])); 38 | } 39 | 40 | virtual ~DGDominator() { } 41 | 42 | private: 43 | 44 | }; 45 | 46 | } /* namespace MIAMI_DG */ 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/FindCliques.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: FindCliques.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines a C++ interface to the Ram Samudrala implementation of the 10 | * algorithm for finding cliques in a graph. 11 | */ 12 | 13 | #ifndef _FIND_CLIQUES_H 14 | #define _FIND_CLIQUES_H 15 | 16 | #include "Clique.h" 17 | 18 | namespace MIAMI 19 | { 20 | 21 | class FindCliques 22 | { 23 | public: 24 | FindCliques (int _num_nodes, char *_connected); 25 | ~FindCliques (); 26 | 27 | int compute_cliques (CliqueList &cliques); 28 | 29 | private: 30 | int extend(int old[], int ne, int ce, CliqueList &cliques); 31 | 32 | int num_nodes; 33 | char *connected; 34 | unsigned int *compsub; 35 | int nel; 36 | }; 37 | 38 | } /* namespace MIAMI */ 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/GenericInstruction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: GenericInstruction.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines a machine independent representation of an instruction with type, 10 | * bit width, vector length, and lists of source and destination operands. 11 | */ 12 | 13 | #ifndef _GENERIC_INSTRUCTION_H 14 | #define _GENERIC_INSTRUCTION_H 15 | 16 | #include 17 | #include "dependency_type.h" 18 | #include "position.h" 19 | #include "instruction_class.h" 20 | #include 21 | 22 | namespace MIAMI 23 | { 24 | 25 | class GenericRegister 26 | { 27 | public: 28 | GenericRegister(const char* _regname, int _type, Position& _pos) : 29 | regName(_regname), type(_type) 30 | { 31 | pos = _pos; 32 | } 33 | ~GenericRegister() { delete[] regName; } 34 | 35 | const char* RegName() { return (regName); } 36 | int Type() { return (type); } 37 | const Position& FilePosition() { return (pos); }; 38 | 39 | private: 40 | const char* regName; 41 | int type; 42 | Position pos; 43 | }; 44 | 45 | typedef std::list GenRegList; 46 | 47 | class GenericInstruction 48 | { 49 | public: 50 | GenericInstruction(InstructionClass _iclass, GenRegList* _srcs, GenRegList* _dests) : 51 | iclass(_iclass), srcRegs(_srcs), destRegs(_dests) 52 | { 53 | exclusiveOutput = false; 54 | if (!srcRegs) srcRegs = new GenRegList(); 55 | if (!destRegs) destRegs = new GenRegList(); 56 | } 57 | ~GenericInstruction() 58 | { 59 | GenRegList::iterator nlit; 60 | if (srcRegs != NULL) 61 | { 62 | for (nlit=srcRegs->begin() ; nlit!=srcRegs->end() ; ++nlit) 63 | delete (*nlit); 64 | delete srcRegs; 65 | } 66 | if (destRegs != NULL) 67 | { 68 | for (nlit=destRegs->begin() ; nlit!=destRegs->end() ; ++nlit) 69 | delete (*nlit); 70 | delete destRegs; 71 | } 72 | } 73 | // int Type() const { return (iclass.type); } 74 | const InstructionClass& getIClass() const { return (iclass); } 75 | GenRegList* SourceRegisters() { return (srcRegs); } 76 | GenRegList* DestRegisters() { return (destRegs); } 77 | 78 | // match only patterns where the result of this instruction is used 79 | // only by instructions matched by the source pattern 80 | void setExclusiveOutputMatch() { exclusiveOutput = true; } 81 | bool ExclusiveOutputMatch() const { return (exclusiveOutput); } 82 | 83 | private: 84 | InstructionClass iclass; 85 | GenRegList* srcRegs; 86 | GenRegList* destRegs; 87 | bool exclusiveOutput; 88 | }; 89 | 90 | typedef std::list GenInstList; 91 | 92 | } /* namespace MIAMI */ 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/InstTemplate.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: InstTemplate.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Data structure to hold an instruction execution template defined in 10 | * a machine description file. 11 | */ 12 | 13 | #include "InstTemplate.h" 14 | 15 | using namespace MIAMI; 16 | 17 | InstTemplate::~InstTemplate () 18 | { 19 | // We must be careful because we can have the same pointer copied in 20 | // multiple consecutive elements of the list. But they are always 21 | // consecutive, so I can test easily for these cases. 22 | TEUList *lastCyc = NULL; 23 | MultiCycTemplate::iterator mctit = iTemplate.begin(); 24 | for( ; mctit!=iTemplate.end() ; ++mctit ) 25 | { 26 | if (*mctit!=NULL && *mctit!=lastCyc) 27 | { 28 | TEUList::iterator teuit = (*mctit)->begin(); 29 | for ( ; teuit!=(*mctit)->end() ; ++teuit) 30 | // all are non NULL and unique pointers in this list 31 | delete (*teuit); 32 | delete (*mctit); 33 | } 34 | lastCyc = *mctit; 35 | } 36 | iTemplate.clear(); 37 | } 38 | 39 | void 40 | InstTemplate::addCycles (TEUList* teul, int repeat) 41 | { 42 | length += repeat; 43 | assert(repeat > 0); 44 | iTemplate.push_back(teul); 45 | for( int i=1 ; i 17 | #include "TemplateExecutionUnit.h" 18 | #include 19 | 20 | namespace MIAMI 21 | { 22 | 23 | typedef std::list MultiCycTemplate; 24 | 25 | class InstTemplate 26 | { 27 | public: 28 | InstTemplate () { length = 0; } 29 | 30 | ~InstTemplate (); 31 | 32 | void addCycles (TEUList* teul, int repeat = 1); 33 | 34 | int getLength () const { return (length); } 35 | MultiCycTemplate& getTemplates () { return (iTemplate); } 36 | 37 | private: 38 | int length; 39 | MultiCycTemplate iTemplate; 40 | }; 41 | 42 | typedef std::list ITemplateList; 43 | 44 | class AscendingInstTemplates 45 | { 46 | public: 47 | int operator () (const InstTemplate* it1, const InstTemplate* it2) const 48 | { 49 | return (it1->getLength() < it2->getLength()); 50 | } 51 | }; 52 | 53 | } /* namespace MIAMI */ 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/MachineExecutionUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: MachineExecutionUnit.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Implements a data structure to store information about one type of machine 10 | * execution units. 11 | */ 12 | 13 | #ifndef _MACHINE_EXECUTION_UNIT_H_ 14 | #define _MACHINE_EXECUTION_UNIT_H_ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include "StringAssocTable.h" 21 | #include "position.h" 22 | 23 | namespace MIAMI 24 | { 25 | 26 | class MachineExecutionUnit 27 | { 28 | public: 29 | MachineExecutionUnit () 30 | { 31 | count = 1; 32 | longname = NULL; 33 | } 34 | 35 | ~MachineExecutionUnit () 36 | { 37 | if (longname) 38 | free (longname); 39 | } 40 | 41 | MachineExecutionUnit (int _count, char* _longname, Position& _pos) 42 | { 43 | count = _count; 44 | if (_longname == NULL) 45 | longname = _longname; 46 | else 47 | longname = strdup (_longname); 48 | position = _pos; 49 | } 50 | 51 | MachineExecutionUnit (const MachineExecutionUnit& meu) 52 | { 53 | count = meu.count; 54 | if (longname) 55 | free (longname); 56 | if (meu.longname) 57 | longname = strdup (meu.longname); 58 | else 59 | longname = NULL; 60 | position = meu.position; 61 | } 62 | 63 | MachineExecutionUnit& operator= (const MachineExecutionUnit& meu) 64 | { 65 | count = meu.count; 66 | if (longname) 67 | free (longname); 68 | if (meu.longname) 69 | longname = strdup (meu.longname); 70 | else 71 | longname = NULL; 72 | position = meu.position; 73 | return (*this); 74 | } 75 | 76 | void setNameAndPosition (const char* _longname, const Position& _pos) 77 | { 78 | if (longname==NULL && _longname!=NULL) 79 | longname = strdup (_longname); 80 | position = _pos; 81 | } 82 | 83 | int getCount () const { return (count); } 84 | const char* getLongName () const { return (longname); } 85 | const Position& getPosition () const { return (position); } 86 | 87 | private: 88 | int count; 89 | char* longname; 90 | Position position; 91 | }; 92 | 93 | typedef StringAssocTable ExecUnitAssocTable; 94 | 95 | } /* namespace MIAMI */ 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/ReplacementRule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: ReplacementRule.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines data structure to hold information about an MDL replacement rule. 10 | */ 11 | 12 | #ifndef _REPLACEMENT_RULE_H 13 | #define _REPLACEMENT_RULE_H 14 | 15 | #include 16 | #include "GenericInstruction.h" 17 | #include "PatternGraph.h" 18 | 19 | #include 20 | #include 21 | 22 | namespace MIAMI 23 | { 24 | 25 | /* For each replacement rule do a DFS traversal of the dependency graph. 26 | * Parse only register and memory dependencies. Use a separate traversal 27 | * for each rule in case I want to use the result of a previous rule in a 28 | * future search. 29 | */ 30 | class ReplacementRule 31 | { 32 | public: 33 | ReplacementRule(GenInstList* _srcPattern, const Position& _srcPos, 34 | GenInstList* _destPattern, const Position& _destPos, 35 | char* _ruleName = NULL) : 36 | srcPattern(_srcPattern), destPattern(_destPattern), 37 | srcPos(_srcPos), destPos(_destPos) 38 | { 39 | if (_ruleName!=NULL) 40 | ruleName = _ruleName; 41 | else 42 | { 43 | ruleName = new char[20]; 44 | sprintf(ruleName, "Replacement %d", ++numRules); 45 | } 46 | srcGraph = new PatternGraph(srcPattern, srcPos, regInfo); 47 | } 48 | 49 | ~ReplacementRule() 50 | { 51 | GenInstList::iterator git = srcPattern->begin(); 52 | for ( ; git!=srcPattern->end() ; ++git) 53 | delete (*git); 54 | delete srcPattern; 55 | git = destPattern->begin(); 56 | for ( ; git!=destPattern->end() ; ++git) 57 | delete (*git); 58 | delete destPattern; 59 | 60 | delete[] ruleName; 61 | delete srcGraph; 62 | } 63 | 64 | GenInstList* SourcePattern() const { return (srcPattern); } 65 | GenInstList* DestinationPattern() const { return (destPattern); } 66 | const char* RuleName() { return (ruleName); } 67 | PatternGraph* TemplateGraph() { return (srcGraph); } 68 | PRegMap& RegisterMap() { return (regInfo); } 69 | const Position& SourcePatternPosition() const { return (srcPos); } 70 | const Position& DestPatternPosition() const { return (destPos); } 71 | 72 | private: 73 | GenInstList *srcPattern; 74 | GenInstList *destPattern; 75 | Position srcPos, destPos; 76 | char* ruleName; 77 | static unsigned int numRules; 78 | PRegMap regInfo; 79 | PatternGraph* srcGraph; 80 | }; 81 | 82 | typedef std::list ReplacementList; 83 | 84 | } 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/SchedDG.C: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/src/Scheduler/SchedDG.C -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/StringAssocTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: StringAssocTable.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Implements an associative container with keys of type string. 10 | */ 11 | 12 | #ifndef _STRING_ASSOC_TABLE_H 13 | #define _STRING_ASSOC_TABLE_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "charless.h" 20 | #include "position.h" 21 | 22 | namespace MIAMI 23 | { 24 | 25 | #define NO_MAPPING (-1) 26 | 27 | typedef std::map StringAssocMap; 28 | 29 | template 30 | class StringAssocTable : public StringAssocMap 31 | { 32 | public: 33 | typedef std::vector ElemVector; 34 | 35 | public: 36 | StringAssocTable(int _strict = 1); 37 | ~StringAssocTable(); 38 | 39 | // move information from a vector structure to an array for faster access 40 | void FinalizeMapping (); 41 | 42 | // the new method 43 | int addElement(const char* _name, ElemType *meu, Position& _pos); 44 | 45 | // get index associated with a name 46 | int getMappingForName(const char* _name, Position& _pos); 47 | 48 | // a quiet version of getMappingForName 49 | int findIndexForName(const char* _name); 50 | 51 | // get the element associated with an index 52 | ElemType* getElementAtIndex (int idx) const; 53 | 54 | // return number of classes of units 55 | int NumberOfElements() const { return (nextId); } 56 | 57 | void setStartPosition (Position &_pos) { position = _pos; } 58 | const Position& getStartPosition () const { return (position); } 59 | 60 | private: 61 | int nextId; 62 | int strictCheck; 63 | bool finalized; 64 | union _elems { 65 | ElemVector* evector; 66 | ElemType** earray; 67 | } elements; 68 | Position position; 69 | }; 70 | 71 | } /* namespace MIAMI */ 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/TemplateExecutionUnit.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: TemplateExecutionUnit.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines data structure to hold information about the use pattern of an 10 | * execution unit type as part of an instruction execution template. 11 | */ 12 | 13 | #include "TemplateExecutionUnit.h" 14 | 15 | using namespace MIAMI; 16 | 17 | TemplateExecutionUnit::TemplateExecutionUnit (int _unit, BitSet* _umask, 18 | int _count) 19 | { 20 | index = _unit; 21 | count = _count; 22 | unit_mask = _umask; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/TemplateExecutionUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: TemplateExecutionUnit.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines data structure to hold information about the use pattern of an 10 | * execution unit type as part of an instruction execution template. 11 | */ 12 | 13 | #ifndef _TEMPLATE_EXECUTION_UNIT_H_ 14 | #define _TEMPLATE_EXECUTION_UNIT_H_ 15 | 16 | #include 17 | #include 18 | #include "BitSet.h" 19 | #include 20 | 21 | namespace MIAMI 22 | { 23 | 24 | #define EXACT_MATCH_ALLOCATE 0 25 | 26 | class TemplateExecutionUnit 27 | { 28 | public: 29 | TemplateExecutionUnit (int _unit, BitSet* _umask, int _count); 30 | ~TemplateExecutionUnit () 31 | { 32 | if (unit_mask) 33 | delete unit_mask; 34 | } 35 | 36 | inline BitSet* UnitsMask () const { return (unit_mask); } 37 | inline int Count () const { return (count); } 38 | 39 | int index; 40 | int count; 41 | BitSet *unit_mask; 42 | }; 43 | 44 | typedef std::list TEUList; 45 | 46 | } /* namespace MIAMI */ 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/TemplateInstantiate.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: TemplateInstantiate.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Declares certain template instantiations to force the compiler to define 10 | * some otherwise missing symbols. 11 | */ 12 | 13 | #include "StringAssocTable.h" 14 | #include "StringAssocTable.C" 15 | #include "MachineExecutionUnit.h" 16 | #include "MemoryHierarchyLevel.h" 17 | 18 | template class MIAMI::StringAssocTable; 19 | template class MIAMI::StringAssocTable; 20 | 21 | #include "SchedDG.h" 22 | #include "Dominator.h" 23 | #include "Dominator.C" 24 | 25 | template class MIAMI::Dominator; 26 | template class MIAMI::Dominator; 27 | /* 28 | template int MIAMI::Dominator::findLCA(SNodeList &nodeset, int nid, DisjointSet *dsuf, DisjointSet *ds, 29 | SNodeList *otherset, SNode **minLCA); 30 | */ 31 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/UnitRestriction.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: UnitRestriction.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Data structure to hold a unit restrictions MDL construct. 10 | */ 11 | 12 | #include "UnitRestriction.h" 13 | 14 | using namespace MIAMI; 15 | 16 | UnitRestriction::UnitRestriction(TEUList* _units, int _maxCount, char* _ruleName) 17 | { 18 | unitsList = _units; 19 | maxCount = _maxCount; 20 | ruleId = ++numRules; 21 | if (_ruleName!=NULL) 22 | ruleName = _ruleName; 23 | else 24 | { 25 | ruleName = new char[20]; 26 | sprintf(ruleName, "Restriction %d", ruleId); 27 | } 28 | active = true; 29 | // check if this rule is actually restrictive 30 | int numUnits = 0; 31 | if (unitsList) 32 | { 33 | TEUList::iterator teuit = unitsList->begin(); 34 | while (numUnits<=maxCount && teuit!=unitsList->end()) 35 | { 36 | numUnits += (*teuit)->UnitsMask()->Size (); 37 | ++ teuit; 38 | } 39 | if (numUnits <= maxCount) 40 | { 41 | fprintf (stderr, "WARNING: Restriction rule \"%s\" is not really restrictive. Number of units in the set (%d) is less or equal than the maximum number of units allowed (%d).\n", 42 | ruleName, numUnits, maxCount); 43 | active = false; 44 | } 45 | } else // set active false for the retirement restriction because I do not want it applied 46 | // for each issued instruction. I only have to use this rule while computing the low 47 | // bound due to resources 48 | active = false; 49 | } 50 | 51 | UnitRestriction::~UnitRestriction() 52 | { 53 | delete[] ruleName; 54 | if (unitsList) 55 | { 56 | TEUList::iterator teuit = unitsList->begin(); 57 | for ( ; teuit!=unitsList->end() ; ++teuit) 58 | delete (*teuit); 59 | delete unitsList; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/UnitRestriction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: UnitRestriction.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Data structure to hold a unit restrictions MDL construct. 10 | */ 11 | 12 | #ifndef _UNIT_RESTRICTION_H 13 | #define _UNIT_RESTRICTION_H 14 | 15 | #include 16 | #include 17 | #include "TemplateExecutionUnit.h" 18 | 19 | namespace MIAMI 20 | { 21 | 22 | /* Specify issue restrictions between units. 23 | * When the unit list is NULL, the restriction applies to the number of 24 | * retired instructions (just a lower bound on kernel length). 25 | */ 26 | class UnitRestriction 27 | { 28 | public: 29 | UnitRestriction(TEUList* _units, int _maxCount, char* _ruleName = NULL); 30 | ~UnitRestriction(); 31 | 32 | bool IsActive() { return (active); } 33 | int MaxCount() { return (maxCount); } 34 | const char* RuleName() { return (ruleName); } 35 | TEUList* UnitsList() { return (unitsList); } 36 | unsigned int getRuleId() { return (ruleId); } 37 | 38 | private: 39 | TEUList* unitsList; 40 | int maxCount; 41 | unsigned int ruleId; 42 | char* ruleName; 43 | bool active; 44 | static unsigned int numRules; 45 | }; 46 | 47 | typedef std::list RestrictionList; 48 | 49 | } /* namespace MIAMI */ 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/debug_scheduler.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: debug_scheduler.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Logging verbosity knobs, useful for debugging. 10 | */ 11 | 12 | #include "debug_scheduler.h" 13 | 14 | int cfg_counts_debug_level = 7; 15 | int sched_debug_level = 1; 16 | int graph_debug_level = 7; 17 | int paths_debug_level = 7; 18 | int machine_debug_level = 1; 19 | int dom_debug_level = 1; 20 | int memory_debug_level = 2; 21 | int output_debug_level = 1; 22 | int stream_debug_level = 1; 23 | int module_debug_level = 1; 24 | int palm_debug_level = 2; 25 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/debug_scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: debug_scheduler.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Logging verbosity knobs, useful for debugging. 10 | */ 11 | 12 | #ifndef _DEBUG_SCHEDULER_H_ 13 | #define _DEBUG_SCHEDULER_H_ 14 | 15 | #include "debug_miami.h" 16 | 17 | extern int cfg_counts_debug_level; 18 | extern int sched_debug_level; 19 | extern int graph_debug_level; 20 | extern int paths_debug_level; 21 | extern int machine_debug_level; 22 | extern int dom_debug_level; 23 | extern int memory_debug_level; 24 | extern int output_debug_level; 25 | extern int stream_debug_level; 26 | extern int module_debug_level; 27 | extern int palm_debug_level; 28 | 29 | #define DEBUG_CFG_COUNTS 0 30 | #define DEBUG_CFG(x, y) if ((x)<=cfg_counts_debug_level) {y} 31 | 32 | #define VERBOSE_DEBUG_SCHEDULER 1 33 | #define DEBUG_SCHED(x, y) if ((x)<=sched_debug_level) {y} 34 | 35 | #define VERBOSE_DEBUG_DOMINATOR 0 36 | #define DEBUG_DOM(x, y) if ((x)<=dom_debug_level) {y} 37 | 38 | #define VERBOSE_DEBUG_MEMORY 0 39 | #define DEBUG_MEM(x, y) if ((x)<=memory_debug_level) {y} 40 | 41 | #define VERBOSE_DEBUG_OUTPUT 0 42 | #define DEBUG_OUT(x, y) if ((x)<=output_debug_level) {y} 43 | 44 | #define DEBUG_STREAM_REUSE 0 45 | #define DEBUG_STREAMS(x, y) if ((x)<=stream_debug_level) {y} 46 | 47 | #define DEBUG_GRAPH_CONSTRUCTION 0 48 | #define DEBUG_GRAPH(x, y) if ((x)<=graph_debug_level) {y} 49 | 50 | #define DEBUG_BLOCK_PATHS_PRINT 0 51 | #define DEBUG_PATHS(x, y) if ((x)<=paths_debug_level) {y} 52 | 53 | #define DEBUG_MACHINE_CONSTRUCTION 1 54 | #define DEBUG_MACHINE(x, y) if ((x)<=machine_debug_level) {y} 55 | 56 | #define VERBOSE_DEBUG_LOAD_MODULE 1 57 | #define DEBUG_LOAD_MODULE(x, y) if ((x)<=module_debug_level) {y} 58 | 59 | #define PROFILE_SCHEDULER 0 60 | 61 | #define VERBOSE_DEBUG_PALM 0 62 | #define DEBUG_PALM(x, y) if ((x)<=palm_debug_level) {y} 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/dependency_type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: dependency_type.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Define dependence type constants and a few helper functions to operate 10 | * on them. 11 | */ 12 | 13 | #ifndef _DEPENDENCY_TYPE_H 14 | #define _DEPENDENCY_TYPE_H 15 | 16 | 17 | enum DependencyDirection { 18 | ANTI_DEPENDENCY = -1, 19 | OUTPUT_DEPENDENCY, 20 | TRUE_DEPENDENCY, 21 | CHANGING_DEPENDENCY }; 22 | 23 | /* DTYPE_TOP_MARKER is a special name that must appear always as the last 24 | * dependency type in the enumeration. It is necessary to enable special 25 | * processing based on the dependency type. 26 | */ 27 | enum DependencyType { 28 | GP_REGISTER_TYPE = 0, 29 | ADDR_REGISTER_TYPE, 30 | MEMORY_TYPE, 31 | CONTROL_TYPE, 32 | STRUCTURE_TYPE, 33 | SUPER_EDGE_TYPE, 34 | DTYPE_TOP_MARKER }; 35 | 36 | enum DependencyDistance { ONE_ITERATION = -2, VARYING_DISTANCE, 37 | LOOP_INDEPENDENT }; // values > 0 represent the depend distance 38 | 39 | #define ANY_DEPENDENCE_DIRECTION (-101) 40 | #define ANY_DEPENDENCE_TYPE (-101) 41 | #define ANY_DEPENDENCE_DISTANCE (-101) 42 | #define ANY_DEPENDENCE_LEVEL (-101) 43 | #define ANY_GRAPH_NODE ((void*)(-1)) 44 | 45 | extern const char* dependencyDirectionToString(int dd); 46 | extern const char* dependencyTypeToString(int dt); 47 | extern const char* dependencyDistanceToString(int dd); 48 | 49 | extern const char* dependencyDirectionColor(int dd, int dist); 50 | extern const char* dependencyTypeStyle(int dt); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/imix_clustering.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: imix_clustering.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines a set of instruction categories for computing simple instruction 10 | * mixes based on static instruction decoding. 11 | */ 12 | 13 | #ifndef _IMIX_CLUSTERING_H 14 | #define _IMIX_CLUSTERING_H 15 | 16 | #include "miami_types.h" 17 | #include "instruction_class.h" 18 | 19 | namespace MIAMI 20 | { 21 | 22 | enum ImixType { 23 | IMIX_INVALID, 24 | IMIX_Mem, 25 | IMIX_MemVec, 26 | IMIX_IntArithm, 27 | IMIX_IntArithmVec, 28 | IMIX_FpArithm, 29 | IMIX_FpArithmVec, 30 | IMIX_Move, 31 | IMIX_Branch, 32 | IMIX_Misc, 33 | IMIX_Nop, 34 | IMIX_Prefetch, 35 | IMIX_LAST 36 | }; 37 | 38 | extern const char* ImixTypeToString(ImixType it); 39 | extern ImixType IClassToImixType(const InstructionClass& iclass, int& count); 40 | 41 | } /* namespace MIAMI */ 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/imix_width_clustering.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: imix_width_clustering.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines a set of instruction categories for computing instruction mixes 10 | * based on operation type and data width. 11 | */ 12 | 13 | #ifndef _IMIX_WIDTH_CLUSTERING_H 14 | #define _IMIX_WIDTH_CLUSTERING_H 15 | 16 | #include "miami_types.h" 17 | #include "instruction_class.h" 18 | 19 | namespace MIAMI 20 | { 21 | 22 | /* Define a basic set of micro-operations. We will cluster a program's 23 | * micro-ops into these categories. Moreover, for the types between 24 | * IMIXW_WIDTH_FIRST and IMIXW_WIDTH_LAST, we will cluster separately 25 | * operations based on their result's bit length: <=32, 64, 128, 256. 26 | */ 27 | enum ImixWType { 28 | IMIXW_INVALID = 0, 29 | IMIXW_Load, 30 | IMIXW_Store, 31 | IMIXW_IntOp, 32 | IMIXW_FpOp, 33 | IMIXW_Move, 34 | IMIXW_Branch, 35 | IMIXW_Misc, 36 | IMIXW_Nop, 37 | IMIXW_Prefetch, 38 | IMIXW_LAST, 39 | IMIXW_WIDTH_FIRST = IMIXW_Load, 40 | IMIXW_WIDTH_LAST = IMIXW_Move 41 | }; 42 | 43 | enum IWidthType { 44 | IWIDTH_INVALID = 0, 45 | IWIDTH_32, 46 | IWIDTH_64, 47 | IWIDTH_128, 48 | IWIDTH_256, 49 | IWIDTH_LAST 50 | }; 51 | 52 | extern const char* ImixWTypeToString(ImixWType it); 53 | extern const char* IWidthTypeToString(IWidthType it); 54 | 55 | extern ImixWType IClassToImixWType(const InstructionClass& iclass, int& count); 56 | extern IWidthType IClassToIWidthType(const InstructionClass& iclass); 57 | 58 | #define NUM_IMIX_WIDTH_BINS ((IMIXW_WIDTH_LAST-IMIXW_WIDTH_FIRST+1)*(IWIDTH_LAST-IWIDTH_INVALID-2) \ 59 | + IMIXW_LAST-IMIXW_INVALID) 60 | 61 | extern int NumImixWidthBins(); 62 | extern int IClassToImixWidthBin(const InstructionClass& iclass, int& count); 63 | extern ImixWType ImixWidthBinToImixWidthType(int b, IWidthType &width); 64 | 65 | } /* namespace MIAMI */ 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/memory_coverage.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: memory_coverage.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Compute footprint coverage for a reuse group. 10 | */ 11 | 12 | #include "memory_coverage.h" 13 | #include 14 | #include 15 | 16 | namespace MIAMI 17 | { 18 | 19 | MemoryCoverage::MemoryCoverage(int32_t _stride, uint32_t _setIndex, 20 | addrtype _pc, int _op, uint32_t bwidth, GFSliceVal& _formula) 21 | { 22 | int i; 23 | leader_pc = _pc; 24 | leader_memop = _op; 25 | l_formula = _formula; 26 | unusedBytes = stride = _stride; 27 | coverage = new char [stride]; 28 | memset (coverage, 0, stride*sizeof(char)); 29 | setIndex = _setIndex; 30 | gap_computed = false; 31 | // reflist.push_back (new MemAccessInfo (_pc, _op, _bwidth)); 32 | for (i=0 ; i=0 and =0 && _offset largest_gap) 85 | largest_gap = local_gap; 86 | } 87 | gap_computed = true; 88 | } 89 | return (largest_gap); 90 | } 91 | 92 | } /* namespace MIAMI */ 93 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/memory_coverage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: memory_coverage.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Compute footprint coverage for a reuse group. 10 | */ 11 | 12 | #ifndef _MEMORY_COVERAGE_H 13 | #define _MEMORY_COVERAGE_H 14 | 15 | #include "miami_types.h" 16 | #include "slice_references.h" 17 | #include 18 | 19 | namespace MIAMI 20 | { 21 | 22 | // A reuse group represents a group of references with similar access 23 | // patterns that are part of the same path and are predicted to have 24 | // close by spatial access. A group is described by a stride value, 25 | // average number of iterations, and a group of references that access 26 | // memory within one "stride" of each other. For each member of a group 27 | // we store a spatial offset relative to the group leader. 28 | // In the end we compute a coverage factor for the references that are part 29 | // of one group, relative to their common access stride. 30 | 31 | class MemAccessInfo 32 | { 33 | public: 34 | MemAccessInfo(addrtype _pc, int _op, int _bwidth, int _offset = 0) : 35 | pc(_pc), bwidth(_bwidth), offset(_offset) 36 | {} 37 | 38 | addrtype pc; // reference address 39 | int memop; // memory operand index 40 | int bwidth; // number of bytes touched by this ref (its footprint in bytes) 41 | int offset; // spatial offset within this memory block, relative to the leader 42 | }; 43 | 44 | typedef std::list MemAccessInfoList; 45 | 46 | class MemoryCoverage 47 | { 48 | public: 49 | MemoryCoverage(int32_t _stride, uint32_t _setIndex, 50 | addrtype _pc, int _op, uint32_t bwidth, GFSliceVal& _formula); 51 | ~MemoryCoverage(); 52 | 53 | inline addrtype leaderAddress() const { return (leader_pc); } 54 | inline int leaderMemOp() const { return (leader_memop); } 55 | inline uint32_t getSetIndex() const { return (setIndex); } 56 | inline int32_t getStrideValue() const { return (stride); } 57 | inline GFSliceVal& LeaderFormula() { return (l_formula); } 58 | 59 | // add a new member; if delay<0, this will become the new leader; 60 | // must update delay and offset for all members; 61 | void addMember(addrtype _pc, int _op, int _offset, int _bwidth); 62 | 63 | int getCoverageValue() const { return (stride - unusedBytes); } 64 | int getLargestGap() const; 65 | 66 | private: 67 | addrtype leader_pc; 68 | int leader_memop; 69 | uint32_t setIndex; 70 | int unusedBytes; 71 | int32_t stride; 72 | char *coverage; 73 | GFSliceVal l_formula; 74 | int largest_gap; 75 | bool gap_computed; 76 | 77 | // MemAccessInfoList reflist; 78 | }; 79 | 80 | typedef std::list MCList; 81 | 82 | } /* namespace MIAMI */ 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/memory_latency_histograms.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: memory_latency_histograms.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Implements the logic for parsing memory latency simulation results, and 10 | * the mechanistic modeling approach to combine them with the instruction 11 | * execution rate predictions from MIAMI, to compute total execution times. 12 | */ 13 | 14 | #ifndef _MEMORY_LATENCY_HISTOGRAMS_H 15 | #define _MEMORY_LATENCY_HISTOGRAMS_H 16 | 17 | #include 18 | #include "miami_types.h" 19 | #include "fast_hashmap.h" 20 | 21 | namespace MIAMI 22 | { 23 | 24 | // I need a data structure to keep the memory latency histograms. 25 | // I can have fixed length arrays for storing latency/count histograms 26 | // because I know the number of bins apriori 27 | typedef float mem_latency_t; 28 | typedef uint32_t access_count_t; 29 | 30 | // define also the printf format strings to be used the for the types defined above 31 | #define PRImlat "g" 32 | #define PRIacnt PRIu32 33 | 34 | typedef std::pair latency_count_bin; 35 | typedef std::vector MemoryLatencyHistogram; 36 | 37 | extern MemoryLatencyHistogram* defaultMLHP; 38 | typedef MIAMIU::HashMap RefLatencyHistMap; 39 | 40 | } /* namespace MIAMI */ 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/mrd_file_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: mrd_file_info.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Store basic information about a mrd file received as input. 10 | */ 11 | 12 | #ifndef _MRD_FILE_INFO_H 13 | #define _MRD_FILE_INFO_H 14 | 15 | #include "miami_types.h" 16 | #include 17 | 18 | namespace MIAMI 19 | { 20 | using std::string; 21 | 22 | #define TEXT_MRD_FILE 1 23 | 24 | // memory reuse distance (MRD) files are associated with a specific 25 | // memory block size. When computing reuse analysis for a memory level 26 | // we need to use MRD data measured with a block size equal to the 27 | // cache line size. 28 | // The block size value is the first field in a MRD file. I will read it 29 | // and store MRD files in a map with the block size as key 30 | struct MrdInfo 31 | { 32 | MrdInfo(const string& _name, addrtype _mask, addrtype _val, uint32_t _bsize, bool isText = true) : 33 | name(_name), bmask(_mask), bvalue(_val), bsize(_bsize) 34 | { 35 | if (isText) 36 | flags |= TEXT_MRD_FILE; 37 | } 38 | 39 | bool IsTextFile() const { return (flags & TEXT_MRD_FILE); } 40 | 41 | string name; // file name 42 | addrtype bmask; // block mask used during data collection 43 | addrtype bvalue;// block value used in conjunction with the mask 44 | uint32_t bsize; // block size 45 | int32_t flags; // set various flags: is text file, etc. 46 | }; 47 | 48 | } /* namespace MIAMI */ 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/path_id.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: path_id.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Implements a path ID class. 10 | */ 11 | 12 | #include "path_id.h" 13 | 14 | namespace MIAMI 15 | { 16 | 17 | std::ostream& operator<< (std::ostream& os, PathID &pId) 18 | { 19 | os << pId.Name(); 20 | return (os); 21 | } 22 | 23 | } /* namespace MIAMI */ 24 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/path_id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: path_id.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Defines a path ID class. 10 | */ 11 | 12 | #ifndef _MIAMI_PATH_ID_H 13 | #define _MIAMI_PATH_ID_H 14 | 15 | #include 16 | #include 17 | 18 | #include "miami_types.h" 19 | 20 | namespace MIAMI 21 | { 22 | 23 | class PathID 24 | { 25 | public: 26 | PathID(addrtype _start = 0, uint32_t _extra = 0) : 27 | start(_start) 28 | { 29 | pathIdx = _extra & 0xffff; 30 | scopeIdx = (_extra >> 16) & 0xffff; 31 | } 32 | PathID(addrtype _start, int _lIdx, int _pIdx) : 33 | start(_start), scopeIdx(_lIdx), pathIdx(_pIdx) 34 | {} 35 | 36 | inline addrtype Start() const { return (start); } 37 | inline int ScopeIndex() const { return (scopeIdx); } 38 | inline int PathIndex() const { return (pathIdx); } 39 | // generate name for printing 40 | const char* Name() { 41 | snprintf(buf, 32, "0x%" PRIxaddr "/%u/%u", start, scopeIdx, pathIdx); 42 | return (buf); 43 | } 44 | // generate name to be used as part of a file name 45 | const char* Filename() { 46 | snprintf(buf, 32, "0x%" PRIxaddr "-%u-%u", start, scopeIdx, pathIdx); 47 | return (buf); 48 | } 49 | 50 | bool operator== (const PathID &pi) const 51 | { 52 | return (start==pi.start && scopeIdx==pi.scopeIdx && pathIdx==pi.pathIdx); 53 | } 54 | bool operator!= (const PathID &pi) const 55 | { 56 | return (start!=pi.start || scopeIdx!=pi.scopeIdx || pathIdx!=pi.pathIdx); 57 | } 58 | operator bool () const 59 | { 60 | return (start || scopeIdx || pathIdx); 61 | } 62 | bool operator! () const 63 | { 64 | return (start==0 && scopeIdx==0 && pathIdx==0); 65 | } 66 | 67 | addrtype start; 68 | uint32_t scopeIdx : 16; // encode scope idx on 16 bits and path number on 16 bits 69 | uint32_t pathIdx : 16; 70 | private: 71 | char buf[32]; 72 | }; 73 | 74 | extern std::ostream& operator<< (std::ostream& os, PathID &pId); 75 | 76 | } /* namespace MIAMI */ 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/position.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: position.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Data structure that holds information about the position in a file. Used 10 | * during the parsing of machine description files. 11 | */ 12 | 13 | #ifndef _POSITION_H 14 | #define _POSITION_H 15 | 16 | namespace MIAMI 17 | { 18 | 19 | class Position 20 | { 21 | public: 22 | void initPosition(const char* _fname, int _line, int _col) 23 | { 24 | file_name = _fname; line = _line; column = _col; 25 | } 26 | 27 | inline const char* FileName() const { return (file_name); } 28 | inline int Line() const { return (line); } 29 | inline int Column() const { return (column); } 30 | 31 | // increment column 32 | Position operator+ (int cols) 33 | { 34 | Position temp; 35 | temp.file_name = file_name; 36 | temp.line = line; 37 | temp.column = column + cols; 38 | return (temp); 39 | } 40 | Position& operator+= (int cols) 41 | { 42 | column += cols; return (*this); 43 | } 44 | // decrement column 45 | Position operator- (int cols) 46 | { 47 | Position temp; 48 | temp.file_name = file_name; 49 | temp.line = line; 50 | temp.column = column - cols; 51 | return (temp); 52 | } 53 | Position& operator-= (int cols) 54 | { 55 | column -= cols; return (*this); 56 | } 57 | 58 | // go to start of next line 59 | Position& operator++ () { line+=1; column=1; return (*this); } 60 | Position& operator++ (int) { line+=1; column=1; return (*this); } 61 | // go to start of previous line 62 | Position& operator-- () { line-=1; column=1; return (*this); } 63 | Position& operator-- (int) { line-=1; column=1; return (*this); } 64 | 65 | // must allow TABS 66 | Position& tab(int tabSize, int count) 67 | { 68 | column = tabSize*((column-1)/tabSize) + 1 + count*tabSize; 69 | return (*this); 70 | } 71 | 72 | private: 73 | const char* file_name; 74 | int line; 75 | int column; 76 | }; 77 | 78 | } /* namespace MIAMI */ 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/reg_sched_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: reg_sched_info.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Data structure to hold scheduling information for input and output 10 | * registers relative to a program scope. 11 | */ 12 | 13 | #ifndef _REG_SCHED_INFO_H 14 | #define _REG_SCHED_INFO_H 15 | 16 | #include 17 | #include "miami_types.h" 18 | #include "register_class.h" 19 | 20 | namespace MIAMI 21 | { 22 | 23 | typedef struct _reg_sched_info 24 | { 25 | // reg_type reg; 26 | register_info reg; 27 | uint32_t cycles; /* clock cycles from start of schedule for src regs 28 | and cycles to end of schedule for dest regs */ 29 | bool dest; /* it is destination register */ 30 | } reg_sched_info; 31 | 32 | typedef std::list RSIList; 33 | 34 | typedef std::list RSIListList; 35 | 36 | } /* namespace MIAMI */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/reuse_group.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: reuse_group.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Data structure to hold information about a set of references with the same 10 | * access pattern that are likely to access the same cache lines. 11 | */ 12 | 13 | #include "reuse_group.h" 14 | 15 | using namespace MIAMI; 16 | 17 | ReuseGroup::ReuseGroup (unsigned int _pc, int _idx, const ScheduleTime &_st, 18 | unsigned int _setIndex, bool _constantStride, 19 | int _valueStride) 20 | { 21 | leader_pc = _pc; 22 | leader_opidx = _idx; 23 | min_offset = max_offset = 0; 24 | leader_st = _st; 25 | setIndex = _setIndex; 26 | constantStride = _constantStride; 27 | valueStride = _valueStride; 28 | reflist.push_back (new RefReuseInfo (_pc, _idx)); 29 | size = 1; 30 | } 31 | 32 | ReuseGroup::~ReuseGroup () 33 | { 34 | RefReuseInfoList::iterator riit = reflist.begin (); 35 | for ( ; riit!=reflist.end() ; ++riit ) 36 | delete (*riit); 37 | reflist.clear (); 38 | size = 0; 39 | } 40 | 41 | // add a new member; if delay<0, this will become the new leader; 42 | // must update delay and offset for all members; 43 | void 44 | ReuseGroup::addMember (unsigned int _pc, int _idx, int _delay, int _offset) 45 | { 46 | reflist.push_back (new RefReuseInfo (_pc, _idx, _delay, _offset)); 47 | if (_offset < min_offset) 48 | min_offset = _offset; 49 | if (_offset > max_offset) 50 | max_offset = _offset; 51 | size += 1; 52 | 53 | if (_delay < 0) 54 | { 55 | // this ref becomes the new leader; long live the king 56 | // adjust all members' offsets, as well as the global offsets 57 | leader_st += _delay; 58 | min_offset -= _offset; 59 | max_offset -= _offset; 60 | RefReuseInfoList::iterator riit = reflist.begin (); 61 | for ( ; riit!=reflist.end() ; ++riit ) 62 | { 63 | RefReuseInfo *ri = *riit; 64 | ri->delay -= _delay; 65 | ri->offset -= _offset; 66 | } 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /bin-anlys/src/Scheduler/reuse_group.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: reuse_group.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Data structure to hold information about a set of references with the same 10 | * access pattern that are likely to access the same cache lines. 11 | */ 12 | 13 | #ifndef _REUSE_GROUP_H 14 | #define _REUSE_GROUP_H 15 | 16 | #include 17 | #include "schedule_time.h" 18 | 19 | namespace MIAMI 20 | { 21 | 22 | // A reuse group represents a group of references with similar access 23 | // patterns that are part of the same path and are predicted to have 24 | // temporal or spatial reuse on each other. A group is described by its 25 | // leader, which represents the reference that is likely to first access 26 | // a cache line, and the list of all references in the group. For each 27 | // reference we store information about the predicted number of clock 28 | // cycles that pass since the line is accessed by the leader, as well as 29 | // a spatial offset between the location touched by the leader and the 30 | // location accessed by each member. 31 | 32 | class RefReuseInfo 33 | { 34 | public: 35 | RefReuseInfo (unsigned int _pc, int _idx = 0, int _delay = 0, int _offset = 0) : 36 | pc(_pc), opidx(_idx), delay(_delay), offset(_offset) 37 | {} 38 | 39 | unsigned int pc; 40 | int opidx; // store the index of the memory operand corresponding to this micro-op 41 | int delay; 42 | int offset; 43 | }; 44 | 45 | typedef std::list RefReuseInfoList; 46 | 47 | class ReuseGroup 48 | { 49 | public: 50 | ReuseGroup (unsigned int _pc, int _idx, const ScheduleTime &_st, 51 | unsigned int _setIndex, bool _constantStride = false, 52 | int _valueStride = 0); 53 | ~ReuseGroup (); 54 | 55 | int Size () { return (size); } 56 | unsigned int leaderAddress() const { return (leader_pc); } 57 | int leaderMemOpIndex() const { return (leader_opidx); } 58 | ScheduleTime& leaderSchedTime() { return (leader_st); } 59 | unsigned int getSetIndex() const { return (setIndex); } 60 | bool hasConstantStride() const { return (constantStride); } 61 | int getStrideValue() const { return (valueStride); } 62 | 63 | // add a new member; if delay<0, this will become the new leader; 64 | // must update delay and offset for all members; 65 | void addMember (unsigned int _pc, int _idx, int _delay, int _offset); 66 | 67 | private: 68 | unsigned int leader_pc; 69 | int leader_opidx; 70 | unsigned int setIndex; 71 | int min_offset; 72 | int max_offset; 73 | int size; 74 | bool constantStride; 75 | int valueStride; 76 | ScheduleTime leader_st; 77 | 78 | RefReuseInfoList reflist; 79 | }; 80 | 81 | typedef std::list RGList; 82 | 83 | } /* namespace MIAMI */ 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /bin-anlys/src/common/BaseDominator.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: BaseDominator.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A base dominator interface. 10 | */ 11 | 12 | #include 13 | #include "BaseDominator.h" 14 | 15 | BaseDominator::BaseDominator (DGraph *_g) 16 | { 17 | g = _g; 18 | numNodes = g->HighWaterMarker(); 19 | nodeDom = new MIAMI::SNode* [numNodes]; 20 | memset (nodeDom, 0, numNodes*sizeof(MIAMI::SNode*)); 21 | } 22 | 23 | BaseDominator::~BaseDominator () 24 | { 25 | delete[] nodeDom; 26 | } 27 | -------------------------------------------------------------------------------- /bin-anlys/src/common/BaseDominator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: BaseDominator.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A base dominator interface. 10 | */ 11 | 12 | #ifndef _MIAMI_BASE_DOMINATOR_H 13 | #define _MIAMI_BASE_DOMINATOR_H 14 | 15 | #include 16 | #include "OAUtils/DGraph.h" 17 | 18 | namespace MIAMI 19 | { 20 | 21 | typedef DGraph::Node SNode; 22 | typedef DGraph::Edge SEdge; 23 | typedef std::list SNodeList; 24 | 25 | } /* namespace MIAMI */ 26 | 27 | // define a base dominator class, so I can use it to pass generic dominator 28 | // objects as arguments. 29 | class BaseDominator 30 | { 31 | public: 32 | BaseDominator (DGraph *_g); 33 | virtual ~BaseDominator (); 34 | 35 | // need a public method to return the immediate dominator of a node 36 | virtual MIAMI::SNode *iDominator (MIAMI::SNode *node) { 37 | return (nodeDom[node->getId()]); 38 | } 39 | 40 | MIAMI::SNode** getDomTree () const { return (nodeDom); } 41 | 42 | protected: 43 | MIAMI::SNode **nodeDom; // stores the immediate dominator of a nodeId 44 | int numNodes; // the number of actual nodes found, duh 45 | DGraph *g; 46 | }; 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /bin-anlys/src/common/Dominator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: Dominator.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Computes dominator information on a directed graph. 10 | */ 11 | 12 | #ifndef _MIAMI_DOMINATOR_H 13 | #define _MIAMI_DOMINATOR_H 14 | 15 | 16 | #include "unionfind.h" 17 | #include "BaseDominator.h" 18 | 19 | #pragma interface "Dominator.h" 20 | 21 | namespace MIAMI 22 | { 23 | #define DRAW_DFS_TREE 0 24 | 25 | 26 | template 27 | class Dominator : public BaseDominator 28 | { 29 | public: 30 | Dominator (DGraph *_g, SNodeList &root_nodes, bool _incl_struct=false, 31 | const char *prefix = ""); 32 | Dominator (DGraph *_g, SNode* rootN, bool _incl_struct=false, 33 | const char *prefix = ""); 34 | virtual ~Dominator (); 35 | 36 | // return number of minLCA operations (edge traversals); used for profiling 37 | int findLCA (SNodeList &nodeset, int nid, DisjointSet *dsuf, DisjointSet *ds, 38 | SNodeList *otherset, SNode **minLCA); 39 | 40 | inline bool Dominates (SNode *n1, SNode *n2) { 41 | int idx1 = dfsIndex[n1->getId()]; 42 | int idx2 = dfsIndex[n2->getId()]; 43 | while (idx2>idx1) 44 | idx2 = idom[idx2]; 45 | return (idx2 == idx1); 46 | } 47 | 48 | private: 49 | #if DRAW_DFS_TREE 50 | void draw_DFS_tree (const char *prefix); 51 | #endif 52 | void DFS_count (SNode *node, int pid); 53 | void calc_idoms (); 54 | void compress (int v); 55 | int eval_forest (int v); 56 | void link_forest (int v, int w); 57 | 58 | SNode **vertex; // translates from a DFS index to an actual node 59 | int *parent; // returns the parent (DFS index) of a node (DFS index) 60 | int *idom; // stores the DFS index of the immediate dominator of a node 61 | int *numChildren;// stores the number of direct dominee of each node, dfs indexed 62 | int *semidom; // stores the semidominator 63 | int *dfsIndex; // translates from node id to DFS index 64 | 65 | int *ancestor; // used to store the forest; pointer to parent in forest 66 | int *label; // used in the link/eval thing. Not clearly explained 67 | int *size; // number of nodes in this tree 68 | int *child; // used in the link method. Unclear. 69 | // Use it also as a temporary storage in findLCA 70 | 71 | int count; 72 | SNodeList *root_nodes; 73 | SNode *rootN; 74 | bool include_struct; 75 | }; 76 | 77 | } // namespace MIAMI 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /bin-anlys/src/common/InstructionDecoder-dyninst.hpp: -------------------------------------------------------------------------------- 1 | // -*-Mode: C++;-*- 2 | 3 | //*BeginPNNLCopyright******************************************************** 4 | // 5 | // $HeadURL$ 6 | // $Id: f2a771029cf30a712072d71ced9c8c5577b8c727 $ 7 | // 8 | //**********************************************************EndPNNLCopyright* 9 | 10 | //*************************************************************************** 11 | // 12 | // Translate ISA Instructions to MIAMI's "internal representation" via 13 | // DynInst's "internal representation". 14 | // 15 | //*************************************************************************** 16 | 17 | //*************************************************************************** 18 | // 19 | //*************************************************************************** 20 | 21 | //*************************************************************************** 22 | // MIAMI includes 23 | //*************************************************************************** 24 | 25 | #include "miami_types.h" 26 | #include "instr_info.H" 27 | 28 | //*************************************************************************** 29 | // DynInst includes 30 | //*************************************************************************** 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | //*************************************************************************** 38 | // 39 | //*************************************************************************** 40 | 41 | int dyninst_decode(void* pc, int len, MIAMI::DecodedInstruction *dInst, BPatch_function *f, BPatch_basicBlock* blk); 42 | 43 | //*************************************************************************** 44 | 45 | -------------------------------------------------------------------------------- /bin-anlys/src/common/canonical_ops.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: canonical_ops.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Define a set of canonical operation types. 10 | */ 11 | 12 | #include "canonical_ops.h" 13 | #include 14 | 15 | namespace MIAMI 16 | { 17 | 18 | const char* 19 | Convert_CanonicalOp_to_string(CanonicalOp cop) 20 | { 21 | switch (cop) 22 | { 23 | case OP_INVALID: return("OpInvalid"); 24 | case OP_CALL: return("OpCall"); 25 | case OP_PC_SET_CALL: return("OpPcSetCall"); 26 | case OP_ICALL: return("OpICall"); 27 | case OP_RET: return("OpRet"); 28 | case OP_BR: return("OpBr"); 29 | case OP_BR_CC: return("OpBrCC"); 30 | case OP_JMP: return("OpJmp"); 31 | case OP_TRAP: return("OpTrap"); 32 | case OP_LIMM: return("OpLoadImm"); 33 | case OP_CMP: return("OpCmp"); 34 | case OP_ADD: return("OpAdd"); 35 | case OP_AND: return("OpAND"); 36 | case OP_ANDN: return("OpANDN"); 37 | case OP_MUL: return("OpMul"); 38 | case OP_UMUL: return("OpUMul"); 39 | case OP_DIV: return("OpDiv"); 40 | case OP_UDIV: return("OpUDiv"); 41 | case OP_OR: return("OpOR"); 42 | case OP_ORN: return("OpORN"); 43 | case OP_SLL: return("OpSLL"); 44 | case OP_SRL: return("OpSRL"); 45 | case OP_SRA: return("OpSRA"); 46 | case OP_SUB: return("OpSub"); 47 | case OP_XNOR: return("OpXNOR"); 48 | case OP_XOR: return("OpXOR"); 49 | case OP_NOT: return("OpNOT"); 50 | case OP_MOV: return("OpMov"); 51 | case OP_LEA: return("OpLEA"); 52 | case OP_FMOV: return("OpFMov"); 53 | case OP_FNEG: return("OpFNeg"); 54 | case OP_FABS: return("OpFAbs"); 55 | case OP_FSQRT: return("OpFSqrt"); 56 | case OP_FADD: return("OpFAdd"); 57 | case OP_FSUB: return("OpFSub"); 58 | case OP_FMUL: return("OpFMul"); 59 | case OP_FDIV: return("OpFDiv"); 60 | case OP_FCMP: return("OpFCmp"); 61 | case OP_FCNVT: return("OpFCnvt"); 62 | case OP_LD: return("OpLoad"); 63 | case OP_ST: return("OpStore"); 64 | case OP_LDST: return("OpLoadStore"); 65 | case OP_SWAP: return("OpSwap"); 66 | case OP_PREFETCH: return("OpPrefetch"); 67 | case OP_MISC: return("OpMisc"); 68 | case OP_LAST: return("OpLAST"); 69 | default: assert(!"unknown Canonical Op"); 70 | }; 71 | return("notReachable"); 72 | } 73 | 74 | } /* namespace MIAMI */ 75 | -------------------------------------------------------------------------------- /bin-anlys/src/common/canonical_ops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: canonical_ops.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Define a set of canonical operation types. 10 | */ 11 | 12 | #ifndef _CANONICAL_OPS_H 13 | #define _CANONICAL_OPS_H 14 | 15 | namespace MIAMI 16 | { 17 | 18 | // Operations that an instruction can perform. 19 | // 20 | enum CanonicalOp 21 | { 22 | OP_INVALID = 0, 23 | OP_CALL, // subroutine call 24 | OP_PC_SET_CALL, // pc setting instruction for PIC code 25 | OP_ICALL, // subroutine call, (register) indirect 26 | OP_RET, // subroutine return 27 | 28 | OP_BR, // branch 29 | OP_BR_CC, // branch on condition codes 30 | OP_JMP, // jump 31 | OP_TRAP, // trap 32 | 33 | OP_LIMM, // load immediate 34 | OP_CMP, // comparison (either primary or secondary (e.g. condition code)) 35 | OP_ADD, // add 36 | OP_AND, // and 37 | OP_ANDN, // andn 38 | OP_MUL, // multiply 39 | OP_UMUL, // multiply, unsigned 40 | OP_DIV, // divide 41 | OP_UDIV, // divide, unsigned 42 | OP_OR, // inclusive-or 43 | OP_ORN, // inclusive-orn 44 | OP_SLL, // shift left logical 45 | OP_SRL, // shift right logical 46 | OP_SRA, // shift right arithmetic 47 | OP_SUB, // subtract 48 | OP_XNOR, // exclusive-nor 49 | OP_XOR, // exclusive-or 50 | OP_NOT, // NOT 51 | OP_MOV, // move or register copy 52 | OP_LEA, // compute effective address LEA 53 | 54 | OP_FMOV, // FP move 55 | OP_FNEG, // FP negate 56 | OP_FABS, // FP absolute value 57 | OP_FSQRT, // FP square root 58 | OP_FADD, // FP add 59 | OP_FSUB, // FP subtract 60 | OP_FMUL, // FP multiply 61 | OP_FDIV, // FP divide 62 | OP_FCMP, // FP compare 63 | OP_FCNVT, // FP 'type-conversion' 64 | 65 | OP_LD, // load 66 | OP_ST, // store 67 | OP_LDST, // load-store 68 | OP_SWAP, // swap register and memory 69 | 70 | OP_PREFETCH, // prefetch instruction 71 | OP_MISC, 72 | OP_LAST 73 | }; 74 | 75 | const char* Convert_CanonicalOp_to_string(CanonicalOp cop); 76 | 77 | } /* namespace MIAMI */ 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /bin-anlys/src/common/charless.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: charless.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Sorting less (<) operator for strings. 10 | */ 11 | 12 | #ifndef _CHAR_LESS_H 13 | #define _CHAR_LESS_H 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace MIAMI 20 | { 21 | 22 | class CharLess 23 | { 24 | public: 25 | bool operator() (const char* str1, const char* str2) const 26 | { 27 | return (strcmp(str1, str2) < 0); 28 | } 29 | }; 30 | 31 | typedef std::set CharPSet; 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /bin-anlys/src/common/config.h: -------------------------------------------------------------------------------- 1 | 2 | /* make a placeholder config.h file because some external packages 3 | * (binutils 2.23+) expect to find the PACKAGE and PACKAGE_VERSION 4 | * variables defined by autoconf. 5 | */ 6 | 7 | #ifndef _MIAMI_CONFIG_H 8 | #define _MIAMI_CONFIG_H 9 | 10 | #define PACKAGE 1 11 | #define PACKAGE_VERSION 1 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /bin-anlys/src/common/debug_miami.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: debug_miami.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Logging verbosity knobs useful for debugging. 10 | */ 11 | 12 | #include "debug_miami.h" 13 | 14 | int static_mem_debug_level = 4; 15 | int indirect_debug_level = 8; 16 | int inst_decode_debug_level = 2; 17 | int cfg_debug_level = 8; 18 | -------------------------------------------------------------------------------- /bin-anlys/src/common/debug_miami.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: debug_miami.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Logging verbosity knobs useful for debugging. 10 | */ 11 | 12 | #ifndef _DEBUG_MIAMI_H_ 13 | #define _DEBUG_MIAMI_H_ 14 | 15 | extern int static_mem_debug_level; 16 | extern int indirect_debug_level; 17 | extern int inst_decode_debug_level; 18 | extern int cfg_debug_level; 19 | 20 | #define DEBUG_STATIC_MEMORY 0 21 | #define DEBUG_STMEM(x, y) if ((x)<=static_mem_debug_level) {y} 22 | 23 | #define DEBUG_INDIRECT_TRANSFER 0 24 | #define DEBUG_INDIRECT(x, y) if ((x)<=indirect_debug_level) {y} 25 | 26 | #define DEBUG_INST_DECODING 0 27 | #define DEBUG_IDECODE(x, y) if ((x)<=inst_decode_debug_level) {y} 28 | 29 | #define DEBUG_CFG_DISCOVERY 0 30 | #define LOG_CFG(x, y) if ((x)<=cfg_debug_level) {y} 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /bin-anlys/src/common/default_values.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: default_values.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A central place to store various global defaults. 10 | */ 11 | 12 | #include "miami_types.h" 13 | 14 | namespace MIAMI 15 | { 16 | 17 | unsigned long long defaultZeroULL = 0; 18 | int defaultZeroInt = 0; 19 | char defaultNACharPValue[8] = {"N/A"}; 20 | uint32_t defaultUI = 0; 21 | unsigned int* const defaultUIP = 0; 22 | unsigned long long defULL = 0; 23 | float defFP = -1; 24 | const char* defaultCharP = 0; 25 | const char* defaultVarName = "unknown"; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /bin-anlys/src/common/file_utilities.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: file_utilities.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A few useful functions for working with files. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "file_utilities.h" 17 | 18 | // Function: fileExists 19 | /** 20 | Check if a file exists 21 | @param[in] filename - the name of the file to check 22 | @return true if the file exists, else false 23 | */ 24 | namespace MIAMI 25 | { 26 | 27 | bool 28 | fileExists(const std::string& filename) 29 | { 30 | struct stat buf; 31 | if (stat(filename.c_str(), &buf) != -1) 32 | { 33 | return true; 34 | } 35 | return false; 36 | } 37 | 38 | bool 39 | fileExists(const char* filename) 40 | { 41 | struct stat buf; 42 | if (stat(filename, &buf) != -1) 43 | { 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | /* There is no Unix API to get the name of the temporary directory. 50 | * POSIX recommends to get the name from environment variables. 51 | * Boost returns the path supplied by the first environment variable found 52 | * in the list TMPDIR, TMP, TEMP, TEMPDIR. If none of these are found, "/tmp". 53 | */ 54 | const char* getTempDirName() 55 | { 56 | const char* tdir = getenv("TMPDIR"); 57 | if (tdir) return (tdir); 58 | 59 | tdir = getenv("TMP"); 60 | if (tdir) return (tdir); 61 | 62 | tdir = getenv("TEMP"); 63 | if (tdir) return (tdir); 64 | 65 | tdir = getenv("TEMPDIR"); 66 | if (tdir) return (tdir); 67 | 68 | return ("/tmp"); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /bin-anlys/src/common/file_utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: file_utilities.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A few useful functions for working with files. 10 | */ 11 | 12 | #include 13 | 14 | namespace MIAMI 15 | { 16 | 17 | bool fileExists(const std::string& filename); 18 | bool fileExists(const char* filename); 19 | 20 | const char* getTempDirName(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /bin-anlys/src/common/generic_math_expression.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: generic_math_expressions.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Support for generic simple math formulas. 10 | */ 11 | 12 | #ifndef GENERIC_MATH_EXPRESSION_H 13 | #define GENERIC_MATH_EXPRESSION_H 14 | 15 | #include 16 | #include 17 | #include "miami_types.h" 18 | #include "register_class.h" 19 | 20 | namespace MIAMI 21 | { 22 | 23 | // support description of machine independent mathematical expressions 24 | // Right now we only need + and * operators 25 | enum ExpressionOperator { 26 | ExpressionOperator_INVALID, 27 | ExpressionOperator_ADD, 28 | ExpressionOperator_MUL, 29 | ExpressionOperator_LAST 30 | }; 31 | 32 | enum ExpressionOperandType { 33 | ExpressionOperandType_INVALID, 34 | ExpressionOperandType_IMM, 35 | ExpressionOperandType_REG, 36 | ExpressionOperandType_LAST 37 | }; 38 | 39 | 40 | class ExpressionOperand 41 | { 42 | public: 43 | ExpressionOperand() 44 | { 45 | type = ExpressionOperandType_INVALID; 46 | val.imm = imm_value_t(); 47 | } 48 | ExpressionOperand(const imm_value_t &v) 49 | { 50 | type = ExpressionOperandType_IMM; 51 | val.imm = v; 52 | } 53 | ExpressionOperand(const register_info &v) 54 | { 55 | type = ExpressionOperandType_REG; 56 | val.reg = v; 57 | } 58 | 59 | ExpressionOperandType type; 60 | union { 61 | imm_value_t imm; 62 | register_info reg; 63 | } val; 64 | }; 65 | 66 | // base class for an expression 67 | class ExpressionBase 68 | { 69 | public: 70 | // define a function type used as a callback by the Traverse method of an expression 71 | typedef int (*TraverseCallback)(void* arg0); 72 | 73 | ExpressionBase(const ExpressionBase *l = 0, const ExpressionBase *r = 0) 74 | : left(l), right(r) 75 | {} 76 | virtual ~ExpressionBase() 77 | { 78 | if (left) delete (left); 79 | if (right) delete (right); 80 | } 81 | virtual int Traverse(void *arg0) = 0; 82 | 83 | ExpressionBase *left, *right; 84 | }; 85 | 86 | class ExpressionTerm: public ExpressionBase 87 | { 88 | public: 89 | ExpressionTerm(const ExpressionOperand &op) : ExpressionBase() 90 | { 91 | term = op; 92 | } 93 | virtual ~ExpressionTerm() 94 | { } 95 | 96 | virtual int Traverse(void *arg0); 97 | 98 | ExpressionOperand term; 99 | }; 100 | 101 | class Expression : public ExpressionBase 102 | { 103 | public: 104 | Expression(const ExpressionBase *op1, ExpressionOperator opt, const ExpressionBase *op2) 105 | : ExpressionBase(op1, op2) 106 | { 107 | optype = opt; 108 | } 109 | virtual ~Expression() 110 | { } 111 | 112 | virtual int Traverse(void *arg0); 113 | 114 | ExpressionOperator optype; 115 | }; 116 | 117 | } /* namespace MIAMI */ 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /bin-anlys/src/common/generic_pair.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: generic_pair.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A generic pair data type with various ordering operators. 10 | */ 11 | 12 | #ifndef _GENERIC_PAIR_H 13 | #define _GENERIC_PAIR_H 14 | 15 | #ifdef __GNUC__ 16 | #pragma interface 17 | #endif 18 | 19 | #include 20 | 21 | namespace MIAMIU 22 | { 23 | 24 | template 25 | class GenericPair 26 | { 27 | public: 28 | GenericPair (Type1 i1 = 0, Type2 i2 = 0) 29 | { 30 | first = i1; 31 | second = i2; 32 | } 33 | 34 | GenericPair (const GenericPair& uip) 35 | { 36 | first = uip.first; second = uip.second; 37 | } 38 | 39 | inline GenericPair& operator= (const GenericPair& uip) 40 | { 41 | first = uip.first; second = uip.second; 42 | return (*this); 43 | } 44 | 45 | inline void dump (FILE* fd) 46 | { 47 | fwrite(&first, sizeof(Type1), 1, fd); 48 | fwrite(&second, sizeof(Type2), 1, fd); 49 | } 50 | 51 | Type1 first; 52 | Type2 second; 53 | 54 | class OrderPairs { 55 | public : 56 | int operator() (const GenericPair &x, const GenericPair &y) const 57 | { 58 | if (x.first != y.first) 59 | return (x.first < y.first); 60 | else 61 | // if 'first' elements are equal, compare 'second' ones 62 | return (x.second < y.second); 63 | } 64 | }; 65 | 66 | class OrderAscByKey1 { 67 | public : 68 | bool operator() (const GenericPair &x, const GenericPair &y) const 69 | { 70 | return (x.first < y.first); 71 | } 72 | }; 73 | 74 | class OrderDescByKey1 { 75 | public : 76 | bool operator() (const GenericPair &x, const GenericPair &y) const 77 | { 78 | return (x.first > y.first); 79 | } 80 | }; 81 | 82 | class OrderAscByKey2 { 83 | public : 84 | bool operator() (const GenericPair &x, const GenericPair &y) const 85 | { 86 | return (x.second < y.second); 87 | } 88 | }; 89 | 90 | class OrderDescByKey2 // : public std::binary_function 91 | { 92 | public : 93 | bool operator() (const GenericPair &x, const GenericPair &y) const 94 | { 95 | return (x.second > y.second); 96 | } 97 | }; 98 | 99 | }; 100 | 101 | } /* namespace MIAMIU */ 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /bin-anlys/src/common/generic_trio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: generic_trio.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A generic trio data type with an ordering operator. 10 | */ 11 | 12 | #ifndef _GENERIC_TRIO_H 13 | #define _GENERIC_TRIO_H 14 | 15 | namespace MIAMIU 16 | { 17 | 18 | template 19 | class GenericTrio 20 | { 21 | public: 22 | GenericTrio(T _first=0, T _second=0, T _third=0) : 23 | first(_first), second(_second), third(_third) 24 | {} 25 | 26 | GenericTrio(const GenericTrio& ut) 27 | { 28 | first=ut.first; second=ut.second; third=ut.third; 29 | } 30 | 31 | inline GenericTrio& operator= (const GenericTrio& ut) 32 | { 33 | first=ut.first; second=ut.second; third=ut.third; 34 | return (*this); 35 | } 36 | 37 | T first; 38 | T second; 39 | T third; 40 | 41 | class OrderTrio { 42 | public : 43 | int operator() (const GenericTrio& te1, const GenericTrio& te2) const 44 | { 45 | if (te1.first < te2.first) 46 | return true; 47 | if (te1.first > te2.first) 48 | return false; 49 | 50 | if (te1.second < te2.second) 51 | return true; 52 | if (te1.second > te2.second) 53 | return false; 54 | 55 | return (te1.third < te2.third); 56 | } 57 | }; 58 | }; 59 | 60 | } /* namespace MIAMIU */ 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /bin-anlys/src/common/hashmaps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: hashmaps.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Common HashMap definitions. 10 | */ 11 | 12 | #ifndef _MIAMI_HASHMAPS_H 13 | #define _MIAMI_HASHMAPS_H 14 | 15 | #include "miami_types.h" 16 | #include "fast_hashmap.h" 17 | 18 | namespace MIAMI 19 | { 20 | extern uint32_t defaultUI; 21 | typedef MIAMIU::HashMap HashMapUI; 22 | 23 | /* Hashmap for mapping memory instructions into logical sets. 24 | */ 25 | //typedef MIAMIU::HashMap AddrUIMap; 26 | 27 | /* hashmap for mapping variable names to memory instruction indecies. 28 | */ 29 | extern const char* defaultCharP; 30 | typedef MIAMIU::HashMap RefNameMap; 31 | 32 | } /* namespace MIAMI */ 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /bin-anlys/src/common/instr_bins.H: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: instr_bins.H 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Defines the generic MIAMI micro-operation types. 10 | */ 11 | 12 | #ifndef INSTR_BINS_H 13 | #define INSTR_BINS_H 14 | 15 | namespace MIAMI 16 | { 17 | 18 | // some sections of code used the order in which the instruction types are 19 | // defined. 20 | // In general try to group together instructions from the same family. 21 | // Memory instructions are grouped at the beginning (yes, I use this for now); 22 | // float operations are grouped between fp_add and fp_madd (conversion and 23 | // register copy are not considered "real" float instructions) 24 | enum InstrBin 25 | { 26 | IB_dg_exit = -2, 27 | IB_dg_entry = -1, 28 | IB_INVALID = 0, 29 | 30 | IB_inner_loop, 31 | 32 | IB_load, 33 | IB_store, 34 | IB_load_store, 35 | IB_mem_fence, 36 | 37 | IB_privl_op, 38 | IB_branch, 39 | IB_br_CC, 40 | IB_jump, /* this should be used only for inter-procedural jump: call, 41 | jmpl to a different procedure */ 42 | IB_ret, /* for returns */ 43 | IB_cvt, 44 | IB_cvt_prec, 45 | IB_copy, 46 | IB_move, 47 | IB_move_cc, 48 | IB_shuffle, 49 | IB_blend, 50 | IB_misc, /* 18 */ 51 | 52 | IB_cmp, 53 | IB_add, 54 | IB_lea, 55 | IB_add_cc, 56 | IB_sub, 57 | IB_mult, 58 | IB_div, 59 | IB_sqrt, 60 | IB_madd, /* 27 */ 61 | 62 | IB_xor, 63 | IB_logical, 64 | IB_shift, 65 | IB_nop, 66 | IB_prefetch, 67 | 68 | IB_trap, 69 | 70 | IB_load_conf, 71 | IB_store_conf, /* 35 */ 72 | IB_fn, 73 | 74 | IB_getf, 75 | IB_setf, 76 | IB_popcnt, 77 | IB_port_rd, 78 | IB_port_wr, 79 | IB_reciprocal, /* 42 */ 80 | IB_insert, 81 | IB_extract, 82 | 83 | IB_xchg, 84 | IB_cmp_xchg, 85 | IB_rotate, 86 | IB_rotate_cc, /* 48 */ 87 | 88 | // have some special instruction for now to use for calls to fortran 89 | // intrinsics 90 | IB_intrinsic, 91 | IB_unknown, 92 | 93 | IB_TOP_MARKER // this must be always on the last position 94 | }; 95 | 96 | const char* Convert_InstrBin_to_string(InstrBin ibin); 97 | 98 | inline int InstrBinIsNOP(InstrBin type) 99 | { 100 | return (type == IB_nop); 101 | } 102 | 103 | inline int InstrBinIsPrefetch(InstrBin type) 104 | { 105 | return (type == IB_prefetch); 106 | } 107 | 108 | // this function was initially named "IsMemoryInstruction" 109 | int InstrBinIsMemoryType(InstrBin type); 110 | 111 | int InstrBinIsLoadType(InstrBin type); 112 | int InstrBinIsStoreType(InstrBin type); 113 | 114 | int InstrBinIsRegisterMove(InstrBin type); 115 | 116 | int InstrBinIsBranchType(InstrBin type); 117 | 118 | } /* namespace MIAMI */ 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /bin-anlys/src/common/instruction_class.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: instruction_class.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Data type to encapsulate the parameters that uniquely define 10 | * a MIAMI instruction type. 11 | */ 12 | 13 | #include 14 | #include "instruction_class.h" 15 | #include 16 | #include 17 | 18 | namespace MIAMI { 19 | 20 | const char* 21 | ExecUnitToString(ExecUnit e) 22 | { 23 | switch (e) { 24 | case ExecUnit_VECTOR: 25 | return "vector"; 26 | case ExecUnit_SCALAR: 27 | return "scalar"; 28 | default: 29 | return ("unknown ExecUnit"); 30 | } 31 | } 32 | 33 | 34 | const char* 35 | ExecUnitTypeToString(ExecUnitType e) 36 | { 37 | switch (e) { 38 | case ExecUnitType_FP: 39 | return "fp"; 40 | case ExecUnitType_INT: 41 | return "int"; 42 | default: 43 | return ("unknown ExecUnitType"); 44 | } 45 | } 46 | 47 | ICIMap& operator+= (ICIMap& f, const ICIMap& s) 48 | { 49 | ICIMap::const_iterator sit = s.begin(); 50 | for ( ; sit!=s.end() ; ++sit) 51 | { 52 | ICIMap::iterator fit = f.find(sit->first); 53 | if (fit == f.end()) 54 | f.insert(*sit); 55 | else 56 | fit->second += sit->second; 57 | } 58 | return (f); 59 | } 60 | 61 | std::string 62 | InstructionClass::ToString() const 63 | { 64 | std::ostringstream oss; 65 | oss << Convert_InstrBin_to_string(type) 66 | << ":" << ExecUnitTypeToString(eu_type) << width; 67 | if (vec_width != width) 68 | oss << ":vec[" << vec_width << "]"; 69 | return (oss.str()); 70 | } 71 | 72 | } 73 | 74 | -------------------------------------------------------------------------------- /bin-anlys/src/common/loadable_class.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: loadable_class.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Simple interface for serializing objects. 10 | */ 11 | 12 | #include "loadable_class.h" 13 | 14 | FILE* operator<< (FILE* fd, LoadableClass &lc) 15 | { 16 | lc.SaveToFile(fd); 17 | return (fd); 18 | } 19 | 20 | FILE* operator>> (FILE* fd, LoadableClass &lc) 21 | { 22 | lc.LoadFromFile(fd); 23 | return (fd); 24 | } 25 | -------------------------------------------------------------------------------- /bin-anlys/src/common/loadable_class.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: loadable_class.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Simple interface for serializing objects. 10 | */ 11 | 12 | #ifndef _LOADABLE_CLASS_H 13 | #define _LOADABLE_CLASS_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | class LoadableClass 21 | { 22 | public: 23 | LoadableClass() {} 24 | virtual int SaveToFile(FILE* fd) const = 0; 25 | virtual int LoadFromFile(FILE* fd) = 0; 26 | protected: 27 | virtual ~LoadableClass() {} 28 | }; 29 | 30 | extern FILE* operator<< (FILE* fd, LoadableClass &gf); 31 | extern FILE* operator>> (FILE* fd, LoadableClass &gf); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bin-anlys/src/common/math_routines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: math_routines.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Support for Fortran intrinsics. 10 | */ 11 | 12 | #ifndef _MATH_ROUTINES_H 13 | #define _MATH_ROUTINES_H 14 | 15 | namespace MIAMI_DG 16 | { 17 | 18 | /* these values may need to be adjusted for the move to 64-bit OSes. 19 | * I cannot remember what they represent. EntryValue will not be used 20 | * initially. We can see all the executed user code, including dynamic 21 | * libraries, so it may not be needed to treat Fortran intrinsics differently. 22 | */ 23 | #define INTRINSIC_REG_SHIFT 27 24 | #define INTRINSIC_REG_MASK 0x1f 25 | #define INTRINSIC_PC_MASK 0x07ffffff 26 | 27 | // Machine independent header file for inclusion in SchedDG 28 | class EntryValue 29 | { 30 | public: 31 | EntryValue (const char* in_regs, const char* out_regs, const char* _name); 32 | 33 | ~EntryValue (); 34 | 35 | const char* intrinsic_name () const { return (rname); } 36 | 37 | int spec_inst_src (int idx) 38 | { 39 | if (!gpSrcRegs || idx>=gpSrcRegs[0]) 40 | return (-1); 41 | else 42 | return (gpSrcRegs[idx+1]); 43 | } 44 | 45 | int spec_inst_fp_src (int idx) 46 | { 47 | if (!fpSrcRegs || idx>=fpSrcRegs[0]) 48 | return (-1); 49 | else 50 | return (fpSrcRegs[idx+1]); 51 | } 52 | 53 | int spec_inst_dest (int idx) 54 | { 55 | if (!gpDestRegs || idx>=gpDestRegs[0]) 56 | return (-1); 57 | else 58 | return (gpDestRegs[idx+1]); 59 | } 60 | 61 | int spec_inst_fp_dest (int idx) 62 | { 63 | if (!fpDestRegs || idx>=fpDestRegs[0]) 64 | return (-1); 65 | else 66 | return (fpDestRegs[idx+1]); 67 | } 68 | 69 | int spec_inst_ref_src (int idx) 70 | { 71 | if (!refSrcRegs || idx>=refSrcRegs[0]) 72 | return (-1); 73 | else 74 | return (refSrcRegs[idx+1]); 75 | } 76 | 77 | int spec_inst_ref_dest (int idx) 78 | { 79 | if (!refDestRegs || idx>=refDestRegs[0]) 80 | return (-1); 81 | else 82 | return (refDestRegs[idx+1]); 83 | } 84 | 85 | private: 86 | void parse_registers (const char *in_regs, int*& gpRegsArray, 87 | int*&fpRegsArray, int*&refRegsArray); 88 | 89 | int* gpSrcRegs; 90 | int* gpDestRegs; 91 | int* fpSrcRegs; 92 | int* fpDestRegs; 93 | int* refSrcRegs; 94 | int* refDestRegs; 95 | const char* rname; 96 | }; 97 | 98 | } /* namespace MIAMI_DG */ 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /bin-anlys/src/common/miami_containers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: miami_containers.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A few commonly used containers. 10 | */ 11 | 12 | #ifndef MIAMI_CONTAINERS_H 13 | #define MIAMI_CONTAINERS_H 14 | 15 | // Define various STL based or otherwise containers commonly used 16 | // by the MIAMI toolkit. Types that are used only locally, should be 17 | // defined at the place where they are used. 18 | 19 | #include 20 | #include "miami_types.h" 21 | #include "generic_pair.h" 22 | 23 | namespace MIAMI 24 | { 25 | 26 | typedef std::set AddrSet; 27 | 28 | // An AddrIntPair can hold both a memory address (instruction PC), and 29 | // an integer, e.g. memory operand index. 30 | typedef MIAMIU::GenericPair AddrIntPair; 31 | typedef std::set AddrIntSet; 32 | 33 | } /* namespace MIAMI */ 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /bin-anlys/src/common/miami_data_sections.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: miami_data_sections.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Data section types for the MIAMI profile files. 10 | */ 11 | 12 | #ifndef _MIAMI_DATA_SECTIONS_H 13 | #define _MIAMI_DATA_SECTIONS_H 14 | 15 | namespace MIAMI 16 | { 17 | 18 | typedef enum { 19 | MIAMI_DATA_SECTION_INVALID = 0, 20 | MIAMI_DATA_SECTION_SCOPE_FOOTPRINT, 21 | MIAMI_DATA_SECTION_MEM_REUSE, 22 | MIAMI_DATA_SECTION_STREAM_INFO, 23 | MIAMI_DATA_SECTION_CFG_PROFILE, 24 | MIAMI_DATA_SECTION_LAST 25 | } MiamiDataSectionType; 26 | 27 | } /* namespace MIAMI */ 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /bin-anlys/src/common/miami_globals.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: miami_globals.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A few MIAMI globals dealing with static analysis dbs. 10 | */ 11 | 12 | #include "miami_types.h" 13 | 14 | namespace MIAMI { 15 | /* magic word is saved at the beginning of each db file; must be 8 characters */ 16 | const char* persistent_db_magic_word = "MIAMI-DB"; 17 | 18 | /* This is the current format version of the db file; used while saving the file, 19 | * but it acts also as an upper bound on the expected file version. 20 | */ 21 | int32_t persistent_db_version = 0x00000001; 22 | 23 | /* the minimum required version for the current analysis; used at load time */ 24 | int32_t persistent_db_min_required_version = 0x00000001; 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /bin-anlys/src/common/miami_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: miami_types.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Defines common data types used by MIAMI. 10 | */ 11 | 12 | #ifndef MIAMI_TYPES_H 13 | #define MIAMI_TYPES_H 14 | 15 | # ifndef __STDC_FORMAT_MACROS 16 | # define _UNDEF__STDC_FORMAT_MACROS 17 | # define __STDC_FORMAT_MACROS 18 | # endif 19 | # include 20 | # ifdef _UNDEF__STDC_FORMAT_MACROS 21 | # undef __STDC_FORMAT_MACROS 22 | # undef _UNDEF__STDC_FORMAT_MACROS 23 | # endif 24 | 25 | #include 26 | 27 | #include 28 | 29 | namespace MIAMI 30 | { 31 | // I need to define address size to use in other macros 32 | #ifndef SIZEOF_VOIP 33 | # define SIZEOF_VOIDP 8 34 | #endif 35 | 36 | typedef unsigned long addrtype; 37 | typedef int32_t ObjId; 38 | typedef uint32_t usize_t; 39 | typedef uint32_t card; 40 | typedef int RegName; 41 | typedef uint16_t width_t; // type for operand bit width values 42 | 43 | typedef int64_t imm_signed_t; 44 | typedef uint64_t imm_unsigned_t; 45 | 46 | struct imm_value_t { 47 | imm_value_t() 48 | { 49 | is_signed = true; 50 | value.s = 0; 51 | } 52 | imm_value_t(imm_signed_t v) 53 | { 54 | is_signed = true; 55 | value.s = v; 56 | } 57 | imm_value_t(imm_unsigned_t v) 58 | { 59 | is_signed = false; 60 | value.u = v; 61 | } 62 | union { 63 | imm_signed_t s; 64 | imm_unsigned_t u; 65 | } value; 66 | bool is_signed; 67 | }; 68 | //ozgurS moving inslvlmap and mem struct to here 69 | struct memStruct { 70 | int level; 71 | double hitCount; 72 | double latency; 73 | }; 74 | 75 | typedef std::map InstlvlMap; 76 | //ozgurE 77 | typedef int64_t coeff_t; 78 | typedef uint64_t ucoeff_t; 79 | 80 | inline coeff_t abs_coeff(coeff_t x) { 81 | return (x < 0) ? -x : x; 82 | } 83 | 84 | // define the correct printf format for each custom type 85 | #define PRIwidth PRIu16 86 | #define PRIobjid PRId32 87 | #define PRIaddr "lu" 88 | #define PRIxaddr "lx" 89 | #define PRIreg "d" 90 | #define PRIsize PRIu32 91 | 92 | #define PRIcoeff PRId64 93 | #define PRIxcoeff PRIx64 94 | #define PRIucoeff PRIu64 95 | #define PRIxucoeff PRIx64 96 | 97 | 98 | #define MIAMI_NO_ADDRESS ((addrtype)-1) 99 | 100 | /* declarations of global constants */ 101 | extern const char* persistent_db_magic_word; 102 | extern int32_t persistent_db_version; 103 | extern int32_t persistent_db_min_required_version; 104 | 105 | } /* namespace MIAMI */ 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /bin-anlys/src/common/miami_utils.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: miami_utils.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: A few useful functions. 10 | */ 11 | 12 | #include "miami_utils.h" 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | namespace MIAMIU { 20 | using std::string; 21 | 22 | void ExtractNameAndPath(const string& input, string& path, string& name) 23 | { 24 | size_t pos = input.rfind('/'); 25 | if (pos == std::string::npos) // no path 26 | { 27 | path = "."; 28 | name = input; 29 | } else 30 | { 31 | path = input.substr(0, pos); 32 | name = input.substr(pos+1); 33 | } 34 | } 35 | 36 | std::string StripPath (const std::string& path) 37 | { 38 | size_t pos = path.rfind('/'); 39 | if (pos == std::string::npos) 40 | return (path); 41 | else 42 | return (path.substr(pos+1)); 43 | } 44 | 45 | const char * StripPath (const char * path) 46 | { 47 | const char * file = strrchr (path,'/'); 48 | if (file) 49 | return file+1; 50 | else 51 | return path; 52 | } 53 | 54 | int CopyFile(const char *to, const char *from) 55 | { 56 | int fd_to, fd_from; 57 | char buf[4096]; 58 | ssize_t nread; 59 | int saved_errno; 60 | 61 | fd_from = open(from, O_RDONLY); 62 | if (fd_from < 0) 63 | return -1; 64 | 65 | fd_to = open(to, O_WRONLY | O_CREAT, 0666); 66 | if (fd_to < 0) 67 | goto out_error; 68 | 69 | while (nread = read(fd_from, buf, sizeof buf), nread > 0) 70 | { 71 | char *out_ptr = buf; 72 | ssize_t nwritten; 73 | 74 | do { 75 | nwritten = write(fd_to, out_ptr, nread); 76 | 77 | if (nwritten >= 0) 78 | { 79 | nread -= nwritten; 80 | out_ptr += nwritten; 81 | } 82 | else if (errno != EINTR) 83 | { 84 | goto out_error; 85 | } 86 | } while (nread > 0); 87 | } 88 | 89 | if (nread == 0) 90 | { 91 | if (close(fd_to) < 0) 92 | { 93 | fd_to = -1; 94 | goto out_error; 95 | } 96 | close(fd_from); 97 | 98 | /* Success! */ 99 | return 0; 100 | } 101 | 102 | out_error: 103 | saved_errno = errno; 104 | 105 | close(fd_from); 106 | if (fd_to >= 0) 107 | close(fd_to); 108 | 109 | errno = saved_errno; 110 | return -1; 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /bin-anlys/src/common/printable_class.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: printable_class.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Simple interface for printing objects. 10 | */ 11 | 12 | #include "printable_class.h" 13 | 14 | std::ostream& operator<< (std::ostream& os, const PrintableClass &pc) 15 | { 16 | pc.PrintObject (os); 17 | return (os); 18 | } 19 | -------------------------------------------------------------------------------- /bin-anlys/src/common/printable_class.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: printable_class.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Simple interface for printing objects. 10 | */ 11 | 12 | #ifndef _PRINTABLE_CLASS_H 13 | #define _PRINTABLE_CLASS_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | class PrintableClass 21 | { 22 | public: 23 | PrintableClass() {} 24 | virtual void PrintObject (std::ostream& os) const = 0; 25 | protected: 26 | virtual ~PrintableClass() {} 27 | }; 28 | 29 | extern std::ostream& operator<< (std::ostream& os, const PrintableClass &gf); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /bin-anlys/src/common/private_load_module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: private_load_module.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Base class for storing image specific data. 10 | */ 11 | 12 | #ifndef MIAMI_PRIVATE_LOAD_MODULE_H 13 | #define MIAMI_PRIVATE_LOAD_MODULE_H 14 | 15 | #include "miami_types.h" 16 | 17 | // standard header 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace MIAMI 25 | { 26 | 27 | class PrivateLoadModule 28 | { 29 | public: 30 | PrivateLoadModule (uint32_t _id, addrtype _load_offset, addrtype _low_addr_offset, std::string _name) 31 | { 32 | img_id = _id; 33 | base_addr = _load_offset; 34 | low_addr_offset = _low_addr_offset; 35 | img_name = _name; 36 | file_offset = 0; 37 | source_data = 0; 38 | // fprintf(stderr, "Loading Image %d with path %s, base_addr=0x%" PRIxaddr ", low_addr_offset=0x%" PRIxaddr "\n", 39 | // img_id, img_name.c_str(), base_addr, low_addr_offset); 40 | } 41 | virtual ~PrivateLoadModule() { } 42 | virtual void saveToFile(FILE *fd) const // save img info in binary format 43 | { 44 | fwrite(&img_id, 4, 1, fd); 45 | fwrite(&base_addr, sizeof(base_addr), 1, fd); 46 | fwrite(&low_addr_offset, sizeof(low_addr_offset), 1, fd); 47 | // now save the file name 48 | uint32_t len = img_name.length(); 49 | fwrite(&len, 4, 1, fd); 50 | fwrite(img_name.c_str(), 1, len, fd); 51 | } 52 | 53 | virtual void printToFile(FILE *fd) const // save img info in text format 54 | { 55 | fprintf(fd, "%" PRIu32 " 0x%" PRIxaddr " 0x%" PRIxaddr " %s\n", 56 | img_id, base_addr, low_addr_offset, img_name.c_str()); 57 | } 58 | 59 | addrtype BaseAddr() const { return (base_addr); } 60 | addrtype LowOffsetAddr() const { return (low_addr_offset); } 61 | const std::string& Name() const { return (img_name); } 62 | uint64_t FileOffset() const { return (file_offset); } 63 | void setFileOffset(uint64_t _fof) { file_offset = _fof; } 64 | uint32_t ImageID() const { return (img_id); } 65 | 66 | virtual addrtype RelocationOffset() const { return (0); } 67 | 68 | void InitializeSourceFileInfo(); 69 | void FinalizeSourceFileInfo(); 70 | void GetSourceFileInfo(addrtype startAddr, addrtype endAddr, 71 | std::string &file, std::string &func, int32_t &startLine, int32_t& endLine); 72 | 73 | protected: 74 | addrtype base_addr; 75 | addrtype low_addr_offset; 76 | std::string img_name; 77 | uint32_t img_id; 78 | uint64_t file_offset; // use this field to store the offset in the cfg file 79 | // where this image starts. Used while loading the CFGs. 80 | 81 | // Next fields is used to store implementation dependent persistent info (if needed) 82 | // It is passed by the SourceFileInfo family of methods to the system specific functions 83 | void *source_data; 84 | }; 85 | 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /bin-anlys/src/common/register_class.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: register_class.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Implements a generic register representation. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "register_class.h" 17 | #include "InstructionDecoder.hpp" 18 | 19 | namespace MIAMI 20 | { 21 | 22 | const register_info MIAMI_NO_REG; 23 | 24 | void 25 | register_info::SaveToFile(FILE* fd) const 26 | { 27 | fwrite(&name, sizeof(name), 1, fd); 28 | fwrite(&type, sizeof(type), 1, fd); 29 | fwrite(&lsb, sizeof(lsb), 1, fd); 30 | fwrite(&msb, sizeof(msb), 1, fd); 31 | fwrite(&stack, sizeof(stack), 1, fd); 32 | } 33 | 34 | void 35 | register_info::LoadFromFile(FILE* fd) 36 | { 37 | fread(&name, sizeof(name), 1, fd); 38 | fread(&type, sizeof(type), 1, fd); 39 | fread(&lsb, sizeof(lsb), 1, fd); 40 | fread(&msb, sizeof(msb), 1, fd); 41 | fread(&stack, sizeof(stack), 1, fd); 42 | } 43 | 44 | const char* 45 | RegisterClassToString(RegisterClass rc) 46 | { 47 | switch (rc) 48 | { 49 | case RegisterClass_INVALID: return "Invalid"; 50 | case RegisterClass_REG_OP: return "RegOp"; 51 | case RegisterClass_MEM_OP: return "MemOp"; 52 | case RegisterClass_LEA_OP: return "LEAOp"; 53 | case RegisterClass_STACK_REG: return "StackReg"; 54 | case RegisterClass_STACK_OPERATION: return "StackOp"; 55 | case RegisterClass_TEMP_REG: return "TempReg"; 56 | case RegisterClass_PSEUDO: return "PseudoReg"; 57 | default: assert(!"Invalid RegisterClass. Should not be here."); 58 | } 59 | return (NULL); 60 | } 61 | 62 | std::string 63 | register_info::ToString() const 64 | { 65 | std::stringstream oss; 66 | oss << "Name "; 67 | if (type == RegisterClass_TEMP_REG) 68 | oss << "T" << name; 69 | else 70 | oss << register_name_to_string(name); 71 | oss << " {type " << RegisterClassToString(type) << "(" << type 72 | << "), stack=" << stack << ", [" << lsb << "," << msb << "]}"; 73 | return (oss.str()); 74 | } 75 | 76 | std::string 77 | register_info::RegNameToString() const 78 | { 79 | std::stringstream oss; 80 | if (type == RegisterClass_TEMP_REG) 81 | oss << "T" << name; 82 | else 83 | oss << register_name_to_string(name); 84 | return (oss.str()); 85 | } 86 | 87 | std::ostream& operator<< (std::ostream& os, const register_info& ri) 88 | { 89 | os << "Name "; 90 | if (ri.type == RegisterClass_TEMP_REG) 91 | os << "T" << ri.name; 92 | else 93 | os << register_name_to_string(ri.name); 94 | os << " {type " << RegisterClassToString(ri.type) << "(" 95 | << ri.type << "), stack=" << ri.stack << ", [" << ri.lsb << "," << ri.msb << "]}"; 96 | return (os); 97 | } 98 | 99 | 100 | } /* namespace MIAMI */ 101 | -------------------------------------------------------------------------------- /bin-anlys/src/common/report_time.C: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: report_time.C 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Simple time profiling API. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include "report_time.h" 16 | 17 | namespace MIAMIP /* MIAMI Profile */ 18 | { 19 | static struct rusage last_time; 20 | static long numCalls = 0; 21 | 22 | void 23 | report_time (FILE *fd, const char *format, ...) 24 | { 25 | struct rusage crt_time; 26 | double secs_u, secs_s; 27 | va_list ap; 28 | va_start (ap, format); 29 | fprintf (fd, "ReportTime: "); 30 | vfprintf (fd, format, ap); 31 | va_end(ap); 32 | 33 | getrusage (RUSAGE_SELF, &crt_time); 34 | if (numCalls) 35 | { 36 | secs_u = (crt_time.ru_utime.tv_sec - last_time.ru_utime.tv_sec) + 37 | (crt_time.ru_utime.tv_usec - last_time.ru_utime.tv_usec) / 1000000.; 38 | secs_s = (crt_time.ru_stime.tv_sec - last_time.ru_stime.tv_sec) + 39 | (crt_time.ru_stime.tv_usec - last_time.ru_stime.tv_usec) / 1000000.; 40 | } else 41 | { 42 | secs_u = (crt_time.ru_utime.tv_sec) + 43 | (crt_time.ru_utime.tv_usec) / 1000000.; 44 | secs_s = (crt_time.ru_stime.tv_sec) + 45 | (crt_time.ru_stime.tv_usec) / 1000000.; 46 | } 47 | ++ numCalls; 48 | fprintf (fd, " in %lg sec (%lg user, %lg system)\n", 49 | secs_u+secs_s, secs_u, secs_s); 50 | last_time = crt_time; 51 | } 52 | 53 | } /* namespace MIAMIP */ 54 | -------------------------------------------------------------------------------- /bin-anlys/src/common/report_time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: report_time.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Simple time profiling API. 10 | */ 11 | 12 | #ifndef REPORT_TIME_H 13 | #define REPORT_TIME_H 14 | 15 | #include 16 | 17 | namespace MIAMIP 18 | { 19 | extern void report_time (FILE *fd, const char *format, ...); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /bin-anlys/src/common/source_file_mapping.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: source_file_mapping.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Generic API for mapping PC addresses to source code 10 | * line numbers and for function name demangling. 11 | */ 12 | 13 | #ifndef MIAMI_SOURCE_FILE_MAPPING_H 14 | #define MIAMI_SOURCE_FILE_MAPPING_H 15 | 16 | #include 17 | #include "miami_types.h" 18 | 19 | using namespace MIAMI; 20 | 21 | namespace MIAMIP 22 | { 23 | 24 | /* find the source location for the provided pc address 25 | */ 26 | int 27 | get_source_file_location (void *data, addrtype pc, int32_t* column, int32_t* line, std::string* file, 28 | std::string* func); 29 | 30 | /* Process an image file. Returns 0 on success, <0 for erroer. */ 31 | int 32 | source_file_info_open_image (const char *file_name, void** data); 33 | 34 | void 35 | source_file_info_close_image (void *data); 36 | 37 | /* Source file location initialization functions. 38 | * You must call this function once before calling any other method 39 | * in this file. 40 | * It performs the implementation dependent initialization. 41 | */ 42 | int 43 | source_file_info_init(); 44 | 45 | /* return a best effort demangling of the specified function name 46 | */ 47 | const char* 48 | get_best_function_name(const char* name, char* outbuf, int buflen); 49 | 50 | /* demangle function name specified in inbuf. Output is stored in 51 | outbuf, up to buflen bytes. 52 | Use function get_max_demangled_name_size to obtain the maximum size 53 | of a demangled name. 54 | */ 55 | const char* 56 | get_demangled_func_name(const char* inbuf, char* outbuf, int buflen); 57 | 58 | /* obtain the maximum size of a demangled function name. 59 | */ 60 | int 61 | get_max_demangled_name_size(); 62 | 63 | } /* namespace MIAMIP */ 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /bin-anlys/src/common/static_branch_analysis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: static_branch_analysis.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Computes generic formulas for branch targets. Attempts to 10 | * resolve targets of indirect branches using data flow analysis. 11 | */ 12 | 13 | #ifndef _STATIC_BRANCH_ANALYSIS_H 14 | #define _STATIC_BRANCH_ANALYSIS_H 15 | 16 | 17 | #include "miami_types.h" 18 | #include "instr_info.H" 19 | #include "slice_references.h" 20 | #include "PrivateCFG.h" 21 | 22 | 23 | //using namespace std; 24 | namespace MIAMI // add everything to namespace MIAMI 25 | { 26 | 27 | /* Compute a branch target formula. The method evaluates only hardwired registers 28 | * (like the IP register) and constant values, of course. For indirect jumps, it will 29 | * leave the target registers unresolved. The second method, below, tries to slice 30 | * on the target registers to resolve the target of most indirect jumps. 31 | */ 32 | int 33 | ComputeBranchTargetFormula(const DecodedInstruction *dInst, const instruction_info *ii, 34 | int uop_idx, addrtype pc, GFSliceVal& targetF); 35 | 36 | /* Compute a branch target formula. For indirect jumps, resolve the target registers 37 | * using data flow analysis. 38 | */ 39 | int 40 | ResolveBranchTargetFormula(const GFSliceVal& targetF, PrivateCFG *cfg, 41 | PrivateCFG::Node *brB, addrtype lpc, InstrBin brType, 42 | AddrSet& targets); 43 | 44 | } /* namespace MIAMI */ 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /bin-anlys/src/common/unionfind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MIAMI framework. For copyright information, see 3 | * the LICENSE file in the MIAMI root folder. 4 | */ 5 | /* 6 | * File: unionfind.h 7 | * Author: Gabriel Marin, mgabi99@gmail.com 8 | * 9 | * Description: Implements the union-find data structure with path 10 | * compression. 11 | */ 12 | 13 | #ifndef _UNIONFIND_SET_H_ 14 | #define _UNIONFIND_SET_H_ 15 | 16 | 17 | class DisjointSet 18 | { 19 | public: 20 | DisjointSet(unsigned int size) : _size(size) 21 | { 22 | elm = new SetElement[_size]; 23 | for (unsigned int i=0 ; i<_size ; ++i) 24 | { 25 | elm[i].iParent = i; 26 | elm[i].iRank = 0; 27 | } 28 | } 29 | 30 | ~DisjointSet() 31 | { 32 | delete[] elm; 33 | } 34 | 35 | inline int Find(int idx) 36 | { 37 | int parent = idx, k; 38 | // find the parent of the set 39 | while(elm[parent].iParent != parent) 40 | parent = elm[parent].iParent; 41 | 42 | // compress the path 43 | while( (k=elm[idx].iParent) != parent ) 44 | { 45 | elm[idx].iParent = parent; 46 | idx = k; 47 | } 48 | return (parent); 49 | } 50 | 51 | inline void Union(int idx1, int idx2) 52 | { 53 | if (elm[idx1].iRank > elm[idx2].iRank) 54 | elm[idx2].iParent = idx1; 55 | else 56 | { 57 | elm[idx1].iParent = idx2; 58 | if (elm[idx1].iRank == elm[idx2].iRank) 59 | elm[idx2].iRank ++; 60 | } 61 | } 62 | 63 | private: 64 | class SetElement 65 | { 66 | public: 67 | int iRank; 68 | int iParent; 69 | }; 70 | 71 | SetElement* elm; 72 | unsigned int _size; 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /bin-anlys/src/tarjans/EdgeDirection.h: -------------------------------------------------------------------------------- 1 | /* * BeginRiceCopyright ***************************************************** 2 | * 3 | * Copyright ((c)) 2002, 2003 Rice University 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of Rice University (RICE) nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * This software is provided by RICE and contributors "as is" and any 22 | * express or implied warranties, including, but not limited to, the 23 | * implied warranties of merchantability and fitness for a particular 24 | * purpose are disclaimed. In no event shall RICE or contributors be 25 | * liable for any direct, indirect, incidental, special, exemplary, or 26 | * consequential damages (including, but not limited to, procurement of 27 | * substitute goods or services; loss of use, data, or profits; or 28 | * business interruption) however caused and on any theory of liability, 29 | * whether in contract, strict liability, or tort (including negligence 30 | * or otherwise) arising in any way out of the use of this software, even 31 | * if advised of the possibility of such damage. 32 | * 33 | * ******************************************************* EndRiceCopyright */ 34 | 35 | 36 | #ifndef EdgeDirection_h 37 | #define EdgeDirection_h 38 | 39 | enum EdgeDirection {ED_INCOMING, ED_OUTGOING}; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /bin-anlys/src/tarjans/ForwardBackward.h: -------------------------------------------------------------------------------- 1 | /* * BeginRiceCopyright ***************************************************** 2 | * 3 | * Copyright ((c)) 2002, 2003 Rice University 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of Rice University (RICE) nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * This software is provided by RICE and contributors "as is" and any 22 | * express or implied warranties, including, but not limited to, the 23 | * implied warranties of merchantability and fitness for a particular 24 | * purpose are disclaimed. In no event shall RICE or contributors be 25 | * liable for any direct, indirect, incidental, special, exemplary, or 26 | * consequential damages (including, but not limited to, procurement of 27 | * substitute goods or services; loss of use, data, or profits; or 28 | * business interruption) however caused and on any theory of liability, 29 | * whether in contract, strict liability, or tort (including negligence 30 | * or otherwise) arising in any way out of the use of this software, even 31 | * if advised of the possibility of such damage. 32 | * 33 | * ******************************************************* EndRiceCopyright */ 34 | 35 | 36 | #ifndef ForwardBackward_h 37 | #define ForwardBackward_h 38 | 39 | enum ForwardBackward { FORWARD, BACKWARD }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /bin-anlys/src/tarjans/UnionFindUniverse.h: -------------------------------------------------------------------------------- 1 | /* * BeginRiceCopyright ***************************************************** 2 | * 3 | * Copyright ((c)) 2002, 2003 Rice University 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of Rice University (RICE) nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * This software is provided by RICE and contributors "as is" and any 22 | * express or implied warranties, including, but not limited to, the 23 | * implied warranties of merchantability and fitness for a particular 24 | * purpose are disclaimed. In no event shall RICE or contributors be 25 | * liable for any direct, indirect, incidental, special, exemplary, or 26 | * consequential damages (including, but not limited to, procurement of 27 | * substitute goods or services; loss of use, data, or profits; or 28 | * business interruption) however caused and on any theory of liability, 29 | * whether in contract, strict liability, or tort (including negligence 30 | * or otherwise) arising in any way out of the use of this software, even 31 | * if advised of the possibility of such damage. 32 | * 33 | * ******************************************************* EndRiceCopyright */ 34 | 35 | 36 | class UnionFindElement; 37 | 38 | class UnionFindUniverse { 39 | public: 40 | UnionFindUniverse(unsigned int highWaterMark); 41 | ~UnionFindUniverse(); 42 | void Union(int i, int j, int k); 43 | int Find(int i); 44 | 45 | private: // methods 46 | int &Count(int i); 47 | int &Root(int i); 48 | int &Parent(int i); 49 | int &Name(int i); 50 | int do_FIND(int i); 51 | 52 | private: // data 53 | UnionFindElement *e; 54 | }; 55 | 56 | -------------------------------------------------------------------------------- /bin-anlys/src/tools/get_path.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE="${BASH_SOURCE[0]}" 4 | while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink 5 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 6 | SOURCE="$(readlink "$SOURCE")" 7 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located 8 | done 9 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 10 | -------------------------------------------------------------------------------- /bin-anlys/src/tools/run_static.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE="${BASH_SOURCE[0]}" 4 | while [ -h "$SOURCE" ]; do 5 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 6 | SOURCE="$(readlink "$SOURCE")" 7 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" 8 | done 9 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 10 | 11 | if [ -f ${DIR}/../etc/vars/XTOOLVARX ] ; then 12 | source ${DIR}/../etc/vars/XTOOLVARX 13 | elif [ -f ${DIR}/../etc/miami_vars ] ; then 14 | source ${DIR}/../etc/miami_vars 15 | else 16 | echo "ERROR: Found neither global nor tool specific settings. Aborting." 17 | exit 18 | fi 19 | 20 | if [ -n "${MIAMI_DEBUG}" ] ; then 21 | echo "*** Debug: Miami libs: '${MIAMI_LIBRARY_PATHS}'" 22 | fi 23 | 24 | export LD_LIBRARY_PATH=${MIAMI_LIBRARY_PATHS}:${LD_LIBRARY_PATH} 25 | 26 | 27 | if [ -n "${MIAMI_DEBUG}" ] ; then 28 | echo "*** Debug: Executing: ${DIR}/libexec/XTOOLLIBX $@" 29 | fi 30 | 31 | ${DIR}/libexec/XTOOLLIBX $@ 32 | -------------------------------------------------------------------------------- /bin-anlys/src/tools/run_tool.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE="${BASH_SOURCE[0]}" 4 | while [ -h "$SOURCE" ]; do 5 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 6 | SOURCE="$(readlink "$SOURCE")" 7 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" 8 | done 9 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 10 | 11 | if [ -f ${DIR}/../etc/vars/XTOOLVARX ] ; then 12 | source ${DIR}/../etc/vars/XTOOLVARX 13 | elif [ -f ${DIR}/../etc/miami_vars ] ; then 14 | source ${DIR}/../etc/miami_vars 15 | else 16 | echo "ERROR: Found neither global nor tool specific settings. Aborting." 17 | exit 18 | fi 19 | #source ${DIR}/../etc/pin_config 20 | 21 | if [ -n "${MIAMI_DEBUG}" ] ; then 22 | echo "*** Debug: Executing: ${PIN_HOME}/pin ${MIAMI_PIN_ARGS} -t ${DIR}/libexec/XTOOLLIBX $@" 23 | fi 24 | 25 | ${PIN_ROOT}/pin ${MIAMI_PIN_ARGS} -t ${DIR}/libexec/XTOOLLIBX $@ 26 | -------------------------------------------------------------------------------- /bin-anlys/test/petsc.x86_64-linux.x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/test/petsc.x86_64-linux.x -------------------------------------------------------------------------------- /bin-anlys/test/test1.x86_64-linux.x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/test/test1.x86_64-linux.x -------------------------------------------------------------------------------- /bin-anlys/test/test2.x86_64-linux.x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/test/test2.x86_64-linux.x -------------------------------------------------------------------------------- /bin-anlys/x-ExtractSourceFiles/canonicalize: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd -P -- "$(dirname -- "$1")" && 3 | printf '%s\n' "$(pwd -P)/$(basename "$1")" 4 | -------------------------------------------------------------------------------- /bin-anlys/x-ExtractSourceFiles/collectSourceFiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case $# in 4 | 0) echo "Usage: $0 list_file1.txt [ list_file2.txt ...]"; exit;; 5 | esac 6 | 7 | exedir=`dirname $0` 8 | 9 | rezdir=src 10 | mkdir -p ${rezdir} 11 | 12 | cat > script_updatePaths.sh << EOF 13 | #!/bin/bash 14 | 15 | infile=\$1 16 | tempfile=tmp_\$1 17 | echo "Processing file \${infile}" 18 | EOF 19 | echo -n "sed" >> script_updatePaths.sh 20 | 21 | for ff in $* 22 | do 23 | cprefix=`cat ${ff} | ${exedir}/commonPrefix` 24 | canonPrefix=`${exedir}/canonicalize ${cprefix}` 25 | destdir=`echo ${ff} | cut -d"." -f1 | cut -d"_" -f2-` 26 | mkdir -p ${rezdir}/${destdir} 27 | sedcprefix=`echo ${cprefix} | sed 's/\./\\\./g'` 28 | echo "${cprefix} -> ${rezdir}/${destdir}" 29 | echo " -e \"s,\(> script_updatePaths.sh 30 | # echo -n "-e \"s,${canonPrefix},${rezdir}/${destdir},g\" " >> script_updatePaths.sh 31 | plen=`echo -n ${cprefix} | wc -c | tr -d " "` 32 | plen=`expr ${plen} + 1` 33 | echo "plen=${plen}" 34 | cat ${ff} |{ 35 | while read line 36 | do 37 | # line=`${exedir}/canonicalize ${line}` 38 | destfile=${rezdir}/${destdir}`echo -n ${line} | cut -c${plen}-` 39 | dname=`dirname ${destfile}` 40 | mkdir -p "${dname}" 41 | cp "${line}" "${destfile}" 42 | done 43 | } 44 | done 45 | 46 | echo ' ${infile} > ${tempfile}' >> script_updatePaths.sh 47 | echo 'mv ${tempfile} ${infile}' >> script_updatePaths.sh 48 | chmod +x script_updatePaths.sh 49 | -------------------------------------------------------------------------------- /bin-anlys/x-ExtractSourceFiles/commonPrefix: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | commonPrefix="" 4 | prefixLen=0 5 | i=0 6 | exedir=`dirname $0` 7 | 8 | #echo -n "Processing file " 9 | while read line 10 | do 11 | # line=`${exedir}/canonicalize ${line}` 12 | line=`dirname ${line}` 13 | line=`echo "@#$"${line} | sed -e "s/ /%@/g"` 14 | if test $i -eq 0 15 | then 16 | commonPrefix=${line} 17 | prefixLen=`echo ${commonPrefix} | tr "/" " " | wc -w | tr -d " "` 18 | else 19 | line1=`echo ${commonPrefix} | tr "/" " " | sed -e "s/^[ \t]*//g"` 20 | line2=`echo ${line} | tr "/" " " | sed -e "s/^[ \t]*//g"` 21 | line2len=`echo ${line2} | tr "/" " " | wc -w | tr -d " "` 22 | minlen=${prefixLen} 23 | if test ${line2len} -lt ${minlen} 24 | then 25 | minlen=${line2len} 26 | fi 27 | 28 | j=0 29 | while test ${j} -lt ${minlen} 30 | do 31 | f=`expr ${j} + 1` 32 | str1=`echo ${line1} | cut -d" " -f${f}` 33 | str2=`echo ${line2} | cut -d" " -f${f}` 34 | if test "${str1}" != "${str2}" 35 | then 36 | break 37 | fi 38 | j=`expr ${j} + 1` 39 | done 40 | # echo "Partial common prefix len = ${j}" 41 | prefixLen=${j} 42 | if test ${j} -eq 0 43 | then 44 | commonPrefix="" 45 | break 46 | else 47 | commonPrefix=`echo ${commonPrefix} | cut -d"/" -f-${j}` 48 | # echo -n "." 49 | # echo "Partial common prefix: >${commonPrefix}<" 50 | fi 51 | fi 52 | 53 | i=`expr ${i} + 1` 54 | done; 55 | 56 | truePrefix=`echo ${commonPrefix} | sed -e "s/^@#\$\(.\)/\1/g" -e "s/%@/ /g"` 57 | #echo 58 | #echo "Common prefix is \"${commonPrefix}\"" 59 | #echo "True prefix is \"${truePrefix}\"" 60 | echo ${truePrefix} 61 | -------------------------------------------------------------------------------- /bin-anlys/x-ExtractSourceFiles/copySourceFiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE="${BASH_SOURCE[0]}" 4 | while [ -h "$SOURCE" ]; do 5 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 6 | SOURCE="$(readlink "$SOURCE")" 7 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" 8 | done 9 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 10 | 11 | case $# in 12 | 1) srcFile=$1;; 13 | *) echo "Specify the name of the XML file to be parsed."; exit;; 14 | esac 15 | 16 | tmp1=`mktemp` 17 | egrep -e "<(A f)|(F n)=" ${srcFile} | cut -d"\"" -f2 | sort | uniq > ${tmp1} 18 | 19 | tmp2=`mktemp` 20 | cat ${tmp1} | while read line 21 | do 22 | if [ -f ${line} ] 23 | then 24 | # if [[ ${line} == ../* ]] 25 | # then 26 | # fname=`${DIR}/canonicalize ${line}` 27 | # else 28 | fname=${line} 29 | # fi 30 | echo `dirname ${fname}`"/,"${fname}; 31 | fi 32 | done > ${tmp2} 33 | 34 | keys=`cat ${tmp2} | sed -e 's,^/,,g' | cut -d"/" -f1 | sort -u` 35 | echo ${tmp2} 36 | params="" 37 | for ff in ${keys} 38 | do 39 | echo ">${ff}<" 40 | key=`echo ${ff} | sed -e 's,\.,\\\.,g'` 41 | if [ "X${ff}" == "X." ] 42 | then 43 | fname="sys" 44 | else 45 | fname=${ff} 46 | fi 47 | egrep -e "^/?${key}" ${tmp2} | cut -d"," -f2- > zyx_${fname}.ll 48 | params="${params} zyx_${fname}.ll" 49 | done 50 | 51 | unlink ${tmp1} 52 | unlink ${tmp2} 53 | 54 | ${DIR}/collectSourceFiles.sh ${params} 55 | -------------------------------------------------------------------------------- /bin-anlys/x-ExtractSourceFiles/getAllFileNames.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case $# in 4 | 1) srcFile=$1;; 5 | *) echo "Specify the name of the XML file to be parsed."; exit;; 6 | esac 7 | 8 | egrep -e "<(A f)|(F n)=" ${srcFile} | cut -d"\"" -f2 | sort | uniq 9 | -------------------------------------------------------------------------------- /bin-anlys/x-Viewer/hpcviewer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnnl/memgaze/81fd1e8efb258a79d396e813b18fc6ea630d8322/bin-anlys/x-Viewer/hpcviewer.jar -------------------------------------------------------------------------------- /mem-anlys/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | fp_intel_pt.x 3 | old_main.cpp 4 | output*.txt 5 | results/ 6 | tags 7 | test.output 8 | testFiles/ 9 | memgaze-analyze 10 | memgaze-analyze-loc -------------------------------------------------------------------------------- /mem-anlys/Access.hpp: -------------------------------------------------------------------------------- 1 | // -*-Mode: C++;-*- 2 | 3 | //*BeginPNNLCopyright******************************************************** 4 | // 5 | // $HeadURL$ 6 | // $Id: 7 | // 8 | //**********************************************************EndPNNLCopyright* 9 | 10 | //*************************************************************************** 11 | // $HeadURL$ 12 | // 13 | // Ozgur Ozan Kilic, Nathan Tallent 14 | //*************************************************************************** 15 | 16 | //*************************************************************************** 17 | #ifndef ACCESS_H 18 | #define ACCESS_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "metrics.hpp" 37 | //*************************************************************************** 38 | //class Address; 39 | //class Instruction; 40 | //class CPU; 41 | //class AccessTime; 42 | #include "Address.hpp" 43 | #include "Instruction.hpp" 44 | #include "CPU.hpp" 45 | #include "AccessTime.hpp" 46 | 47 | //*************************************************************************** 48 | using namespace std; 49 | 50 | class Access { 51 | public: 52 | Address *addr; 53 | CPU *cpu; 54 | Instruction *ip; 55 | AccessTime *time; 56 | 57 | 58 | 59 | 60 | Access(unsigned long _ip, uint16_t _cpu, unsigned long _addr, unsigned long _time){ 61 | addr = new Address(_addr); 62 | cpu = new CPU(_cpu); 63 | ip = new Instruction(_ip); 64 | time = new AccessTime(_time); 65 | 66 | // addr.setAddr(_addr); 67 | // cpu.setCPU(_cpu); 68 | // ip.setIp(_ip); 69 | // time.setTime(_time); 70 | } 71 | 72 | Access(); 73 | ~Access(){ 74 | delete addr; 75 | delete cpu; 76 | delete ip; 77 | delete time; 78 | } 79 | Instruction* getIP(){return ip;} 80 | Address * getAddr(){return addr;} 81 | CPU * getCPU(){return cpu;} 82 | AccessTime * getTime(){return time;} 83 | 84 | }; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /mem-anlys/AccessTime.hpp: -------------------------------------------------------------------------------- 1 | // -*-Mode: C++;-*- 2 | 3 | //*BeginPNNLCopyright******************************************************** 4 | // 5 | // $HeadURL$ 6 | // $Id: 7 | // 8 | //**********************************************************EndPNNLCopyright* 9 | 10 | //*************************************************************************** 11 | // $HeadURL$ 12 | // 13 | // Ozgur Ozan Kilic, Nathan Tallent 14 | //*************************************************************************** 15 | 16 | //*************************************************************************** 17 | #ifndef ACCESSTIME_H 18 | #define ACCESSTIME_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | //*************************************************************************** 37 | //OZGURCLEANUP class Address; 38 | //OZGURCLEANUP class Instruction; 39 | //OZGURCLEANUP class CPU; 40 | //OZGURCLEANUP class AccessTime; 41 | //*************************************************************************** 42 | using namespace std; 43 | 44 | 45 | //This class hold the access time 46 | //v1: hold a pointer to each other classes 47 | //v2: holds an array/map to CPUs 48 | class AccessTime { 49 | public: 50 | unsigned long time; 51 | uint32_t sampleID; 52 | //v1 53 | //OZGURCLEANUP Address *addr; 54 | //OZGURCLEANUP CPU *cpu; 55 | //OZGURCLEANUP Instruction *ip; 56 | AccessTime(unsigned long _time, uint32_t _sampleID){ 57 | time = _time; 58 | sampleID = _sampleID; 59 | } 60 | AccessTime(unsigned long _time){ 61 | time = _time; 62 | } 63 | AccessTime (){ 64 | time = 0; 65 | } 66 | 67 | /* AccessTime(unsigned long _time, Address *_addr = NULL, Instruction *_ip = NULL, CPU *_cpu = NULL ){ 68 | cpu = _cpu; 69 | time = _time; 70 | ip = _ip; 71 | addr= _addr; 72 | sampleID = 0; 73 | } 74 | 75 | AccessTime(unsigned long _time, int _sampleID, Address *_addr = NULL, Instruction *_ip = NULL, CPU *_cpu = NULL ){ 76 | cpu = _cpu; 77 | time = _time; 78 | ip = _ip; 79 | addr= _addr; 80 | sampleID = _sampleID; 81 | } 82 | */ 83 | void setTime(unsigned long _time){ time = _time;} 84 | /* void setAll(unsigned long _time, int _sampleID, CPU *_cpu , Address *_addr , Instruction *_ip){ 85 | cpu = _cpu; 86 | time = _time; 87 | ip = _ip; 88 | addr = _addr; 89 | sampleID = _sampleID; 90 | } 91 | */ 92 | bool operator < (const AccessTime& input) const 93 | { 94 | return (time < input.time); 95 | } 96 | 97 | bool operator > (const AccessTime& input) const 98 | { 99 | return (time > input.time); 100 | } 101 | void setSampleID(uint32_t _sampleID){ sampleID = _sampleID;} 102 | uint32_t getSampleID(){return sampleID;} 103 | }; 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /mem-anlys/Address.hpp: -------------------------------------------------------------------------------- 1 | // -*-Mode: C++;-*- 2 | 3 | //*BeginPNNLCopyright******************************************************** 4 | // 5 | // $HeadURL$ 6 | // $Id: 7 | // 8 | //**********************************************************EndPNNLCopyright* 9 | 10 | //*************************************************************************** 11 | // $HeadURL$ 12 | // 13 | // Ozgur Ozan Kilic, Nathan Tallent 14 | //*************************************************************************** 15 | 16 | //*************************************************************************** 17 | #ifndef ADDRESS_H 18 | #define ADDRESS_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | //*************************************************************************** 37 | //OZGURCLEANUP class Address; 38 | //OZGURCLEANUP class Instruction; 39 | //OZGURCLEANUP class CPU; 40 | //OZGURCLEANUP class AccessTime; 41 | //*************************************************************************** 42 | using namespace std; 43 | 44 | 45 | //This class will hold the memory addresses that has been accessed 46 | //addr it the virtual address that has been accessed 47 | //cpu holds a pointer to the cpu object 48 | //time holds a pointer to the time object 49 | //ip holds a pointer to the instruction pointer. 50 | class Address { 51 | public: 52 | unsigned long addr; 53 | //OZGURCLEANUP string fName; TODO needs to move to Instruction as a map 54 | //OZGURCLEANUP CPU *cpu; 55 | //OZGURCLEANUP AccessTime *time; 56 | //OZGURCLEANUP Instruction *ip; 57 | //OZGURCLEANUP int rDist 58 | 59 | Address(unsigned long _addr){ addr = _addr;} 60 | 61 | //OZGURCLEANUP 62 | /* Address(unsigned long _addr, 63 | int _rDist = -1, CPU *_cpu = NULL, AccessTime *_time = NULL, Instruction *_ip = NULL ){ 64 | // rDist = _rDist;//REMOVING_XTRA 65 | cpu = _cpu; 66 | time = _time; 67 | ip = _ip; 68 | addr = _addr; 69 | fName = ""; 70 | } 71 | void setFuncName(string _name){fName= _name; } 72 | string getFuncName(){return fName;} 73 | // void setReuseDistance(int _rDist) {rDist = _rDist;} //REMOVING_XTRA 74 | */ 75 | void setAddr(unsigned long _addr){ addr = _addr;} 76 | /* void setAll(unsigned long _addr, CPU *_cpu , AccessTime *_time , Instruction *_ip, int _rDist = -1){ 77 | // rDist = _rDist;//REMOVING_XTRA 78 | cpu = _cpu; 79 | time = _time; 80 | ip = _ip; 81 | addr = _addr; 82 | } 83 | */ 84 | bool operator < (const Address& input) const 85 | { 86 | cout << "Comparing this: " << hex << this->addr << " with " <addr < input.addr); 88 | } 89 | 90 | bool operator > (const Address& input) const 91 | { 92 | return (this->addr > input.addr); 93 | } 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /mem-anlys/CPU.hpp: -------------------------------------------------------------------------------- 1 | // -*-Mode: C++;-*- 2 | 3 | //*BeginPNNLCopyright******************************************************** 4 | // 5 | // $HeadURL$ 6 | // $Id: 7 | // 8 | //**********************************************************EndPNNLCopyright* 9 | 10 | //*************************************************************************** 11 | // $HeadURL$ 12 | // 13 | // Ozgur Ozan Kilic, Nathan Tallent 14 | //*************************************************************************** 15 | 16 | //*************************************************************************** 17 | #ifndef CPU_H 18 | #define CPU_H 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | //*************************************************************************** 38 | //OZGURCLEANUP class Address; 39 | //OZGURCLEANUP class Instruction; 40 | //OZGURCLEANUP class CPU; 41 | //OZGURCLEANUP class AccessTime; 42 | //*************************************************************************** 43 | using namespace std; 44 | 45 | 46 | 47 | //This class is for each CPU 48 | //v1: Holds pointer to al other classes 49 | //v2: Holds a list of ponters of IP Addresses and pointer to the time. 50 | class CPU { 51 | public: 52 | uint16_t cpu; 53 | //OZGURCLEANUP AccessTime *time; 54 | //For v1 55 | //OZGURCLEANUP Instruction *ip; 56 | //OZGURCLEANUP Address *addr; 57 | 58 | CPU(uint16_t _cpu){ cpu = _cpu;} 59 | //OZGURCLEANUP 60 | /* CPU(int _cpu, Address *_addr = NULL, AccessTime *_time = NULL, Instruction *_ip = NULL ){ 61 | cpu = _cpu; 62 | time = _time; 63 | ip = _ip; 64 | addr= _addr; 65 | } 66 | */ 67 | void setCPU(uint16_t _cpu){ cpu = _cpu;} 68 | uint16_t getCPU(){return cpu;} 69 | /* void setAll(int _cpu, Address *_addr , AccessTime *_time , Instruction *_ip){ 70 | cpu = _cpu; 71 | time = _time; 72 | ip = _ip; 73 | addr = _addr; 74 | } 75 | */ 76 | bool operator < (const CPU& input) const 77 | { 78 | return (cpu < input.cpu); 79 | } 80 | 81 | bool operator > (const CPU& input) const 82 | { 83 | return (cpu > input.cpu); 84 | } 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /mem-anlys/Function.hpp: -------------------------------------------------------------------------------- 1 | // -*-Mode: C++;-*- 2 | 3 | //*BeginPNNLCopyright******************************************************** 4 | // 5 | // $HeadURL$ 6 | // $Id: 7 | // 8 | //**********************************************************EndPNNLCopyright* 9 | 10 | //*************************************************************************** 11 | // $HeadURL$ 12 | // 13 | // Ozgur Ozan Kilic, Nathan Tallent 14 | //*************************************************************************** 15 | 16 | //*************************************************************************** 17 | #ifndef FUNCTION_H 18 | #define FUNCTION_H 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | //*************************************************************************** 38 | //#include "AccessTime.hpp" 39 | #include "Trace.hpp" 40 | #include "metrics.hpp" 41 | using namespace std; 42 | 43 | 44 | namespace memgaze { 45 | class Function { 46 | public: 47 | int fp; 48 | uint16_t ncpus; 49 | std::vector cpuFP; 50 | double totalLoads; 51 | std::string name; 52 | uint32_t nameID; 53 | uint16_t load_module; 54 | unsigned long startIP; 55 | unsigned long endIP; 56 | std::vector children; 57 | Function * parrent; 58 | //OZGURCLEANUP std::vector timeVec; 59 | Trace * trace; 60 | map > fpMap; //
61 | std::vector >> cpuFPMap; //
62 | void getdiagMap (map *typeMap, map *fpDiagMap); 63 | void getFPDiag(map *diagMap); 64 | void getCPUFPDiag(map *cpuDiagMap, uint16_t cpuid); 65 | int getFP(); 66 | void calcFP(); 67 | void calcCPUFP(); 68 | Function (std::string _name, unsigned long _s = 0, unsigned long _e = 0, int _ncpus = 24); 69 | Function (std::string _name, uint16_t _load_module, unsigned long _s = 0, unsigned long _e = 0, int _ncpus = 24); 70 | 71 | //OZGURCLEANUP DEPRICATE ?? std::vector calculateFunctionFP(); // depricate TODO: remove/revisit 72 | //OZGURCLEANUP DEPRICATE ?? std::vector calculateFunctionCPUFP(); // depricated TODO: remove/revisit 73 | void printFunctionTree(); 74 | float getMultiplier(unsigned long period, bool is_load = false); 75 | private: 76 | Trace * calculateFunctionFPRec(Function *root, int level ); 77 | //OZGURCLEANUP std::vector calculateFunctionFPRec(Function *root, int level ); 78 | Trace * calculateFunctionCPUFPRec(Function *root, int level ); 79 | //OZGURCLEANUP std::vector calculateFunctionCPUFPRec(Function *root, int level ); 80 | void printFunctionTreeRec(Function *root, int level ); 81 | }; 82 | 83 | } // namespace memgaze 84 | #endif 85 | -------------------------------------------------------------------------------- /mem-anlys/README-notes.md: -------------------------------------------------------------------------------- 1 | Memory Management: 2 | Finding un used variable for each class: 3 | Window: 4 | fload ws , zs , multiplierAvg DONE 5 | int number_of_samples DONE 6 | AccessTime: 7 | Address: 8 | int rDist DONE 9 | Instruction: 10 | CPU: 11 | Function: 12 | 13 | Maybe change: 14 | maybe move funcName from Address class to instruction calls 15 | 16 | //OZGURCLEANUP 17 | 18 | enum EnumType : uint16_t 19 | { 20 |   Bar, 21 |   Baz, 22 |   Bork, 23 | }; 24 | 25 |     - Savings/entry       26 | - 12 pointers: 4 objects x 3 pointers       27 | - 2 bytes: 'cpuid' is short       28 | - 4 bytes: 'int rDist' is not needed       29 | - ~50-100/bytes: string for func-name; should be a id in string table  30 | - ~100/bytes: string for load module; should be a id in string table  31 | - 2 bytes: load class is a short       32 | - 2 bytes: extra-frame-loads is a short 33 | 34 | AccessTime 35 | u long + int 36 | CPU -> short id instead of int 2 bytes -> only 2 bytes 37 | instruction 38 | type should be ENUM ==>> 39 | extra constant load -> short 40 | Fname and DSO(load_module) names should be a string table or hash map 41 | Address: rm fName 42 | 43 | 44 | In MAIN I started to do modificcation: 45 | 46 | are theese necessary ?? 47 | 299 vector Zs; 48 | 300 vector Zt; 49 | 301 vector wSize; 50 | 302 vector wTime; 51 | 303 vector wMultipliers; 52 | 53 | 54 | WINDOW.HPP: 55 | 56 | 62 Address* maxFP_addr; //TODO Why we need this?? 57 | -------------------------------------------------------------------------------- /mem-anlys/Trace.hpp: -------------------------------------------------------------------------------- 1 | // -*-Mode: C++;-*- 2 | 3 | //*BeginPNNLCopyright******************************************************** 4 | // 5 | // $HeadURL$ 6 | // $Id: 7 | // 8 | //**********************************************************EndPNNLCopyright* 9 | 10 | //*************************************************************************** 11 | // $HeadURL$ 12 | // 13 | // Ozgur Ozan Kilic, Nathan Tallent 14 | //*************************************************************************** 15 | 16 | //*************************************************************************** 17 | #ifndef TRACE_H 18 | #define TRACE_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "metrics.hpp" 37 | //*************************************************************************** 38 | //class Access; 39 | #include "Access.hpp" 40 | //*************************************************************************** 41 | using namespace std; 42 | 43 | //This class hold the access time 44 | //v1: hold a pointer to each other classes 45 | //v2: holds an array/map to CPUs 46 | class Trace { 47 | public: 48 | vector trace; 49 | 50 | ~Trace(){emptyTrace();} 51 | 52 | vector * getTrace(){return &trace;} 53 | 54 | int getSize(){return trace.size();} 55 | 56 | void addAccess(Access * access){ 57 | trace.push_back(access); 58 | } 59 | 60 | void emptyTrace(){ 61 | this->trace.clear(); 62 | } 63 | 64 | void removeAfter(int index){ 65 | trace.erase(trace.begin()+index+1, trace.end()); 66 | } 67 | void removeBefore( int index){ 68 | trace.erase(trace.begin(), trace.begin()+index); 69 | } 70 | 71 | void addTrace(Trace * inTrace){ 72 | for (auto it = inTrace->trace.begin(); it != inTrace->trace.end(); it++){ 73 | this->addAccess(*it); 74 | } 75 | } 76 | 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /mem-anlys/check/ubench-O3-n500k-buf8k-p100000/ubench-O3-n500k-buf8k-p100000.binanlys: -------------------------------------------------------------------------------- 1 | 0x30062a 1 0x0 0x1 0x0 2 | 0x3005f9 1 0x0 0x4 0x1 3 | 0x300844 1 0x0 0x4 0x0 4 | 0x30083c 1 0x0 0x1 0x0 5 | 0x3000f6 0 0x0 0x0 0x6 6 | 0x300639 2 0x0 0x4 0x0 7 | 0x30064c 0 0x0 0x0 0x0 8 | e8d 1 0x20117c 0x1 0x0 9 | 0x300735 1 0xfffffffc 0x4 0x1 10 | 0x3007a3 1 0x0 0x4 0x0 11 | 0x3009d8 0 0x0 0x0 0x1 12 | 0x30070c 1 0x0 0x4 0x0 13 | 672 1 0x201997 0x1 0x0 14 | 0x300936 0 0x0 0x0 0x6 15 | a0c 1 0x54c 0x1 0x2 16 | 76a 1 0x20189f 0x1 0x0 17 | 6cb 1 0x20193e 0x1 0x0 18 | 7b5 1 0x201854 0x1 0x0 19 | 0x30023f 0 0x0 0x0 0x0 20 | 7cf 1 0x20183a 0x1 0x0 21 | 0x30095c 0 0x0 0x0 0x0 22 | 0x3004d8 1 0xfffffffc 0x4 0x1 23 | 0x300494 1 0x0 0x1 0x0 24 | 0x3003d7 0 0x0 0x0 0x5 25 | 0x3006a8 2 0x0 0x4 0x0 26 | 7e3 1 0x201826 0x1 0x0 27 | 0x30040c 1 0x0 0x1 0x0 28 | 0x3004c6 1 0x0 0x1 0x0 29 | 0x3005a1 1 0x0 0x4 0x0 30 | 0x30071a 2 0x0 0x4 0x0 31 | 59c 1 0x201a45 0x1 0x0 32 | 5f0 1 0x2019da 0x1 0x0 33 | 0x300815 2 0x0 0x4 0x0 34 | 0x300762 2 0x0 0x4 0x0 35 | 787 1 0x201882 0x1 0x0 36 | 8b8 1 0x201731 0x1 0x0 37 | 0x30055c 1 0x0 0x1 0x0 38 | 79e 1 0x20186b 0x1 0x0 39 | 0x30041e 1 0xfffffffc 0x4 0x1 40 | 0x30087f 0 0x0 0x0 0x0 41 | 627 1 0x2019e2 0x1 0x0 42 | 0x30058f 1 0x0 0x4 0x0 43 | 0x300800 1 0x0 0x4 0x0 44 | 5e0 1 0x2019e2 0x1 0x0 45 | 0x3006c1 1 0xfffffffc 0x4 0x1 46 | 0x300671 2 0x0 0x4 0x0 47 | 0x30088e 0 0x0 0x0 0x0 48 | 7fd 1 0x20180c 0x1 0x0 49 | 0x3009aa 0 0x0 0x0 0x0 50 | 0x300475 1 0xfffffffc 0x4 0x1 51 | 5d0 1 0x2019ea 0x1 0x0 52 | 0x3003bd 2 0x0 0x1 0x0 53 | 0x30077b 1 0xfffffffc 0x4 0x1 54 | 844 1 0x201796 0x1 0x1 55 | 0x300662 1 0x0 0x1 0x0 56 | 0x3008cb 0 0x0 0x0 0x1 57 | 0x30069a 1 0x0 0x4 0x0 58 | 867 1 0x20176a 0x1 0x0 59 | 0x3007b1 2 0x0 0x4 0x0 60 | 721 1 0x2018e8 0x1 0x0 61 | 0x300463 1 0x0 0x1 0x0 62 | a1a 1 0x54e 0x1 0x0 63 | 0x3005b7 1 0x0 0x4 0x0 64 | 600 1 0x2019f2 0x1 0x0 65 | 5c0 1 0x2019f2 0x1 0x0 66 | 0x30091b 1 0x0 0x8 0x0 67 | 0x30060b 0 0x0 0x0 0x0 68 | 0x300754 1 0x0 0x4 0x0 69 | 0x300864 2 0x0 0x4 0x0 70 | 8e0 1 0x201731 0x1 0x0 71 | 0x30099e 0 0x0 0x0 0x0 72 | 0x30085c 1 0x0 0x1 0x0 73 | 8e9 1 0x201707 0x1 0x0 74 | 0x30044e 1 0x0 0x1 0x0 75 | 0x3006e0 1 0x0 0x4 0x0 76 | 0x300106 1 0x8 0x1 0x0 77 | 0x3004a6 1 0xfffffffc 0x4 0x1 78 | 0x300993 0 0x0 0x0 0x0 79 | 0x3005e7 1 0x0 0x4 0x0 80 | 0x3003a5 1 0x0 0x4 0x0 81 | 8f7 1 0x20170a 0x1 0x0 82 | 0x3006ee 2 0x0 0x4 0x0 83 | 0x3007cd 1 0xfffffffc 0x4 0x1 84 | 0x3005cd 1 0x0 0x4 0x0 85 | 0x300684 0 0x0 0x0 0x0 86 | 681 1 0x201988 0x1 0x0 87 | -------------------------------------------------------------------------------- /mem-anlys/loc-anlys/Makefile: -------------------------------------------------------------------------------- 1 | # -*-Mode: makefile;-*- 2 | 3 | #*BeginPNNLCopyright********************************************************* 4 | # 5 | # $HeadURL$ 6 | # $Id: 7f51d456209f4e06233af0321def1918e53fba19 $ 7 | # 8 | #***********************************************************EndPNNLCopyright* 9 | 10 | #**************************************************************************** 11 | # 12 | #**************************************************************************** 13 | 14 | #**************************************************************************** 15 | # Package defs 16 | #**************************************************************************** 17 | 18 | include ../../Makefile-defs.mk 19 | 20 | #**************************************************************************** 21 | # Recursion 22 | #**************************************************************************** 23 | 24 | MK_SUBDIRS = 25 | 26 | #**************************************************************************** 27 | # 28 | #**************************************************************************** 29 | 30 | #---------------------------------------------------------------------------- 31 | # Build 32 | #---------------------------------------------------------------------------- 33 | 34 | CXX = g++ -Wall -g -O3 35 | 36 | 37 | #**************************************************************************** 38 | 39 | mg_analyze := memgaze-analyze-loc 40 | 41 | MK_PROGRAMS_CXX = $(mg_analyze) 42 | 43 | $(mg_analyze)_SRCS = \ 44 | src/main.cpp \ 45 | src/structure.cpp \ 46 | src/BlockInfo.cpp \ 47 | src/SpatialRUD.cpp \ 48 | src/memoryanalysis.cpp \ 49 | 50 | # src/memoryanalysis.h \ 51 | # src/memorymodeling.h\ 52 | # src/structure.h\ 53 | # src/TraceLine.hpp\ 54 | # src/BlockInfo.hpp\ 55 | # src/SpatialRUD.hpp 56 | 57 | $(mg_analyze)_CXXFLAGS = 58 | 59 | $(mg_analyze)_LDFLAGS = 60 | 61 | $(mg_analyze)_LDADD = 62 | 63 | 64 | #**************************************************************************** 65 | # Template Rules 66 | #**************************************************************************** 67 | 68 | include ../../Makefile-template.mk 69 | 70 | 71 | #**************************************************************************** 72 | # Local Rules 73 | #**************************************************************************** 74 | 75 | info.local : 76 | 77 | install.local : 78 | $(INSTALL) -d $(PREFIX_LIBEXEC) 79 | $(INSTALL) memgaze-analyze-loc $(PREFIX_LIBEXEC) 80 | 81 | check.local : 82 | -------------------------------------------------------------------------------- /mem-anlys/loc-anlys/README.md: -------------------------------------------------------------------------------- 1 | memgaze-analyze-loc - location based analysis on memory traces 2 | 3 | 4 | ### Compile ### 5 | Run make to build the memgaze-analyze-loc executable file. 6 | 7 | ### RUN with default configuration ### 8 | memgaze-analyze-loc needs a trace file to run 9 | Trace format - [