├── booksim2 ├── .gitignore ├── src │ ├── .gitignore │ ├── rc_configs │ │ └── .gitignore │ ├── rc_traces │ │ └── .gitignore │ ├── rc_traffics │ │ └── .gitignore │ ├── rc_routing_tables │ │ └── .gitignore │ ├── rc_topologies │ │ └── .gitignore │ ├── power │ │ ├── techfile.txt │ │ ├── switch_monitor.hpp │ │ ├── buffer_monitor.hpp │ │ ├── switch_monitor.cpp │ │ └── buffer_monitor.cpp │ ├── config.y │ ├── config.l │ ├── rng_wrapper.cpp │ ├── misc_utils.hpp │ ├── rng_double_wrapper.cpp │ ├── booksim.hpp │ ├── allocators │ │ ├── pim.hpp │ │ ├── loa.hpp │ │ ├── islip.hpp │ │ ├── selalloc.hpp │ │ ├── maxsize.hpp │ │ ├── separable_output_first.hpp │ │ ├── wavefront.hpp │ │ ├── separable_input_first.hpp │ │ ├── separable.hpp │ │ ├── separable.cpp │ │ ├── loa.cpp │ │ ├── pim.cpp │ │ ├── separable_input_first.cpp │ │ └── separable_output_first.cpp │ ├── misc_utils.cpp │ ├── timed_module.hpp │ ├── booksim_config.hpp │ ├── globals.hpp │ ├── credit.hpp │ ├── packet_reply_info.hpp │ ├── random_utils.cpp │ ├── packet_reply_info.cpp │ ├── networks │ │ ├── fly.hpp │ │ ├── kncube.hpp │ │ ├── qtree.hpp │ │ ├── fattree.hpp │ │ ├── tree4.hpp │ │ ├── dragonfly.hpp │ │ ├── anynet.hpp │ │ ├── cmesh.hpp │ │ └── flatfly_onchip.hpp │ ├── routefunc.hpp │ ├── arbiters │ │ ├── prio_arb.hpp │ │ ├── matrix_arb.hpp │ │ ├── tree_arb.hpp │ │ ├── roundrobin_arb.hpp │ │ ├── roundrobin_arb.cpp │ │ └── arbiter.hpp │ ├── module.hpp │ ├── credit.cpp │ ├── outputset.hpp │ ├── stats.hpp │ ├── random_utils.hpp │ ├── batchtrafficmanager.hpp │ ├── Makefile │ ├── buffer.cpp │ ├── flit.hpp │ ├── module.cpp │ ├── injection.hpp │ ├── pipefifo.hpp │ ├── flitchannel.cpp │ ├── config_utils.hpp │ ├── flit.cpp │ ├── flitchannel.hpp │ ├── vc.hpp │ ├── channel.hpp │ └── stats.cpp ├── README.md └── LICENSE.md ├── requirements.txt ├── netrace ├── .gitignore ├── traces_in │ └── .gitignore ├── traces_out │ └── .gitignore ├── LICENSE ├── queue.h └── export_trace.c ├── plots ├── case_study.pdf ├── evaluation.pdf ├── .gitignore ├── latency_vs_load.pdf └── extended_evaluation.pdf ├── images └── .gitignore ├── results └── .gitignore ├── inputs ├── chiplets │ ├── .gitignore │ └── chiplets_example_experiment.json ├── designs │ ├── .gitignore │ └── design_example_experiment.json ├── traces │ └── .gitignore ├── packagings │ ├── .gitignore │ └── example_packaging.json ├── placements │ └── .gitignore ├── technologies │ ├── .gitignore │ └── example_technologies.json ├── topologies │ └── .gitignore ├── booksim_configs │ ├── .gitignore │ ├── example_booksim_config.json │ └── booksim_config_example_experiment.json ├── routing_tables │ └── .gitignore ├── traffic_by_chiplet │ └── .gitignore ├── traffic_by_unit │ └── .gitignore └── trace_to_traffic.py ├── global_config.py ├── experiments ├── case_study.json ├── example_experiment.json ├── evaluation_latency.json ├── evaluation_links.json ├── evaluation_booksim.json └── evaluation_throughput.json ├── case_study.py ├── create_plots.py ├── generate_placement.py ├── reproduce_paper_results.py ├── routing_utils.py ├── run_experiment.py └── generate_chiplet.py /booksim2/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#*# 3 | ._* 4 | .Apple* 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib==3.8.4 2 | networkx==3.3 3 | numpy==2.1.1 4 | -------------------------------------------------------------------------------- /booksim2/src/.gitignore: -------------------------------------------------------------------------------- 1 | booksim 2 | lex.yy.c 3 | y.tab.c 4 | y.tab.h 5 | *.o 6 | *.d 7 | -------------------------------------------------------------------------------- /netrace/.gitignore: -------------------------------------------------------------------------------- 1 | main 2 | *.o 3 | *~ 4 | \#*# 5 | ._* 6 | .Apple* 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /plots/case_study.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spcl/rapidchiplet/HEAD/plots/case_study.pdf -------------------------------------------------------------------------------- /plots/evaluation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spcl/rapidchiplet/HEAD/plots/evaluation.pdf -------------------------------------------------------------------------------- /plots/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /plots/latency_vs_load.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spcl/rapidchiplet/HEAD/plots/latency_vs_load.pdf -------------------------------------------------------------------------------- /images/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /results/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/chiplets/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/designs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/traces/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /plots/extended_evaluation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spcl/rapidchiplet/HEAD/plots/extended_evaluation.pdf -------------------------------------------------------------------------------- /inputs/packagings/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/placements/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/technologies/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/topologies/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /netrace/traces_in/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /netrace/traces_out/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /booksim2/src/rc_configs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /booksim2/src/rc_traces/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /booksim2/src/rc_traffics/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/booksim_configs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/routing_tables/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/traffic_by_chiplet/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/traffic_by_unit/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /booksim2/src/rc_routing_tables/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /booksim2/src/rc_topologies/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /inputs/packagings/example_packaging.json: -------------------------------------------------------------------------------- 1 | { 2 | "link_routing" : "manhattan", 3 | "link_latency_type" : "function", 4 | "link_latency" : "lambda x : 0.25 * x", 5 | "link_power_type" : "constant", 6 | "link_power" : 1, 7 | "packaging_yield" : 0.9, 8 | "bump_pitch" : 0.05, 9 | "non_data_wires" : 12, 10 | "is_active" : true, 11 | "latency_irouter" : 5, 12 | "power_irouter" : 0.25, 13 | "has_interposer" : true, 14 | "interposer_technology" : "tech_3" 15 | } 16 | -------------------------------------------------------------------------------- /inputs/technologies/example_technologies.json: -------------------------------------------------------------------------------- 1 | { 2 | "tech_1" : { 3 | "phy_latency" : 12, 4 | "wafer_radius" : 101.6, 5 | "wafer_cost" : 500, 6 | "defect_density" : 0.005 7 | }, 8 | "tech_2" : { 9 | "phy_latency" : 12, 10 | "wafer_radius" : 101.6, 11 | "wafer_cost" : 750, 12 | "defect_density" : 0.01 13 | }, 14 | "tech_3" : { 15 | "phy_latency" : 12, 16 | "wafer_radius" : 250, 17 | "wafer_cost" : 1100, 18 | "defect_density" : 0.0005 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /inputs/booksim_configs/example_booksim_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "mode": "traffic", 3 | "ignore_cycles": 0, 4 | "precision": 0.001, 5 | "saturation_factor": 5, 6 | "num_vcs": 4, 7 | "vc_buf_size": 16, 8 | "warmup_periods": 1, 9 | "sim_count": 1, 10 | "hold_switch_for_packet": 0, 11 | "packet_size": 1, 12 | "vc_allocator": "separable_input_first", 13 | "sw_allocator": "separable_input_first", 14 | "alloc_iters": 1, 15 | "sample_period": 5300, 16 | "wait_for_tail_credit": 0, 17 | "priority": "none", 18 | "injection_rate_uses_flits": 1, 19 | "deadlock_warn_timeout": 1024 20 | } -------------------------------------------------------------------------------- /inputs/booksim_configs/booksim_config_example_experiment.json: -------------------------------------------------------------------------------- 1 | { 2 | "mode": "traffic", 3 | "ignore_cycles": 0, 4 | "precision": 0.001, 5 | "saturation_factor": 5, 6 | "num_vcs": 4, 7 | "vc_buf_size": 16, 8 | "warmup_periods": 1, 9 | "sim_count": 1, 10 | "hold_switch_for_packet": 0, 11 | "packet_size": 1, 12 | "vc_allocator": "separable_input_first", 13 | "sw_allocator": "separable_input_first", 14 | "alloc_iters": 1, 15 | "sample_period": 5300, 16 | "wait_for_tail_credit": 0, 17 | "priority": "none", 18 | "injection_rate_uses_flits": 1, 19 | "deadlock_warn_timeout": 1024 20 | } -------------------------------------------------------------------------------- /global_config.py: -------------------------------------------------------------------------------- 1 | # Colors to be used in various parts of the project 2 | colors = [ 3 | "#000000", # Black 4 | "#000099", # Blue 5 | "#009900", # Green 6 | "#990000", # Red 7 | "#999900", # Yellow 8 | "#990099", # Purple 9 | "#CC6600", # Orange 10 | "#3366FF", # Light Blue 11 | "#33CC33", # Light Green 12 | "#CC3333", # Light Red 13 | "#990099", # Light Purple 14 | "#999900", # Light Yellow 15 | "#FF6600", # Light Orange 16 | ] 17 | 18 | # Colors for visualization of chiplets 19 | chiplet_colors = { 20 | "compute" : "#66AADD", 21 | "memory" : "#DDAA66", 22 | "io" : "#66BB99", 23 | } 24 | 25 | # Colors for visualization of links 26 | link_color = "#666666" 27 | 28 | 29 | -------------------------------------------------------------------------------- /inputs/designs/design_example_experiment.json: -------------------------------------------------------------------------------- 1 | { 2 | "design_name": "example_experiment", 3 | "technologies": "inputs/technologies/example_technologies.json", 4 | "chiplets": "inputs/chiplets/chiplets_example_experiment.json", 5 | "placement": "inputs/placements/placement_example_experiment.json", 6 | "topology": "inputs/topologies/topology_example_experiment.json", 7 | "packaging": "inputs/packagings/example_packaging.json", 8 | "routing_table": "inputs/routing_tables/routing_table_example_experiment.json", 9 | "traffic_by_unit": "inputs/traffic_by_unit/traffic_example_experiment.json", 10 | "traffic_by_chiplet": "inputs/traffic_by_chiplet/traffic_example_experiment.json", 11 | "trace": "none", 12 | "booksim_config": "inputs/booksim_configs/booksim_config_example_experiment.json" 13 | } -------------------------------------------------------------------------------- /booksim2/src/power/techfile.txt: -------------------------------------------------------------------------------- 1 | // 2007 ITRS predictions for a 32nm high-performance library 2 | H_INVD2 = 8;//int 3 | W_INVD2 = 3;//int 4 | H_DFQD1 = 8;//int 5 | W_DFQD1 = 16;//int 6 | H_ND2D1 = 8;//int 7 | W_ND2D1 = 3;//int 8 | H_SRAM = 8;//int 9 | W_SRAM = 6;//int 10 | Vdd = 0.9;//float 11 | R = 606.321;//float 12 | IoffSRAM = 0.00000032;//float 13 | // 70 C 14 | IoffP = 0.00000102;//float 15 | IoffN = 0.00000102;//float 16 | Cg_pwr = 0.000000000000000534;//float 17 | Cd_pwr = 0.000000000000000267;//float 18 | Cgdl = 0.0000000000000001068;//float 19 | Cg = 0.000000000000000534;//float 20 | Cd = 0.000000000000000267;//float 21 | LAMBDA = 0.016;//float 22 | MetalPitch = 0.000080;//float 23 | Rw = 0.720044;//float 24 | Cw_gnd = 0.000000000000267339;//float 25 | Cw_cpl = 0.000000000000267339;//float 26 | wire_length = 2.0;//float -------------------------------------------------------------------------------- /booksim2/src/config.y: -------------------------------------------------------------------------------- 1 | %{ 2 | 3 | int yylex(void); 4 | void yyerror(char * msg); 5 | void config_assign_string( char const * field, char const * value ); 6 | void config_assign_int( char const * field, int value ); 7 | void config_assign_float( char const * field, double value ); 8 | 9 | #ifdef _WIN32 10 | #pragma warning ( disable : 4102 ) 11 | #pragma warning ( disable : 4244 ) 12 | #endif 13 | 14 | %} 15 | 16 | %union { 17 | char *name; 18 | int num; 19 | double fnum; 20 | } 21 | 22 | %token STR 23 | %token NUM 24 | %token FNUM 25 | 26 | %% 27 | 28 | commands : commands command 29 | | command 30 | ; 31 | 32 | command : STR '=' STR ';' { config_assign_string( $1, $3 ); free( $1 ); free( $3 ); } 33 | | STR '=' NUM ';' { config_assign_int( $1, $3 ); free( $1 ); } 34 | | STR '=' FNUM ';' { config_assign_float( $1, $3 ); free( $1 ); } 35 | ; 36 | 37 | %% 38 | -------------------------------------------------------------------------------- /experiments/case_study.json: -------------------------------------------------------------------------------- 1 | { 2 | "exp_name" : "case_study", 3 | "metrics" : ["latency","throughput","area_summary"], 4 | "technologies_file" : ["inputs/technologies/example_technologies.json"], 5 | "packaging_file" : ["inputs/packagings/example_packaging.json"], 6 | "booksim_config_file" : ["inputs/booksim_configs/example_booksim_config.json"], 7 | "use_memory" : [false], 8 | "topology" : ["sparse_hamming_graph"], 9 | "grid_scale" : ["10x10"], 10 | "hex_scale" : [], 11 | "mode" : ["traffic"], 12 | "traffic_pattern" : ["random_uniform"], 13 | "trace" : [], 14 | "units_per_chiplet" : [8], 15 | "base_chiplet_area" : [74], 16 | "phy_area" : [0.85], 17 | "base_chiplet_power" : [20], 18 | "phy_power" : [0.125], 19 | "fraction_power_bumps" : [0.5], 20 | "technology" : ["tech_1"], 21 | "chiplets_can_relay" : [true], 22 | "internal_latency" : [3], 23 | "chiplet_spacing" : [0.15], 24 | "routing_algorithm" : ["splif"], 25 | "do_validate" : [false] 26 | } 27 | -------------------------------------------------------------------------------- /case_study.py: -------------------------------------------------------------------------------- 1 | # Import python libraries 2 | import itertools 3 | 4 | # Import RapidChiplet files 5 | import helpers as hlp 6 | import run_experiment as re 7 | 8 | def case_study(): 9 | # Read the experiment file 10 | experiment = hlp.read_json("experiments/case_study.json") 11 | # Construct all possible combinations of sets Sr and Sc 12 | rows, cols = (int(x) for x in experiment["grid_scale"][0].split("x")) 13 | row_options = list(range(2, rows)) 14 | col_options = list(range(2, cols)) 15 | row_combinations = [] 16 | col_combinations = [] 17 | for x in range(len(row_options) + 1): 18 | row_combinations.extend([list(x) for x in itertools.combinations(row_options, x)]) 19 | for x in range(len(col_options) + 1): 20 | col_combinations.extend([list(x) for x in itertools.combinations(col_options, x)]) 21 | experiment["shg_sr"] = row_combinations 22 | experiment["shg_sc"] = col_combinations 23 | # Run the experiment 24 | re.run_experiment(experiment) 25 | 26 | if __name__ == '__main__': 27 | case_study() 28 | 29 | -------------------------------------------------------------------------------- /experiments/example_experiment.json: -------------------------------------------------------------------------------- 1 | { 2 | "exp_name" : "example_experiment", 3 | "metrics" : ["area_summary","power_summary","link_summary","cost","latency","throughput","booksim_simulation"], 4 | "technologies_file" : ["inputs/technologies/example_technologies.json"], 5 | "packaging_file" : ["inputs/packagings/example_packaging.json"], 6 | "booksim_config_file" : ["inputs/booksim_configs/example_booksim_config.json"], 7 | "use_memory" : [false], 8 | "topology" : ["torus"], 9 | "grid_scale" : ["4x4","8x8","16x16"], 10 | "mode" : ["traffic"], 11 | "traffic_pattern" : ["random_uniform"], 12 | "trace" : [], 13 | "units_per_chiplet" : [8], 14 | "base_chiplet_area" : [74], 15 | "phy_area" : [0.85], 16 | "base_chiplet_power" : [20], 17 | "phy_power" : [0.125], 18 | "fraction_power_bumps" : [0.5], 19 | "technology" : ["tech_1"], 20 | "chiplets_can_relay" : [true], 21 | "internal_latency" : [3], 22 | "chiplet_spacing" : [0.15], 23 | "routing_algorithm" : ["splif"], 24 | "n_hotspot" : [4], 25 | "p_hotspot" : [0.5], 26 | "do_validate" : [true] 27 | } 28 | -------------------------------------------------------------------------------- /booksim2/README.md: -------------------------------------------------------------------------------- 1 | BookSim Interconnection Network Simulator 2 | ========================================= 3 | 4 | BookSim is a cycle-accurate interconnection network simulator. 5 | Originally developed for and introduced with the [Principles and Practices of Interconnection Networks](http://cva.stanford.edu/books/ppin/) book, its functionality has since been continuously extended. 6 | The current major release, BookSim 2.0, supports a wide range of topologies such as mesh, torus and flattened butterfly networks, provides diverse routing algorithms and includes numerous options for customizing the network's router microarchitecture. 7 | 8 | --- 9 | 10 | If you use BookSim in your research, we would appreciate the following citation in any publications to which it has contributed: 11 | 12 | Nan Jiang, Daniel U. Becker, George Michelogiannakis, James Balfour, Brian Towles, John Kim and William J. Dally. A Detailed and Flexible Cycle-Accurate Network-on-Chip Simulator. In *Proceedings of the 2013 IEEE International Symposium on Performance Analysis of Systems and Software*, 2013. -------------------------------------------------------------------------------- /experiments/evaluation_latency.json: -------------------------------------------------------------------------------- 1 | { 2 | "exp_name" : "evaluation_latency", 3 | "metrics" : ["latency"], 4 | "technologies_file" : ["inputs/technologies/example_technologies.json"], 5 | "packaging_file" : ["inputs/packagings/example_packaging.json"], 6 | "booksim_config_file" : ["inputs/booksim_configs/example_booksim_config.json"], 7 | "use_memory" : [false], 8 | "topology" : ["mesh","torus","folded_torus","sid_mesh"], 9 | "grid_scale" : ["2x2","3x3","4x4","5x5","6x6","7x7","8x8","9x9","10x10"], 10 | "hex_scale" : [], 11 | "mode" : ["traffic"], 12 | "traffic_pattern" : ["random_uniform","transpose","permutation","hotspot"], 13 | "trace" : [], 14 | "units_per_chiplet" : [8], 15 | "base_chiplet_area" : [74], 16 | "phy_area" : [0.85], 17 | "base_chiplet_power" : [20], 18 | "phy_power" : [0.125], 19 | "fraction_power_bumps" : [0.5], 20 | "technology" : ["tech_1"], 21 | "chiplets_can_relay" : [true], 22 | "internal_latency" : [3], 23 | "chiplet_spacing" : [0.15], 24 | "routing_algorithm" : ["splif"], 25 | "do_validate" : [false], 26 | "n_hotspot" : [4], 27 | "p_hotspot" : [0.5] 28 | } 29 | -------------------------------------------------------------------------------- /experiments/evaluation_links.json: -------------------------------------------------------------------------------- 1 | { 2 | "exp_name" : "evaluation_links", 3 | "metrics" : ["link_summary"], 4 | "technologies_file" : ["inputs/technologies/example_technologies.json"], 5 | "packaging_file" : ["inputs/packagings/example_packaging.json"], 6 | "booksim_config_file" : ["inputs/booksim_configs/example_booksim_config.json"], 7 | "use_memory" : [false], 8 | "topology" : ["mesh","torus","folded_torus","sid_mesh"], 9 | "grid_scale" : ["2x2","3x3","4x4","5x5","6x6","7x7","8x8","9x9","10x10"], 10 | "hex_scale" : [], 11 | "mode" : ["traffic"], 12 | "traffic_pattern" : ["random_uniform","transpose","permutation","hotspot"], 13 | "trace" : [], 14 | "units_per_chiplet" : [8], 15 | "base_chiplet_area" : [74], 16 | "phy_area" : [0.85], 17 | "base_chiplet_power" : [20], 18 | "phy_power" : [0.125], 19 | "fraction_power_bumps" : [0.5], 20 | "technology" : ["tech_1"], 21 | "chiplets_can_relay" : [true], 22 | "internal_latency" : [3], 23 | "chiplet_spacing" : [0.15], 24 | "routing_algorithm" : ["splif"], 25 | "do_validate" : [false], 26 | "n_hotspot" : [4], 27 | "p_hotspot" : [0.5] 28 | } 29 | -------------------------------------------------------------------------------- /experiments/evaluation_booksim.json: -------------------------------------------------------------------------------- 1 | { 2 | "exp_name" : "evaluation_booksim", 3 | "metrics" : ["booksim_simulation"], 4 | "technologies_file" : ["inputs/technologies/example_technologies.json"], 5 | "packaging_file" : ["inputs/packagings/example_packaging.json"], 6 | "booksim_config_file" : ["inputs/booksim_configs/example_booksim_config.json"], 7 | "use_memory" : [false], 8 | "topology" : ["mesh","torus","folded_torus","sid_mesh"], 9 | "grid_scale" : ["3x3","4x4","5x5","6x6","7x7","8x8","9x9","10x10"], 10 | "hex_scale" : [], 11 | "mode" : ["traffic"], 12 | "traffic_pattern" : ["random_uniform","transpose","permutation","hotspot"], 13 | "trace" : [], 14 | "units_per_chiplet" : [8], 15 | "base_chiplet_area" : [74], 16 | "phy_area" : [0.85], 17 | "base_chiplet_power" : [20], 18 | "phy_power" : [0.125], 19 | "fraction_power_bumps" : [0.5], 20 | "technology" : ["tech_1"], 21 | "chiplets_can_relay" : [true], 22 | "internal_latency" : [3], 23 | "chiplet_spacing" : [0.15], 24 | "routing_algorithm" : ["splif"], 25 | "do_validate" : [false], 26 | "n_hotspot" : [4], 27 | "p_hotspot" : [0.5] 28 | } 29 | -------------------------------------------------------------------------------- /experiments/evaluation_throughput.json: -------------------------------------------------------------------------------- 1 | { 2 | "exp_name" : "evaluation_throughput", 3 | "metrics" : ["throughput"], 4 | "technologies_file" : ["inputs/technologies/example_technologies.json"], 5 | "packaging_file" : ["inputs/packagings/example_packaging.json"], 6 | "booksim_config_file" : ["inputs/booksim_configs/example_booksim_config.json"], 7 | "use_memory" : [false], 8 | "topology" : ["mesh","torus","folded_torus","sid_mesh"], 9 | "grid_scale" : ["2x2","3x3","4x4","5x5","6x6","7x7","8x8","9x9","10x10"], 10 | "hex_scale" : [], 11 | "mode" : ["traffic"], 12 | "traffic_pattern" : ["random_uniform","transpose","permutation","hotspot"], 13 | "trace" : [], 14 | "units_per_chiplet" : [8], 15 | "base_chiplet_area" : [74], 16 | "phy_area" : [0.85], 17 | "base_chiplet_power" : [20], 18 | "phy_power" : [0.125], 19 | "fraction_power_bumps" : [0.5], 20 | "technology" : ["tech_1"], 21 | "chiplets_can_relay" : [true], 22 | "internal_latency" : [3], 23 | "chiplet_spacing" : [0.15], 24 | "routing_algorithm" : ["splif"], 25 | "do_validate" : [false], 26 | "n_hotspot" : [4], 27 | "p_hotspot" : [0.5] 28 | } 29 | -------------------------------------------------------------------------------- /inputs/chiplets/chiplets_example_experiment.json: -------------------------------------------------------------------------------- 1 | { 2 | "example_experiment": { 3 | "dimensions": { 4 | "x": 8.79772697916911, 5 | "y": 8.79772697916911 6 | }, 7 | "type": "compute", 8 | "phys": [ 9 | { 10 | "x": 0.6441986432926979, 11 | "y": 4.398863489584555, 12 | "fraction_bump_area": 0.25 13 | }, 14 | { 15 | "x": 4.398863489584555, 16 | "y": 8.15352833587641, 17 | "fraction_bump_area": 0.25 18 | }, 19 | { 20 | "x": 8.15352833587641, 21 | "y": 4.398863489584555, 22 | "fraction_bump_area": 0.25 23 | }, 24 | { 25 | "x": 4.398863489584555, 26 | "y": 0.6441986432926979, 27 | "fraction_bump_area": 0.25 28 | } 29 | ], 30 | "fraction_power_bumps": 0.5, 31 | "technology": "tech_1", 32 | "power": 20.5, 33 | "relay": true, 34 | "internal_latency": 3, 35 | "unit_count": 8 36 | } 37 | } -------------------------------------------------------------------------------- /booksim2/src/config.l: -------------------------------------------------------------------------------- 1 | %option noinput 2 | %option nounput 3 | 4 | %{ 5 | 6 | #include 7 | 8 | #include "y.tab.h" 9 | 10 | static unsigned int lineno = 1; 11 | 12 | void config_error(char * msg, int lineno); 13 | void yyerror(char * msg); 14 | 15 | extern int config_input(char *, int); 16 | #undef YY_INPUT 17 | #define YY_INPUT(b, r, ms) (r = config_input(b, ms)) 18 | 19 | %} 20 | 21 | Digit [0-9] 22 | Exponent [eE][+-]?{Digit}+ 23 | DblConst ({Digit}*\.)?{Digit}+{Exponent}? 24 | StrConst [A-Za-z_\-/\.][A-Za-z0-9_\-/\.\+(\{\,)\}]* 25 | 26 | %% 27 | 28 | /* Ignore comments and all spaces */ 29 | 30 | \/\/[^\n]* ; 31 | [ \t\r]* ; 32 | 33 | \n { lineno++; } 34 | 35 | /* Commands */ 36 | 37 | \{[A-Za-z0-9_\-\.(\{\,)\}]+(\,[A-Za-z0-9_\-\.(\{\,)\}]+)*\} { yylval.name = strdup( yytext ); return STR; } 38 | 39 | -?[0-9]+ { yylval.num = atoi( yytext ); return NUM; } 40 | 41 | -?[0-9]*\.[0-9]+ { yylval.fnum = atof( yytext ); return FNUM; } 42 | 43 | -?{DblConst} { yylval.fnum = atof( yytext ); return FNUM;} 44 | 45 | {StrConst} { yylval.name = strdup( yytext ); return STR; } 46 | 47 | . { return yytext[0]; } 48 | 49 | %% 50 | 51 | void yyerror( char * msg ) 52 | { 53 | config_error( msg, lineno ); 54 | } 55 | 56 | int yywrap() 57 | { 58 | return 1; 59 | } 60 | -------------------------------------------------------------------------------- /booksim2/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior 2 | University 3 | 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 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. 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 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /booksim2/src/rng_wrapper.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #define main rng_main 29 | #include "rng.c" 30 | 31 | long ran_next( ) 32 | { 33 | return ran_arr_next( ); 34 | } 35 | -------------------------------------------------------------------------------- /booksim2/src/misc_utils.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _MISC_UTILS_HPP_ 29 | #define _MISC_UTILS_HPP_ 30 | 31 | int log_two( int x ); 32 | int powi( int x, int y ); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /booksim2/src/rng_double_wrapper.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #define main rng_double_main 29 | #include "rng-double.c" 30 | 31 | double ranf_next( ) 32 | { 33 | return ranf_arr_next( ); 34 | } 35 | -------------------------------------------------------------------------------- /create_plots.py: -------------------------------------------------------------------------------- 1 | # Python modules 2 | import os 3 | import sys 4 | import argparse 5 | import matplotlib.pyplot as plt 6 | 7 | # RapidChiplet modules 8 | import helpers as hlp 9 | 10 | def create_latency_vs_load_plot(results): 11 | # Verify that the results file contains the necessary information 12 | if "booksim_simulation" not in results: 13 | print("The latency_vs_load plot requires the booksim_simulation results") 14 | sys.exit(1) 15 | # Prepare Plot 16 | (fig, ax) = plt.subplots(1,1, figsize=(3, 3)) 17 | fig.subplots_adjust(left=0.2, right=0.99, top=0.99, bottom=0.15) 18 | loads = [float(x) for x in results["booksim_simulation"].keys() if hlp.is_float(x)] 19 | loads = sorted(loads) 20 | latencies = [results["booksim_simulation"][str(load)]["packet_latency"]["avg"] for load in loads] 21 | # Plot 22 | ax.plot(loads, latencies, marker='o') 23 | # Configure Axes 24 | ax.grid() 25 | ax.set_xlabel("Load") 26 | ax.set_ylabel("Latency (cycles)") 27 | # Save Plot 28 | plt.savefig("plots/latency_vs_load.pdf") 29 | 30 | if __name__ == "__main__": 31 | parser = argparse.ArgumentParser() 32 | parser.add_argument("-rf", "--results_file", type=str, help="Results file to plot", required=True) 33 | parser.add_argument("-pt", "--plot_type", type=str, help="Type of plot to create", required=True) 34 | args = parser.parse_args() 35 | results = hlp.read_json(args.results_file) 36 | if args.plot_type == "latency_vs_load": 37 | create_latency_vs_load_plot(results) 38 | else: 39 | print("Invalid plot type \"%s\". Valid plot types are: latency_vs_load" % args.plot_type) 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /netrace/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2011 The University of Texas at Austin 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer; 9 | * redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution; 12 | * neither the name of the copyright holders nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | -------------------------------------------------------------------------------- /booksim2/src/booksim.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _BOOKSIM_HPP_ 29 | #define _BOOKSIM_HPP_ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #ifdef _WIN32_ 37 | #pragma warning (disable: 4786) 38 | #include 39 | #endif 40 | 41 | using namespace std; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /booksim2/src/allocators/pim.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _PIM_HPP_ 29 | #define _PIM_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class PIM : public DenseAllocator { 36 | int _PIM_iter; 37 | 38 | public: 39 | PIM( Module *parent, const string& name, 40 | int inputs, int outputs, int iters ); 41 | 42 | ~PIM( ); 43 | 44 | void Allocate( ); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /booksim2/src/misc_utils.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "booksim.hpp" 29 | #include "misc_utils.hpp" 30 | 31 | int powi( int x, int y ) // compute x to the y 32 | { 33 | int r = 1; 34 | 35 | for ( int i = 0; i < y; ++i ) { 36 | r *= x; 37 | } 38 | 39 | return r; 40 | } 41 | 42 | int log_two( int x ) 43 | { 44 | int r = 0; 45 | 46 | x >>= 1; 47 | while( x ) { 48 | r++; x >>= 1; 49 | } 50 | 51 | return r; 52 | } 53 | -------------------------------------------------------------------------------- /booksim2/src/timed_module.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _TIMED_MODULE_HPP_ 29 | #define _TIMED_MODULE_HPP_ 30 | 31 | #include "module.hpp" 32 | 33 | class TimedModule : public Module { 34 | 35 | public: 36 | TimedModule(Module * parent, string const & name) : Module(parent, name) {} 37 | virtual ~TimedModule() {} 38 | 39 | virtual void ReadInputs() = 0; 40 | virtual void Evaluate() = 0; 41 | virtual void WriteOutputs() = 0; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /booksim2/src/allocators/loa.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _LOA_HPP_ 29 | #define _LOA_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class LOA : public DenseAllocator { 36 | vector _counts; 37 | vector _req; 38 | 39 | vector _rptr; 40 | vector _gptr; 41 | 42 | public: 43 | LOA( Module *parent, const string& name, 44 | int inputs, int outputs ); 45 | 46 | void Allocate( ); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /booksim2/src/allocators/islip.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _ISLIP_HPP_ 29 | #define _ISLIP_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class iSLIP_Sparse : public SparseAllocator { 36 | int _iSLIP_iter; 37 | 38 | vector _gptrs; 39 | vector _aptrs; 40 | 41 | public: 42 | iSLIP_Sparse( Module *parent, const string& name, 43 | int inputs, int outputs, int iters ); 44 | 45 | void Allocate( ); 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /booksim2/src/booksim_config.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _BOOKSIM_CONFIG_HPP_ 29 | #define _BOOKSIM_CONFIG_HPP_ 30 | 31 | #include "config_utils.hpp" 32 | 33 | class BookSimConfig : public Configuration { 34 | protected: 35 | 36 | public: 37 | BookSimConfig( ); 38 | }; 39 | 40 | #endif 41 | 42 | #ifndef _POWER_CONFIG_HPP_ 43 | #define _POWER_CONFIG_HPP_ 44 | 45 | #include "config_utils.hpp" 46 | 47 | class PowerConfig : public Configuration { 48 | public: 49 | PowerConfig( ); 50 | 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /booksim2/src/globals.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _GLOBALS_HPP_ 29 | #define _GLOBALS_HPP_ 30 | #include 31 | #include 32 | #include 33 | 34 | /*all declared in main.cpp*/ 35 | 36 | int GetSimTime(); 37 | 38 | class Stats; 39 | Stats * GetStats(const std::string & name); 40 | 41 | extern bool gPrintActivity; 42 | 43 | extern int gK; 44 | extern int gN; 45 | extern int gC; 46 | 47 | extern int gNodes; 48 | 49 | extern bool gTrace; 50 | 51 | extern std::ostream * gWatchOut; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /inputs/trace_to_traffic.py: -------------------------------------------------------------------------------- 1 | # Python modules 2 | import argparse 3 | import sys 4 | import os 5 | 6 | 7 | # RapidChiplet modules 8 | parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) 9 | sys.path.insert(0, parent_dir) 10 | import helpers as hlp 11 | 12 | 13 | def convert_trace_to_traffic(trace): 14 | # Convert trace to traffic 15 | traffic = {} 16 | for packet in trace: 17 | src_node = (packet["source_chiplet"], packet["source_unit"]) 18 | dst_node = (packet["destination_chiplet"], packet["destination_unit"]) 19 | n_flits = packet["size_in_flits"] 20 | if (src_node, dst_node) not in traffic: 21 | traffic[(src_node, dst_node)] = 0 22 | traffic[(src_node, dst_node)] += n_flits 23 | # Divide the traffic entries by the total number of cycle that the trace covers 24 | min_cycle = min([packet["injection_cycle"] for packet in trace]) 25 | max_cycle = max([packet["injection_cycle"] for packet in trace]) 26 | total_cycles = max_cycle - min_cycle 27 | for key in traffic: 28 | traffic[key] /= total_cycles 29 | # Return the traffic 30 | return traffic 31 | 32 | def trace_to_traffic(trace_file, output_file): 33 | trace = hlp.read_json(trace_file) 34 | traffic = convert_trace_to_traffic(trace) 35 | # Store results 36 | hlp.write_json("./traffic_by_unit/%s.json" % output_file, traffic) 37 | traffic_by_chiplet = hlp.convert_by_unit_traffic_to_by_chiplet_traffic(traffic) 38 | hlp.write_json("./traffic_by_chiplet/%s.json" % output_file, traffic_by_chiplet) 39 | 40 | if __name__ == "__main__": 41 | # Convert trace to traffic 42 | parser = argparse.ArgumentParser() 43 | parser.add_argument("-if", "--input_file", required = True, help = "Path to the \"trace\" input file") 44 | parser.add_argument("-of", "--output_file", required = True, help = "Name of the \"traffic\" output file (stored in ./traffic_by_unit/ and ./traffic_by_chiplet/") 45 | args = parser.parse_args() 46 | trace_to_traffic(args.input_file, args.output_file) 47 | 48 | -------------------------------------------------------------------------------- /booksim2/src/credit.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _CREDIT_HPP_ 29 | #define _CREDIT_HPP_ 30 | 31 | #include 32 | #include 33 | 34 | class Credit { 35 | 36 | public: 37 | 38 | set vc; 39 | 40 | // these are only used by the event router 41 | bool head, tail; 42 | int id; 43 | 44 | void Reset(); 45 | 46 | static Credit * New(); 47 | void Free(); 48 | static void FreeAll(); 49 | static int OutStanding(); 50 | private: 51 | 52 | static stack _all; 53 | static stack _free; 54 | 55 | Credit(); 56 | ~Credit() {} 57 | 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /booksim2/src/allocators/selalloc.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _SELALLOC_HPP_ 29 | #define _SELALLOC_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class SelAlloc : public SparseAllocator { 36 | int _iter; 37 | 38 | vector _aptrs; 39 | vector _gptrs; 40 | 41 | vector _outmask; 42 | 43 | public: 44 | SelAlloc( Module *parent, const string& name, 45 | int inputs, int outputs, int iters ); 46 | 47 | void Allocate( ); 48 | 49 | void MaskOutput( int out, int mask = 1 ); 50 | 51 | virtual void PrintRequests( ostream * os = NULL ) const; 52 | 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /booksim2/src/packet_reply_info.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _PACKET_REPLY_INFO_HPP_ 29 | #define _PACKET_REPLY_INFO_HPP_ 30 | 31 | #include 32 | 33 | #include "flit.hpp" 34 | 35 | //register the requests to a node 36 | class PacketReplyInfo { 37 | 38 | public: 39 | int source; 40 | int time; 41 | bool record; 42 | Flit::FlitType type; 43 | 44 | static PacketReplyInfo* New(); 45 | void Free(); 46 | static void FreeAll(); 47 | 48 | private: 49 | 50 | static stack _all; 51 | static stack _free; 52 | 53 | PacketReplyInfo() {} 54 | ~PacketReplyInfo() {} 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /booksim2/src/allocators/maxsize.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _MAXSIZE_HPP_ 29 | #define _MAXSIZE_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class MaxSizeMatch : public DenseAllocator { 36 | vector _from; // array to hold breadth-first tree 37 | int *_s; // stack of leaf nodes in tree 38 | int *_ns; // next stack 39 | int _prio; // priority pointer to ensure fairness 40 | 41 | bool _ShortestAugmenting( ); 42 | 43 | public: 44 | MaxSizeMatch( Module *parent, const string& name, 45 | int inputs, int ouputs ); 46 | ~MaxSizeMatch( ); 47 | 48 | void Allocate( ); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /booksim2/src/random_utils.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "random_utils.hpp" 29 | #include 30 | #include 31 | 32 | extern long ran_x[]; 33 | extern double ran_u[]; 34 | #define KK 100 35 | 36 | void SaveRandomState( std::vector & save_x, std::vector & save_u ) { 37 | save_x.assign(ran_x, ran_x + KK); 38 | save_u.assign(ran_u, ran_u + KK); 39 | } 40 | 41 | void RestoreRandomState( std::vector const & save_x, std::vector const & save_u) { 42 | assert(save_x.size() == KK); 43 | std::copy(save_x.begin(), save_x.end(), ran_x); 44 | assert(save_u.size() == KK); 45 | std::copy(save_u.begin(), save_u.end(), ran_u); 46 | } 47 | -------------------------------------------------------------------------------- /booksim2/src/packet_reply_info.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "packet_reply_info.hpp" 29 | 30 | stack PacketReplyInfo::_all; 31 | stack PacketReplyInfo::_free; 32 | 33 | PacketReplyInfo * PacketReplyInfo::New() 34 | { 35 | PacketReplyInfo * pr; 36 | if(_free.empty()) { 37 | pr = new PacketReplyInfo(); 38 | _all.push(pr); 39 | } else { 40 | pr = _free.top(); 41 | _free.pop(); 42 | } 43 | return pr; 44 | } 45 | 46 | void PacketReplyInfo::Free() 47 | { 48 | _free.push(this); 49 | } 50 | 51 | void PacketReplyInfo::FreeAll() 52 | { 53 | while(!_all.empty()) { 54 | delete _all.top(); 55 | _all.pop(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /booksim2/src/networks/fly.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _FLY_HPP_ 29 | #define _FLY_HPP_ 30 | 31 | #include "network.hpp" 32 | 33 | class KNFly : public Network { 34 | 35 | int _k; 36 | int _n; 37 | 38 | void _ComputeSize( const Configuration &config ); 39 | void _BuildNet( const Configuration &config ); 40 | 41 | int _OutChannel( int stage, int addr, int port ) const; 42 | int _InChannel( int stage, int addr, int port ) const; 43 | 44 | public: 45 | KNFly( const Configuration &config, const string & name ); 46 | 47 | int GetN( ) const; 48 | int GetK( ) const; 49 | static void RegisterRoutingFunctions(){}; 50 | double Capacity( ) const; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /booksim2/src/routefunc.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _ROUTEFUNC_HPP_ 29 | #define _ROUTEFUNC_HPP_ 30 | 31 | #include "flit.hpp" 32 | #include "router.hpp" 33 | #include "outputset.hpp" 34 | #include "config_utils.hpp" 35 | 36 | typedef void (*tRoutingFunction)( const Router *, const Flit *, int in_channel, OutputSet *, bool ); 37 | 38 | void InitializeRoutingMap( const Configuration & config ); 39 | 40 | extern map gRoutingFunctionMap; 41 | 42 | extern int gNumVCs; 43 | extern int gReadReqBeginVC, gReadReqEndVC; 44 | extern int gWriteReqBeginVC, gWriteReqEndVC; 45 | extern int gReadReplyBeginVC, gReadReplyEndVC; 46 | extern int gWriteReplyBeginVC, gWriteReplyEndVC; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /booksim2/src/allocators/separable_output_first.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableOutputFirstAllocator: Separable Output-First Allocator 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _SEPARABLE_OUTPUT_FIRST_HPP_ 35 | #define _SEPARABLE_OUTPUT_FIRST_HPP_ 36 | 37 | #include "separable.hpp" 38 | 39 | class SeparableOutputFirstAllocator : public SeparableAllocator { 40 | 41 | public: 42 | 43 | SeparableOutputFirstAllocator( Module* parent, const string& name, int inputs, 44 | int outputs, const string& arb_type ) ; 45 | 46 | virtual void Allocate() ; 47 | 48 | } ; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /booksim2/src/allocators/wavefront.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _WAVEFRONT_HPP_ 29 | #define _WAVEFRONT_HPP_ 30 | 31 | #include 32 | 33 | #include "allocator.hpp" 34 | 35 | class Wavefront : public DenseAllocator { 36 | 37 | private: 38 | int _last_in; 39 | int _last_out; 40 | set > _priorities; 41 | bool _skip_diags; 42 | 43 | protected: 44 | int _square; 45 | int _pri; 46 | int _num_requests; 47 | 48 | public: 49 | Wavefront( Module *parent, const string& name, 50 | int inputs, int outputs, bool skip_diags = false ); 51 | 52 | virtual void AddRequest( int in, int out, int label = 1, 53 | int in_pri = 0, int out_pri = 0 ); 54 | virtual void Allocate( ); 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /booksim2/src/allocators/separable_input_first.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableInputFirstAllocator: Separable Input-First Allocator 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _SEPARABLE_INPUT_FIRST_HPP_ 35 | #define _SEPARABLE_INPUT_FIRST_HPP_ 36 | 37 | #include 38 | 39 | #include "separable.hpp" 40 | 41 | class SeparableInputFirstAllocator : public SeparableAllocator { 42 | 43 | public: 44 | 45 | SeparableInputFirstAllocator( Module* parent, const string& name, int inputs, 46 | int outputs, const string& arb_type ) ; 47 | 48 | virtual void Allocate() ; 49 | 50 | } ; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /booksim2/src/allocators/separable.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableAllocator: Separable Allocator Base Class 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _SEPARABLE_HPP_ 35 | #define _SEPARABLE_HPP_ 36 | 37 | #include 38 | 39 | #include "allocator.hpp" 40 | 41 | class Arbiter; 42 | 43 | class SeparableAllocator : public SparseAllocator { 44 | 45 | protected: 46 | 47 | vector _input_arb ; 48 | vector _output_arb ; 49 | 50 | public: 51 | 52 | SeparableAllocator( Module* parent, const string& name, int inputs, 53 | int outputs, const string& arb_type ) ; 54 | 55 | virtual ~SeparableAllocator() ; 56 | 57 | virtual void Clear() ; 58 | 59 | } ; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /booksim2/src/arbiters/prio_arb.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _PRIO_ARB_HPP_ 29 | #define _PRIO_ARB_HPP_ 30 | 31 | #include 32 | 33 | #include "module.hpp" 34 | #include "config_utils.hpp" 35 | 36 | class PriorityArbiter : public Module { 37 | int _rr_ptr; 38 | 39 | protected: 40 | const int _inputs; 41 | 42 | struct sRequest { 43 | int in; 44 | int label; 45 | int pri; 46 | }; 47 | 48 | list _requests; 49 | 50 | int _match; 51 | 52 | public: 53 | PriorityArbiter( const Configuration &config, 54 | Module *parent, const string& name, 55 | int inputs ); 56 | 57 | void Clear( ); 58 | 59 | void AddRequest( int in, int label = 0, int pri = 0 ); 60 | void RemoveRequest( int in, int label = 0 ); 61 | 62 | int Match( ) const; 63 | 64 | void Arbitrate( ); 65 | void Update( ); 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /booksim2/src/networks/kncube.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _KNCUBE_HPP_ 29 | #define _KNCUBE_HPP_ 30 | 31 | #include "network.hpp" 32 | 33 | class KNCube : public Network { 34 | 35 | bool _mesh; 36 | 37 | int _k; 38 | int _n; 39 | 40 | void _ComputeSize( const Configuration &config ); 41 | void _BuildNet( const Configuration &config ); 42 | 43 | int _LeftChannel( int node, int dim ); 44 | int _RightChannel( int node, int dim ); 45 | 46 | int _LeftNode( int node, int dim ); 47 | int _RightNode( int node, int dim ); 48 | 49 | public: 50 | KNCube( const Configuration &config, const string & name, bool mesh ); 51 | static void RegisterRoutingFunctions(); 52 | 53 | int GetN( ) const; 54 | int GetK( ) const; 55 | 56 | double Capacity( ) const; 57 | 58 | void InsertRandomFaults( const Configuration &config ); 59 | 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /booksim2/src/module.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _MODULE_HPP_ 29 | #define _MODULE_HPP_ 30 | 31 | #include "booksim.hpp" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | class Module { 38 | private: 39 | string _name; 40 | string _fullname; 41 | 42 | vector _children; 43 | 44 | protected: 45 | void _AddChild( Module *child ); 46 | 47 | public: 48 | Module( Module *parent, const string& name ); 49 | virtual ~Module( ) { } 50 | 51 | inline const string & Name() const { return _name; } 52 | inline const string & FullName() const { return _fullname; } 53 | 54 | void DisplayHierarchy( int level = 0, ostream & os = cout ) const; 55 | 56 | void Error( const string& msg ) const; 57 | void Debug( const string& msg ) const; 58 | 59 | virtual void Display( ostream & os = cout ) const; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /booksim2/src/credit.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /*credit.cpp 29 | * 30 | *A class for credits 31 | */ 32 | 33 | #include "booksim.hpp" 34 | #include "credit.hpp" 35 | 36 | stack Credit::_all; 37 | stack Credit::_free; 38 | 39 | Credit::Credit() 40 | { 41 | Reset(); 42 | } 43 | 44 | void Credit::Reset() 45 | { 46 | vc.clear(); 47 | head = false; 48 | tail = false; 49 | id = -1; 50 | } 51 | 52 | Credit * Credit::New() { 53 | Credit * c; 54 | if(_free.empty()) { 55 | c = new Credit(); 56 | _all.push(c); 57 | } else { 58 | c = _free.top(); 59 | c->Reset(); 60 | _free.pop(); 61 | } 62 | return c; 63 | } 64 | 65 | void Credit::Free() { 66 | _free.push(this); 67 | } 68 | 69 | void Credit::FreeAll() { 70 | while(!_all.empty()) { 71 | delete _all.top(); 72 | _all.pop(); 73 | } 74 | } 75 | 76 | 77 | int Credit::OutStanding(){ 78 | return _all.size()-_free.size(); 79 | } 80 | -------------------------------------------------------------------------------- /generate_placement.py: -------------------------------------------------------------------------------- 1 | # Parameters: 2 | # - rows: number of rows 3 | # - cols: number of columns 4 | # - chiplet_spacing: spacing between chiplets 5 | def generate_grid_placement(params, chiplet, chiplet_name, use_memory = False): 6 | # Extract parameters 7 | rows = params["rows"] 8 | cols = params["cols"] 9 | spacing = params["chiplet_spacing"] 10 | # Create the placement 11 | placement = [] 12 | center_chiplet = chiplet_name 13 | border_chiplet = (chiplet_name + "_memory") if use_memory else chiplet_name 14 | # Add the chiplets 15 | for row in range(rows): 16 | for col in range(cols): 17 | x = col * (chiplet["dimensions"]["x"] + spacing) 18 | y = row * (chiplet["dimensions"]["y"] + spacing) 19 | full_chiplet_name = border_chiplet if col in [0, cols-1] else center_chiplet 20 | placement.append({"position" : {"x" : x, "y" : y}, "rotation" : 0, "name" : full_chiplet_name}) 21 | # Return the placement 22 | return {"chiplets" : placement, "interposer_routers" : []} 23 | 24 | # Parameters: 25 | # - r: Radius of the hexagonal grid (see HexaMesh paper) 26 | # - chiplet_spacing: spacing between chiplets 27 | def generate_hexagonal_placement(params, chiplet, chiplet_name, use_memory = False): 28 | # Extract parameters 29 | r = params["radius"] 30 | spacing = params["chiplet_spacing"] 31 | # Create the placement 32 | placement = [] 33 | center_chiplet = chiplet_name 34 | border_chiplet = (chiplet_name + "_memory") if use_memory else chiplet_name 35 | # Add the chiplets 36 | rows = 2 * r + 1 37 | x_unit = chiplet["dimensions"]["x"] + spacing 38 | chiplets_per_row = list(range(r+1,2 * r+1,1)) + list(range(2 * r+1,r,-1)) 39 | row_start_ids = [sum(chiplets_per_row[:i]) for i in range(len(chiplets_per_row))] 40 | row_start_x = [abs(i - (rows - 1) / 2) * x_unit / 2 for i in range(rows)] 41 | for row in range(rows): 42 | for col in range(chiplets_per_row[row]): 43 | x = row_start_x[row] + col * x_unit 44 | y = row * (chiplet["dimensions"]["y"] + spacing) 45 | full_chiplet_name = border_chiplet if col in [0, chiplets_per_row[row]-1] else center_chiplet 46 | placement.append({"position" : {"x" : x, "y" : y}, "rotation" : 0, "name" : full_chiplet_name}) 47 | # Return the placement 48 | return {"chiplets" : placement, "interposer_routers" : []} 49 | 50 | placement_generation_functions = { 51 | "grid" : generate_grid_placement, 52 | "hexagonal" : generate_hexagonal_placement, 53 | } 54 | -------------------------------------------------------------------------------- /netrace/queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2011 The University of Texas at Austin 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are 7 | * met: redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer; 9 | * redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution; 12 | * neither the name of the copyright holders nor the names of its 13 | * contributors may be used to endorse or promote products derived from 14 | * this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef QUEUE_H_ 30 | #define QUEUE_H_ 31 | 32 | #include 33 | #include 34 | 35 | typedef struct node node_t; 36 | typedef struct queue queue_t; 37 | 38 | struct node { 39 | node_t* prev; 40 | node_t* next; 41 | unsigned long long int prio; 42 | void* elem; 43 | }; 44 | 45 | struct queue { 46 | node_t* head; 47 | node_t* tail; 48 | }; 49 | 50 | queue_t* queue_new( void ); 51 | void queue_delete( queue_t* ); 52 | int queue_empty( queue_t* ); 53 | void queue_push_back( queue_t*, void* ); 54 | void queue_push( queue_t*, void*, unsigned long long int ); 55 | void* queue_peek_front( queue_t* ); 56 | void* queue_pop_front( queue_t* ); 57 | void queue_remove( queue_t*, void* ); 58 | 59 | #endif /*QUEUE_H_*/ 60 | -------------------------------------------------------------------------------- /booksim2/src/outputset.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _OUTPUTSET_HPP_ 29 | #define _OUTPUTSET_HPP_ 30 | 31 | #include 32 | 33 | class OutputSet { 34 | 35 | 36 | public: 37 | struct sSetElement { 38 | int vc_start; 39 | int vc_end; 40 | int pri; 41 | int output_port; 42 | }; 43 | 44 | void Clear( ); 45 | void Add( int output_port, int vc, int pri = 0 ); 46 | void AddRange( int output_port, int vc_start, int vc_end, int pri = 0 ); 47 | 48 | bool OutputEmpty( int output_port ) const; 49 | int NumVCs( int output_port ) const; 50 | 51 | const set & GetSet() const; 52 | 53 | int GetVC( int output_port, int vc_index, int *pri = 0 ) const; 54 | bool GetPortVC( int *out_port, int *out_vc ) const; 55 | private: 56 | set _outputs; 57 | }; 58 | 59 | inline bool operator<(const OutputSet::sSetElement & se1, 60 | const OutputSet::sSetElement & se2) { 61 | return se1.pri > se2.pri; // higher priorities first! 62 | } 63 | 64 | #endif 65 | 66 | 67 | -------------------------------------------------------------------------------- /booksim2/src/power/switch_monitor.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _SWITCH_MONITOR_HPP_ 29 | #define _SWITCH_MONITOR_HPP_ 30 | 31 | #include 32 | #include 33 | 34 | using namespace std; 35 | 36 | class Flit; 37 | 38 | class SwitchMonitor { 39 | int _cycles ; 40 | int _inputs ; 41 | int _outputs ; 42 | int _classes ; 43 | vector _event ; 44 | int index( int input, int output, int cl ) const ; 45 | public: 46 | SwitchMonitor( int inputs, int outputs, int classes ) ; 47 | void cycle() ; 48 | vector const & GetActivity() const { 49 | return _event; 50 | } 51 | inline int const & NumInputs() const { 52 | return _inputs; 53 | } 54 | inline int const & NumOutputs() const { 55 | return _outputs; 56 | } 57 | inline int const & NumClasses() const { 58 | return _classes; 59 | } 60 | void traversal( int input, int output, Flit const * f ) ; 61 | void display(ostream & os) const; 62 | } ; 63 | 64 | ostream & operator<<( ostream & os, SwitchMonitor const & obj ) ; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /booksim2/src/power/buffer_monitor.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _BUFFER_MONITOR_HPP_ 29 | #define _BUFFER_MONITOR_HPP_ 30 | 31 | #include 32 | #include 33 | 34 | using namespace std; 35 | 36 | class Flit; 37 | 38 | class BufferMonitor { 39 | int _cycles ; 40 | int _inputs ; 41 | int _classes ; 42 | vector _reads ; 43 | vector _writes ; 44 | int index( int input, int cl ) const ; 45 | public: 46 | BufferMonitor( int inputs, int classes ) ; 47 | void cycle() ; 48 | void write( int input, Flit const * f ) ; 49 | void read( int input, Flit const * f ) ; 50 | inline const vector & GetReads() const { 51 | return _reads; 52 | } 53 | inline const vector & GetWrites() const { 54 | return _writes; 55 | } 56 | inline int NumInputs() const { 57 | return _inputs; 58 | } 59 | inline int NumClasses() const { 60 | return _classes; 61 | } 62 | void display(ostream & os) const; 63 | 64 | } ; 65 | 66 | ostream & operator<<( ostream & os, BufferMonitor const & obj ) ; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /reproduce_paper_results.py: -------------------------------------------------------------------------------- 1 | # Python modules 2 | import sys 3 | 4 | # RapidChiplet modules 5 | import helpers as hlp 6 | import create_paper_plots as cpp 7 | import create_plots as cp 8 | import visualizer as vis 9 | import run_experiment as re 10 | import rapidchiplet as rc 11 | import case_study as cs 12 | 13 | def reproduce_paper_results(): 14 | ################################################## 15 | # Visualization 16 | ################################################## 17 | # Load the design 18 | design = hlp.read_json("inputs/designs/example_design.json") 19 | # Run RapidChiplet 20 | inputs = {"design" : design} 21 | intermediates = {} 22 | do_compute = {"latency" : True, "throughput" : True, "area_summary" : True, "power_summary" : True, "link_summary" : True, "cost" : True, "booksim_simulation" : True} 23 | results_file = "example_design.json" 24 | results = rc.rapidchiplet(inputs, intermediates, do_compute, results_file, verbose = False, validate = True) 25 | # Save and read the results (hack to fix formatting) 26 | hlp.write_json("./results/example_design.json", results) 27 | results = hlp.read_json("./results/example_design.json") 28 | # Visualize the design 29 | inputs = {"design":design,"verbose":True,"validate":True} 30 | vis.visualize_design(inputs, "example_design", show_chiplet_id = True, show_phy_id = False) 31 | # Create the latency-vs-load plot 32 | cp.create_latency_vs_load_plot(results) 33 | ################################################## 34 | # Evaluation 35 | ################################################## 36 | # Load experiments for the evaluation 37 | experiment_lat = hlp.read_json("experiments/evaluation_latency.json") 38 | experiment_tp = hlp.read_json("experiments/evaluation_throughput.json") 39 | experiment_link = hlp.read_json("experiments/evaluation_links.json") 40 | experiment_bs = hlp.read_json("experiments/evaluation_booksim.json") 41 | # Run the experiment 42 | re.run_experiment(experiment_lat) 43 | re.run_experiment(experiment_tp) 44 | re.run_experiment(experiment_link) 45 | re.run_experiment(experiment_bs) 46 | # Create the evaluation plot for the paper and the extended evaluation plot 47 | cpp.create_evaluation_plot() 48 | cpp.create_extended_evaluation_plot() 49 | ################################################## 50 | # Case study 51 | ################################################## 52 | cs.case_study() 53 | cpp.create_case_study_plot() 54 | 55 | if __name__ == "__main__": 56 | reproduce_paper_results() 57 | 58 | -------------------------------------------------------------------------------- /routing_utils.py: -------------------------------------------------------------------------------- 1 | # Import python libraries 2 | import networkx as nx 3 | import itertools as it 4 | from copy import deepcopy 5 | 6 | #modifies the parameter graph, returns a cycle breaking set of turns for G 7 | def simple_cycle_breaking(G, forbidden_turns): 8 | #end of recursion 9 | if G.number_of_nodes() == 2: 10 | return 11 | else: 12 | #compute all cut nodes: 13 | cut_vertices = (list(nx.articulation_points(G))) 14 | #compute a min deg non cut vertice 15 | min_deg = min([G.degree(x) for x in list(G.nodes()) if x not in cut_vertices]) 16 | non_cut_min_vertices = [x for x in list(G.nodes()) if x not in cut_vertices and G.degree(x) == min_deg] 17 | 18 | #find vertex for step 2 in algo 19 | chosen_vertex = -1 20 | for x in non_cut_min_vertices: 21 | #check if ineq from paper 22 | if G.degree(x) <= sum([G.degree(v)-1 for v in G[x]]): 23 | chosen_vertex = x 24 | break 25 | assert(chosen_vertex != -1) 26 | #add forbidden turns to forbidden turn list 27 | for neigh1,neigh2 in it.combinations(G[chosen_vertex],2): 28 | forbidden_turns.append(((neigh1,chosen_vertex), (chosen_vertex, neigh2))) 29 | forbidden_turns.append(((neigh2,chosen_vertex), (chosen_vertex, neigh1))) 30 | 31 | G.remove_node(chosen_vertex) 32 | simple_cycle_breaking(G, forbidden_turns) 33 | 34 | # corresponds one to one to the cpp booksim code. 35 | def generate_line_graph(G: nx.DiGraph): 36 | LG = nx.DiGraph() 37 | for e in G.edges(): 38 | LG.add_node(e) 39 | 40 | for v1 in G.nodes(): 41 | for v2 in G.nodes(): 42 | for v3 in G.nodes(): 43 | if v1 != v3 and (v1,v2) in G.edges() and (v2,v3) in G.edges(): 44 | LG.add_edge((v1,v2),(v2,v3)) 45 | 46 | return LG 47 | 48 | # computes the predecessor map for all paths starting from chiplets. nx.predecessor computes the predecessor map containing all possible predecesssors on 49 | # shortest paths from src to other nodes. note that this is called on the dual graph and thus the starting point in the algo corresponds to an edge in the original graph. 50 | def get_shortest_valid_paths(LG, chiplets, src, pred_map): 51 | #now compute minimal paths for each pair of nodes in the graph. first iterate over all pairs of nodes: 52 | for u in chiplets: 53 | pred_map[u] = deepcopy(nx.predecessor(LG,(src,u))) 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /booksim2/src/stats.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _STATS_HPP_ 29 | #define _STATS_HPP_ 30 | 31 | #include "module.hpp" 32 | 33 | class Stats : public Module { 34 | int _num_samples; 35 | double _sample_sum; 36 | double _sample_squared_sum; 37 | 38 | //bool _reset; 39 | double _min; 40 | double _max; 41 | 42 | int _num_bins; 43 | double _bin_size; 44 | 45 | vector _hist; 46 | 47 | public: 48 | Stats( Module *parent, const string &name, 49 | double bin_size = 1.0, int num_bins = 10 ); 50 | 51 | void Clear( ); 52 | 53 | double Average( ) const; 54 | double Variance( ) const; 55 | double Max( ) const; 56 | double Min( ) const; 57 | double Sum( ) const; 58 | double SquaredSum( ) const; 59 | int NumSamples( ) const; 60 | 61 | void AddSample( double val ); 62 | inline void AddSample( int val ) { 63 | AddSample( (double)val ); 64 | } 65 | 66 | int GetBin(int b){ return _hist[b];} 67 | 68 | void Display( ostream & os = cout ) const; 69 | 70 | friend ostream & operator<<(ostream & os, const Stats & s); 71 | 72 | }; 73 | 74 | ostream & operator<<(ostream & os, const Stats & s); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /booksim2/src/networks/qtree.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | //////////////////////////////////////////////////////////////////////// 29 | // 30 | // QTree: A Quad-Tree Indirect Network. 31 | // 32 | // 33 | //////////////////////////////////////////////////////////////////////// 34 | // 35 | // RCS Information: 36 | // $Author: jbalfour $ 37 | // $Date: 2007/05/17 17:14:07 $ 38 | // $Id$ 39 | // 40 | //////////////////////////////////////////////////////////////////////// 41 | 42 | #ifndef _QTREE_HPP_ 43 | #define _QTREE_HPP_ 44 | #include 45 | #include "network.hpp" 46 | 47 | class QTree : public Network { 48 | 49 | int _k; 50 | int _n; 51 | 52 | void _ComputeSize( const Configuration& config ); 53 | void _BuildNet( const Configuration& config ); 54 | 55 | int _RouterIndex( int height, int pos ); 56 | int _InputIndex( int height, int pos, int port ); 57 | int _OutputIndex( int height, int pos, int port ); 58 | 59 | public: 60 | 61 | QTree( const Configuration& config, const string & name ); 62 | static void RegisterRoutingFunctions() ; 63 | 64 | static int HeightFromID( int id ); 65 | static int PosFromID( int id ); 66 | 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /booksim2/src/networks/fattree.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | //////////////////////////////////////////////////////////////////////// 29 | // 30 | // FatTree 31 | // 32 | //////////////////////////////////////////////////////////////////////// 33 | // 34 | // RCS Information: 35 | // $Author: jbalfour $ 36 | // $Date: 2007/06/26 22:49:23 $ 37 | // $Id$ 38 | // 39 | //////////////////////////////////////////////////////////////////////// 40 | 41 | #ifndef _FatTree_HPP_ 42 | #define _FatTree_HPP_ 43 | 44 | #include "network.hpp" 45 | 46 | class FatTree : public Network { 47 | 48 | int _k; 49 | int _n; 50 | 51 | 52 | void _ComputeSize( const Configuration& config ); 53 | void _BuildNet( const Configuration& config ); 54 | 55 | Router*& _Router( int depth, int pos ); 56 | 57 | int _mapSize; 58 | int* _inputChannelMap; 59 | int* _outputChannelMap; 60 | int* _latencyMap; 61 | 62 | 63 | 64 | public: 65 | 66 | FatTree( const Configuration& config ,const string & name ); 67 | static void RegisterRoutingFunctions() ; 68 | 69 | // 70 | // Methods to Assit Routing Functions 71 | // 72 | static int PreferedPort( const Router* r, int index ); 73 | 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /booksim2/src/arbiters/matrix_arb.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // Matrix: Matrix Arbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _MATRIX_ARB_HPP_ 35 | #define _MATRIX_ARB_HPP_ 36 | 37 | #include 38 | 39 | #include "arbiter.hpp" 40 | 41 | using namespace std; 42 | 43 | class MatrixArbiter : public Arbiter { 44 | 45 | // Priority matrix 46 | vector > _matrix ; 47 | 48 | int _last_req ; 49 | 50 | public: 51 | 52 | // Constructors 53 | MatrixArbiter( Module *parent, const string &name, int size ) ; 54 | 55 | // Print priority matrix to standard output 56 | virtual void PrintState() const ; 57 | 58 | // Update priority matrix based on last aribtration result 59 | virtual void UpdateState() ; 60 | 61 | // Arbitrate amongst requests. Returns winning input and 62 | // updates pointers to metadata when valid pointers are passed 63 | virtual int Arbitrate( int* id = 0, int* pri = 0) ; 64 | 65 | virtual void AddRequest( int input, int id, int pri ) ; 66 | 67 | virtual void Clear(); 68 | 69 | } ; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /booksim2/src/arbiters/tree_arb.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // TreeArbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _TREE_ARB_HPP_ 35 | #define _TREE_ARB_HPP_ 36 | 37 | #include "arbiter.hpp" 38 | 39 | class TreeArbiter : public Arbiter { 40 | 41 | int _group_size ; 42 | 43 | vector _group_arbiters; 44 | Arbiter * _global_arbiter; 45 | 46 | vector _group_reqs; 47 | 48 | public: 49 | 50 | // Constructors 51 | TreeArbiter( Module *parent, const string &name, int size, int groups, const string & arb_type ) ; 52 | 53 | ~TreeArbiter(); 54 | 55 | // Print priority matrix to standard output 56 | virtual void PrintState() const ; 57 | 58 | // Update priority matrix based on last aribtration result 59 | virtual void UpdateState() ; 60 | 61 | // Arbitrate amongst requests. Returns winning input and 62 | // updates pointers to metadata when valid pointers are passed 63 | virtual int Arbitrate( int* id = 0, int* pri = 0) ; 64 | 65 | virtual void AddRequest( int input, int id, int pri ) ; 66 | 67 | virtual void Clear(); 68 | 69 | } ; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /booksim2/src/random_utils.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _RANDOM_UTILS_HPP_ 29 | #define _RANDOM_UTILS_HPP_ 30 | 31 | #include 32 | 33 | // interface to Knuth's RANARRAY RNG 34 | void ran_start(long seed); 35 | long ran_next( ); 36 | void ranf_start(long seed); 37 | double ranf_next( ); 38 | 39 | inline void RandomSeed( long seed ) { 40 | ran_start( seed ); 41 | ranf_start( seed ); 42 | } 43 | 44 | inline unsigned long RandomIntLong( ) { 45 | return ran_next( ); 46 | } 47 | 48 | // Returns a random integer in the range [0,max] 49 | inline int RandomInt( int max ) { 50 | return ( ran_next( ) % (max+1) ); 51 | } 52 | 53 | // Returns a random floating-point value in the rage [0,1] 54 | inline double RandomFloat( ) { 55 | return ranf_next( ); 56 | } 57 | 58 | // Returns a random floating-point value in the rage [0,max] 59 | inline double RandomFloat( double max ) { 60 | return ( ranf_next( ) * max ); 61 | } 62 | 63 | // Saves the current generator state 64 | void SaveRandomState( std::vector & save_x, std::vector & save_u ); 65 | 66 | // Restores the generator state from previously saved values 67 | void RestoreRandomState( std::vector const & save_x, std::vector const & save_u ); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /booksim2/src/networks/tree4.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | //////////////////////////////////////////////////////////////////////// 29 | // 30 | // Tree4: Network with 64 Terminal Nodes arranged in a tree topology 31 | // with 4 routers at the root of the tree 32 | // 33 | //////////////////////////////////////////////////////////////////////// 34 | // 35 | // RCS Information: 36 | // $Author: jbalfour $ 37 | // $Date: 2007/06/26 22:49:23 $ 38 | // $Id$ 39 | // 40 | //////////////////////////////////////////////////////////////////////// 41 | 42 | #ifndef _TREE4_HPP_ 43 | #define _TREE4_HPP_ 44 | #include 45 | #include "network.hpp" 46 | 47 | class Tree4 : public Network { 48 | 49 | int _k; 50 | int _n; 51 | 52 | int _channelWidth; 53 | 54 | void _ComputeSize( const Configuration& config ); 55 | void _BuildNet( const Configuration& config ); 56 | 57 | 58 | Router*& _Router( int height, int pos ); 59 | 60 | int _WireLatency( int height1, int pos1, int height2, int pos2 ); 61 | 62 | public: 63 | 64 | Tree4( const Configuration& config, const string & name ); 65 | static void RegisterRoutingFunctions() ; 66 | 67 | static int HeightFromID( int id ); 68 | static int PosFromID( int id ); 69 | static int SpeedUp( int height ); 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /booksim2/src/power/switch_monitor.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "switch_monitor.hpp" 29 | 30 | #include "flit.hpp" 31 | 32 | SwitchMonitor::SwitchMonitor( int inputs, int outputs, int classes ) 33 | : _cycles(0), _inputs(inputs), _outputs(outputs), _classes(classes) { 34 | _event.resize(inputs * outputs * classes, 0) ; 35 | } 36 | 37 | int SwitchMonitor::index( int input, int output, int cl ) const { 38 | assert((input >= 0) && (input < _inputs)); 39 | assert((output >= 0) && (output < _outputs)); 40 | assert((cl >= 0) && (cl < _classes)); 41 | return cl + _classes * ( output + _outputs * input ) ; 42 | } 43 | 44 | void SwitchMonitor::cycle() { 45 | _cycles++ ; 46 | } 47 | 48 | void SwitchMonitor::traversal( int input, int output, Flit const * f ) { 49 | _event[ index( input, output, f->cl) ]++ ; 50 | } 51 | 52 | void SwitchMonitor::display(ostream & os) const { 53 | for ( int i = 0 ; i < _inputs ; i++ ) { 54 | for ( int o = 0 ; o < _outputs ; o++) { 55 | os << "[" << i << " -> " << o << "] " ; 56 | for ( int c = 0 ; c < _classes ; c++ ) { 57 | os << c << ":" << _event[index(i,o,c)] << " " ; 58 | } 59 | os << endl ; 60 | } 61 | } 62 | } 63 | 64 | ostream & operator<<( ostream & os, SwitchMonitor const & obj ) { 65 | obj.display(os); 66 | return os ; 67 | } 68 | -------------------------------------------------------------------------------- /booksim2/src/power/buffer_monitor.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "buffer_monitor.hpp" 29 | 30 | #include "flit.hpp" 31 | 32 | BufferMonitor::BufferMonitor( int inputs, int classes ) 33 | : _cycles(0), _inputs(inputs), _classes(classes) { 34 | _reads.resize(inputs * classes, 0) ; 35 | _writes.resize(inputs * classes, 0) ; 36 | } 37 | 38 | int BufferMonitor::index( int input, int cl ) const { 39 | assert((input >= 0) && (input < _inputs)); 40 | assert((cl >= 0) && (cl < _classes)); 41 | return cl + _classes * input ; 42 | } 43 | 44 | void BufferMonitor::cycle() { 45 | _cycles++ ; 46 | } 47 | 48 | void BufferMonitor::write( int input, Flit const * f ) { 49 | _writes[ index(input, f->cl) ]++ ; 50 | } 51 | 52 | void BufferMonitor::read( int input, Flit const * f ) { 53 | _reads[ index(input, f->cl) ]++ ; 54 | } 55 | 56 | void BufferMonitor::display(ostream & os) const { 57 | for ( int i = 0 ; i < _inputs ; i++ ) { 58 | os << "[ " << i << " ] " ; 59 | for ( int c = 0 ; c < _classes ; c++ ) { 60 | os << "Type=" << c 61 | << ":(R#" << _reads[ index( i, c) ] << "," 62 | << "W#" << _writes[ index( i, c) ] << ")" << " " ; 63 | } 64 | os << endl ; 65 | } 66 | } 67 | 68 | ostream & operator<<( ostream & os, BufferMonitor const & obj ) { 69 | obj.display(os); 70 | return os ; 71 | } 72 | -------------------------------------------------------------------------------- /booksim2/src/batchtrafficmanager.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _BATCHTRAFFICMANAGER_HPP_ 29 | #define _BATCHTRAFFICMANAGER_HPP_ 30 | 31 | #include 32 | 33 | #include "config_utils.hpp" 34 | #include "stats.hpp" 35 | #include "trafficmanager.hpp" 36 | 37 | class BatchTrafficManager : public TrafficManager { 38 | 39 | protected: 40 | 41 | int _max_outstanding; 42 | int _batch_size; 43 | int _batch_count; 44 | int _last_id; 45 | int _last_pid; 46 | 47 | Stats * _batch_time; 48 | double _overall_min_batch_time; 49 | double _overall_avg_batch_time; 50 | double _overall_max_batch_time; 51 | 52 | ostream * _sent_packets_out; 53 | 54 | virtual void _RetireFlit( Flit *f, int dest ); 55 | 56 | virtual int _IssuePacket( int source, int cl ); 57 | virtual void _ClearStats( ); 58 | virtual bool _SingleSim( ); 59 | 60 | virtual void _UpdateOverallStats( ); 61 | 62 | virtual string _OverallStatsCSV(int c = 0) const; 63 | 64 | public: 65 | 66 | BatchTrafficManager( const Configuration &config, const vector & net ); 67 | virtual ~BatchTrafficManager( ); 68 | 69 | virtual void WriteStats( ostream & os = cout ) const; 70 | virtual void DisplayStats( ostream & os = cout ) const; 71 | virtual void DisplayOverallStats( ostream & os = cout ) const; 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /booksim2/src/Makefile: -------------------------------------------------------------------------------- 1 | # $Id $ 2 | 3 | # Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior 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 met: 8 | # 9 | # Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # Redistributions in binary form must reproduce the above copyright notice, 12 | # this list of conditions and the following disclaimer in the documentation 13 | # and/or other materials provided with the distribution. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | # POSSIBILITY OF SUCH DAMAGE. 26 | 27 | LEX = flex 28 | YACC = bison -y 29 | DEFINE = 30 | INCPATH = -I. -Iarbiters -Iallocators -Irouters -Inetworks -Ipower 31 | CPPFLAGS += -Wall $(INCPATH) $(DEFINE) 32 | CPPFLAGS += -O3 33 | CPPFLAGS += -g 34 | LFLAGS += 35 | 36 | PROG := booksim 37 | 38 | # simulator source files 39 | CPP_SRCS = $(wildcard *.cpp) $(wildcard */*.cpp) 40 | CPP_HDRS = $(wildcard *.hpp) $(wildcard */*.hpp) 41 | CPP_DEPS = $(CPP_SRCS:.cpp=.d) 42 | CPP_OBJS = $(CPP_SRCS:.cpp=.o) 43 | 44 | LEX_SRCS = lex.yy.c 45 | LEX_OBJS = lex.yy.o 46 | 47 | YACC_SRCS = y.tab.c 48 | YACC_HDRS = y.tab.h 49 | YACC_OBJS = y.tab.o 50 | 51 | OBJS := $(CPP_OBJS) $(LEX_OBJS) $(YACC_OBJS) 52 | 53 | .PHONY: clean 54 | 55 | all: $(PROG) 56 | 57 | $(PROG): $(OBJS) 58 | $(CXX) $(LFLAGS) $^ -o $@ 59 | 60 | $(LEX_SRCS): config.l 61 | $(LEX) $< 62 | 63 | $(YACC_SRCS) $(YACC_HDRS): config.y 64 | $(YACC) -d $< 65 | 66 | $(LEX_OBJS): $(LEX_SRCS) $(YACC_HDRS) 67 | $(CC) $(CPPFLAGS) -c $< -o $@ 68 | 69 | $(YACC_OBJS): $(YACC_SRCS) 70 | $(CC) $(CPPFLAGS) -c $< -o $@ 71 | 72 | %.o: %.cpp 73 | $(CXX) $(CPPFLAGS) -MMD -c $< -o $@ 74 | 75 | clean: 76 | rm -f $(YACC_SRCS) $(YACC_HDRS) 77 | rm -f $(LEX_SRCS) 78 | rm -f $(CPP_DEPS) 79 | rm -f $(OBJS) 80 | rm -f $(PROG) 81 | 82 | distclean: clean 83 | rm -f *~ */*~ 84 | rm -f *.o */*.o 85 | rm -f *.d */*.d 86 | 87 | -include $(CPP_DEPS) 88 | -------------------------------------------------------------------------------- /booksim2/src/buffer.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | 30 | #include "globals.hpp" 31 | #include "booksim.hpp" 32 | #include "buffer.hpp" 33 | 34 | Buffer::Buffer( const Configuration& config, int outputs, 35 | Module *parent, const string& name ) : 36 | Module( parent, name ), _occupancy(0) 37 | { 38 | int num_vcs = config.GetInt( "num_vcs" ); 39 | 40 | _size = config.GetInt("buf_size"); 41 | if(_size < 0) { 42 | _size = num_vcs * config.GetInt( "vc_buf_size" ); 43 | }; 44 | 45 | _vc.resize(num_vcs); 46 | 47 | for(int i = 0; i < num_vcs; ++i) { 48 | ostringstream vc_name; 49 | vc_name << "vc_" << i; 50 | _vc[i] = new VC(config, outputs, this, vc_name.str( ) ); 51 | } 52 | 53 | #ifdef TRACK_BUFFERS 54 | int classes = config.GetInt("classes"); 55 | _class_occupancy.resize(classes, 0); 56 | #endif 57 | } 58 | 59 | Buffer::~Buffer() 60 | { 61 | for(vector::iterator i = _vc.begin(); i != _vc.end(); ++i) { 62 | delete *i; 63 | } 64 | } 65 | 66 | void Buffer::AddFlit( int vc, Flit *f ) 67 | { 68 | if(_occupancy >= _size) { 69 | Error("Flit buffer overflow."); 70 | } 71 | ++_occupancy; 72 | _vc[vc]->AddFlit(f); 73 | #ifdef TRACK_BUFFERS 74 | ++_class_occupancy[f->cl]; 75 | #endif 76 | } 77 | 78 | void Buffer::Display( ostream & os ) const 79 | { 80 | for(vector::const_iterator i = _vc.begin(); i != _vc.end(); ++i) { 81 | (*i)->Display(os); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /booksim2/src/networks/dragonfly.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | 27 | 28 | #ifndef _DragonFly_HPP_ 29 | #define _DragonFly_HPP_ 30 | 31 | #include "network.hpp" 32 | #include "routefunc.hpp" 33 | 34 | class DragonFlyNew : public Network { 35 | 36 | int _m; 37 | int _n; 38 | int _r; 39 | int _k; 40 | int _p, _a, _g; 41 | int _radix; 42 | int _net_size; 43 | int _stageout; 44 | int _numinput; 45 | int _stages; 46 | int _num_of_switch; 47 | int _grp_num_routers; 48 | int _grp_num_nodes; 49 | 50 | 51 | void _ComputeSize( const Configuration &config ); 52 | void _BuildNet( const Configuration &config ); 53 | 54 | 55 | 56 | public: 57 | DragonFlyNew( const Configuration &config, const string & name ); 58 | 59 | int GetN( ) const; 60 | int GetK( ) const; 61 | 62 | double Capacity( ) const; 63 | static void RegisterRoutingFunctions(); 64 | void InsertRandomFaults( const Configuration &config ); 65 | 66 | }; 67 | int dragonfly_port(int rID, int source, int dest); 68 | 69 | void ugal_dragonflynew( const Router *r, const Flit *f, int in_channel, 70 | OutputSet *outputs, bool inject ); 71 | void min_dragonflynew( const Router *r, const Flit *f, int in_channel, 72 | OutputSet *outputs, bool inject ); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /booksim2/src/flit.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _FLIT_HPP_ 29 | #define _FLIT_HPP_ 30 | 31 | #include 32 | #include 33 | 34 | #include "booksim.hpp" 35 | #include "outputset.hpp" 36 | 37 | class Flit { 38 | 39 | public: 40 | 41 | const static int NUM_FLIT_TYPES = 5; 42 | enum FlitType { READ_REQUEST = 0, 43 | READ_REPLY = 1, 44 | WRITE_REQUEST = 2, 45 | WRITE_REPLY = 3, 46 | ANY_TYPE = 4 }; 47 | FlitType type; 48 | 49 | int vc; 50 | 51 | int cl; 52 | 53 | bool head; 54 | bool tail; 55 | 56 | int ctime; 57 | int itime; 58 | int atime; 59 | 60 | int id; 61 | int pid; 62 | 63 | bool record; 64 | 65 | int src; 66 | int dest; 67 | 68 | int pri; 69 | 70 | int hops; 71 | bool watch; 72 | int subnetwork; 73 | 74 | // intermediate destination (if any) 75 | mutable int intm; 76 | 77 | // phase in multi-phase algorithms 78 | mutable int ph; 79 | 80 | // Fields for arbitrary data 81 | void* data ; 82 | 83 | // Lookahead route info 84 | OutputSet la_route_set; 85 | 86 | void Reset(); 87 | 88 | static Flit * New(); 89 | void Free(); 90 | static void FreeAll(); 91 | 92 | private: 93 | 94 | Flit(); 95 | ~Flit() {} 96 | 97 | static stack _all; 98 | static stack _free; 99 | 100 | }; 101 | 102 | ostream& operator<<( ostream& os, const Flit& f ); 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /booksim2/src/module.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /*module.cpp 29 | * 30 | *The basic class that is extended by all other components of the network 31 | *Provides the basic hierarchy structure and basic fuctions 32 | * 33 | */ 34 | 35 | #include 36 | #include 37 | 38 | #include "booksim.hpp" 39 | #include "module.hpp" 40 | 41 | Module::Module( Module *parent, const string& name ) 42 | { 43 | _name = name; 44 | 45 | if ( parent ) { 46 | parent->_AddChild( this ); 47 | _fullname = parent->_fullname + "/" + name; 48 | } else { 49 | _fullname = name; 50 | } 51 | } 52 | 53 | void Module::_AddChild( Module *child ) 54 | { 55 | _children.push_back( child ); 56 | } 57 | 58 | void Module::DisplayHierarchy( int level, ostream & os ) const 59 | { 60 | vector::const_iterator mod_iter; 61 | 62 | for ( int l = 0; l < level; l++ ) { 63 | os << " "; 64 | } 65 | 66 | os << _name << endl; 67 | 68 | for ( mod_iter = _children.begin( ); 69 | mod_iter != _children.end( ); mod_iter++ ) { 70 | (*mod_iter)->DisplayHierarchy( level + 1 ); 71 | } 72 | } 73 | 74 | void Module::Error( const string& msg ) const 75 | { 76 | cout << "Error in " << _fullname << " : " << msg << endl; 77 | exit( -1 ); 78 | } 79 | 80 | void Module::Debug( const string& msg ) const 81 | { 82 | cout << "Debug (" << _fullname << ") : " << msg << endl; 83 | } 84 | 85 | void Module::Display( ostream & os ) const 86 | { 87 | os << "Display method not implemented for " << _fullname << endl; 88 | } 89 | -------------------------------------------------------------------------------- /booksim2/src/injection.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _INJECTION_HPP_ 29 | #define _INJECTION_HPP_ 30 | 31 | #include "config_utils.hpp" 32 | 33 | using namespace std; 34 | 35 | class InjectionProcess { 36 | protected: 37 | int _nodes; 38 | double _rate; 39 | InjectionProcess(int nodes, double rate); 40 | public: 41 | virtual ~InjectionProcess() {} 42 | virtual bool test(int source) = 0; 43 | virtual void reset(); 44 | static InjectionProcess * New(string const & inject, int nodes, double load, 45 | Configuration const * const config = NULL); 46 | }; 47 | 48 | class BernoulliInjectionProcess : public InjectionProcess { 49 | public: 50 | BernoulliInjectionProcess(int nodes, double rate); 51 | virtual bool test(int source); 52 | }; 53 | 54 | // TODO: Start: Added by RapidChiplet developers 55 | 56 | class CustomInjectionProcess : public InjectionProcess { 57 | private: 58 | vector _does_inject; 59 | public: 60 | CustomInjectionProcess(int nodes, double rate, vector does_inject, Configuration const * const config); 61 | virtual bool test(int source); 62 | }; 63 | 64 | // TODO: End: Added by RapidChiplet developers 65 | 66 | 67 | class OnOffInjectionProcess : public InjectionProcess { 68 | private: 69 | double _alpha; 70 | double _beta; 71 | double _r1; 72 | vector _initial; 73 | vector _state; 74 | public: 75 | OnOffInjectionProcess(int nodes, double rate, double alpha, double beta, 76 | double r1, vector initial); 77 | virtual void reset(); 78 | virtual bool test(int source); 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /booksim2/src/arbiters/roundrobin_arb.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // RoundRobin: Round Robin Arbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _ROUNDROBIN_HPP_ 35 | #define _ROUNDROBIN_HPP_ 36 | 37 | #include "arbiter.hpp" 38 | 39 | class RoundRobinArbiter : public Arbiter { 40 | 41 | // Priority pointer 42 | int _pointer ; 43 | 44 | public: 45 | 46 | // Constructors 47 | RoundRobinArbiter( Module *parent, const string &name, int size ) ; 48 | 49 | // Print priority matrix to standard output 50 | virtual void PrintState() const ; 51 | 52 | // Update priority matrix based on last aribtration result 53 | virtual void UpdateState() ; 54 | 55 | // Arbitrate amongst requests. Returns winning input and 56 | // updates pointers to metadata when valid pointers are passed 57 | virtual int Arbitrate( int* id = 0, int* pri = 0) ; 58 | 59 | virtual void AddRequest( int input, int id, int pri ) ; 60 | 61 | virtual void Clear(); 62 | 63 | static inline bool Supersedes(int input1, int pri1, int input2, int pri2, int offset, int size) 64 | { 65 | // in a round-robin scheme with the given number of positions and current 66 | // offset, should a request at input1 with priority pri1 supersede a 67 | // request at input2 with priority pri2? 68 | return ((pri1 > pri2) || 69 | ((pri1 == pri2) && 70 | (((input1 - offset + size) % size) < ((input2 - offset + size) % size)))); 71 | } 72 | 73 | } ; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /booksim2/src/arbiters/roundrobin_arb.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // RoundRobin: RoundRobin Arbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #include "roundrobin_arb.hpp" 35 | #include 36 | #include 37 | 38 | using namespace std ; 39 | 40 | RoundRobinArbiter::RoundRobinArbiter( Module *parent, const string &name, 41 | int size ) 42 | : Arbiter( parent, name, size ), _pointer( 0 ) { 43 | } 44 | 45 | void RoundRobinArbiter::PrintState() const { 46 | cout << "Round Robin Priority Pointer: " << endl ; 47 | cout << " _pointer = " << _pointer << endl ; 48 | } 49 | 50 | void RoundRobinArbiter::UpdateState() { 51 | // update priority matrix using last grant 52 | if ( _selected > -1 ) 53 | _pointer = ( _selected + 1 ) % _size ; 54 | } 55 | 56 | void RoundRobinArbiter::AddRequest( int input, int id, int pri ) 57 | { 58 | if(!_request[input].valid || (_request[input].pri < pri)) { 59 | if((_num_reqs == 0) || 60 | Supersedes(input, pri, _best_input, _highest_pri, _pointer,_size )) { 61 | _highest_pri = pri; 62 | _best_input = input; 63 | } 64 | } 65 | Arbiter::AddRequest(input, id, pri); 66 | } 67 | 68 | int RoundRobinArbiter::Arbitrate( int* id, int* pri ) { 69 | 70 | _selected = _best_input; 71 | 72 | return Arbiter::Arbitrate(id, pri); 73 | } 74 | 75 | void RoundRobinArbiter::Clear() 76 | { 77 | _highest_pri = numeric_limits::min(); 78 | _best_input = -1; 79 | Arbiter::Clear(); 80 | } 81 | -------------------------------------------------------------------------------- /booksim2/src/arbiters/arbiter.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // Arbiter: Base class for Matrix and Round Robin Arbiter 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #ifndef _ARBITER_HPP_ 35 | #define _ARBITER_HPP_ 36 | 37 | #include 38 | 39 | #include "module.hpp" 40 | 41 | class Arbiter : public Module { 42 | 43 | protected: 44 | 45 | typedef struct { 46 | bool valid ; 47 | int id ; 48 | int pri ; 49 | } entry_t ; 50 | 51 | vector _request ; 52 | int _size ; 53 | 54 | int _selected ; 55 | int _highest_pri; 56 | int _best_input; 57 | 58 | public: 59 | int _num_reqs ; 60 | // Constructors 61 | Arbiter( Module *parent, const string &name, int size ) ; 62 | 63 | // Print priority matrix to standard output 64 | virtual void PrintState() const = 0 ; 65 | 66 | // Register request with arbiter 67 | virtual void AddRequest( int input, int id, int pri ) ; 68 | 69 | // Update priority matrix based on last aribtration result 70 | virtual void UpdateState() = 0 ; 71 | 72 | // Arbitrate amongst requests. Returns winning input and 73 | // updates pointers to metadata when valid pointers are passed 74 | virtual int Arbitrate( int* id = 0, int* pri = 0 ) ; 75 | 76 | virtual void Clear(); 77 | 78 | inline int LastWinner() const { 79 | return _selected; 80 | } 81 | 82 | static Arbiter *NewArbiter( Module *parent, const string &name, 83 | const string &arb_type, int size ); 84 | } ; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /booksim2/src/pipefifo.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _PIPEFIFO_HPP_ 29 | #define _PIPEFIFO_HPP_ 30 | 31 | #include 32 | 33 | #include "module.hpp" 34 | 35 | template class PipelineFIFO : public Module { 36 | int _lanes; 37 | int _depth; 38 | 39 | int _pipe_len; 40 | int _pipe_ptr; 41 | 42 | vector > _data; 43 | 44 | public: 45 | PipelineFIFO( Module *parent, const string& name, int lanes, int depth ); 46 | ~PipelineFIFO( ); 47 | 48 | void Write( T* val, int lane = 0 ); 49 | void WriteAll( T* val ); 50 | 51 | T* Read( int lane = 0 ); 52 | 53 | void Advance( ); 54 | }; 55 | 56 | template PipelineFIFO::PipelineFIFO( Module *parent, 57 | const string& name, 58 | int lanes, int depth ) : 59 | Module( parent, name ), 60 | _lanes( lanes ), _depth( depth ) 61 | { 62 | _pipe_len = depth + 1; 63 | _pipe_ptr = 0; 64 | 65 | _data.resize(_lanes); 66 | for ( int l = 0; l < _lanes; ++l ) { 67 | _data[l].resize(_pipe_len, 0); 68 | } 69 | } 70 | 71 | template PipelineFIFO::~PipelineFIFO( ) 72 | { 73 | } 74 | 75 | template void PipelineFIFO::Write( T* val, int lane ) 76 | { 77 | _data[lane][_pipe_ptr] = val; 78 | } 79 | 80 | template void PipelineFIFO::WriteAll( T* val ) 81 | { 82 | for ( int l = 0; l < _lanes; ++l ) { 83 | _data[l][_pipe_ptr] = val; 84 | } 85 | } 86 | 87 | template T* PipelineFIFO::Read( int lane ) 88 | { 89 | return _data[lane][_pipe_ptr]; 90 | } 91 | 92 | template void PipelineFIFO::Advance( ) 93 | { 94 | _pipe_ptr = ( _pipe_ptr + 1 ) % _pipe_len; 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /booksim2/src/networks/anynet.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _ANYNET_HPP_ 29 | #define _ANYNET_HPP_ 30 | 31 | #include "network.hpp" 32 | #include "routefunc.hpp" 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | class AnyNet : public Network { 39 | 40 | string file_name; 41 | //associtation between nodes and routers 42 | map node_list; 43 | //[link type][src router][dest router]=(port, latency) 44 | vector > > > router_list; 45 | //stores minimal routing information from every router to every node 46 | //[router][dest_node]=port 47 | vector > routing_table; 48 | // TODO: Start of additional code by RapidChiplet developers 49 | vector > default_routing_table; 50 | vector > > extended_routing_table; 51 | string routing_table_type; 52 | // TODO: End of additional code by RapidChiplet developers 53 | 54 | void _ComputeSize( const Configuration &config ); 55 | void _BuildNet( const Configuration &config ); 56 | void readFile(); 57 | void buildRoutingTable(const Configuration &config); 58 | void route(int r_start); 59 | 60 | public: 61 | AnyNet( const Configuration &config, const string & name ); 62 | ~AnyNet(); 63 | 64 | int GetN( ) const{ return -1;} 65 | int GetK( ) const{ return -1;} 66 | 67 | static void RegisterRoutingFunctions(); 68 | double Capacity( ) const {return -1;} 69 | void InsertRandomFaults( const Configuration &config ){} 70 | }; 71 | 72 | void min_anynet( const Router *r, const Flit *f, int in_channel, 73 | OutputSet *outputs, bool inject ); 74 | #endif 75 | -------------------------------------------------------------------------------- /booksim2/src/allocators/separable.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableAllocator: Separable Allocator Base Class 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #include "separable.hpp" 35 | 36 | #include 37 | 38 | #include "arbiter.hpp" 39 | 40 | SeparableAllocator::SeparableAllocator( Module* parent, const string& name, 41 | int inputs, int outputs, 42 | const string& arb_type ) 43 | : SparseAllocator( parent, name, inputs, outputs ) 44 | { 45 | 46 | _input_arb.resize(inputs); 47 | 48 | for (int i = 0; i < inputs; ++i) { 49 | ostringstream arb_name("arb_i"); 50 | arb_name << i; 51 | _input_arb[i] = Arbiter::NewArbiter(this, arb_name.str(), arb_type, outputs); 52 | } 53 | 54 | _output_arb.resize(outputs); 55 | 56 | for (int i = 0; i < outputs; ++i) { 57 | ostringstream arb_name("arb_o"); 58 | arb_name << i; 59 | _output_arb[i] = Arbiter::NewArbiter(this, arb_name.str( ), arb_type, inputs); 60 | } 61 | 62 | } 63 | 64 | SeparableAllocator::~SeparableAllocator() { 65 | 66 | for (int i = 0; i < _inputs; ++i) { 67 | delete _input_arb[i]; 68 | } 69 | 70 | for (int i = 0; i < _outputs; ++i) { 71 | delete _output_arb[i]; 72 | } 73 | 74 | } 75 | 76 | void SeparableAllocator::Clear() { 77 | for ( int i = 0 ; i < _inputs ; i++ ) { 78 | if(_input_arb[i]-> _num_reqs) 79 | _input_arb[i]->Clear(); 80 | } 81 | for ( int o = 0; o < _outputs; o++ ) { 82 | if(_output_arb[o]->_num_reqs) 83 | _output_arb[o]->Clear(); 84 | } 85 | SparseAllocator::Clear(); 86 | } 87 | -------------------------------------------------------------------------------- /booksim2/src/networks/cmesh.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | //////////////////////////////////////////////////////////////////////// 29 | // 30 | // CMesh: Mesh topology with concentration and express links along the 31 | // edge of the network 32 | // 33 | //////////////////////////////////////////////////////////////////////// 34 | // 35 | // RCS Information: 36 | // $Author: jbalfour $ 37 | // $Date: 2007/06/26 22:49:23 $ 38 | // $Id$ 39 | // 40 | //////////////////////////////////////////////////////////////////////// 41 | #ifndef _CMESH_HPP_ 42 | #define _CMESH_HPP_ 43 | 44 | #include "network.hpp" 45 | #include "routefunc.hpp" 46 | 47 | class CMesh : public Network { 48 | public: 49 | CMesh( const Configuration &config, const string & name ); 50 | int GetN() const; 51 | int GetK() const; 52 | 53 | static int NodeToRouter( int address ) ; 54 | static int NodeToPort( int address ) ; 55 | 56 | static void RegisterRoutingFunctions() ; 57 | 58 | private: 59 | 60 | static int _cX ; 61 | static int _cY ; 62 | 63 | static int _memo_NodeShiftX ; 64 | static int _memo_NodeShiftY ; 65 | static int _memo_PortShiftY ; 66 | 67 | void _ComputeSize( const Configuration &config ); 68 | void _BuildNet( const Configuration& config ); 69 | 70 | int _k ; 71 | int _n ; 72 | int _c ; 73 | int _xcount; 74 | int _ycount; 75 | int _xrouter; 76 | int _yrouter; 77 | bool _express_channels; 78 | }; 79 | 80 | // 81 | // Routing Functions 82 | // 83 | void xy_yx_cmesh( const Router *r, const Flit *f, int in_channel, 84 | OutputSet *outputs, bool inject ) ; 85 | 86 | void xy_yx_no_express_cmesh( const Router *r, const Flit *f, int in_channel, 87 | OutputSet *outputs, bool inject ) ; 88 | 89 | void dor_cmesh( const Router *r, const Flit *f, int in_channel, 90 | OutputSet *outputs, bool inject ) ; 91 | 92 | void dor_no_express_cmesh( const Router *r, const Flit *f, int in_channel, 93 | OutputSet *outputs, bool inject ) ; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /booksim2/src/flitchannel.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // File Name: flitchannel.cpp 31 | // Author: James Balfour, Rebecca Schultz 32 | // 33 | // ---------------------------------------------------------------------- 34 | 35 | #include "flitchannel.hpp" 36 | 37 | #include 38 | #include 39 | 40 | #include "router.hpp" 41 | #include "globals.hpp" 42 | 43 | // ---------------------------------------------------------------------- 44 | // $Author: jbalfour $ 45 | // $Date: 2007/06/27 23:10:17 $ 46 | // $Id$ 47 | // ---------------------------------------------------------------------- 48 | FlitChannel::FlitChannel(Module * parent, string const & name, int classes) 49 | : Channel(parent, name), _routerSource(NULL), _routerSourcePort(-1), 50 | _routerSink(NULL), _routerSinkPort(-1), _idle(0) { 51 | _active.resize(classes, 0); 52 | } 53 | 54 | void FlitChannel::SetSource(Router const * const router, int port) { 55 | _routerSource = router; 56 | _routerSourcePort = port; 57 | } 58 | 59 | void FlitChannel::SetSink(Router const * const router, int port) { 60 | _routerSink = router; 61 | _routerSinkPort = port; 62 | } 63 | 64 | void FlitChannel::Send(Flit * f) { 65 | if(f) { 66 | ++_active[f->cl]; 67 | } else { 68 | ++_idle; 69 | } 70 | Channel::Send(f); 71 | } 72 | 73 | void FlitChannel::ReadInputs() { 74 | Flit const * const & f = _input; 75 | if(f && f->watch) { 76 | *gWatchOut << GetSimTime() << " | " << FullName() << " | " 77 | << "Beginning channel traversal for flit " << f->id 78 | << " with delay " << _delay 79 | << "." << endl; 80 | } 81 | Channel::ReadInputs(); 82 | } 83 | 84 | void FlitChannel::WriteOutputs() { 85 | Channel::WriteOutputs(); 86 | if(_output && _output->watch) { 87 | *gWatchOut << GetSimTime() << " | " << FullName() << " | " 88 | << "Completed channel traversal for flit " << _output->id 89 | << "." << endl; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /booksim2/src/config_utils.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _CONFIG_UTILS_HPP_ 29 | #define _CONFIG_UTILS_HPP_ 30 | 31 | #include "booksim.hpp" 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | extern "C" int yyparse(); 39 | 40 | class Configuration { 41 | static Configuration * theConfig; 42 | FILE * _config_file; 43 | string _config_string; 44 | 45 | protected: 46 | map _str_map; 47 | map _int_map; 48 | map _float_map; 49 | 50 | public: 51 | Configuration(); 52 | 53 | void AddStrField(string const & field, string const & value); 54 | 55 | void Assign(string const & field, string const & value); 56 | void Assign(string const & field, int value); 57 | void Assign(string const & field, double value); 58 | 59 | string GetStr(string const & field) const; 60 | int GetInt(string const & field) const; 61 | double GetFloat(string const & field) const; 62 | 63 | vector GetStrArray(const string & field) const; 64 | vector GetIntArray(const string & field) const; 65 | vector GetFloatArray(const string & field) const; 66 | 67 | void ParseFile(string const & filename); 68 | void ParseString(string const & str); 69 | int Input(char * line, int max_size); 70 | void ParseError(string const & msg, unsigned int lineno = 0) const; 71 | 72 | void WriteFile(string const & filename); 73 | void WriteMatlabFile(ostream * o) const; 74 | 75 | inline const map & GetStrMap() const { 76 | return _str_map; 77 | } 78 | inline const map & GetIntMap() const { 79 | return _int_map; 80 | } 81 | inline const map & GetFloatMap() const { 82 | return _float_map; 83 | } 84 | 85 | static Configuration * GetTheConfig(); 86 | 87 | }; 88 | 89 | bool ParseArgs(Configuration * cf, int argc, char **argv); 90 | 91 | vector tokenize_str(string const & data); 92 | vector tokenize_int(string const & data); 93 | vector tokenize_float(string const & data); 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /booksim2/src/flit.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /*flit.cpp 29 | * 30 | *flit struct is a flit, carries all the control signals that a flit needs 31 | *Add additional signals as necessary. Flits has no concept of length 32 | *it is a singluar object. 33 | * 34 | *When adding objects make sure to set a default value in this constructor 35 | */ 36 | 37 | #include "booksim.hpp" 38 | #include "flit.hpp" 39 | 40 | stack Flit::_all; 41 | stack Flit::_free; 42 | 43 | ostream& operator<<( ostream& os, const Flit& f ) 44 | { 45 | os << " Flit ID: " << f.id << " (" << &f << ")" 46 | << " Packet ID: " << f.pid 47 | << " Type: " << f.type 48 | << " Head: " << f.head 49 | << " Tail: " << f.tail << endl; 50 | os << " Source: " << f.src << " Dest: " << f.dest << " Intm: "<Reset(); 93 | _free.pop(); 94 | } 95 | return f; 96 | } 97 | 98 | void Flit::Free() { 99 | _free.push(this); 100 | } 101 | 102 | void Flit::FreeAll() { 103 | while(!_all.empty()) { 104 | delete _all.top(); 105 | _all.pop(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /netrace/export_trace.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "queue.h" 6 | #include "netrace.h" 7 | 8 | int main( int argc, char** argv ) { 9 | // Read command line arguments 10 | char* tracefile; 11 | int region = -1; 12 | long long int packet_limit = 1000000000; 13 | int packets_in_region; 14 | long long int start_cycle = 0; 15 | long long int start_id = -1; 16 | // Trace file 17 | nt_context_t* ctx; 18 | nt_header_t* header; 19 | if( argc > 1 ) { 20 | tracefile = argv[1]; 21 | } else { 22 | printf( "ERROR: Please specify trace file (first argument)\n" ); 23 | exit(0); 24 | } 25 | // Region 26 | if( argc > 2 ) { 27 | region = atoi(argv[2]); 28 | } 29 | // Packet limit 30 | if( argc > 3 ) { 31 | packet_limit = atoi(argv[3]); 32 | } 33 | // Open the trace file using netrace 34 | ctx = calloc( 1, sizeof(nt_context_t) ); 35 | nt_open_trfile( ctx, tracefile ); 36 | // Get trace header 37 | header = nt_get_trheader( ctx ); 38 | // Skip to the specified region 39 | if (region >= 0) { 40 | packets_in_region = header->regions[region].num_packets; 41 | nt_seek_region( ctx, &header->regions[region] ); 42 | // Compute the cycle in which the region starts 43 | for(int i = 0; i < region; i++ ) { 44 | start_cycle += header->regions[i].num_cycles; 45 | } 46 | } 47 | else { 48 | packets_in_region = header->num_packets; 49 | } 50 | // Variables to store packet information 51 | nt_packet_t* packet; 52 | unsigned int id; 53 | unsigned int dep_packet_id; 54 | unsigned long long int cycle; 55 | unsigned char type_num; 56 | unsigned char src_id; 57 | unsigned char dst_id; 58 | unsigned char num_deps; 59 | int src_type_num; 60 | int dst_type_num; 61 | const char* src_type_str; 62 | const char* dst_type_str; 63 | // Read all packets 64 | printf( "{\n" ); 65 | printf( "\"nodes\" : %i,\n", header->num_nodes ); 66 | printf( "\"packets\" : \n"); 67 | printf( "[\n" ); 68 | for(int i = 0; (i < packets_in_region) && (i < packet_limit); i++ ) { 69 | packet = nt_read_packet( ctx ); 70 | // Set the start-id to remap all ids 71 | if(i == 0){ 72 | start_id = packet->id; 73 | } 74 | // Extract information relevant for us 75 | id = packet->id - start_id; 76 | cycle = packet->cycle - start_cycle; 77 | type_num = packet->type; 78 | src_id = packet->src; 79 | dst_id = packet->dst; 80 | src_type_num = nt_get_src_type(packet); 81 | dst_type_num = nt_get_dst_type(packet); 82 | src_type_str = nt_node_type_to_string(src_type_num); 83 | dst_type_str = nt_node_type_to_string(dst_type_num); 84 | char* line = "{\"id\" : %u, \"cycle\" : %llu, \"type\" : %hhu, \"src\" : %hhu, \"dst\" : %hhu, \"src_type\" : \"%s\", \"dst_type\" : \"%s\", \"reverse_dependencies\" : ["; 85 | printf(line, id, cycle, type_num, src_id, dst_id, src_type_str, dst_type_str); 86 | bool first = true; 87 | for (int j = 0; j < packet->num_deps; j++) { 88 | dep_packet_id = packet->deps[j] - start_id; 89 | if ((dep_packet_id < packet_limit) && (dep_packet_id < packets_in_region)){ 90 | if (!first) { 91 | printf(","); 92 | } 93 | printf("%u", dep_packet_id); 94 | first = false; 95 | } 96 | } 97 | printf("]}"); 98 | if ((i < packets_in_region - 1) && (i < packet_limit - 1)) { 99 | printf(","); 100 | } 101 | printf("\n"); 102 | } 103 | printf( "]\n" ); 104 | printf( "}" ); 105 | nt_close_trfile( ctx ); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /booksim2/src/networks/flatfly_onchip.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _FlatFlyOnChip_HPP_ 29 | #define _FlatFlyOnChip_HPP_ 30 | 31 | #include "network.hpp" 32 | 33 | #include "routefunc.hpp" 34 | #include 35 | 36 | 37 | class FlatFlyOnChip : public Network { 38 | 39 | int _m; 40 | int _n; 41 | int _r; 42 | int _k; 43 | int _c; 44 | int _radix; 45 | int _net_size; 46 | int _stageout; 47 | int _numinput; 48 | int _stages; 49 | int _num_of_switch; 50 | 51 | void _ComputeSize( const Configuration &config ); 52 | void _BuildNet( const Configuration &config ); 53 | 54 | int _OutChannel( int stage, int addr, int port, int outputs ) const; 55 | int _InChannel( int stage, int addr, int port ) const; 56 | 57 | public: 58 | FlatFlyOnChip( const Configuration &config, const string & name ); 59 | 60 | int GetN( ) const; 61 | int GetK( ) const; 62 | 63 | static void RegisterRoutingFunctions() ; 64 | double Capacity( ) const; 65 | void InsertRandomFaults( const Configuration &config ); 66 | }; 67 | void adaptive_xyyx_flatfly( const Router *r, const Flit *f, int in_channel, 68 | OutputSet *outputs, bool inject ); 69 | void xyyx_flatfly( const Router *r, const Flit *f, int in_channel, 70 | OutputSet *outputs, bool inject ); 71 | void min_flatfly( const Router *r, const Flit *f, int in_channel, 72 | OutputSet *outputs, bool inject ); 73 | void ugal_xyyx_flatfly_onchip( const Router *r, const Flit *f, int in_channel, 74 | OutputSet *outputs, bool inject ); 75 | void ugal_flatfly_onchip( const Router *r, const Flit *f, int in_channel, 76 | OutputSet *outputs, bool inject ); 77 | void ugal_pni_flatfly_onchip( const Router *r, const Flit *f, int in_channel, 78 | OutputSet *outputs, bool inject ); 79 | void valiant_flatfly( const Router *r, const Flit *f, int in_channel, 80 | OutputSet *outputs, bool inject ); 81 | 82 | int find_distance (int src, int dest); 83 | int find_ran_intm (int src, int dest); 84 | int flatfly_outport(int dest, int rID); 85 | int flatfly_transformation(int dest); 86 | int flatfly_outport_yx(int dest, int rID); 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /run_experiment.py: -------------------------------------------------------------------------------- 1 | # Python modules 2 | import copy as cpy 3 | import argparse 4 | 5 | 6 | # RapidChiplet modules 7 | import helpers as hlp 8 | import generate_inputs as igen 9 | import rapidchiplet as rc 10 | 11 | 12 | def split_parameters(experiment): 13 | # Divide parameters into fixed ones and ones where we iterate over a range 14 | base_params = {} 15 | ranged_params = {} 16 | for param in experiment: 17 | if len(experiment[param]) > 1: 18 | ranged_params[param] = experiment[param] 19 | elif len(experiment[param]) == 1: 20 | base_params[param] = experiment[param][0] 21 | else: 22 | # We assume that the given parameter is not used for the configured experiment 23 | # If this is not the case, the function generate_inputs() will fail and the user 24 | # will be able to identify the issue and add the missing parameter to the experiment file 25 | pass 26 | return (base_params, ranged_params) 27 | 28 | 29 | def compute_parameter_combinations(experiment, exp_name): 30 | (base_params, ranged_params) = split_parameters(experiment) 31 | # Create a list of all possible combinations of the ranged parameters (all single experiments) 32 | # NOTE: The number of experiments can grow exponentially 33 | experiments = {exp_name : base_params} 34 | range_param_idx = 0 35 | for (ranged_param_name, ranged_param_values) in ranged_params.items(): 36 | new_experiments = {} 37 | for (exp_name, exp_params) in experiments.items(): 38 | for ranged_param_value in ranged_param_values: 39 | suffix = ("_".join([str(x) for x in ranged_param_value]) if type(ranged_param_value) == list else str(ranged_param_value)) 40 | suffix = "_" if suffix == "" else suffix 41 | new_exp_name = exp_name + "-" + suffix 42 | new_exp_params = cpy.deepcopy(exp_params) 43 | new_exp_params[ranged_param_name] = ranged_param_value 44 | new_experiments[new_exp_name] = new_exp_params 45 | experiments = new_experiments 46 | return experiments 47 | 48 | 49 | def run_single_configuration(params, metrics_to_compute, exp_name): 50 | # Generate the experiment setup 51 | inputs = igen.generate_inputs(params, exp_name, do_write = False) 52 | # Arguments for the rapidchiplet function 53 | intermediates = {} 54 | do_compute = {metric : (metric in metrics_to_compute) for metric in rc.metrics} 55 | results_file = exp_name 56 | # Run RapidChiplet 57 | results = rc.rapidchiplet(inputs, intermediates, do_compute, results_file, verbose = True, validate = params["do_validate"]) 58 | # Save the results 59 | hlp.write_json("./results/%s.json" % exp_name, results) 60 | 61 | 62 | def run_experiment(experiment): 63 | # Extract the experiment name and metrics to compute 64 | exp_name = experiment["exp_name"] 65 | metrics_to_compute = experiment["metrics"] 66 | del experiment["exp_name"] 67 | del experiment["metrics"] 68 | experiments = compute_parameter_combinations(experiment, exp_name) 69 | n_exp = len(experiments) 70 | # Run all experiments 71 | for (idx, new_exp_name) in enumerate(experiments): 72 | print("=" * 100) 73 | print("Running experiment %d/%d: %s" % (idx + 1, n_exp, new_exp_name)) 74 | print("=" * 100) 75 | run_single_configuration(experiments[new_exp_name], metrics_to_compute, new_exp_name) 76 | 77 | 78 | if __name__ == "__main__": 79 | parser = argparse.ArgumentParser() 80 | parser.add_argument("-e", "--experiment", required=True, help="Path to the \"experiment\" input file") 81 | args = parser.parse_args() 82 | # Load the experiment file 83 | experiment = hlp.read_json(args.experiment) 84 | # Run the experiment 85 | run_experiment(experiment) 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /booksim2/src/allocators/loa.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "booksim.hpp" 29 | #include 30 | 31 | #include "loa.hpp" 32 | #include "random_utils.hpp" 33 | 34 | LOA::LOA( Module *parent, const string& name, 35 | int inputs, int outputs ) : 36 | DenseAllocator( parent, name, inputs, outputs ) 37 | { 38 | _req.resize(inputs); 39 | _counts.resize(outputs); 40 | 41 | _rptr.resize(inputs); 42 | _gptr.resize(outputs); 43 | } 44 | 45 | void LOA::Allocate( ) 46 | { 47 | int input; 48 | int output; 49 | 50 | int input_offset; 51 | int output_offset; 52 | 53 | int lonely; 54 | int lonely_cnt; 55 | 56 | // Count phase --- the number of requests 57 | // per output is counted 58 | 59 | for ( int j = 0; j < _outputs; ++j ) { 60 | _counts[j] = 0; 61 | for ( int i = 0; i < _inputs; ++i ) { 62 | _counts[j] += ( _request[i][j].label != -1 ) ? 1 : 0; 63 | } 64 | } 65 | 66 | // Request phase 67 | for ( input = 0; input < _inputs; ++input ) { 68 | 69 | // Find the lonely output 70 | output_offset = _rptr[input]; 71 | lonely = -1; 72 | lonely_cnt = _inputs + 1; 73 | 74 | for ( int o = 0; o < _outputs; ++o ) { 75 | output = ( o + output_offset ) % _outputs; 76 | 77 | if ( ( _request[input][output].label != -1 ) && 78 | ( _counts[output] < lonely_cnt ) ) { 79 | lonely = output; 80 | lonely_cnt = _counts[output]; 81 | } 82 | } 83 | 84 | // Request the lonely output (-1 for no request) 85 | _req[input] = lonely; 86 | } 87 | 88 | // Grant phase 89 | for ( output = 0; output < _outputs; ++output ) { 90 | input_offset = _gptr[output]; 91 | 92 | for ( int i = 0; i < _inputs; ++i ) { 93 | input = ( i + input_offset ) % _inputs; 94 | 95 | if ( _req[input] == output ) { 96 | // Grant! 97 | 98 | _inmatch[input] = output; 99 | _outmatch[output] = input; 100 | 101 | _rptr[input] = ( _rptr[input] + 1 ) % _outputs; 102 | _gptr[output] = ( _gptr[output] + 1 ) % _inputs; 103 | 104 | break; 105 | } 106 | } 107 | } 108 | 109 | 110 | } 111 | 112 | 113 | -------------------------------------------------------------------------------- /booksim2/src/flitchannel.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // File Name: flitchannel.hpp 31 | // 32 | // The FlitChannel models a flit channel with a multi-cycle 33 | // transmission delay. The channel latency can be specified as 34 | // an integer number of simulator cycles. 35 | // ---------------------------------------------------------------------- 36 | 37 | #ifndef FLITCHANNEL_HPP 38 | #define FLITCHANNEL_HPP 39 | 40 | // ---------------------------------------------------------------------- 41 | // $Author: jbalfour $ 42 | // $Date: 2007/06/27 23:10:17 $ 43 | // $Id$ 44 | // ---------------------------------------------------------------------- 45 | 46 | #include "channel.hpp" 47 | #include "flit.hpp" 48 | 49 | using namespace std; 50 | 51 | class Router ; 52 | 53 | class FlitChannel : public Channel { 54 | public: 55 | FlitChannel(Module * parent, string const & name, int classes); 56 | 57 | void SetSource(Router const * const router, int port) ; 58 | inline Router const * const GetSource() const { 59 | return _routerSource; 60 | } 61 | inline int const & GetSourcePort() const { 62 | return _routerSourcePort; 63 | } 64 | void SetSink(Router const * const router, int port) ; 65 | inline Router const * const GetSink() const { 66 | return _routerSink; 67 | } 68 | inline int const & GetSinkPort() const { 69 | return _routerSinkPort; 70 | } 71 | inline vector const & GetActivity() const { 72 | return _active; 73 | } 74 | 75 | // Send flit 76 | virtual void Send(Flit * flit); 77 | 78 | virtual void ReadInputs(); 79 | virtual void WriteOutputs(); 80 | 81 | private: 82 | 83 | //////////////////////////////////////// 84 | // 85 | // Power Models OBSOLETE 86 | // 87 | //////////////////////////////////////// 88 | 89 | Router const * _routerSource; 90 | int _routerSourcePort; 91 | Router const * _routerSink; 92 | int _routerSinkPort; 93 | 94 | // Statistics for Activity Factors 95 | vector _active; 96 | int _idle; 97 | }; 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /booksim2/src/allocators/pim.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "booksim.hpp" 29 | #include 30 | 31 | #include "pim.hpp" 32 | #include "random_utils.hpp" 33 | 34 | //#define DEBUG_PIM 35 | 36 | PIM::PIM( Module *parent, const string& name, 37 | int inputs, int outputs, int iters ) : 38 | DenseAllocator( parent, name, inputs, outputs ), 39 | _PIM_iter(iters) 40 | { 41 | } 42 | 43 | PIM::~PIM( ) 44 | { 45 | } 46 | 47 | void PIM::Allocate( ) 48 | { 49 | int input; 50 | int output; 51 | 52 | int input_offset; 53 | int output_offset; 54 | 55 | for ( int iter = 0; iter < _PIM_iter; ++iter ) { 56 | // Grant phase --- outputs randomly choose 57 | // between one of their requests 58 | 59 | vector grants(_outputs, -1); 60 | 61 | for ( output = 0; output < _outputs; ++output ) { 62 | 63 | // A random arbiter between input requests 64 | input_offset = RandomInt( _inputs - 1 ); 65 | 66 | for ( int i = 0; i < _inputs; ++i ) { 67 | input = ( i + input_offset ) % _inputs; 68 | 69 | if ( ( _request[input][output].label != -1 ) && 70 | ( _inmatch[input] == -1 ) && 71 | ( _outmatch[output] == -1 ) ) { 72 | 73 | // Grant 74 | grants[output] = input; 75 | break; 76 | } 77 | } 78 | } 79 | 80 | // Accept phase -- inputs randomly choose 81 | // between input_speedup of their grants 82 | 83 | for ( input = 0; input < _inputs; ++input ) { 84 | 85 | // A random arbiter between output grants 86 | output_offset = RandomInt( _outputs - 1 ); 87 | 88 | for ( int o = 0; o < _outputs; ++o ) { 89 | output = ( o + output_offset ) % _outputs; 90 | 91 | if ( grants[output] == input ) { 92 | 93 | // Accept 94 | _inmatch[input] = output; 95 | _outmatch[output] = input; 96 | 97 | break; 98 | } 99 | } 100 | } 101 | } 102 | 103 | #ifdef DEBUG_PIM 104 | if ( _outputs == 8 ) { 105 | cout << "input match: " << endl; 106 | for ( int i = 0; i < _inputs; ++i ) { 107 | cout << " from " << i << " to " << _inmatch[i] << endl; 108 | } 109 | cout << endl; 110 | } 111 | 112 | cout << "output match: "; 113 | for ( int j = 0; j < _outputs; ++j ) { 114 | cout << _outmatch[j] << " "; 115 | } 116 | cout << endl; 117 | #endif 118 | } 119 | 120 | 121 | -------------------------------------------------------------------------------- /booksim2/src/allocators/separable_input_first.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableInputFirstAllocator: Separable Input-First Allocator 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #include "separable_input_first.hpp" 35 | 36 | #include "booksim.hpp" 37 | #include "arbiter.hpp" 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | SeparableInputFirstAllocator:: 44 | SeparableInputFirstAllocator( Module* parent, const string& name, int inputs, 45 | int outputs, const string& arb_type ) 46 | : SeparableAllocator( parent, name, inputs, outputs, arb_type ) 47 | {} 48 | 49 | void SeparableInputFirstAllocator::Allocate() { 50 | 51 | set::const_iterator port_iter = _in_occ.begin(); 52 | while(port_iter != _in_occ.end()) { 53 | 54 | const int & input = *port_iter; 55 | 56 | // add requests to the input arbiter 57 | 58 | map::const_iterator req_iter = _in_req[input].begin(); 59 | while(req_iter != _in_req[input].end()) { 60 | 61 | const sRequest & req = req_iter->second; 62 | 63 | _input_arb[input]->AddRequest(req.port, req.label, req.in_pri); 64 | 65 | ++req_iter; 66 | } 67 | 68 | // Execute the input arbiters and propagate the grants to the 69 | // output arbiters. 70 | 71 | int label = -1; 72 | const int output = _input_arb[input]->Arbitrate(&label, NULL); 73 | assert(output > -1); 74 | 75 | const sRequest & req = _out_req[output][input]; 76 | assert((req.port == input) && (req.label == label)); 77 | 78 | _output_arb[output]->AddRequest(req.port, req.label, req.out_pri); 79 | 80 | ++port_iter; 81 | } 82 | 83 | port_iter = _out_occ.begin(); 84 | while(port_iter != _out_occ.end()) { 85 | 86 | const int & output = *port_iter; 87 | 88 | // Execute the output arbiters. 89 | 90 | const int input = _output_arb[output]->Arbitrate(NULL, NULL); 91 | 92 | if(input > -1) { 93 | assert((_inmatch[input] == -1) && (_outmatch[output] == -1)); 94 | 95 | _inmatch[input] = output ; 96 | _outmatch[output] = input ; 97 | _input_arb[input]->UpdateState() ; 98 | _output_arb[output]->UpdateState() ; 99 | } 100 | 101 | ++port_iter; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /booksim2/src/allocators/separable_output_first.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------- 29 | // 30 | // SeparableOutputFirstAllocator: Separable Output-First Allocator 31 | // 32 | // ---------------------------------------------------------------------- 33 | 34 | #include "separable_output_first.hpp" 35 | 36 | #include "booksim.hpp" 37 | #include "arbiter.hpp" 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | SeparableOutputFirstAllocator:: 44 | SeparableOutputFirstAllocator( Module* parent, const string& name, int inputs, 45 | int outputs, const string& arb_type ) 46 | : SeparableAllocator( parent, name, inputs, outputs, arb_type ) 47 | {} 48 | 49 | void SeparableOutputFirstAllocator::Allocate() { 50 | 51 | set::const_iterator port_iter = _out_occ.begin(); 52 | while(port_iter != _out_occ.end()) { 53 | 54 | const int & output = *port_iter; 55 | 56 | // add requests to the output arbiter 57 | 58 | map::const_iterator req_iter = _out_req[output].begin(); 59 | while(req_iter != _out_req[output].end()) { 60 | 61 | const sRequest & req = req_iter->second; 62 | 63 | _output_arb[output]->AddRequest(req.port, req.label, req.out_pri); 64 | 65 | ++req_iter; 66 | } 67 | 68 | // Execute the output arbiter and propagate the grants to the 69 | // input arbiters. 70 | 71 | int label = -1; 72 | const int input = _output_arb[output]->Arbitrate(&label, NULL); 73 | assert(input > -1); 74 | 75 | const sRequest & req = _in_req[input][output]; 76 | assert((req.port == output) && (req.label == label)); 77 | 78 | _input_arb[input]->AddRequest(req.port, req.label, req.in_pri); 79 | 80 | ++port_iter; 81 | } 82 | 83 | port_iter = _in_occ.begin(); 84 | while(port_iter != _in_occ.end()) { 85 | 86 | const int & input = *port_iter; 87 | 88 | // Execute the input arbiters. 89 | 90 | const int output = _input_arb[input]->Arbitrate(NULL, NULL); 91 | 92 | if(output > -1) { 93 | assert((_inmatch[input] == -1) && (_outmatch[output] == -1)); 94 | 95 | _inmatch[input] = output; 96 | _outmatch[output] = input; 97 | _input_arb[input]->UpdateState() ; 98 | _output_arb[output]->UpdateState() ; 99 | } 100 | 101 | ++port_iter; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /booksim2/src/vc.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _VC_HPP_ 29 | #define _VC_HPP_ 30 | 31 | #include 32 | 33 | #include "flit.hpp" 34 | #include "outputset.hpp" 35 | #include "routefunc.hpp" 36 | #include "config_utils.hpp" 37 | 38 | class VC : public Module { 39 | public: 40 | enum eVCState { state_min = 0, idle = state_min, routing, vc_alloc, active, 41 | state_max = active }; 42 | struct state_info_t { 43 | int cycles; 44 | }; 45 | static const char * const VCSTATE[]; 46 | 47 | private: 48 | 49 | deque _buffer; 50 | 51 | eVCState _state; 52 | 53 | OutputSet *_route_set; 54 | int _out_port, _out_vc; 55 | 56 | enum ePrioType { local_age_based, queue_length_based, hop_count_based, none, other }; 57 | 58 | ePrioType _pri_type; 59 | 60 | int _pri; 61 | 62 | int _priority_donation; 63 | 64 | bool _watched; 65 | 66 | int _expected_pid; 67 | 68 | int _last_id; 69 | int _last_pid; 70 | 71 | bool _lookahead_routing; 72 | 73 | public: 74 | 75 | VC( const Configuration& config, int outputs, 76 | Module *parent, const string& name ); 77 | ~VC(); 78 | 79 | void AddFlit( Flit *f ); 80 | inline Flit *FrontFlit( ) const 81 | { 82 | return _buffer.empty() ? NULL : _buffer.front(); 83 | } 84 | 85 | Flit *RemoveFlit( ); 86 | 87 | 88 | inline bool Empty( ) const 89 | { 90 | return _buffer.empty( ); 91 | } 92 | 93 | inline VC::eVCState GetState( ) const 94 | { 95 | return _state; 96 | } 97 | 98 | 99 | void SetState( eVCState s ); 100 | 101 | const OutputSet *GetRouteSet( ) const; 102 | void SetRouteSet( OutputSet * output_set ); 103 | 104 | void SetOutput( int port, int vc ); 105 | 106 | inline int GetOutputPort( ) const 107 | { 108 | return _out_port; 109 | } 110 | 111 | 112 | inline int GetOutputVC( ) const 113 | { 114 | return _out_vc; 115 | } 116 | 117 | void UpdatePriority(); 118 | 119 | inline int GetPriority( ) const 120 | { 121 | return _pri; 122 | } 123 | void Route( tRoutingFunction rf, const Router* router, const Flit* f, int in_channel ); 124 | 125 | inline int GetOccupancy() const 126 | { 127 | return (int)_buffer.size(); 128 | } 129 | 130 | // ==== Debug functions ==== 131 | 132 | void SetWatch( bool watch = true ); 133 | bool IsWatched( ) const; 134 | void Display( ostream & os = cout ) const; 135 | }; 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /booksim2/src/channel.hpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | ////////////////////////////////////////////////////////////////////// 29 | // 30 | // File Name: channel.hpp 31 | // 32 | // The Channel models a generic channel with a multi-cycle 33 | // transmission delay. The channel latency can be specified as 34 | // an integer number of simulator cycles. 35 | // 36 | ///// 37 | #ifndef _CHANNEL_HPP 38 | #define _CHANNEL_HPP 39 | 40 | #include 41 | #include 42 | 43 | #include "globals.hpp" 44 | #include "module.hpp" 45 | #include "timed_module.hpp" 46 | 47 | using namespace std; 48 | 49 | template 50 | class Channel : public TimedModule { 51 | public: 52 | Channel(Module * parent, string const & name); 53 | virtual ~Channel() {} 54 | 55 | // Physical Parameters 56 | void SetLatency(int cycles); 57 | int GetLatency() const { return _delay ; } 58 | 59 | // Send data 60 | virtual void Send(T * data); 61 | 62 | // Receive data 63 | virtual T * Receive(); 64 | 65 | virtual void ReadInputs(); 66 | virtual void Evaluate() {} 67 | virtual void WriteOutputs(); 68 | 69 | protected: 70 | int _delay; 71 | T * _input; 72 | T * _output; 73 | queue > _wait_queue; 74 | 75 | }; 76 | 77 | template 78 | Channel::Channel(Module * parent, string const & name) 79 | : TimedModule(parent, name), _delay(1), _input(0), _output(0) { 80 | } 81 | 82 | template 83 | void Channel::SetLatency(int cycles) { 84 | if(cycles <= 0) { 85 | Error("Channel must have positive delay."); 86 | } 87 | _delay = cycles ; 88 | } 89 | 90 | template 91 | void Channel::Send(T * data) { 92 | _input = data; 93 | } 94 | 95 | template 96 | T * Channel::Receive() { 97 | return _output; 98 | } 99 | 100 | template 101 | void Channel::ReadInputs() { 102 | if(_input) { 103 | _wait_queue.push(make_pair(GetSimTime() + _delay - 1, _input)); 104 | _input = 0; 105 | } 106 | } 107 | 108 | template 109 | void Channel::WriteOutputs() { 110 | _output = 0; 111 | if(_wait_queue.empty()) { 112 | return; 113 | } 114 | pair const & item = _wait_queue.front(); 115 | int const & time = item.first; 116 | if(GetSimTime() < time) { 117 | return; 118 | } 119 | assert(GetSimTime() == time); 120 | _output = item.second; 121 | assert(_output); 122 | _wait_queue.pop(); 123 | } 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /booksim2/src/stats.cpp: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | 3 | /* 4 | Copyright (c) 2007-2015, Trustees of The Leland Stanford Junior University 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /*stats.cpp 29 | * 30 | *class stores statistics gnerated by the trafficmanager such as the latency 31 | *hope count of the the flits 32 | * 33 | *reset option resets the min and max alues of this statistiscs 34 | */ 35 | 36 | #include "booksim.hpp" 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include "stats.hpp" 44 | 45 | Stats::Stats( Module *parent, const string &name, 46 | double bin_size, int num_bins ) : 47 | Module( parent, name ), _num_bins( num_bins ), _bin_size( bin_size ) 48 | { 49 | Clear(); 50 | } 51 | 52 | void Stats::Clear( ) 53 | { 54 | _num_samples = 0; 55 | _sample_sum = 0.0; 56 | _sample_squared_sum = 0.0; 57 | 58 | _hist.assign(_num_bins, 0); 59 | 60 | _min = numeric_limits::quiet_NaN(); 61 | _max = -numeric_limits::quiet_NaN(); 62 | 63 | // _reset = true; 64 | } 65 | 66 | double Stats::Average( ) const 67 | { 68 | return _sample_sum / (double)_num_samples; 69 | } 70 | 71 | double Stats::Variance( ) const 72 | { 73 | return (_sample_squared_sum * (double)_num_samples - _sample_sum * _sample_sum) / ((double)_num_samples * (double)_num_samples); 74 | } 75 | 76 | double Stats::Min( ) const 77 | { 78 | return _min; 79 | } 80 | 81 | double Stats::Max( ) const 82 | { 83 | return _max; 84 | } 85 | 86 | double Stats::Sum( ) const 87 | { 88 | return _sample_sum; 89 | } 90 | 91 | double Stats::SquaredSum( ) const 92 | { 93 | return _sample_squared_sum; 94 | } 95 | 96 | int Stats::NumSamples( ) const 97 | { 98 | return _num_samples; 99 | } 100 | 101 | void Stats::AddSample( double val ) 102 | { 103 | ++_num_samples; 104 | _sample_sum += val; 105 | 106 | // NOTE: the negation ensures that NaN values are handled correctly! 107 | _max = !(val <= _max) ? val : _max; 108 | _min = !(val >= _min) ? val : _min; 109 | 110 | //double clamp between 0 and num_bins-1 111 | int b = (int)fmax(floor( val / _bin_size ), 0.0); 112 | b = (b >= _num_bins) ? (_num_bins - 1) : b; 113 | 114 | _hist[b]++; 115 | } 116 | 117 | void Stats::Display( ostream & os ) const 118 | { 119 | os << *this << endl; 120 | } 121 | 122 | ostream & operator<<(ostream & os, const Stats & s) { 123 | vector const & v = s._hist; 124 | os << "[ "; 125 | for(size_t i = 0; i < v.size(); ++i) { 126 | os << v[i] << " "; 127 | } 128 | os << "]"; 129 | return os; 130 | } 131 | -------------------------------------------------------------------------------- /generate_chiplet.py: -------------------------------------------------------------------------------- 1 | # Import python libraries 2 | import sys 3 | import math 4 | 5 | # Generate a chiplet 6 | # Currently supported PHY placements are: 4PHY_Corner, 4PHY_Edge, 6PHY_HM, 8PHY_OM, and xPHY_yPHY 7 | def generate_chiplet(params, phy_placement): 8 | # Get the number of PHYs to compute the chiplet area 9 | phy_count_map = {"4PHY_Corner" : 4, "4PHY_Edge" : 4, "6PHY_HM" : 6, "8PHY_OM" : 8} 10 | # For PHY placements 4PHY_Corner, 4PHY_Edge, 6PHY_HM, and 8PHY_OM 11 | if phy_placement in phy_count_map: 12 | n_phys = phy_count_map[phy_placement] 13 | # For PHY placement "xPHY_yPHY" 14 | else: 15 | try: 16 | (x,y) = phy_placement.replace("PHY","").split("_") 17 | (x, y) = (int(x), int(y)) 18 | n_phys = x + y 19 | except: 20 | print("Error: Invalid PHY placement \"%s\"" % phy_placement) 21 | sys.exit(1) 22 | # Compute the chiplet area 23 | area = params["base_chiplet_area"] + n_phys * params["phy_area"] 24 | power = params["base_chiplet_power"] + n_phys * params["phy_power"] 25 | # Compute the PHY positions. We specify the center of the PHY with the bottom-left corner of the chiplet as origin 26 | phys = [] 27 | a = math.sqrt(area) # Side length of the square chiplet 28 | fp = params["fraction_power_bumps"] 29 | if phy_placement == "4PHY_Corner": 30 | p = math.sqrt(a**2 * (1 - fp)) / 4 31 | phys.append({"x" : p, "y" : p}) # South-west ID 0 32 | phys.append({"x" : p, "y" : a-p}) # North-west ID 1 33 | phys.append({"x" : a-p, "y" : a-p}) # North-east ID 2 34 | phys.append({"x" : a-p, "y" : p}) # South-east ID 3 35 | elif phy_placement == "4PHY_Edge": 36 | p = (a * (1 - math.sqrt(fp))) / 4 37 | phys.append({"x" : p, "y" : a/2}) # West ID 0 38 | phys.append({"x" : a/2, "y" : a-p}) # North ID 1 39 | phys.append({"x" : a-p, "y" : a/2}) # East ID 2 40 | phys.append({"x" : a/2, "y" : p}) # South ID 3 41 | elif phy_placement == "6PHY_HM": 42 | p1 = (a * (1 - fp)) / 6 43 | p2 = (a * (1 - fp)) / (4 + 8 * fp) 44 | phys.append({"x" : p2, "y" : a/2}) # West ID 0 45 | phys.append({"x" : a/4, "y" : a-p1}) # North-west ID 1 46 | phys.append({"x" : 3*a/4, "y" : a-p1}) # North-east ID 2 47 | phys.append({"x" : a - p2, "y" : a/2}) # East ID 3 48 | phys.append({"x" : 3*a/4, "y" : p1}) # South-east ID 4 49 | phys.append({"x" : a/4, "y" : p1}) # South-west ID 5 50 | elif phy_placement == "8PHY_OM": 51 | p1 = math.sqrt((a**2 * (1 - fp)) / 32) 52 | p2 = (a * (1 - fp)) / (16 - 8 * math.sqrt(2 - 2 * fp)) 53 | phys.append({"x" : p1, "y" : p1}) # South-West ID 0 54 | phys.append({"x" : p2, "y" : a/2}) # West ID 1 55 | phys.append({"x" : p1, "y" : a-p1}) # North-West ID 2 56 | phys.append({"x" : a/2, "y" : a-p2}) # North ID 3 57 | phys.append({"x" : a-p1, "y" : a-p1}) # North-East ID 4 58 | phys.append({"x" : a-p2, "y" : a/2}) # East ID 5 59 | phys.append({"x" : a-p1, "y" : p1}) # South-East ID 6 60 | phys.append({"x" : a/2, "y" : p2}) # South ID 7 61 | # This must be the "xPHY_yPHY" case 62 | else: 63 | p1 = (a * x * (1-fp)) / (2 * (x + y)) 64 | p2 = (a * y * (1-fp)) / (2 * y + 2 * x * fp) 65 | r = a - 2 * p1 66 | # South (IDs 0 to x-1) 67 | for i in range(x): 68 | phys.append({"x" : a / (2 * x) + i * (a / x), "y" : p1}) 69 | # East (IDs x to x+y-1) 70 | for i in range(y): 71 | phys.append({"x" : a - p2, "y" : 2 * p1 + r / (2 * y) + i * (r / y)}) 72 | # Add the fraction of bumps used by each phy 73 | for phy in phys: 74 | phy["fraction_bump_area"] = 1.0 / len(phys) 75 | # Create the chiplet 76 | chiplet = { 77 | "dimensions" : {"x" : a, "y" : a}, 78 | "type" : params["chiplet_type"], 79 | "phys" : phys, 80 | "fraction_power_bumps" : params["fraction_power_bumps"], 81 | "technology" : params["technology"], 82 | "power" : power, 83 | "relay" : params["chiplets_can_relay"], 84 | "internal_latency" : params["internal_latency"], 85 | "unit_count" : params["units_per_chiplet"], 86 | } 87 | # Return the chiplet 88 | return chiplet 89 | --------------------------------------------------------------------------------