├── runall.sh ├── run_figure7_100_times.sh ├── XRbench_evaluation ├── plots │ ├── 4K │ │ ├── AR_gaming.pdf │ │ ├── VR_gaming.pdf │ │ ├── AR_Assistant.pdf │ │ ├── gross_average.pdf │ │ ├── outdoor_activity_A.pdf │ │ ├── outdoor_activity_B.pdf │ │ ├── social_interactionA.pdf │ │ └── social_interactionB.pdf │ ├── 8K │ │ ├── AR_gaming.pdf │ │ ├── VR_gaming.pdf │ │ ├── AR_Assistant.pdf │ │ ├── gross_average.pdf │ │ ├── outdoor_activity_A.pdf │ │ ├── outdoor_activity_B.pdf │ │ ├── social_interactionA.pdf │ │ └── social_interactionB.pdf │ ├── figure7_base.pdf │ ├── AR_gaming___Dual_4K__WS_OS.pdf │ └── AR_gaming___Dual_8K__WS_OS.pdf ├── eval_data │ └── summary │ │ └── summary_VR_gaming__Single_4K__WS.csv ├── dataflows │ ├── single │ │ ├── OS.m │ │ ├── WS.m │ │ └── RS.m │ ├── dual │ │ ├── OS_OS.m │ │ ├── WS_OS.m │ │ ├── WS_WS.m │ │ └── RS_RS.m │ ├── Not_Used │ │ ├── RS_OS.m │ │ ├── WS_RS.m │ │ ├── WS_RS_WS_RS.m │ │ ├── RS_OS_RS_OS.m │ │ └── WS_RS_Dataflow.m │ └── quad │ │ ├── OS_OS_OS_OS.m │ │ ├── WS_OS_WS_OS.m │ │ ├── WS_WS_WS_WS.m │ │ └── RS_RS_RS_RS.m ├── hw_configs │ ├── single │ │ ├── Single_4K.m │ │ └── Single_8K.m │ ├── Not_Used │ │ ├── Single_2K.m │ │ ├── Single_16K.m │ │ ├── Dual_2K.m │ │ ├── Dual_16K.m │ │ ├── Dual_16K_BigLittle.m │ │ ├── Dual_16K_LittleBig.m │ │ ├── Quad_2K.m │ │ └── Quad_16K.m │ ├── dual │ │ ├── Dual_4K.m │ │ ├── Dual_8K.m │ │ ├── Dual_4K_BigLittle.m │ │ ├── Dual_4K_LittleBig.m │ │ ├── Dual_8K_BigLittle.m │ │ └── Dual_8K_LittleBig.m │ └── quad │ │ ├── Quad_4K.m │ │ └── Quad_8K.m └── scripts │ ├── draw_timeline.py │ ├── run_evals.py │ └── generate_figure7.py ├── reproduce_figure5.sh ├── lib ├── include │ ├── design-space-exploration │ │ ├── DSE_design-options.hpp │ │ ├── DSE_config.hpp │ │ ├── DSE_scaling-coefficients.hpp │ │ ├── DSE_cost-database.hpp │ │ └── DSE_design_point.hpp │ ├── cost-analysis │ │ ├── CA_analysis-types.hpp │ │ ├── CA_iteration-analysis.hpp │ │ └── CA_iterations.hpp │ ├── heterogeneous-space-exploration │ │ ├── HET_keywords.hpp │ │ ├── HET_integrated-parsers.hpp │ │ ├── HET_process.hpp │ │ ├── HET_inference-request.hpp │ │ ├── HET_timeline-extractor.hpp │ │ ├── HET_summary-generator.hpp │ │ ├── HET_timer.hpp │ │ ├── HET_task.hpp │ │ ├── HET_load-generator.hpp │ │ ├── HET_logger.hpp │ │ ├── HET_scoring-module.hpp │ │ └── HET_configuration.hpp │ ├── base │ │ ├── BASE_base-objects.hpp │ │ ├── BASE_constants.hpp │ │ └── BASE_maestro-class.hpp │ ├── tools │ │ ├── TL_analysis-results-csv-writer.hpp │ │ ├── TL_message-printer.hpp │ │ ├── TL_generic-csv-writer.hpp │ │ └── TL_error-handler.hpp │ ├── dataflow-analysis │ │ ├── DFA_analysis-output.hpp │ │ ├── DFA_tensor.hpp │ │ ├── DFA_dimension-overlap-info-table.hpp │ │ ├── DFA_cluster-table.hpp │ │ ├── DFA_neural-network.hpp │ │ ├── DFA_tensor-table.hpp │ │ ├── DFA_directive-table.hpp │ │ ├── DFA_dimension-table.hpp │ │ └── DFA_directives.hpp │ ├── abstract-hardware-model │ │ ├── AHW-pe-array.hpp │ │ ├── AHW-pe-model.hpp │ │ ├── AHW_Accelerator.hpp │ │ └── AHW-noc-model.hpp │ ├── user-api │ │ └── API_configuration.hpp │ └── dataflow-specification-language │ │ └── DFSL_syntax_tokens.hpp ├── SConscript └── src │ └── BASE_base-objects.cpp ├── draw_timeline.sh ├── .gitignore ├── SConstruct ├── LICENSE ├── README.md ├── reproduce_figure6.sh ├── process_figure7_data.py └── reproduce_figure7_data.sh /runall.sh: -------------------------------------------------------------------------------- 1 | ./reproduce_figure5.sh 2 | ./reproduce_figure6.sh 3 | ./reproduce_figure7_data.sh 4 | -------------------------------------------------------------------------------- /run_figure7_100_times.sh: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | for (( i = 1; i<= 100; i++ )) 6 | do 7 | ./reproduce_figure7_data.sh 8 | done 9 | -------------------------------------------------------------------------------- /XRbench_evaluation/plots/4K/AR_gaming.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/4K/AR_gaming.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/4K/VR_gaming.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/4K/VR_gaming.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/8K/AR_gaming.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/8K/AR_gaming.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/8K/VR_gaming.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/8K/VR_gaming.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/figure7_base.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/figure7_base.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/4K/AR_Assistant.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/4K/AR_Assistant.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/4K/gross_average.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/4K/gross_average.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/8K/AR_Assistant.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/8K/AR_Assistant.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/8K/gross_average.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/8K/gross_average.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/4K/outdoor_activity_A.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/4K/outdoor_activity_A.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/4K/outdoor_activity_B.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/4K/outdoor_activity_B.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/4K/social_interactionA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/4K/social_interactionA.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/4K/social_interactionB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/4K/social_interactionB.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/8K/outdoor_activity_A.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/8K/outdoor_activity_A.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/8K/outdoor_activity_B.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/8K/outdoor_activity_B.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/8K/social_interactionA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/8K/social_interactionA.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/8K/social_interactionB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/8K/social_interactionB.pdf -------------------------------------------------------------------------------- /reproduce_figure5.sh: -------------------------------------------------------------------------------- 1 | 2 | 3 | python3.10 ./XRbench_evaluation/scripts/run_evals.py 4 | python3.10 ./XRbench_evaluation/scripts/generate_plots.py 5 | 6 | 7 | -------------------------------------------------------------------------------- /XRbench_evaluation/plots/AR_gaming___Dual_4K__WS_OS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/AR_gaming___Dual_4K__WS_OS.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/plots/AR_gaming___Dual_8K__WS_OS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XRBench/XRBench-MLSys2023/HEAD/XRbench_evaluation/plots/AR_gaming___Dual_8K__WS_OS.pdf -------------------------------------------------------------------------------- /XRbench_evaluation/eval_data/summary/summary_VR_gaming__Single_4K__WS.csv: -------------------------------------------------------------------------------- 1 | Model Name,Real-time Score,Energy Score,User-Experience Score 2 | ES_RITNet,1.000000,0.976447,1.000000 3 | GE_FBNet_C,1.000000,0.976719,1.000000 4 | HT_hand_graph_cnn_half,0.743658,0.861711,1.000000 5 | Overall Score,86.466141 6 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/single/OS.m: -------------------------------------------------------------------------------- 1 | // Hand-optimized OS 2 | Dataflow { 3 | TemporalMap(1,1) K; 4 | SpatialMap(1,1) Y'; //' 5 | TemporalMap(4,4) X'; //' 6 | TemporalMap(16,16) C; 7 | Cluster(4,P); 8 | SpatialMap(1,1) X'; //' 9 | Cluster(16, P); 10 | SpatialMap(1,1) C; 11 | } 12 | -------------------------------------------------------------------------------- /lib/include/design-space-exploration/DSE_design-options.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MAESTRO_DSE_DESIGN_OPTIONS_HPP_ 2 | #define MAESTRO_DSE_DESIGN_OPTIONS_HPP_ 3 | 4 | namespace maestro { 5 | 6 | namespace DSE { 7 | 8 | enum class OpType{FloatPoint, FixedPoint}; 9 | }; // End of namespace DSE 10 | }; // End of namesapce maestro 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/single/WS.m: -------------------------------------------------------------------------------- 1 | // NVDLA 2 | Dataflow { 3 | TemporalMap(16,16) C; 4 | TemporalMap(16,16) K; 5 | TemporalMap(1,1) Y'; //' 6 | SpatialMap(1,1) X'; //' 7 | Cluster(16,P); 8 | SpatialMap(1,1) K; 9 | TemporalMap(64,64) C; 10 | TemporalMap(1,1) Y'; 11 | TemporalMap(1,1) X'; 12 | Cluster(16, P); 13 | SpatialMap(1,1) C; 14 | } 15 | -------------------------------------------------------------------------------- /draw_timeline.sh: -------------------------------------------------------------------------------- 1 | 2 | python3 XRbench_evaluation/scripts/draw_timeline.py XRbench_evaluation/eval_data/schedule/schedule_AR_gaming__Dual_4K__WS_OS.csv XRbench_evaluation/plots/AR_gaming___Dual_4K__WS_OS.pdf 2 520 3 | python3 XRbench_evaluation/scripts/draw_timeline.py XRbench_evaluation/eval_data/schedule/schedule_AR_gaming__Dual_8K__WS_OS.csv XRbench_evaluation/plots/AR_gaming___Dual_8K__WS_OS.pdf 2 520 4 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/single/Single_4K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_4K { 5 | num_pes: 4096 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/Not_Used/Single_2K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_4K { 5 | num_pes: 2048 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/single/Single_8K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_8K { 5 | num_pes: 8192 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 8388608 // 8 MiB 14 | PE_local_memory: 16384 // 16KiB 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/single/RS.m: -------------------------------------------------------------------------------- 1 | // Hand-optimized row-stationary 2 | Dataflow { 3 | TemporalMap(1,1) Y'; // ' 4 | TemporalMap(16,16) X'; //' 5 | TemporalMap(4,4) C; 6 | SpatialMap(1,1) K; 7 | Cluster(16,P); 8 | TemporalMap(1,1) Y'; 9 | SpatialMap(1,1) X'; 10 | TemporalMap(4,4) C; 11 | TemporalMap(1,1) K; 12 | Cluster(4,P); 13 | SpatialMap(1,1) Y; 14 | SpatialMap(1,1) R; 15 | } 16 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/Not_Used/Single_16K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_16K { 5 | num_pes: 16384 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 8388608 // 8 MiB 14 | PE_local_memory: 16384 // 16KiB 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /lib/include/cost-analysis/CA_analysis-types.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MAESTRO_CA_ANALYSIS_TYPES_HPP_ 2 | #define MAESTRO_CA_ANALYSIS_TYPES_HPP_ 3 | 4 | 5 | namespace maestro { 6 | namespace CA { 7 | 8 | enum class IterationStatus {Init, Steady, Edge, Unroll, InitEdge, InitUnroll, InitEdgeSpEdge, EdgeSpEdge, NumIterStatus}; 9 | enum class EstimationType {Min, Max, Exact, NumEstimationTypes}; 10 | const int num_iter_status = 3; 11 | 12 | }; 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /lib/SConscript: -------------------------------------------------------------------------------- 1 | 2 | Import ('env') 3 | 4 | env.Append(CPPPATH = ['./lib/include/', 5 | './lib/include/DFSL', 6 | './lib/include/DSE', 7 | './lib/include/DFA', 8 | './lib/include/AHW-model', 9 | './lib/src/']) 10 | 11 | #env.Append(CXXFLAGS=['-std=c++17', '-lboost_program_options' ]) 12 | env.Append(CXXFLAGS=['-std=c++17']) 13 | #env.Append(LINKFLAGS=['-lboost_program_options']) 14 | 15 | print "cc" 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # MAC-specific files 35 | .DS_Store 36 | 37 | # Scons 38 | .sconsign.dblite 39 | 40 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/dual/OS_OS.m: -------------------------------------------------------------------------------- 1 | // Hand-optimized OS 2 | Dataflow { 3 | TemporalMap(1,1) K; 4 | SpatialMap(1,1) Y'; //' 5 | TemporalMap(4,4) X'; //' 6 | TemporalMap(16,16) C; 7 | Cluster(4,P); 8 | SpatialMap(1,1) X'; //' 9 | Cluster(16, P); 10 | SpatialMap(1,1) C; 11 | } 12 | 13 | // Hand-optimized OS 14 | Dataflow { 15 | TemporalMap(1,1) K; 16 | SpatialMap(1,1) Y'; //' 17 | TemporalMap(4,4) X'; //' 18 | TemporalMap(16,16) C; 19 | Cluster(4,P); 20 | SpatialMap(1,1) X'; //' 21 | Cluster(16, P); 22 | SpatialMap(1,1) C; 23 | } 24 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/dual/WS_OS.m: -------------------------------------------------------------------------------- 1 | // NVDLA 2 | Dataflow { 3 | TemporalMap(16,16) C; 4 | TemporalMap(16,16) K; 5 | TemporalMap(1,1) Y'; //' 6 | SpatialMap(1,1) X'; //' 7 | Cluster(16,P); 8 | SpatialMap(1,1) K; 9 | TemporalMap(64,64) C; 10 | TemporalMap(1,1) Y'; 11 | TemporalMap(1,1) X'; 12 | Cluster(16, P); 13 | SpatialMap(1,1) C; 14 | } 15 | 16 | // Hand-optimized OS 17 | Dataflow { 18 | TemporalMap(1,1) K; 19 | SpatialMap(1,1) Y'; //' 20 | TemporalMap(4,4) X'; //' 21 | TemporalMap(16,16) C; 22 | Cluster(4,P); 23 | SpatialMap(1,1) X'; //' 24 | Cluster(16, P); 25 | SpatialMap(1,1) C; 26 | } 27 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/Not_Used/RS_OS.m: -------------------------------------------------------------------------------- 1 | // Hand-optimized row-stationary 2 | Dataflow { 3 | TemporalMap(1,1) Y'; // ' 4 | TemporalMap(16,16) X'; //' 5 | TemporalMap(4,4) C; 6 | SpatialMap(1,1) K; 7 | Cluster(16,P); 8 | TemporalMap(1,1) Y'; 9 | SpatialMap(1,1) X'; 10 | TemporalMap(4,4) C; 11 | TemporalMap(1,1) K; 12 | Cluster(4,P); 13 | SpatialMap(1,1) Y; 14 | SpatialMap(1,1) R; 15 | } 16 | 17 | 18 | // Hand-optimized OS 19 | Dataflow { 20 | TemporalMap(1,1) K; 21 | SpatialMap(1,1) Y'; //' 22 | TemporalMap(4,4) X'; //' 23 | TemporalMap(16,16) C; 24 | Cluster(4,P); 25 | SpatialMap(1,1) X'; //' 26 | Cluster(16, P); 27 | SpatialMap(1,1) C; 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/dual/Dual_4K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_2K { 5 | num_pes: 2048 6 | offchip_bw: 128 7 | top_noc_bw: 128 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 128 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 2097152 // 2 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | Accelerator Acc1_2K { 18 | num_pes: 2048 19 | offchip_bw: 128 20 | top_noc_bw: 128 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 128 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 2097152 // 2 MiB 27 | PE_local_memory: 8192 // 8KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/Not_Used/Dual_2K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_1K { 5 | num_pes: 1024 6 | offchip_bw: 128 7 | top_noc_bw: 128 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 128 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 2097152 // 2 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | Accelerator Acc1_1K { 18 | num_pes: 1024 19 | offchip_bw: 128 20 | top_noc_bw: 128 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 128 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 2097152 // 2 MiB 27 | PE_local_memory: 8192 // 8KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/dual/Dual_8K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_4K { 5 | num_pes: 4096 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 16384 // 16KiB 15 | } 16 | 17 | Accelerator Acc1_4K { 18 | num_pes: 4096 19 | offchip_bw: 128 20 | top_noc_bw: 256 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 256 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 4194304 // 4 MiB 27 | PE_local_memory: 16384 // 16KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/Not_Used/Dual_16K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_8K { 5 | num_pes: 8192 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 16384 // 16KiB 15 | } 16 | 17 | Accelerator Acc1_8K { 18 | num_pes: 8192 19 | offchip_bw: 128 20 | top_noc_bw: 256 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 256 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 4194304 // 4 MiB 27 | PE_local_memory: 16384 // 16KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/dual/Dual_4K_BigLittle.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_2K { 5 | num_pes: 3072 6 | offchip_bw: 128 7 | top_noc_bw: 128 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 128 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 2097152 // 2 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | Accelerator Acc1_2K { 18 | num_pes: 1024 19 | offchip_bw: 128 20 | top_noc_bw: 128 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 128 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 2097152 // 2 MiB 27 | PE_local_memory: 8192 // 8KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/dual/Dual_4K_LittleBig.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_2K { 5 | num_pes: 1024 6 | offchip_bw: 128 7 | top_noc_bw: 128 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 128 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 2097152 // 2 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | Accelerator Acc1_2K { 18 | num_pes: 3072 19 | offchip_bw: 128 20 | top_noc_bw: 128 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 128 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 2097152 // 2 MiB 27 | PE_local_memory: 8192 // 8KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/dual/WS_WS.m: -------------------------------------------------------------------------------- 1 | // NVDLA 2 | Dataflow { 3 | TemporalMap(16,16) C; 4 | TemporalMap(16,16) K; 5 | TemporalMap(1,1) Y'; //' 6 | SpatialMap(1,1) X'; //' 7 | Cluster(16,P); 8 | SpatialMap(1,1) K; 9 | TemporalMap(64,64) C; 10 | TemporalMap(1,1) Y'; 11 | TemporalMap(1,1) X'; 12 | Cluster(16, P); 13 | SpatialMap(1,1) C; 14 | } 15 | 16 | // NVDLA 17 | Dataflow { 18 | TemporalMap(16,16) C; 19 | TemporalMap(16,16) K; 20 | TemporalMap(1,1) Y'; //' 21 | SpatialMap(1,1) X'; //' 22 | Cluster(16,P); 23 | SpatialMap(1,1) K; 24 | TemporalMap(64,64) C; 25 | TemporalMap(1,1) Y'; 26 | TemporalMap(1,1) X'; 27 | Cluster(16, P); 28 | SpatialMap(1,1) C; 29 | } 30 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/dual/Dual_8K_BigLittle.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_4K { 5 | num_pes: 6144 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 16384 // 16KiB 15 | } 16 | 17 | Accelerator Acc1_4K { 18 | num_pes: 2048 19 | offchip_bw: 128 20 | top_noc_bw: 256 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 256 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 4194304 // 4 MiB 27 | PE_local_memory: 16384 // 16KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/dual/Dual_8K_LittleBig.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | Accelerator Acc1_4K { 4 | num_pes: 2048 5 | offchip_bw: 128 6 | top_noc_bw: 256 7 | top_noc_latency: 1 8 | top_noc_multicast: True 9 | col_noc_bw: 256 10 | col_noc_latency: 1 11 | col_noc_multicast: True 12 | global_shared_memory: 4194304 // 4 MiB 13 | PE_local_memory: 16384 // 16KiB 14 | } 15 | 16 | Accelerator Acc0_4K { 17 | num_pes: 6144 18 | offchip_bw: 128 19 | top_noc_bw: 256 20 | top_noc_latency: 1 21 | top_noc_multicast: True 22 | col_noc_bw: 256 23 | col_noc_latency: 1 24 | col_noc_multicast: True 25 | global_shared_memory: 4194304 // 4 MiB 26 | PE_local_memory: 16384 // 16KiB 27 | } 28 | 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/Not_Used/Dual_16K_BigLittle.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_12K { 5 | num_pes: 12576 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 16384 // 16KiB 15 | } 16 | 17 | Accelerator Acc1_4K { 18 | num_pes: 4096 19 | offchip_bw: 128 20 | top_noc_bw: 256 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 256 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 4194304 // 4 MiB 27 | PE_local_memory: 16384 // 16KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/Not_Used/Dual_16K_LittleBig.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_4K { 5 | num_pes: 4096 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 16384 // 16KiB 15 | } 16 | 17 | Accelerator Acc1_12K { 18 | num_pes: 12576 19 | offchip_bw: 128 20 | top_noc_bw: 256 21 | top_noc_latency: 1 22 | top_noc_multicast: True 23 | col_noc_bw: 256 24 | col_noc_latency: 1 25 | col_noc_multicast: True 26 | global_shared_memory: 4194304 // 4 MiB 27 | PE_local_memory: 16384 // 16KiB 28 | } 29 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/Not_Used/WS_RS.m: -------------------------------------------------------------------------------- 1 | // NVDLA 2 | Dataflow { 3 | TemporalMap(16,16) C; 4 | TemporalMap(16,16) K; 5 | TemporalMap(1,1) Y'; //' 6 | SpatialMap(1,1) X'; //' 7 | Cluster(16,P); 8 | SpatialMap(1,1) K; 9 | TemporalMap(64,64) C; 10 | TemporalMap(1,1) Y'; 11 | TemporalMap(1,1) X'; 12 | Cluster(16, P); 13 | SpatialMap(1,1) C; 14 | } 15 | 16 | // Hand-optimized row-stationary 17 | Dataflow { 18 | TemporalMap(1,1) Y'; // ' 19 | TemporalMap(16,16) X'; //' 20 | TemporalMap(4,4) C; 21 | SpatialMap(1,1) K; 22 | Cluster(16,P); 23 | TemporalMap(1,1) Y'; 24 | SpatialMap(1,1) X'; 25 | TemporalMap(4,4) C; 26 | TemporalMap(1,1) K; 27 | Cluster(4,P); 28 | SpatialMap(1,1) Y; 29 | SpatialMap(1,1) R; 30 | } 31 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/dual/RS_RS.m: -------------------------------------------------------------------------------- 1 | // Hand-optimized row-stationary 2 | Dataflow { 3 | TemporalMap(1,1) Y'; // ' 4 | TemporalMap(16,16) X'; //' 5 | TemporalMap(4,4) C; 6 | SpatialMap(1,1) K; 7 | Cluster(16,P); 8 | TemporalMap(1,1) Y'; 9 | SpatialMap(1,1) X'; 10 | TemporalMap(4,4) C; 11 | TemporalMap(1,1) K; 12 | Cluster(4,P); 13 | SpatialMap(1,1) Y; 14 | SpatialMap(1,1) R; 15 | } 16 | 17 | // Hand-optimized row-stationary 18 | Dataflow { 19 | TemporalMap(1,1) Y'; // ' 20 | TemporalMap(16,16) X'; //' 21 | TemporalMap(4,4) C; 22 | SpatialMap(1,1) K; 23 | Cluster(16,P); 24 | TemporalMap(1,1) Y'; 25 | SpatialMap(1,1) X'; 26 | TemporalMap(4,4) C; 27 | TemporalMap(1,1) K; 28 | Cluster(4,P); 29 | SpatialMap(1,1) Y; 30 | SpatialMap(1,1) R; 31 | } 32 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/quad/OS_OS_OS_OS.m: -------------------------------------------------------------------------------- 1 | // Hand-optimized OS 2 | Dataflow { 3 | TemporalMap(1,1) K; 4 | SpatialMap(1,1) Y'; //' 5 | TemporalMap(4,4) X'; //' 6 | TemporalMap(16,16) C; 7 | Cluster(4,P); 8 | SpatialMap(1,1) X'; //' 9 | Cluster(16, P); 10 | SpatialMap(1,1) C; 11 | } 12 | 13 | // Hand-optimized OS 14 | Dataflow { 15 | TemporalMap(1,1) K; 16 | SpatialMap(1,1) Y'; //' 17 | TemporalMap(4,4) X'; //' 18 | TemporalMap(16,16) C; 19 | Cluster(4,P); 20 | SpatialMap(1,1) X'; //' 21 | Cluster(16, P); 22 | SpatialMap(1,1) C; 23 | } 24 | 25 | // Hand-optimized OS 26 | Dataflow { 27 | TemporalMap(1,1) K; 28 | SpatialMap(1,1) Y'; //' 29 | TemporalMap(4,4) X'; //' 30 | TemporalMap(16,16) C; 31 | Cluster(4,P); 32 | SpatialMap(1,1) X'; //' 33 | Cluster(16, P); 34 | SpatialMap(1,1) C; 35 | } 36 | 37 | // Hand-optimized OS 38 | Dataflow { 39 | TemporalMap(1,1) K; 40 | SpatialMap(1,1) Y'; //' 41 | TemporalMap(4,4) X'; //' 42 | TemporalMap(16,16) C; 43 | Cluster(4,P); 44 | SpatialMap(1,1) X'; //' 45 | Cluster(16, P); 46 | SpatialMap(1,1) C; 47 | } 48 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | 2 | env = Environment() 3 | 4 | includes = ''' 5 | . 6 | ./lib/include 7 | ./lib/include/base 8 | ./lib/include/tools 9 | ./lib/include/user-api 10 | ./lib/include/dataflow-analysis 11 | ./lib/include/dataflow-specification-language 12 | ./lib/include/design-space-exploration 13 | ./lib/include/cost-analysis 14 | ./lib/include/abstract-hardware-model 15 | ./lib/include/heterogeneous-space-exploration 16 | ./lib/src 17 | /opt/homebrew/Cellar/boost/1.81.0_1/include 18 | ''' 19 | 20 | env.Append(LINKFLAGS=['-L/opt/homebrew/lib', '-lboost_program_options', '-lboost_filesystem', '-lboost_system']) 21 | env.Append(CXXFLAGS=['-std=c++17', '-lboost_program_options', '-lboost_filesystem', '-lboost_system', '-O2']) 22 | env.Append(LIBS=['-lboost_program_options', '-lboost_filesystem', '-lboost_system' ]) 23 | 24 | env.Append(CPPPATH = Split(includes)) 25 | env.Program('maestro', ['XRBench-MAESTRO.cpp', 'lib/src/BASE_base-objects.cpp' ]) 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 XRBench 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/Not_Used/WS_RS_WS_RS.m: -------------------------------------------------------------------------------- 1 | // NVDLA 2 | Dataflow { 3 | SpatialMap(1,1) K; 4 | TemporalMap(64,64) C; 5 | TemporalMap(1,1) Y'; 6 | TemporalMap(1,1) X'; 7 | Cluster(64, P); 8 | SpatialMap(1,1) C; 9 | } 10 | 11 | // Hand-optimized row-stationary 12 | Dataflow { 13 | TemporalMap(1,1) Y'; // ' 14 | TemporalMap(16,16) X'; //' 15 | TemporalMap(1,1) K; 16 | SpatialMap(1,1) C; 17 | Cluster(16,P); 18 | TemporalMap(1,1) Y'; 19 | SpatialMap(1,1) X'; 20 | TemporalMap(1,1) K; 21 | TemporalMap(1,1) C; 22 | Cluster(8,P); 23 | SpatialMap(1,1) Y; 24 | SpatialMap(1,1) R; 25 | } 26 | 27 | 28 | // NVDLA 29 | Dataflow { 30 | SpatialMap(1,1) K; 31 | TemporalMap(64,64) C; 32 | TemporalMap(1,1) Y'; 33 | TemporalMap(1,1) X'; 34 | Cluster(64, P); 35 | SpatialMap(1,1) C; 36 | } 37 | 38 | // Hand-optimized row-stationary 39 | Dataflow { 40 | TemporalMap(1,1) Y'; // ' 41 | TemporalMap(16,16) X'; //' 42 | TemporalMap(1,1) K; 43 | SpatialMap(1,1) C; 44 | Cluster(16,P); 45 | TemporalMap(1,1) Y'; 46 | SpatialMap(1,1) X'; 47 | TemporalMap(1,1) K; 48 | TemporalMap(1,1) C; 49 | Cluster(8,P); 50 | SpatialMap(1,1) Y; 51 | SpatialMap(1,1) R; 52 | } 53 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/quad/WS_OS_WS_OS.m: -------------------------------------------------------------------------------- 1 | // NVDLA 2 | Dataflow { 3 | TemporalMap(16,16) C; 4 | TemporalMap(16,16) K; 5 | TemporalMap(1,1) Y'; //' 6 | SpatialMap(1,1) X'; //' 7 | Cluster(16,P); 8 | SpatialMap(1,1) K; 9 | TemporalMap(64,64) C; 10 | TemporalMap(1,1) Y'; 11 | TemporalMap(1,1) X'; 12 | Cluster(16, P); 13 | SpatialMap(1,1) C; 14 | } 15 | 16 | // Hand-optimized OS 17 | Dataflow { 18 | TemporalMap(1,1) K; 19 | SpatialMap(1,1) Y'; //' 20 | TemporalMap(4,4) X'; //' 21 | TemporalMap(16,16) C; 22 | Cluster(4,P); 23 | SpatialMap(1,1) X'; //' 24 | Cluster(16, P); 25 | SpatialMap(1,1) C; 26 | } 27 | 28 | 29 | // NVDLA 30 | Dataflow { 31 | TemporalMap(16,16) C; 32 | TemporalMap(16,16) K; 33 | TemporalMap(1,1) Y'; //' 34 | SpatialMap(1,1) X'; //' 35 | Cluster(16,P); 36 | SpatialMap(1,1) K; 37 | TemporalMap(64,64) C; 38 | TemporalMap(1,1) Y'; 39 | TemporalMap(1,1) X'; 40 | Cluster(16, P); 41 | SpatialMap(1,1) C; 42 | } 43 | 44 | 45 | // Hand-optimized OS 46 | Dataflow { 47 | TemporalMap(1,1) K; 48 | SpatialMap(1,1) Y'; //' 49 | TemporalMap(4,4) X'; //' 50 | TemporalMap(16,16) C; 51 | Cluster(4,P); 52 | SpatialMap(1,1) X'; //' 53 | Cluster(16, P); 54 | SpatialMap(1,1) C; 55 | } 56 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_keywords.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HET_KEYWORDS_HPP_ 2 | #define HET_KEYWORDS_HPP_ 3 | 4 | #include 5 | 6 | namespace maestro { 7 | namespace HET { 8 | const std::string partition_strategy_energy_greedy = "EnergyGreedy"; 9 | const std::string partition_strategy_latency_greedy = "LatencyGreedy"; 10 | const std::string partition_strategy_edp_greedy = "EDPGreedy"; 11 | const std::string partition_strategy_edp_balance = "EDPBalance"; 12 | const std::string partition_strategy_ed2p_greedy = "ED2PGreedy"; 13 | 14 | const std::string bw_partition_strategy_uniform = "Uniform"; 15 | const std::string bw_partition_strategy_bruteforce = "BruteForce"; 16 | 17 | const std::string pe_partition_strategy_uniform = "Uniform"; 18 | const std::string pe_partition_strategy_bruteforce = "BruteForce"; 19 | 20 | const std::string ordering_strategy_dependence_chaining = "DependenceChain"; 21 | const std::string ordering_strategy_model_interleaving = "Interleaved"; 22 | 23 | 24 | const std::string alignment_strategy_standard = "Standard"; 25 | const std::string alignment_strategy_sequential = "Sequential"; 26 | const std::string alignment_strategy_lookahead = "LookAhead"; 27 | 28 | }; // End of namespace HET 29 | }; // End of namespace maestro 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XRBench-MLSys2023 2 | A version of XRBench-MAESTRO used for MLSys 2023 publication. 3 | 4 | # Dependencies 5 | - scons 6 | - libboost (Homebrew in a MAC) or libboost-all-dev (apt-get in a Linux machine) 7 | - g++ or clang++ 8 | 9 | # How to compile 10 | > scons 11 | 12 | # How to run evaluation (Push button-style scripts) 13 | > ./reproduce_figure5.sh 14 | 15 | > ./reproduce_figure6.sh 16 | 17 | > ./reproduce_figure7_data.sh 18 | 19 | # Note 20 | - The results are non-deterministic as the evaluation has dynamic factors (dynamic cascading of models in an ML pipeline). 21 | - Deterministic results (Expect near-exact match): Social Interaction A, Soctial Interaction B, VR Gaming, and AR Gaming results of Figure 5 22 | 23 | -> Check "XRbench_evaluation/plots/4K/AR_gaming.pdf," "XRbench_evaluation/plots/8K/AR_gaming.pdf," ... (for each usage scenario) 24 | - Another deterministic results: Figure 6 25 | 26 | -> Check "XRbench_evaluation/plots/AR_gaming___Dual_4K__WS_OS.pdf" and "XRbench_evaluation/plots/AR_gaming___Dual_8K__WS_OS.pdf" 27 | 28 | # Development Plan 29 | - This version is tightly intergrated with MAESTRO. We plan to make it more modular so that XRBench can be plugged into other cost models and simulators as well. Please refer to our website for more details https://xrbench.ai 30 | 31 | # Contact 32 | If you have any questions, please reach out to us via info@xrbench.ai 33 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/Not_Used/Quad_2K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_512 { 5 | num_pes: 512 6 | offchip_bw: 128 7 | top_noc_bw: 128 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 128 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 2097152 // 2 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | 18 | Accelerator Acc1_512 { 19 | num_pes: 512 20 | offchip_bw: 128 21 | top_noc_bw: 128 22 | top_noc_latency: 1 23 | top_noc_multicast: True 24 | col_noc_bw: 128 25 | col_noc_latency: 1 26 | col_noc_multicast: True 27 | global_shared_memory: 2097152 // 2 MiB 28 | PE_local_memory: 8192 // 8KiB 29 | } 30 | 31 | 32 | Accelerator Acc2_512 { 33 | num_pes: 512 34 | offchip_bw: 128 35 | top_noc_bw: 128 36 | top_noc_latency: 1 37 | top_noc_multicast: True 38 | col_noc_bw: 128 39 | col_noc_latency: 1 40 | col_noc_multicast: True 41 | global_shared_memory: 2097152 // 2 MiB 42 | PE_local_memory: 8192 // 8KiB 43 | } 44 | 45 | 46 | Accelerator Acc3_512 { 47 | num_pes: 512 48 | offchip_bw: 128 49 | top_noc_bw: 128 50 | top_noc_latency: 1 51 | top_noc_multicast: True 52 | col_noc_bw: 128 53 | col_noc_latency: 1 54 | col_noc_multicast: True 55 | global_shared_memory: 2097152 // 2 MiB 56 | PE_local_memory: 8192 // 8KiB 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/quad/Quad_4K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_1K { 5 | num_pes: 1024 6 | offchip_bw: 128 7 | top_noc_bw: 128 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 128 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 2097152 // 2 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | 18 | Accelerator Acc1_1K { 19 | num_pes: 1024 20 | offchip_bw: 128 21 | top_noc_bw: 128 22 | top_noc_latency: 1 23 | top_noc_multicast: True 24 | col_noc_bw: 128 25 | col_noc_latency: 1 26 | col_noc_multicast: True 27 | global_shared_memory: 2097152 // 2 MiB 28 | PE_local_memory: 8192 // 8KiB 29 | } 30 | 31 | 32 | Accelerator Acc2_1K { 33 | num_pes: 1024 34 | offchip_bw: 128 35 | top_noc_bw: 128 36 | top_noc_latency: 1 37 | top_noc_multicast: True 38 | col_noc_bw: 128 39 | col_noc_latency: 1 40 | col_noc_multicast: True 41 | global_shared_memory: 2097152 // 2 MiB 42 | PE_local_memory: 8192 // 8KiB 43 | } 44 | 45 | 46 | Accelerator Acc3_1K { 47 | num_pes: 1024 48 | offchip_bw: 128 49 | top_noc_bw: 128 50 | top_noc_latency: 1 51 | top_noc_multicast: True 52 | col_noc_bw: 128 53 | col_noc_latency: 1 54 | col_noc_multicast: True 55 | global_shared_memory: 2097152 // 2 MiB 56 | PE_local_memory: 8192 // 8KiB 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/quad/Quad_8K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_2K { 5 | num_pes: 2048 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | 18 | Accelerator Acc1_2K { 19 | num_pes: 2048 20 | offchip_bw: 128 21 | top_noc_bw: 256 22 | top_noc_latency: 1 23 | top_noc_multicast: True 24 | col_noc_bw: 256 25 | col_noc_latency: 1 26 | col_noc_multicast: True 27 | global_shared_memory: 4194304 // 4 MiB 28 | PE_local_memory: 8192 // 8KiB 29 | } 30 | 31 | 32 | Accelerator Acc2_2K { 33 | num_pes: 2048 34 | offchip_bw: 128 35 | top_noc_bw: 256 36 | top_noc_latency: 1 37 | top_noc_multicast: True 38 | col_noc_bw: 256 39 | col_noc_latency: 1 40 | col_noc_multicast: True 41 | global_shared_memory: 4194304 // 4 MiB 42 | PE_local_memory: 8192 // 8KiB 43 | } 44 | 45 | 46 | Accelerator Acc3_2K { 47 | num_pes: 2048 48 | offchip_bw: 128 49 | top_noc_bw: 256 50 | top_noc_latency: 1 51 | top_noc_multicast: True 52 | col_noc_bw: 256 53 | col_noc_latency: 1 54 | col_noc_multicast: True 55 | global_shared_memory: 4194304 // 4 MiB 56 | PE_local_memory: 8192 // 8KiB 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /XRbench_evaluation/hw_configs/Not_Used/Quad_16K.m: -------------------------------------------------------------------------------- 1 | // tmp verison; top and col order needs to be maintained 2 | 3 | 4 | Accelerator Acc0_4K { 5 | num_pes: 4096 6 | offchip_bw: 128 7 | top_noc_bw: 256 8 | top_noc_latency: 1 9 | top_noc_multicast: True 10 | col_noc_bw: 256 11 | col_noc_latency: 1 12 | col_noc_multicast: True 13 | global_shared_memory: 4194304 // 4 MiB 14 | PE_local_memory: 8192 // 8KiB 15 | } 16 | 17 | 18 | Accelerator Acc1_4K { 19 | num_pes: 4096 20 | offchip_bw: 128 21 | top_noc_bw: 256 22 | top_noc_latency: 1 23 | top_noc_multicast: True 24 | col_noc_bw: 256 25 | col_noc_latency: 1 26 | col_noc_multicast: True 27 | global_shared_memory: 4194304 // 4 MiB 28 | PE_local_memory: 8192 // 8KiB 29 | } 30 | 31 | 32 | Accelerator Acc2_4K { 33 | num_pes: 4096 34 | offchip_bw: 128 35 | top_noc_bw: 256 36 | top_noc_latency: 1 37 | top_noc_multicast: True 38 | col_noc_bw: 256 39 | col_noc_latency: 1 40 | col_noc_multicast: True 41 | global_shared_memory: 4194304 // 4 MiB 42 | PE_local_memory: 8192 // 8KiB 43 | } 44 | 45 | 46 | Accelerator Acc3_4K { 47 | num_pes: 4096 48 | offchip_bw: 128 49 | top_noc_bw: 256 50 | top_noc_latency: 1 51 | top_noc_multicast: True 52 | col_noc_bw: 256 53 | col_noc_latency: 1 54 | col_noc_multicast: True 55 | global_shared_memory: 4194304 // 4 MiB 56 | PE_local_memory: 8192 // 8KiB 57 | } 58 | 59 | 60 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/Not_Used/RS_OS_RS_OS.m: -------------------------------------------------------------------------------- 1 | // Hand-optimized row-stationary 2 | Dataflow { 3 | TemporalMap(1,1) Y'; // ' 4 | TemporalMap(16,16) X'; //' 5 | TemporalMap(1,1) K; 6 | SpatialMap(1,1) C; 7 | Cluster(16,P); 8 | TemporalMap(1,1) Y'; 9 | SpatialMap(1,1) X'; 10 | TemporalMap(1,1) K; 11 | TemporalMap(1,1) C; 12 | Cluster(8,P); 13 | SpatialMap(1,1) Y; 14 | SpatialMap(1,1) R; 15 | } 16 | 17 | 18 | // Hand-optimized output-stationary 19 | Dataflow { 20 | TemporalMap(4,4) Y'; 21 | TemporalMap(1,1) X'; 22 | SpatialMap(1,1) K; 23 | TemporalMap(64,64) C; 24 | Cluster(4,P); 25 | SpatialMap(1,1) Y'; //' 26 | Cluster(64, P); 27 | SpatialMap(1,1) C; 28 | } 29 | 30 | // Hand-optimized row-stationary 31 | Dataflow { 32 | TemporalMap(1,1) Y'; // ' 33 | TemporalMap(16,16) X'; //' 34 | TemporalMap(1,1) K; 35 | SpatialMap(1,1) C; 36 | Cluster(16,P); 37 | TemporalMap(1,1) Y'; 38 | SpatialMap(1,1) X'; 39 | TemporalMap(1,1) K; 40 | TemporalMap(1,1) C; 41 | Cluster(8,P); 42 | SpatialMap(1,1) Y; 43 | SpatialMap(1,1) R; 44 | } 45 | 46 | 47 | // Hand-optimized output-stationary 48 | Dataflow { 49 | TemporalMap(4,4) Y'; 50 | TemporalMap(1,1) X'; 51 | SpatialMap(1,1) K; 52 | TemporalMap(64,64) C; 53 | Cluster(4,P); 54 | SpatialMap(1,1) Y'; //' 55 | Cluster(64, P); 56 | SpatialMap(1,1) C; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/quad/WS_WS_WS_WS.m: -------------------------------------------------------------------------------- 1 | // NVDLA 2 | Dataflow { 3 | TemporalMap(16,16) C; 4 | TemporalMap(16,16) K; 5 | TemporalMap(1,1) Y'; //' 6 | SpatialMap(1,1) X'; //' 7 | Cluster(16,P); 8 | SpatialMap(1,1) K; 9 | TemporalMap(64,64) C; 10 | TemporalMap(1,1) Y'; 11 | TemporalMap(1,1) X'; 12 | Cluster(16, P); 13 | SpatialMap(1,1) C; 14 | } 15 | 16 | // NVDLA 17 | Dataflow { 18 | TemporalMap(16,16) C; 19 | TemporalMap(16,16) K; 20 | TemporalMap(1,1) Y'; //' 21 | SpatialMap(1,1) X'; //' 22 | Cluster(16,P); 23 | SpatialMap(1,1) K; 24 | TemporalMap(64,64) C; 25 | TemporalMap(1,1) Y'; 26 | TemporalMap(1,1) X'; 27 | Cluster(16, P); 28 | SpatialMap(1,1) C; 29 | } 30 | 31 | // NVDLA 32 | Dataflow { 33 | TemporalMap(16,16) C; 34 | TemporalMap(16,16) K; 35 | TemporalMap(1,1) Y'; //' 36 | SpatialMap(1,1) X'; //' 37 | Cluster(16,P); 38 | SpatialMap(1,1) K; 39 | TemporalMap(64,64) C; 40 | TemporalMap(1,1) Y'; 41 | TemporalMap(1,1) X'; 42 | Cluster(16, P); 43 | SpatialMap(1,1) C; 44 | } 45 | 46 | // NVDLA 47 | Dataflow { 48 | TemporalMap(16,16) C; 49 | TemporalMap(16,16) K; 50 | TemporalMap(1,1) Y'; //' 51 | SpatialMap(1,1) X'; //' 52 | Cluster(16,P); 53 | SpatialMap(1,1) K; 54 | TemporalMap(64,64) C; 55 | TemporalMap(1,1) Y'; 56 | TemporalMap(1,1) X'; 57 | Cluster(16, P); 58 | SpatialMap(1,1) C; 59 | } 60 | -------------------------------------------------------------------------------- /reproduce_figure6.sh: -------------------------------------------------------------------------------- 1 | ./maestro --verbose=true \ 2 | --full_buffer=false \ 3 | --model_file='XRbench_evaluation/usage_scenarios/AR_gaming.m' \ 4 | --dataflow_file='XRbench_evaluation/dataflows/dual/WS_OS.m' \ 5 | --hw_file='XRbench_evaluation/hw_configs/dual/Dual_4K.m' \ 6 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure6/sched_4K_AR_gaming.csv' \ 7 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure6/summary_4K_AR_gaming.csv' \ 8 | --do_schedule_only=false 9 | 10 | 11 | ./maestro --verbose=true \ 12 | --full_buffer=false \ 13 | --model_file='XRbench_evaluation/usage_scenarios/AR_gaming.m' \ 14 | --dataflow_file='XRbench_evaluation/dataflows/dual/WS_OS.m' \ 15 | --hw_file='XRbench_evaluation/hw_configs/dual/Dual_8K.m' \ 16 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure6/sched_8K_AR_gaming.csv' \ 17 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure6/summary_8K_AR_gaming.csv' \ 18 | --do_schedule_only=false 19 | 20 | 21 | python3 XRbench_evaluation/scripts/draw_timeline.py XRbench_evaluation/eval_data/schedule/schedule_AR_gaming__Dual_4K__WS_OS.csv XRbench_evaluation/plots/AR_gaming___Dual_4K__WS_OS.pdf 2 520 22 | python3 XRbench_evaluation/scripts/draw_timeline.py XRbench_evaluation/eval_data/schedule/schedule_AR_gaming__Dual_8K__WS_OS.csv XRbench_evaluation/plots/AR_gaming___Dual_8K__WS_OS.pdf 2 520 23 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_integrated-parsers.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MAESTRO_INTEGRATED_PARSERS_ 2 | #define MAESTRO_INTEGRATED_PARSERS_ 3 | 4 | #include 5 | 6 | 7 | #include "DFSL_parser.hpp" 8 | 9 | namespace maestro { 10 | namespace HET { 11 | class IntegratedParsers { 12 | public: 13 | IntegratedParsers( 14 | std::string model_file_name, 15 | std::string dataflow_file_name) { 16 | model_parser_= std::make_shared(model_file_name); 17 | dataflow_parser_ = std::make_shared(dataflow_file_name); 18 | 19 | models_ = model_parser_->ParseModel(); 20 | dataflows_ = dataflow_parser_->ParseDataflow(); 21 | } 22 | 23 | std::shared_ptr>>>> GetModels() { 24 | return models_; 25 | } 26 | 27 | std::shared_ptr>> GetDataflows() { 28 | return dataflows_; 29 | } 30 | 31 | protected: 32 | std::shared_ptr model_parser_; 33 | std::shared_ptr dataflow_parser_; 34 | 35 | std::shared_ptr>>>> models_; 36 | std::shared_ptr>> dataflows_; 37 | 38 | private: 39 | 40 | }; // End of class IntegratedParsers 41 | 42 | }; // End of namespace HET 43 | }; // End of namespace maestro 44 | 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/quad/RS_RS_RS_RS.m: -------------------------------------------------------------------------------- 1 | // Hand-optimized row-stationary 2 | Dataflow { 3 | TemporalMap(1,1) Y'; // ' 4 | TemporalMap(16,16) X'; //' 5 | TemporalMap(4,4) C; 6 | SpatialMap(1,1) K; 7 | Cluster(16,P); 8 | TemporalMap(1,1) Y'; 9 | SpatialMap(1,1) X'; 10 | TemporalMap(4,4) C; 11 | TemporalMap(1,1) K; 12 | Cluster(4,P); 13 | SpatialMap(1,1) Y; 14 | SpatialMap(1,1) R; 15 | } 16 | 17 | // Hand-optimized row-stationary 18 | Dataflow { 19 | TemporalMap(1,1) Y'; // ' 20 | TemporalMap(16,16) X'; //' 21 | TemporalMap(4,4) C; 22 | SpatialMap(1,1) K; 23 | Cluster(16,P); 24 | TemporalMap(1,1) Y'; 25 | SpatialMap(1,1) X'; 26 | TemporalMap(4,4) C; 27 | TemporalMap(1,1) K; 28 | Cluster(4,P); 29 | SpatialMap(1,1) Y; 30 | SpatialMap(1,1) R; 31 | } 32 | 33 | // Hand-optimized row-stationary 34 | Dataflow { 35 | TemporalMap(1,1) Y'; // ' 36 | TemporalMap(16,16) X'; //' 37 | TemporalMap(4,4) C; 38 | SpatialMap(1,1) K; 39 | Cluster(16,P); 40 | TemporalMap(1,1) Y'; 41 | SpatialMap(1,1) X'; 42 | TemporalMap(4,4) C; 43 | TemporalMap(1,1) K; 44 | Cluster(4,P); 45 | SpatialMap(1,1) Y; 46 | SpatialMap(1,1) R; 47 | } 48 | 49 | // Hand-optimized row-stationary 50 | Dataflow { 51 | TemporalMap(1,1) Y'; // ' 52 | TemporalMap(16,16) X'; //' 53 | TemporalMap(4,4) C; 54 | SpatialMap(1,1) K; 55 | Cluster(16,P); 56 | TemporalMap(1,1) Y'; 57 | SpatialMap(1,1) X'; 58 | TemporalMap(4,4) C; 59 | TemporalMap(1,1) K; 60 | Cluster(4,P); 61 | SpatialMap(1,1) Y; 62 | SpatialMap(1,1) R; 63 | } 64 | -------------------------------------------------------------------------------- /lib/include/design-space-exploration/DSE_config.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSE_CONFIG_HPP_ 24 | #define MAESTRO_DSE_CONFIG_HPP_ 25 | 26 | namespace maestro { 27 | 28 | namespace DSE { 29 | 30 | enum class OptimizationTarget {Runtime, Energy, PerformancePerWatt}; 31 | 32 | }; // End of namespace DSE 33 | }; // End of namesapce maestro 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/include/base/BASE_base-objects.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_BASE_BASE_OBJECTS_HPP_ 24 | #define MAESTRO_BASE_BASE_OBJECTS_HPP_ 25 | 26 | #include 27 | #include "TL_error-handler.hpp" 28 | #include "TL_message-printer.hpp" 29 | 30 | namespace maestro { 31 | 32 | extern std::shared_ptr error_handler; 33 | extern std::shared_ptr message_printer; 34 | 35 | extern int printout_level; 36 | 37 | void InitializeBaseObjects(int print_lv = 256); 38 | void SetPrintOutLevel(int new_lv); 39 | 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/include/tools/TL_analysis-results-csv-writer.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_TL_ERROR_HANDLER_HPP_ 24 | #define MAESTRO_TL_ERROR_HANDLER_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | namespace maestro { 32 | namespace TL { 33 | class AnalysisResCSVWriter { 34 | public: 35 | AnalysisResCSVWriter(std::string file_name) { 36 | outfile_.open(file_name); 37 | 38 | } 39 | protected: 40 | std::ofstream outfile_; 41 | 42 | }; // End of class AnalysisResCSVWriter 43 | }; // End of namespace TL 44 | }; // End of namespace maestro 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lib/src/BASE_base-objects.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | #include 23 | 24 | #include "TL_error-handler.hpp" 25 | #include "TL_message-printer.hpp" 26 | 27 | namespace maestro { 28 | 29 | //Singleton objects for common functionalities 30 | std::shared_ptr error_handler; 31 | std::shared_ptr message_printer; 32 | int printout_level = 0; 33 | 34 | void InitializeBaseObjects(int print_lv = 0) { 35 | error_handler = std::make_shared(); 36 | message_printer = std::make_shared(print_lv); 37 | } 38 | 39 | void SetPrintOutLevel(int new_lv) { 40 | message_printer->SetPrintLv(new_lv); 41 | } 42 | 43 | }; 44 | -------------------------------------------------------------------------------- /lib/include/base/BASE_constants.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef BASE_CONSTANTS_HPP_ 24 | #define BASE_CONSTANTS_HPP_ 25 | 26 | 27 | #include 28 | 29 | namespace maestro{ 30 | const std::string init_dim = "Init"; 31 | const std::string wgt_init_dim = "Init"; 32 | const std::string ipt_init_dim = "Init"; 33 | 34 | 35 | 36 | enum class DataClass{Input, Weight, Output, NumDataClasses}; 37 | // Source: "GANAX: A Unified MIMD-SIMD Acceleration for Generative Adversarial Network" 38 | const double l1_energy_multiplier = 0.55; 39 | const double l2_energy_multiplier = 6.00; 40 | const double DRAM_energy_multiplier = 75.00; 41 | 42 | }; // End of namespace maestro 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lib/include/design-space-exploration/DSE_scaling-coefficients.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSE_SCALING_COEFFICIENTS_HPP_ 24 | #define MAESTRO_DSE_SCALING_COEFFICIENTS_HPP_ 25 | 26 | namespace maestro { 27 | namespace DSE { 28 | namespace scaling_model { 29 | /* Embedded scaling model */ 30 | // Based on 28nm technology 31 | const double matrix_arbiter_c2 = 1.2886; 32 | const double matrix_arbirter_c1 = 5.5814; 33 | const double matrix_arbiter_c0 = -23.711; 34 | 35 | const double bus_c1 = 14.662; 36 | const double bus_c0 = 28.895; 37 | 38 | }; // End of namespace scaling_model 39 | }; // End of namespace DSE 40 | }; // End of namespace maestro 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_analysis-output.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_ANALYSIS_OUTPUT_HPP_ 24 | #define MAESTRO_DFA_ANALYSIS_OUTPUT_HPP_ 25 | 26 | namespace maestro { 27 | namespace DFA { 28 | 29 | class BufferAnalysis { 30 | public: 31 | BufferAnalysis() { 32 | } 33 | 34 | void AddSizeReq(int size_req) { 35 | size_req_.push_back(size_req); 36 | } 37 | 38 | void AddAccessCounts(int counts) { 39 | access_counts_.push_back(counts); 40 | } 41 | 42 | protected: 43 | std::vector size_req_; 44 | std::vector access_counts_; 45 | }; 46 | 47 | 48 | }; // End of namespace DFA 49 | }; // End of namespace maestro 50 | 51 | #endif /* MAESTRO_V2_LIB_INCLUDE_DATAFLOW_ANALYSIS_DFA_ANALYSIS_OUTPUT_HPP_ */ 52 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_process.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "HET_cost-class.hpp" 8 | #include "HET_inference-request.hpp" 9 | 10 | #define FP_ERROR_MARGIN 1e-2f 11 | 12 | namespace maestro{ 13 | namespace HET { 14 | class InferenceProcess { 15 | public: 16 | InferenceProcess( 17 | float dispatch_time, 18 | std::shared_ptr<::maestro::HET::InferenceRequest> inference_request 19 | ): 20 | dispatch_time_(dispatch_time), 21 | inference_request_(inference_request) { 22 | completeion_time_ = -1; 23 | energy_ = 0; 24 | } 25 | 26 | int GetFrameID() { 27 | return inference_request_->GetFrameID(); 28 | } 29 | 30 | void SetLatency(float latency) { 31 | assert(latency > 0); 32 | completeion_time_ = dispatch_time_ + latency; 33 | } 34 | 35 | void SetEnergy(double energy) { 36 | energy_ = energy; 37 | } 38 | 39 | bool IsFinished(float current_time) { 40 | return current_time + FP_ERROR_MARGIN >= completeion_time_; 41 | } 42 | 43 | std::string GetModelName(){ 44 | return inference_request_->GetModelName(); 45 | } 46 | 47 | float GetInjectionTime() { 48 | return inference_request_->GetInjectionTime(); 49 | } 50 | 51 | float GetDeadline() { 52 | return inference_request_->GetDeadline(); 53 | } 54 | 55 | float GetCompletionTime() { 56 | return completeion_time_; 57 | } 58 | 59 | double GetEnergy() { 60 | return energy_; 61 | } 62 | 63 | float GetDispatchTime() { 64 | return dispatch_time_; 65 | } 66 | 67 | 68 | protected: 69 | float dispatch_time_; 70 | float completeion_time_; 71 | double energy_; 72 | std::shared_ptr<::maestro::HET::InferenceRequest> inference_request_; 73 | }; 74 | 75 | }; // End of namespace HET 76 | 77 | }; // End of namespace maestro 78 | -------------------------------------------------------------------------------- /lib/include/abstract-hardware-model/AHW-pe-array.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_AHW_PE_ARRAY_HPP_ 24 | #define MAESTRO_AHW_PE_ARRAY_HPP_ 25 | 26 | #include 27 | 28 | #include "../abstract-hardware-model/AHW-pe-model.hpp" 29 | 30 | namespace maestro { 31 | 32 | namespace AHW { 33 | class ProcessingElementArray { 34 | public: 35 | ProcessingElementArray(int num_pes, std::shared_ptr pe_model) : 36 | num_pes_(num_pes), pe_model_(pe_model) { 37 | 38 | } 39 | 40 | int GetNumPEs () { 41 | return num_pes_; 42 | } 43 | 44 | std::shared_ptr GetPEModel() { 45 | return pe_model_; 46 | } 47 | 48 | protected: 49 | int num_pes_; 50 | std::shared_ptr pe_model_; 51 | 52 | }; 53 | 54 | }; // End of namespace abstract_hw 55 | }; // End of namespace maestro 56 | #endif 57 | -------------------------------------------------------------------------------- /lib/include/tools/TL_message-printer.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_TL_MESSAGE_PRINTER_HPP_ 24 | #define MAESTRO_TL_MESSAGE_PRINTER_HPP_ 25 | 26 | #include 27 | 28 | namespace maestro { 29 | namespace TL { 30 | class MessagePrinter { 31 | public: 32 | MessagePrinter(int target_lv) : print_lv_(target_lv) { 33 | } 34 | 35 | void PrintMsg(int lv, std::string msg, bool change_line = true) { 36 | if(lv <= print_lv_) { 37 | if(change_line) { 38 | std::cout << msg << std::endl; 39 | } 40 | else { 41 | std::cout << msg; 42 | } 43 | } 44 | } 45 | 46 | void SetPrintLv(int new_lv) { 47 | print_lv_ = new_lv; 48 | } 49 | 50 | protected: 51 | int print_lv_= 0; 52 | }; 53 | 54 | 55 | }; 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_inference-request.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef MAESTRO_HET_INFERENCE_REQUEST_HPP_ 4 | #define MAESTRO_HET_INFERENCE_REQUEST_HPP_ 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "HET_cost-class.hpp" 12 | 13 | 14 | namespace maestro{ 15 | namespace HET { 16 | class InferenceRequest { 17 | public: 18 | InferenceRequest( 19 | int frame_id, 20 | float injection_time, 21 | float deadline, 22 | float jitter, 23 | std::shared_ptr model 24 | ): 25 | frame_id_(frame_id), 26 | injection_time_(injection_time), 27 | deadline_(deadline), 28 | jitter_(jitter), 29 | model_(model) { 30 | } 31 | 32 | bool HasInputData(float current_time) { 33 | return (injection_time_ <= current_time); 34 | } 35 | 36 | bool IsDropped(float current_time) { 37 | return (deadline_ < current_time); 38 | } 39 | 40 | bool IsDependent(std::shared_ptr targ_model) { 41 | return model_->CheckDependency(targ_model->GetName()); 42 | } 43 | 44 | int GetFrameID() { 45 | return frame_id_; 46 | } 47 | 48 | std::string GetModelName() { 49 | return model_->GetName(); 50 | } 51 | 52 | std::shared_ptr> GetDependencyList() { 53 | return model_->GetDependencyList(); 54 | } 55 | 56 | float GetInjectionTime() { 57 | return injection_time_; 58 | } 59 | 60 | float GetDeadline() { 61 | return deadline_; 62 | } 63 | 64 | float GetJitter() { 65 | return jitter_; 66 | } 67 | 68 | std::shared_ptr GetModel() { 69 | return model_; 70 | } 71 | 72 | protected: 73 | int frame_id_; 74 | float injection_time_; 75 | float deadline_; 76 | float jitter_; 77 | std::shared_ptr model_; 78 | }; 79 | 80 | }; // End of namespace HET 81 | 82 | }; // End of namespace maestro 83 | #endif 84 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_timeline-extractor.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "HET_cost-class.hpp" 12 | #include "TL_generic-csv-writer.hpp" 13 | 14 | namespace maestro{ 15 | namespace HET { 16 | 17 | class TimelineExtractor { 18 | public: 19 | TimelineExtractor(std::string output_file_name) { 20 | csv_writer_ = std::make_unique(output_file_name); 21 | // Write headers 22 | csv_writer_->WriteWord("AcceleratorID"); 23 | csv_writer_->WriteWord("Model Name"); 24 | csv_writer_->WriteWord("Frame ID"); 25 | csv_writer_->WriteWord("Injection Time (ms)"); 26 | csv_writer_->WriteWord("Dispatch Time (ms)"); 27 | csv_writer_->WriteWord("Deadline Time (ms)"); 28 | csv_writer_->WriteWord("Completion Time (ms)"); 29 | csv_writer_->WriteWord("Violated Deadline Amount (ms)"); 30 | csv_writer_->WriteWord("Energy (mJ)", true); 31 | } 32 | 33 | void ExtractTimeline(int acc_id, std::shared_ptr>> acc_logs) { 34 | for(auto log : *acc_logs) { 35 | if(!log->IsDropped()) { 36 | csv_writer_->WriteWord(std::to_string(acc_id)); 37 | csv_writer_->WriteWord(log->GetModelName()); 38 | csv_writer_->WriteWord(std::to_string(log->GetFrameID())); 39 | csv_writer_->WriteWord(std::to_string(log->GetInjectionTime())); 40 | csv_writer_->WriteWord(std::to_string(log->GetDispatchTime())); 41 | csv_writer_->WriteWord(std::to_string(log->GetDeadline())); 42 | csv_writer_->WriteWord(std::to_string(log->GetCompletionTime())); 43 | csv_writer_->WriteWord(std::to_string(log->GetCompletionTime() - log->GetDeadline())); 44 | csv_writer_->WriteWord(std::to_string(log->GetEnergy()), true); 45 | } 46 | } 47 | } 48 | 49 | protected: 50 | std::unique_ptr csv_writer_; 51 | 52 | }; // End of class TimelineExtractor 53 | 54 | }; // End of namespace HET 55 | }; // End of namespace maestro 56 | -------------------------------------------------------------------------------- /lib/include/tools/TL_generic-csv-writer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TL_GENERIC_CSV_WRITER_HPP_ 2 | #define TL_GENERIC_CSV_WRITER_HPP_ 3 | 4 | #include 5 | #include 6 | 7 | namespace maestro { 8 | namespace TL { 9 | class GenericCSVWriter { 10 | public: 11 | GenericCSVWriter(std::string output_file_name) { 12 | output_file_.open(output_file_name, std::fstream::in | std::fstream::out | std::fstream::app); 13 | } 14 | 15 | void WriteWord(std::string input_string, bool end_of_line = false) { 16 | 17 | if(!end_of_line) { 18 | output_file_ << input_string << ","; 19 | } 20 | else { 21 | output_file_ << input_string << std::endl;; 22 | } 23 | } 24 | 25 | void WriteVector(std::vector input_str_vector, bool end_of_line = false) { 26 | for(int str_id = 0; str_id < input_str_vector.size(); str_id++) { 27 | output_file_ << input_str_vector[str_id]; 28 | if(!end_of_line) { 29 | output_file_ << ","; 30 | } 31 | else { 32 | if(str_id == input_str_vector.size()-1) { 33 | output_file_ << std::endl; 34 | } 35 | else { 36 | output_file_ << ","; 37 | } 38 | } 39 | } 40 | } 41 | 42 | void WriteVector(std::vector input_double_vector, bool end_of_line = false) { 43 | for(int str_id = 0; str_id < input_double_vector.size(); str_id++) { 44 | output_file_ << std::to_string(input_double_vector[str_id]); 45 | if(!end_of_line) { 46 | output_file_ << ","; 47 | } 48 | else { 49 | if(str_id == input_double_vector.size()-1) { 50 | output_file_ << std::endl; 51 | } 52 | else { 53 | output_file_ << ","; 54 | } 55 | } 56 | } 57 | } 58 | 59 | 60 | protected: 61 | std::ofstream output_file_; 62 | 63 | private: 64 | 65 | }; 66 | 67 | }; // End of namespace TL (Tools) 68 | }; // End of namespace maestro 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /lib/include/base/BASE_maestro-class.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_BASE_MAESTRO_CLASS_HPP_ 24 | #define MAESTRO_BASE_MAESTRO_CLASS_HPP_ 25 | 26 | #include 27 | 28 | #include "BASE_base-objects.hpp" 29 | #include "TL_error-handler.hpp" 30 | 31 | namespace maestro { 32 | class MAESTROClass { 33 | public: 34 | 35 | MAESTROClass() : 36 | instance_name_("class"), 37 | error_handler_(error_handler), 38 | message_printer_(message_printer) { 39 | } 40 | 41 | MAESTROClass(std::string instance_name) : 42 | instance_name_(instance_name), 43 | error_handler_(error_handler), 44 | message_printer_(message_printer) { 45 | } 46 | 47 | std::string GetName() { 48 | return instance_name_; 49 | } 50 | 51 | void ToString() { 52 | std::cout << "Base class" << std::endl;; 53 | } 54 | 55 | protected: 56 | std::string instance_name_; 57 | std::shared_ptr error_handler_; 58 | std::shared_ptr message_printer_; 59 | }; 60 | }; 61 | #endif 62 | -------------------------------------------------------------------------------- /XRbench_evaluation/dataflows/Not_Used/WS_RS_Dataflow.m: -------------------------------------------------------------------------------- 1 | 2 | // Balanced DLA++ 3 | // Dataflow { 4 | // TemporalMap(32,32) K; 5 | // TemporalMap(8,8) C; 6 | // SpatialMap(1,1) Y'; 7 | // TemporalMap(1,1) X'; 8 | // Cluster(32, P); 9 | // SpatialMap(1,1) K; 10 | // Cluster(8, P); 11 | // SpatialMap(1,1) C; 12 | // } 13 | 14 | // NVDLA 15 | Dataflow { 16 | SpatialMap(1,1) K; 17 | TemporalMap(64,64) C; 18 | TemporalMap(1,1) Y'; 19 | TemporalMap(1,1) X'; 20 | Cluster(64, P); 21 | SpatialMap(1,1) C; 22 | } 23 | 24 | 25 | // Hand-optimized row-stationary 26 | Dataflow { 27 | TemporalMap(16,16) Y'; // ' 28 | TemporalMap(16,16) X'; //' 29 | TemporalMap(1,1) K; 30 | SpatialMap(1,1) C; 31 | Cluster(16,P); 32 | SpatialMap(1,1) Y'; 33 | TemporalMap(16,16) X'; 34 | TemporalMap(1,1) K; 35 | TemporalMap(1,1) C; 36 | Cluster(4,P); 37 | SpatialMap(1,1) Y; 38 | SpatialMap(1,1) R; 39 | } 40 | 41 | 42 | // Hand-optimized output-stationary 43 | // Dataflow { 44 | // TemporalMap(4,4) Y'; 45 | // TemporalMap(1,1) X'; 46 | // SpatialMap(1,1) K; 47 | // TemporalMap(64,64) C; 48 | // Cluster(4,P); 49 | // SpatialMap(1,1) Y'; //' 50 | // Cluster(64, P); 51 | // SpatialMap(1,1) C; 52 | // } 53 | 54 | 55 | //Shi diannao style 56 | // Dataflow { 57 | // TemporalMap(1,1) C; 58 | // SpatialMap(1,1) Y'; 59 | // TemporalMap(128,128) X'; 60 | // TemporalMap(16,16) K; 61 | // Cluster(128,P); 62 | // TemporalMap(16,16) K; 63 | // TemporalMap(1,1) C; 64 | // TemporalMap(1,1) Y'; 65 | // SpatialMap(1,1) X'; 66 | // } 67 | 68 | // Dataflow { 69 | // TemporalMap(1,1) C; 70 | // TemporalMap(16,16) Y'; 71 | // TemporalMap(3,1) X; 72 | // SpatialMap(1,1) K; 73 | // TemporalMap(3,3) R; 74 | // TemporalMap(3,3) S; 75 | // Cluster(16, P); 76 | // TemporalMap(1,1) C; 77 | // SpatialMap(1,1) Y'; 78 | // TemporalMap(3,1) X; 79 | // TemporalMap(1,1) K; 80 | // TemporalMap(3,3) R; 81 | // TemporalMap(3,3) S; 82 | // } 83 | 84 | 85 | // RS 86 | // Dataflow { 87 | // TemporalMap(4,4) C; 88 | // TemporalMap(4,4) K; 89 | // TemporalMap(3,3) R; 90 | // TemporalMap(3,3) S; 91 | // SpatialMap(3,1) Y; 92 | // TemporalMap(3,1) X; 93 | // Cluster(3,P); 94 | // SpatialMap(1,1) Y; 95 | // SpatialMap(1,1) R; 96 | // TemporalMap(3,3) S; 97 | // } 98 | 99 | -------------------------------------------------------------------------------- /lib/include/abstract-hardware-model/AHW-pe-model.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_AHW_PE_MODEL_HPP_ 24 | #define MAESTRO_AHW_PE_MODEL_HPP_ 25 | 26 | namespace maestro { 27 | namespace AHW { 28 | 29 | enum class Precision {FP8, FP16, FP32, INT8, INT16, INT32}; 30 | 31 | class ProcessingElement { 32 | public: 33 | ProcessingElement(int l1_size, int vector_width, Precision mult_precision, Precision add_precision) : 34 | l1_size_(l1_size), vector_width_(vector_width), mult_precision_(mult_precision), add_precision_(add_precision) { 35 | } 36 | 37 | int GetL1Size() { 38 | return l1_size_; 39 | } 40 | 41 | int GetVectorWidth() { 42 | return vector_width_; 43 | } 44 | 45 | Precision GetMultPrecision() { 46 | return mult_precision_; 47 | } 48 | 49 | Precision GetAddPrecision() { 50 | return add_precision_; 51 | } 52 | 53 | protected: 54 | int l1_size_; 55 | int vector_width_; 56 | Precision mult_precision_; 57 | Precision add_precision_; 58 | }; 59 | 60 | }; // End of namespace abstract_hw 61 | }; // End of namespace maestro 62 | #endif 63 | -------------------------------------------------------------------------------- /lib/include/abstract-hardware-model/AHW_Accelerator.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MAESTRO_AHW_ACCELERATOR_HPP_ 2 | #define MAESTRO_AHW_ACCELERATOR_HPP_ 3 | 4 | #include 5 | #include 6 | 7 | #include "DSE_design-options.hpp" 8 | 9 | namespace maestro { 10 | 11 | namespace AHW { 12 | 13 | class Accelerator { 14 | public: 15 | 16 | 17 | protected: 18 | int num_pes_; 19 | int pe_vector_width_; 20 | DSE::OpType mult_op_type_; 21 | int mult_precision_; 22 | DSE::OpType add_op_type_; 23 | int add_precision_; 24 | 25 | std::vector buffer_name_; 26 | std::vector buffer_sizes_; 27 | std::vector noc_name_; 28 | std::vector noc_bandwidth_; 29 | std::vector noc_latency_; 30 | 31 | 32 | }; // End of class Accelerator 33 | 34 | class AcceleratorInfo { 35 | public: 36 | std::string name; 37 | int num_pes; 38 | // NoC Info 39 | int offchip_bw; 40 | // TODO: Use a data structure for NoC info 41 | std::vector noc_bandwidth; 42 | std::vector noc_latency; 43 | std::vector noc_multicast; 44 | 45 | // Buffer Info 46 | // TODO: Use a data structure for buffer info 47 | std::vector memory_size; 48 | 49 | std::string to_string() { 50 | std::string ret = ""; 51 | ret += "Accelerator " + name + " \n"; 52 | ret += "num_pes " + std::to_string(num_pes) + " \n"; 53 | ret += "offchip_bw " + std::to_string(offchip_bw) + " \n"; 54 | 55 | ret += "noc_bw\n"; 56 | for(auto it: noc_bandwidth) { 57 | ret += " " + std::to_string(it) + " \n"; 58 | } 59 | 60 | ret += "noc_latency\n"; 61 | for(auto it: noc_latency) { 62 | ret += " " + std::to_string(it) + "\n"; 63 | } 64 | 65 | ret += "noc_multicast\n"; 66 | for(auto it: noc_latency) { 67 | std::string print_string = (it)? "True" : "False"; 68 | ret += " " + print_string + "\n"; 69 | } 70 | 71 | ret += "memory_size\n"; 72 | for(auto it: memory_size) { 73 | ret += " " + std::to_string(it) + "\n"; 74 | } 75 | 76 | return ret; 77 | } 78 | }; 79 | 80 | }; // End of namespace AHW 81 | }; // End of namespace maestro 82 | 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /lib/include/design-space-exploration/DSE_cost-database.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSE_COST_DATABASE_HPP_ 24 | #define MAESTRO_DSE_COST_DATABASE_HPP_ 25 | 26 | namespace maestro { 27 | namespace DSE { 28 | namespace cost { 29 | /* Embedded scaling model */ 30 | 31 | const double mac_area = 4470.9014; 32 | const double mac_power = 1.2223; 33 | 34 | // Source: "GANAX: A Unified MIMD-SIMD Acceleration for Generative Adversarial Network" 35 | const double mac_energy = 0.00288; // unit: nJ 36 | //2.88pJ 37 | //0.00288pJ 38 | const double sram_unit_size_64 = 64; 39 | const double sram_area_64 = 4505.1889; 40 | const double sram_power_64 = 0.2208; 41 | 42 | const double sram_unit_size_32768 = 32768; 43 | const double sram_area_32768 = 4161.536; 44 | const double sram_power_32768 = 4; 45 | 46 | const double bus_unit_area = 101.7938; 47 | const double bus_unit_power = 0.8; 48 | 49 | const double arbiter_unit_area = 395.473; 50 | const double arbiter_unit_power = 0.34; 51 | 52 | }; // End of namespace scaling_model 53 | }; // End of namespace DSE 54 | }; // End of namespace maestro 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lib/include/cost-analysis/CA_iteration-analysis.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_CA_ITERATION_ANALYSIS_HPP_ 24 | #define MAESTRO_CA_ITERATION_ANALYSIS_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | #include "CA_iterations.hpp" 30 | 31 | namespace maestro { 32 | namespace CA { 33 | class IterationAnalysis { 34 | public: 35 | IterationAnalysis() { 36 | iterations_ = std::make_shared>> (); 37 | } 38 | 39 | int GetTemporalIteration() { 40 | int tmp_iter = 1; 41 | 42 | for(auto& it : *iterations_) { 43 | tmp_iter *= it->GetNumTemporalIteration(); 44 | } 45 | 46 | return tmp_iter; 47 | } 48 | 49 | int GetSpatialIteration() { 50 | int sp_iter = 1; 51 | 52 | for(auto& it : *iterations_) { 53 | sp_iter *= it->GetNumSpatialIteration(); 54 | } 55 | return sp_iter; 56 | } 57 | 58 | void AddUnitIterationAnalysis(std::shared_ptr iteration) { 59 | iterations_->push_back(iteration); 60 | } 61 | 62 | protected: 63 | std::shared_ptr>> iterations_; 64 | 65 | }; // End of class IterationAnalysis 66 | }; // End of namespace CA 67 | }; // End of namespace maestro 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /lib/include/abstract-hardware-model/AHW-noc-model.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | #ifndef MAESTRO_AHW_NOC_MODEL_HPP_ 23 | #define MAESTRO_AHW_NOC_MODEL_HPP_ 24 | 25 | namespace maestro { 26 | 27 | namespace AHW { 28 | 29 | class NetworkOnChipModel { 30 | public: 31 | NetworkOnChipModel(int bw, int hops, int hop_latency ,bool mc) : 32 | bandwidth_(bw), num_average_hops_(hops), latency_per_hops_(hop_latency), multicast_support_(mc) { 33 | } 34 | 35 | int GetBandwidth() { 36 | return bandwidth_; 37 | } 38 | 39 | bool IsMulticastSupported() { 40 | return multicast_support_; 41 | } 42 | 43 | void SetBandwidth(int bw) { 44 | bandwidth_ = bw; 45 | } 46 | 47 | long GetOutStandingDelay(long data_amount) { 48 | long delay; 49 | 50 | long num_sends; 51 | if(data_amount % bandwidth_ != 0) { 52 | num_sends = data_amount / bandwidth_ + 1; 53 | } 54 | else { 55 | num_sends = data_amount / bandwidth_; 56 | } 57 | 58 | long avg_zero_load_delay = num_average_hops_ * latency_per_hops_; 59 | 60 | delay = avg_zero_load_delay // Head delay 61 | + (num_sends-1); // Pipeline delay 62 | 63 | return delay; 64 | } // End of GetOutStandingDelay 65 | 66 | protected: 67 | int bandwidth_; 68 | int num_average_hops_; 69 | int latency_per_hops_; 70 | bool multicast_support_; 71 | 72 | }; // End of class NetworkOnChipModel 73 | }; // End of namespace abstract_hw 74 | }; // End of namespace maestro 75 | #endif 76 | -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_tensor.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_TENSOR_HPP_ 24 | #define MAESTRO_DFA_TENSOR_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | #include "BASE_constants.hpp" 30 | 31 | namespace maestro { 32 | namespace DFA { 33 | 34 | enum class TensorClass {InputTensor, OutputTensor}; 35 | 36 | class Tensor { 37 | public: 38 | Tensor(std::string name, 39 | TensorClass tensor_class, 40 | DataClass data_class, 41 | std::shared_ptr> correlated_variables) : 42 | tensor_name_(name), 43 | tensor_class_(tensor_class), 44 | data_class_(data_class), 45 | coupled_variables_(correlated_variables) { 46 | } 47 | 48 | std::string GetTensorName() { 49 | return tensor_name_; 50 | } 51 | 52 | TensorClass GetTensorClass() { 53 | return tensor_class_; 54 | } 55 | 56 | DataClass GetDataClass() { 57 | return data_class_; 58 | } 59 | 60 | std::shared_ptr> GetCoupledVariables() { 61 | return coupled_variables_; 62 | } 63 | 64 | bool HasVariable(std::string search_var) { 65 | bool ret =false; 66 | for(auto& var : *coupled_variables_) { 67 | if(var == search_var) { 68 | ret = true; 69 | break; 70 | } 71 | } 72 | return ret; 73 | } 74 | 75 | protected: 76 | TensorClass tensor_class_; 77 | DataClass data_class_; 78 | std::string tensor_name_; 79 | std::shared_ptr> coupled_variables_; 80 | }; // End of class Tensor 81 | 82 | }; // End of namespace DFA 83 | }; // End of namespace maestro 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_summary-generator.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "HET_cost-class.hpp" 12 | #include "TL_generic-csv-writer.hpp" 13 | 14 | namespace maestro{ 15 | namespace HET { 16 | 17 | class SummaryGenerator { 18 | public: 19 | SummaryGenerator(std::string output_file_name) { 20 | csv_writer_ = std::make_unique(output_file_name); 21 | // Write headers 22 | csv_writer_->WriteWord("Model Name"); 23 | csv_writer_->WriteWord("Real-time Score"); 24 | csv_writer_->WriteWord("Energy Score"); 25 | csv_writer_->WriteWord("User-Experience Score", true); 26 | } 27 | 28 | void WriteSummary( 29 | std::shared_ptr>>> rt_scores, 30 | std::shared_ptr>>> en_scores, 31 | std::shared_ptr> ux_scores 32 | ) { 33 | for(auto it: *rt_scores) { 34 | auto model_name = it.first; 35 | auto rt_scores_logs = it.second; 36 | auto en_scores_logs = (*en_scores)[model_name]; 37 | auto ux_score_this_model = (*ux_scores)[model_name]; 38 | 39 | double rt_scores_sum = 0; 40 | double en_scores_sum = 0; 41 | int num_logs_this_model = rt_scores_logs->size(); 42 | for(int log_idx = 0; log_idx < num_logs_this_model; log_idx++) { 43 | //std::cout << "[" << model_name << "] rt_scores_sum: " << rt_scores_sum << std::endl; 44 | rt_scores_sum += (*rt_scores_logs)[log_idx]; 45 | en_scores_sum += (*en_scores_logs)[log_idx]; 46 | } 47 | 48 | double avg_rt_scores; 49 | double avg_en_scores; 50 | if(num_logs_this_model != 0) { 51 | avg_rt_scores = rt_scores_sum/static_cast(num_logs_this_model); 52 | avg_en_scores = en_scores_sum/static_cast(num_logs_this_model); 53 | } 54 | else { 55 | avg_rt_scores = 0; 56 | avg_en_scores = 0; 57 | } 58 | 59 | csv_writer_->WriteWord(model_name); 60 | csv_writer_->WriteWord(std::to_string(avg_rt_scores)); 61 | csv_writer_->WriteWord(std::to_string(avg_en_scores)); 62 | csv_writer_->WriteWord(std::to_string(ux_score_this_model), true); 63 | } 64 | 65 | } 66 | 67 | void WriteOverallScore(float score) { 68 | csv_writer_->WriteWord("Overall Score"); 69 | csv_writer_->WriteWord(std::to_string(score),true); 70 | } 71 | 72 | protected: 73 | std::unique_ptr csv_writer_; 74 | 75 | }; // End of class TimelineExtractor 76 | 77 | }; // End of namespace HET 78 | }; // End of namespace maestro 79 | -------------------------------------------------------------------------------- /XRbench_evaluation/scripts/draw_timeline.py: -------------------------------------------------------------------------------- 1 | # Importing the matplotlib.pyplot 2 | import matplotlib.pyplot as plt 3 | import csv 4 | import sys 5 | 6 | colorScheme = [ 7 | "#2D728F", 8 | "#FFCA3A", 9 | "#8AC926", 10 | "#FF595E", 11 | "#D5896F", 12 | "#DAB785", 13 | "#70A288", 14 | "#04395E", 15 | ] 16 | 17 | 18 | def draw_timeline_figure( 19 | input_csv_file_name, 20 | output_figure_file_name, 21 | num_accs, 22 | duration 23 | ): 24 | 25 | print("Draw timeline figure") 26 | # Declaring a figure "gnt" 27 | fig, gnt = plt.subplots() 28 | 29 | # Setting Y-axis limits 30 | gnt.set_ylim(0, num_accs) 31 | 32 | # Setting X-axis limits 33 | gnt.set_xlim(0, duration * 1.1) 34 | 35 | # Setting labels for x-axis and y-axis 36 | gnt.set_xlabel('Time (ms)') 37 | gnt.set_ylabel('Accelerator') 38 | 39 | yticks = [i for i in range(0, num_accs+2)] 40 | yticklabes = [""] + [ ("acc " + str(i)) for i in range(0, num_accs)] + [""] 41 | 42 | 43 | 44 | color_list = ['tab:orange', 'tab:blue', 'tab:red', 'tab:green', 'tab:purple', 'tab:brown', 'tab:olive'] 45 | model_name_list = [] 46 | 47 | # Setting ticks on y-axis 48 | #gnt.set_yticks([15, 25, 35]) 49 | gnt.set_yticks(yticks) 50 | # Labelling tickes of y-axis 51 | #gnt.set_yticklabels(['1', '2', '3']) 52 | gnt.set_yticklabels(yticklabes) 53 | 54 | # Setting graph attribute 55 | gnt.grid(True) 56 | 57 | with open(input_csv_file_name) as input_csv_file: 58 | csv_reader = csv.reader(input_csv_file, delimiter=',') 59 | line_count = 0 60 | for row in csv_reader: 61 | if line_count != 0: 62 | acc_id = float(row[0]) 63 | model_name = row[1] 64 | frame_id = int(row[2]) 65 | injection_time = float(row[3]) 66 | dispatch_time = float(row[4]) 67 | deadline_time = float(row[5]) 68 | completion_time = float(row[6]) 69 | 70 | color_Id = 0 71 | bar_color ='' 72 | if not model_name in model_name_list: 73 | model_name_list.append(model_name) 74 | 75 | model_idx = model_name_list.index(model_name) 76 | color_Id = model_idx 77 | bar_color = colorScheme[color_Id] 78 | 79 | gnt.broken_barh( 80 | [(dispatch_time, completion_time - dispatch_time)], 81 | (acc_id+0.7, 0.6), 82 | facecolors=(bar_color) 83 | ) 84 | 85 | 86 | line_count += 1 87 | 88 | 89 | plt.savefig(output_figure_file_name) 90 | 91 | 92 | if __name__ == "__main__": 93 | if len(sys.argv) == 5 and sys.argv[1].endswith(".csv"): # and sys.argv[2].endswith(".pdf") and isinstance(sys.argv[3],int) and sys.argv[3] > 0 and isinstance(sys.argv[4],int) and sys.argv[4] > 0 : 94 | input_csv_file_name = sys.argv[1] 95 | output_figure_file_name = sys.argv[2] 96 | num_accs = int(sys.argv[3]) 97 | duration = int(sys.argv[4]) 98 | draw_timeline_figure(input_csv_file_name, output_figure_file_name, num_accs, duration) 99 | -------------------------------------------------------------------------------- /XRbench_evaluation/scripts/run_evals.py: -------------------------------------------------------------------------------- 1 | import os 2 | import glob 3 | 4 | def GenerateExecCommand( 5 | hw_config_file_name, 6 | dataflow_config_file_name, 7 | usage_scenario_file_name, 8 | num_sub_accs_id 9 | ): 10 | 11 | num_sub_acc_prefix = "" 12 | 13 | if num_sub_accs_id == 0: 14 | num_sub_acc_prefix = "single/" 15 | elif num_sub_accs_id == 1: 16 | num_sub_acc_prefix = "dual/" 17 | elif num_sub_accs_id == 2: 18 | num_sub_acc_prefix = "quad/" 19 | else: 20 | pass 21 | 22 | hw_config = (hw_config_file_name.removeprefix("XRbench_evaluation/hw_configs/" + num_sub_acc_prefix)).removesuffix(".m") 23 | dataflow_config = (dataflow_config_file_name.removeprefix("XRbench_evaluation/dataflows/" + num_sub_acc_prefix)).removesuffix(".m") 24 | usage_scenario = usage_scenario_file_name.removeprefix("XRbench_evaluation/usage_scenarios/").removesuffix(".m") 25 | 26 | print("") 27 | print("===============") 28 | print(usage_scenario) 29 | print(hw_config) 30 | print(dataflow_config) 31 | 32 | sched_output_file_name = "XRbench_evaluation/eval_data/schedule/schedule_" + usage_scenario + "__" + hw_config + "__" + dataflow_config + ".csv" 33 | summary_output_file_name = "XRbench_evaluation/eval_data/summary/summary_" + usage_scenario + "__" + hw_config + "__" + dataflow_config + ".csv" 34 | 35 | ret = "./maestro " 36 | ret += " --model_file='" + usage_scenario_file_name + "'" 37 | ret += " --dataflow_file='" + dataflow_config_file_name + "'" 38 | ret += " --hw_file='" + hw_config_file_name + "'" 39 | ret += " --XRBench_timeline_output_file_name='" + sched_output_file_name + "'" 40 | ret += " --XRBench_summary_output_file_name='" + summary_output_file_name + "'" 41 | 42 | return ret 43 | 44 | 45 | def RunAllEvals(): 46 | os.system("rm -rf XRbench_evaluation/eval_data/schedule/*") 47 | os.system("rm -rf XRbench_evaluation/eval_data/summary/*") 48 | 49 | 50 | acc_hw_config_files = [] 51 | acc_hw_config_files.append(glob.glob("XRbench_evaluation/hw_configs/single/*")) 52 | acc_hw_config_files.append(glob.glob("XRbench_evaluation/hw_configs/dual/*")) 53 | acc_hw_config_files.append(glob.glob("XRbench_evaluation/hw_configs/quad/*")) 54 | 55 | datafow_config_files = [] 56 | datafow_config_files.append(glob.glob("XRbench_evaluation/dataflows/single/*")) 57 | datafow_config_files.append(glob.glob("XRbench_evaluation/dataflows/dual/*")) 58 | datafow_config_files.append(glob.glob("XRbench_evaluation/dataflows/quad/*")) 59 | 60 | 61 | usage_scenario_files = glob.glob("XRbench_evaluation/usage_scenarios/*") 62 | 63 | 64 | for i in range(0,len(usage_scenario_files)): 65 | #for i in range(0,1): 66 | usage_scenario_file = usage_scenario_files[i] 67 | for j in range(0, 3): 68 | #for j in range(1, 2): 69 | for k in range(0, len(acc_hw_config_files[j])): 70 | for l in range(0, len(datafow_config_files[j])): 71 | 72 | hw_config_file = acc_hw_config_files[j][k] 73 | dataflow_file = datafow_config_files[j][l] 74 | 75 | exec_cmd = GenerateExecCommand(hw_config_file, dataflow_file, usage_scenario_file, j) 76 | os.system(exec_cmd) 77 | 78 | 79 | if __name__ == "__main__": 80 | RunAllEvals() -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_timer.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "DFA_neural-network.hpp" 14 | #include "HET_inference-request.hpp" 15 | #include "HET_process.hpp" 16 | 17 | namespace maestro{ 18 | namespace HET { 19 | class Timer { 20 | public: 21 | Timer( 22 | float max_jitter, 23 | std::shared_ptr>> workloads, 24 | std::shared_ptr>> active_job_queue 25 | ): 26 | max_jitter_(max_jitter), 27 | workloads_(workloads), 28 | active_job_queue_(active_job_queue) { 29 | 30 | assert(workloads->size() > 0); 31 | num_models_ = workloads->size(); 32 | 33 | // Random seed for modeling jitter 34 | std::srand(static_cast(std::time(nullptr))); 35 | 36 | base_fps_ = -1; 37 | for(auto it: *workloads) { 38 | int fps_target = it->GetFPS(); 39 | base_fps_ = std::max(base_fps_, fps_target); 40 | } 41 | 42 | assert(base_fps_>0); 43 | 44 | base_tick_ = 1000/base_fps_; // time unit: ms 45 | 46 | current_time_ = 0; 47 | base_frame_ = 0; 48 | } 49 | 50 | float GetNextEventTime() { 51 | float next_bast_tick_time = (base_frame_+1) * base_tick_; 52 | float ret = next_bast_tick_time; 53 | /* 54 | std::cout << "[Timer] Current time: " << current_time_ << std::endl; 55 | std::cout << "[Timer] Next event time list" << std::endl; 56 | std::cout << " - Next FPS tick: " << ret << std::endl; 57 | */ 58 | // Check the active job queue 59 | int acc_id = 0; 60 | for(auto process: *active_job_queue_) { 61 | if(process != nullptr) { 62 | auto completion_time = process->GetCompletionTime(); 63 | // std::cout << " - Next completion time on accelerator " << acc_id << ": " << completion_time << std::endl; 64 | ret = std::min(ret, completion_time); 65 | } 66 | acc_id++; 67 | } 68 | 69 | assert(current_time_ < ret); 70 | 71 | if(ret == next_bast_tick_time) { 72 | base_frame_++; 73 | } 74 | current_time_ = ret; 75 | 76 | // std::cout << "[Timer] Selected next event time:" << ret << std::endl; 77 | 78 | return ret; 79 | } 80 | 81 | protected: 82 | float max_jitter_; 83 | int num_models_; 84 | int base_fps_; 85 | float base_tick_; 86 | float current_time_; 87 | 88 | int base_frame_; 89 | 90 | std::shared_ptr>> workloads_; 91 | std::shared_ptr>> active_job_queue_; // size: num_accs 92 | 93 | private: 94 | float GeneratorRandomNumber() { 95 | return ((float) std::rand()/RAND_MAX); 96 | } 97 | }; // End of class Timer 98 | 99 | }; // End of namespace HET 100 | }; // End of namespace maestro 101 | -------------------------------------------------------------------------------- /process_figure7_data.py: -------------------------------------------------------------------------------- 1 | 2 | import csv 3 | import os 4 | 5 | data_path = "XRbench_evaluation/eval_data/figure7/" 6 | 7 | filename_prefix = "summary__4K__" 8 | workload_name = "VR_gaming_" 9 | 10 | 11 | ACC_B_TAG = "AccB__OS__" 12 | ACC_J_TAG = "AccJ__WS_OS__" 13 | acc_tags = [ACC_B_TAG, ACC_J_TAG] 14 | 15 | PROB_25_TAG = "25p" 16 | PROB_50_TAG = "50p" 17 | PROB_75_TAG = "75p" 18 | PROB_100_TAG = "100p" 19 | probabilities = [PROB_25_TAG, PROB_50_TAG, PROB_75_TAG, PROB_100_TAG] 20 | 21 | overall_scores = [] 22 | rt_scores = [[0] * 3] 23 | 24 | # RT, EN, UE, Overall, COUNT 25 | Log = { 26 | ACC_B_TAG: {}, 27 | ACC_J_TAG: {} 28 | } 29 | 30 | Log[ACC_B_TAG] = { 31 | PROB_25_TAG: [0, 0, 0, 0, 0], 32 | PROB_50_TAG: [0, 0, 0, 0, 0], 33 | PROB_75_TAG: [0, 0, 0, 0, 0], 34 | PROB_100_TAG: [0, 0, 0, 0, 0], 35 | } 36 | 37 | Log[ACC_J_TAG] = { 38 | PROB_25_TAG: [0, 0, 0, 0, 0], 39 | PROB_50_TAG: [0, 0, 0, 0, 0], 40 | PROB_75_TAG: [0, 0, 0, 0, 0], 41 | PROB_100_TAG: [0, 0, 0, 0, 0], 42 | } 43 | 44 | N = 0 45 | 46 | for acc in acc_tags: 47 | for prob in probabilities: 48 | file_name = data_path + filename_prefix + acc + workload_name + prob + ".csv" 49 | print(N) 50 | N += 1 51 | if os.path.isfile(file_name): 52 | with open(file_name, 'r') as current_csv_file: 53 | for row in current_csv_file: 54 | split_row = row.split(",") 55 | if split_row[0] == "Overall Score": 56 | Log[acc][prob][3] += float(split_row[1]) 57 | Log[acc][prob][4] += 1 58 | elif split_row[0] == "Model Name": 59 | continue 60 | else: 61 | Log[acc][prob][0] += float(split_row[1]) 62 | Log[acc][prob][1] += float(split_row[2]) 63 | Log[acc][prob][2] += float(split_row[3]) 64 | 65 | 66 | for acc in acc_tags: 67 | for prob in probabilities: 68 | Log[acc][prob][0] /= (3 * Log[acc][prob][4]) 69 | Log[acc][prob][1] /= (3 * Log[acc][prob][4]) 70 | Log[acc][prob][2] /= (3 * Log[acc][prob][4]) 71 | Log[acc][prob][3] /= (Log[acc][prob][4] * 100) 72 | 73 | 74 | fig7_data_filename = data_path + "all_summary.csv" 75 | 76 | with open(fig7_data_filename, 'w') as res_csv_file: 77 | writer = csv.writer(res_csv_file) 78 | writer.writerow(["Accelerator", "Prob", "RT Score", "EN Score", "UX Score", "Overall Score"]) 79 | writer.writerow(["AccB", "25P", str(Log[ACC_B_TAG][PROB_25_TAG][0]),str(Log[ACC_B_TAG][PROB_25_TAG][1]), str(Log[ACC_B_TAG][PROB_25_TAG][2]), str(Log[ACC_B_TAG][PROB_25_TAG][3])]) 80 | writer.writerow(["AccB", "50P", str(Log[ACC_B_TAG][PROB_50_TAG][0]),str(Log[ACC_B_TAG][PROB_50_TAG][1]), str(Log[ACC_B_TAG][PROB_50_TAG][2]), str(Log[ACC_B_TAG][PROB_50_TAG][3])]) 81 | writer.writerow(["AccB", "75P", str(Log[ACC_B_TAG][PROB_75_TAG][0]),str(Log[ACC_B_TAG][PROB_75_TAG][1]), str(Log[ACC_B_TAG][PROB_75_TAG][2]), str(Log[ACC_B_TAG][PROB_75_TAG][3])]) 82 | writer.writerow(["AccB", "100P", str(Log[ACC_B_TAG][PROB_100_TAG][0]),str(Log[ACC_B_TAG][PROB_100_TAG][1]), str(Log[ACC_B_TAG][PROB_100_TAG][2]), str(Log[ACC_B_TAG][PROB_100_TAG][3])]) 83 | writer.writerow(["AccJ", "25P", str(Log[ACC_J_TAG][PROB_25_TAG][0]),str(Log[ACC_J_TAG][PROB_25_TAG][1]), str(Log[ACC_J_TAG][PROB_25_TAG][2]), str(Log[ACC_J_TAG][PROB_25_TAG][3])]) 84 | writer.writerow(["AccJ", "50P", str(Log[ACC_J_TAG][PROB_50_TAG][0]),str(Log[ACC_J_TAG][PROB_50_TAG][1]), str(Log[ACC_J_TAG][PROB_50_TAG][2]), str(Log[ACC_J_TAG][PROB_50_TAG][3])]) 85 | writer.writerow(["AccJ", "75P", str(Log[ACC_J_TAG][PROB_75_TAG][0]),str(Log[ACC_J_TAG][PROB_75_TAG][1]), str(Log[ACC_J_TAG][PROB_75_TAG][2]), str(Log[ACC_J_TAG][PROB_75_TAG][3])]) 86 | writer.writerow(["AccJ", "100P", str(Log[ACC_J_TAG][PROB_100_TAG][0]),str(Log[ACC_J_TAG][PROB_100_TAG][1]), str(Log[ACC_J_TAG][PROB_100_TAG][2]), str(Log[ACC_J_TAG][PROB_100_TAG][3])]) 87 | 88 | 89 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_task.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MAESTRO_HET_TASK_HPP_ 3 | #define MAESTRO_HET_TASK_HPP_ 4 | 5 | #include 6 | #include 7 | 8 | 9 | namespace maestro{ 10 | namespace HET { 11 | 12 | class Task { 13 | public: 14 | Task() { 15 | task_id_vector_ = std::make_shared>(); 16 | } 17 | 18 | int GetTopLevelTaskID() { 19 | if(task_id_vector_->empty()) { 20 | return -1; 21 | } 22 | else { 23 | return task_id_vector_->at(0); 24 | } 25 | } 26 | 27 | int GetGlobalTaskID() { 28 | if(task_id_vector_->empty()) { 29 | return -1; 30 | } 31 | 32 | int ret = 1; 33 | for (auto& task_id_at_dim : *task_id_vector_) { 34 | ret *= task_id_at_dim; 35 | } 36 | return ret; 37 | } 38 | 39 | void AddTaskID(int tid_at_lv) { 40 | task_id_vector_->push_back(tid_at_lv); 41 | } 42 | 43 | 44 | protected: 45 | std::shared_ptr> task_id_vector_; 46 | 47 | private: 48 | 49 | }; // End of class Task 50 | 51 | class ConvTask : public Task { 52 | public: 53 | 54 | void SetTaskID(int model_id, int layer_id) { 55 | task_id_vector_->push_back(model_id); 56 | task_id_vector_->push_back(layer_id); 57 | } 58 | 59 | protected: 60 | 61 | private: 62 | 63 | }; // End of class ConvTask 64 | 65 | enum class TaskDependence {Independent, Predecessor, Successor, NumTaskDependence}; 66 | 67 | template 68 | class TaskInfo { 69 | public: 70 | 71 | TaskInfo( 72 | std::shared_ptr task, 73 | std::shared_ptr> task_id_vector) : 74 | task_(task), 75 | task_id_vector_(task_id_vector) { 76 | } 77 | 78 | int GetTopLevelTaskID() { 79 | if(task_id_vector_->empty()) { 80 | return -1; 81 | } 82 | else { 83 | return task_id_vector_->at(0); 84 | } 85 | } 86 | 87 | int GetTaskID(int lv) { 88 | if(lv < task_id_vector_->size()) { 89 | return task_id_vector_->at(lv); 90 | } 91 | else { 92 | return -1; 93 | } 94 | } 95 | 96 | int GetGlobalTaskID() { 97 | int ret = 1; 98 | 99 | for(auto& task_id_dim: *task_id_vector_) { 100 | ret *= task_id_dim; 101 | } 102 | 103 | return ret; 104 | } 105 | 106 | TaskDependence operator < (TaskInfo& t2) { 107 | return this->Compare(t2); 108 | } 109 | 110 | TaskDependence Compare(TaskInfo& t2, int lv = 1) { 111 | int t1_topid = this->GetTopLevelTaskID(); 112 | int t2_topid = t2.GetTopLevelTaskID(); 113 | 114 | if(t1_topid != t2_topid) { 115 | return TaskDependence::Independent; 116 | } 117 | 118 | if(task_id_vector_->size() <2) { 119 | lv = 0; 120 | } 121 | 122 | int t1_gtid = this->GetTaskID(lv); 123 | int t2_gtid = t2.GetTaskID(lv); 124 | 125 | if(t1_gtid < t2_gtid) { 126 | return TaskDependence::Predecessor; 127 | } 128 | else { 129 | return TaskDependence::Successor; 130 | } 131 | } 132 | 133 | std::shared_ptr GetTask() { 134 | return task_; 135 | } 136 | 137 | private: 138 | const int max_layers_per_model_ = 256; 139 | 140 | std::shared_ptr> task_id_vector_; 141 | std::shared_ptr task_; 142 | }; // End of class TaskInfo 143 | 144 | 145 | }; // End of namespace HET 146 | }; // End of namespace maestro 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_dimension-overlap-info-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_DIMENSION_OVERLAP_INFO_HPP_ 24 | #define MAESTRO_DFA_DIMENSION_OVERLAP_INFO_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | namespace maestro { 33 | namespace DFA { 34 | 35 | class DimensionOverlapInfoTable { 36 | public: 37 | DimensionOverlapInfoTable() { 38 | overlapping_dimensions_ = std::make_unique>>>(); 39 | } 40 | 41 | void AddOverlapDimension(std::string reference_dim, std::string sliding_dim) { 42 | auto new_overlap_info = std::make_shared>(reference_dim, sliding_dim); 43 | overlapping_dimensions_->push_back(new_overlap_info); 44 | } 45 | 46 | void AddOverlapDimensions(std::shared_ptr>>> overlap_dim_list) { 47 | for(auto& it: *overlap_dim_list) { 48 | overlapping_dimensions_->push_back(it); 49 | } 50 | } 51 | 52 | bool IsOverlapped(std::string dim) { 53 | bool ret = false; 54 | 55 | for(auto& it: *overlapping_dimensions_) { 56 | auto ref_dim = it->first; 57 | auto sliding_dim = it->second; 58 | if(dim == ref_dim || dim == sliding_dim) { 59 | ret = true; 60 | break; 61 | } 62 | } 63 | 64 | return ret; 65 | } 66 | 67 | bool IsSlidingDim(std::string dim) { 68 | bool ret = false; 69 | 70 | for(auto& it: *overlapping_dimensions_) { 71 | auto sliding_dim = it->second; 72 | if(dim == sliding_dim) { 73 | ret = true; 74 | } 75 | } 76 | 77 | return ret; 78 | } 79 | 80 | std::string GetCounterPart(std::string dim) { 81 | std::string ret = ""; 82 | 83 | for(auto& it: *overlapping_dimensions_) { 84 | auto reference_dim = it->first; 85 | auto sliding_dim = it->second; 86 | if(dim == sliding_dim) { 87 | ret = reference_dim; 88 | } 89 | else if(dim == reference_dim) { 90 | ret = sliding_dim; 91 | } 92 | } 93 | 94 | return ret; 95 | } 96 | 97 | protected: 98 | std::unique_ptr>>> overlapping_dimensions_; 99 | 100 | }; // End of class DiemensionOverlapInfoTable 101 | 102 | 103 | }; // End of namespace DFA 104 | }; // End of namespace maestro 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /lib/include/cost-analysis/CA_iterations.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | #ifndef MAESTRO_CA_ITERATION_HPP_ 23 | #define MAESTRO_CA_ITERATION_HPP_ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "BASE_maestro-class.hpp" 34 | 35 | #include "DFA_directives.hpp" 36 | #include "DFA_tensor.hpp" 37 | 38 | #include "CA_analysis-types.hpp" 39 | 40 | namespace maestro { 41 | namespace CA { 42 | 43 | 44 | class IterationStatusInfo : public MAESTROClass { 45 | public: 46 | IterationStatusInfo() : 47 | MAESTROClass("IterationStatusInfo") { 48 | } 49 | 50 | void AddIterationInfo(std::pair>> iteration_info) { 51 | possible_status_.push_back(iteration_info); 52 | } 53 | 54 | protected: 55 | std::vector>>> possible_status_; 56 | 57 | }; 58 | 59 | 60 | class IterationStatusInstance : public MAESTROClass { 61 | public: 62 | IterationStatusInstance() : 63 | MAESTROClass("IterationStatusInstance") { 64 | } 65 | 66 | 67 | 68 | protected: 69 | std::map status_; 70 | 71 | }; 72 | 73 | 74 | class UnitIterationAnalysis { 75 | public: 76 | UnitIterationAnalysis(std::shared_ptr dataflow_directive, int dim_bound, int num_clusters) 77 | : dataflow_directive_(dataflow_directive), dimension_bound_(dim_bound), num_targ_clusters_(num_clusters) { 78 | } 79 | 80 | int GetNumTemporalIteration() { 81 | int ret = 1; 82 | if(dataflow_directive_->GetClass() == DFA::directive::DirectiveClass::TemporalMap) { 83 | ret = ceil(static_cast(dimension_bound_ - dataflow_directive_->GetSize() +1 ) / static_cast(dataflow_directive_->GetOfs())); 84 | } 85 | return ret; 86 | } 87 | 88 | int GetNumSpatialIteration() { 89 | int ret = 1; 90 | if(dataflow_directive_->GetClass() == DFA::directive::DirectiveClass::SpatialMap) { 91 | ret = ceil(static_cast(dimension_bound_ - dataflow_directive_->GetSize() +1 ) / static_cast(dataflow_directive_->GetOfs() * num_targ_clusters_)); 92 | } 93 | return ret; 94 | } 95 | 96 | int GetNumSpatialEdgeClusters() { 97 | return (dimension_bound_ - dataflow_directive_->GetSize() +1 ) % (dataflow_directive_->GetOfs() * num_targ_clusters_); 98 | } 99 | 100 | protected: 101 | std::shared_ptr dataflow_directive_; 102 | int dimension_bound_; 103 | int num_targ_clusters_; 104 | }; // End of class UnitIterationAnalysis 105 | 106 | 107 | }; // End of namespace CA 108 | }; // End of namespace maestro 109 | 110 | #endif 111 | 112 | -------------------------------------------------------------------------------- /XRbench_evaluation/scripts/generate_figure7.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | import glob 4 | import string 5 | import csv 6 | import os 7 | 8 | from math import pow 9 | 10 | dynamicSettingFolderName = { 11 | 25: "25percent/", 12 | 50: "25percent/", 13 | 75: "25percent/", 14 | } 15 | 16 | 17 | plot_path = "XRbench_evaluation/plots" 18 | 19 | 20 | colorScheme = [ 21 | "#D7233B", 22 | "#2D728F", 23 | ] 24 | 25 | 26 | num_benchmark_models = 11 27 | 28 | 29 | def generate_dynamic_cascading_plot( 30 | summary_csv_file_name = "XRbench_evaluation/eval_data/figure7/all_summary.csv", 31 | plot_path = "XRbench_evaluation/plots/", 32 | resolution = (12,5), 33 | bar_width = 0.2, 34 | ): 35 | scores = { 36 | "AccB": { 37 | "25P": [0,0,0,0], 38 | "50P": [0,0,0,0], 39 | "75P": [0,0,0,0], 40 | "100P": [0,0,0,0], 41 | }, 42 | "AccJ": { 43 | "25P": [0,0,0,0], 44 | "50P": [0,0,0,0], 45 | "75P": [0,0,0,0], 46 | "100P": [0,0,0,0], 47 | }, 48 | } 49 | 50 | with open(summary_csv_file_name, 'r') as data_csv_file: 51 | is_first_line = True 52 | summary_csv_reader = csv.reader(data_csv_file, delimiter=',') 53 | for row in summary_csv_reader: 54 | if is_first_line: 55 | is_first_line = False 56 | else: 57 | # RT Score 58 | scores[row[0]][row[1]][0] = float(row[2]) 59 | # EN Score 60 | scores[row[0]][row[1]][1] = float(row[3]) 61 | # QoE Score 62 | scores[row[0]][row[1]][2] = float(row[4]) 63 | # XRBench Score 64 | scores[row[0]][row[1]][3] = float(row[5]) 65 | 66 | 67 | scores_for_plotting = np.zeros((2,16)) 68 | 69 | # RT Score 70 | scores_for_plotting[0][0] = scores["AccB"]["25P"][0] 71 | scores_for_plotting[0][1] = scores["AccB"]["50P"][0] 72 | scores_for_plotting[0][2] = scores["AccB"]["75P"][0] 73 | scores_for_plotting[0][3] = scores["AccB"]["100P"][0] 74 | 75 | scores_for_plotting[1][0] = scores["AccJ"]["25P"][0] 76 | scores_for_plotting[1][1] = scores["AccJ"]["50P"][0] 77 | scores_for_plotting[1][2] = scores["AccJ"]["75P"][0] 78 | scores_for_plotting[1][3] = scores["AccJ"]["100P"][0] 79 | 80 | # EN Score 81 | scores_for_plotting[0][4] = scores["AccB"]["25P"][1] 82 | scores_for_plotting[0][5] = scores["AccB"]["50P"][1] 83 | scores_for_plotting[0][6] = scores["AccB"]["75P"][1] 84 | scores_for_plotting[0][7] = scores["AccB"]["100P"][1] 85 | 86 | scores_for_plotting[1][4] = scores["AccJ"]["25P"][1] 87 | scores_for_plotting[1][5] = scores["AccJ"]["50P"][1] 88 | scores_for_plotting[1][6] = scores["AccJ"]["75P"][1] 89 | scores_for_plotting[1][7] = scores["AccJ"]["100P"][1] 90 | 91 | # QoE Score 92 | scores_for_plotting[0][8] = scores["AccB"]["25P"][2] 93 | scores_for_plotting[0][9] = scores["AccB"]["50P"][2] 94 | scores_for_plotting[0][10] = scores["AccB"]["75P"][2] 95 | scores_for_plotting[0][11] = scores["AccB"]["100P"][2] 96 | 97 | scores_for_plotting[1][8] = scores["AccJ"]["25P"][2] 98 | scores_for_plotting[1][9] = scores["AccJ"]["50P"][2] 99 | scores_for_plotting[1][10] = scores["AccJ"]["75P"][2] 100 | scores_for_plotting[1][11] = scores["AccJ"]["100P"][2] 101 | 102 | # XRBench Score 103 | scores_for_plotting[0][12] = scores["AccB"]["25P"][3] 104 | scores_for_plotting[0][13] = scores["AccB"]["50P"][3] 105 | scores_for_plotting[0][14] = scores["AccB"]["75P"][3] 106 | scores_for_plotting[0][15] = scores["AccB"]["100P"][3] 107 | 108 | scores_for_plotting[1][12] = scores["AccJ"]["25P"][3] 109 | scores_for_plotting[1][13] = scores["AccJ"]["50P"][3] 110 | scores_for_plotting[1][14] = scores["AccJ"]["75P"][3] 111 | scores_for_plotting[1][15] = scores["AccJ"]["100P"][3] 112 | 113 | output_file_name = plot_path + "figure7_base" + ".pdf" 114 | 115 | xbar_labels = list(string.ascii_uppercase) 116 | x = np.arange(16) 117 | 118 | plt.rcParams["figure.figsize"] = (resolution[0],resolution[1]) 119 | 120 | plt.bar(x-0.7*bar_width, scores_for_plotting[0], width=bar_width, color=colorScheme[0]) 121 | plt.bar(x+0.7*bar_width, scores_for_plotting[1], width=bar_width, color=colorScheme[1]) 122 | #plt.xticks(x, xbar_labels[0:15]) 123 | plt.yticks([0,0.2,0.4,0.6,0.8,1.0], ["0", "0.2", "0.4", "0.6", "0.8", "1.0"]) 124 | print("Storing plot to " + output_file_name) 125 | plt.savefig(output_file_name, dpi=300, format="pdf", bbox_inches='tight', transparent=True) 126 | plt.clf() 127 | 128 | 129 | 130 | if __name__ == "__main__": 131 | generate_dynamic_cascading_plot() -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_cluster-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_CLUSTER_TABLE_HPP_ 24 | #define MAESTRO_DFA_CLUSTER_TABLE_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | #include "BASE_maestro-class.hpp" 30 | #include "TL_error-handler.hpp" 31 | 32 | #include "DFA_layer.hpp" 33 | #include "DFA_analysis-output.hpp" 34 | #include "DFA_cluster-unit.hpp" 35 | 36 | namespace maestro { 37 | namespace DFA { 38 | class ClusterTable: public MAESTROClass { 39 | public: 40 | 41 | /* 42 | * Custom iterator to support "for-each" loop over this data structure 43 | */ 44 | class iterator { 45 | private: 46 | std::shared_ptr>> iter_clusters_; 47 | public: 48 | 49 | int curr_idx_; 50 | 51 | iterator(std::shared_ptr>> ptr, int idx) : 52 | iter_clusters_(ptr), curr_idx_(idx) { 53 | } 54 | 55 | iterator operator++() { 56 | this->curr_idx_++; 57 | iterator iter = *this; 58 | return iter; 59 | } 60 | 61 | iterator operator--() { 62 | if(this->curr_idx_ != 0) { 63 | this->curr_idx_--; 64 | } 65 | iterator iter = *this; 66 | return iter; 67 | } 68 | 69 | std::shared_ptr& operator*() { 70 | return iter_clusters_->at(curr_idx_); 71 | } 72 | 73 | bool operator==(const iterator& rhs) { 74 | return (this->curr_idx_ == rhs.curr_idx_); 75 | } 76 | 77 | bool operator!=(const iterator& rhs) { 78 | return (this->curr_idx_ != rhs.curr_idx_); 79 | } 80 | 81 | }; // End of class iterator for class Directive_table 82 | 83 | iterator begin() { 84 | iterator iter(clusters_, 0); 85 | return iter; 86 | } 87 | 88 | iterator end() { 89 | iterator iter(clusters_, clusters_->size()); 90 | return iter; 91 | } 92 | /***********************************************************************************************/ 93 | 94 | ClusterTable(LayerType layer_type) : 95 | layer_type_(layer_type), 96 | MAESTROClass("ClusterTable") { 97 | clusters_ = std::make_shared>>(); 98 | } 99 | 100 | int size() { 101 | return clusters_->size(); 102 | } 103 | 104 | void PutCluster(std::shared_ptr new_cluster) { 105 | clusters_->push_back(new_cluster); 106 | } 107 | 108 | std::shared_ptr GetCluster(int lv) { 109 | if(lv < clusters_->size()) { 110 | return clusters_->at(lv); 111 | } 112 | else { 113 | error_handler_->PrintErrorMsg(TL::ErrorCode::InvalidClusterLevel, std::to_string(lv), instance_name_); 114 | return nullptr; 115 | } 116 | } 117 | 118 | LayerType GetLayerType() { 119 | return layer_type_; 120 | } 121 | 122 | protected: 123 | LayerType layer_type_; 124 | std::shared_ptr>> clusters_; 125 | 126 | }; // End of class ClusterTable 127 | }; // End of namespace DFA 128 | };// End of namespace maestro 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /lib/include/design-space-exploration/DSE_design_point.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSE_DESIGN_POINT_HPP_ 24 | #define MAESTRO_DSE_DESIGN_POINT_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "DSE_config.hpp" 31 | 32 | namespace maestro { 33 | namespace DSE { 34 | 35 | class DesignPoint { 36 | public: 37 | 38 | OptimizationTarget target_ = OptimizationTarget::Runtime; 39 | long runtime_ = 0; 40 | double energy_ = 0; 41 | long double performance_per_energy_ = 0; 42 | double area_ = 0; 43 | double power_ = 0; 44 | int num_pes_ = 1; 45 | int noc_bw_ = 16; 46 | int vector_width_ = 1; 47 | int l2_sram_sz = 1; 48 | int l1_sram_sz = 1; 49 | std::shared_ptr>> multicasting_factors_; 50 | 51 | DesignPoint(OptimizationTarget optimization_target, long runtime, 52 | double energy, long double performance_per_energy, double area, 53 | double power, int num_pes, int noc_bw, int vector_width, 54 | int l2_size, int l1_size) : 55 | target_(optimization_target), runtime_(runtime), energy_(energy), performance_per_energy_( 56 | performance_per_energy), area_(area), power_(power), num_pes_( 57 | num_pes), noc_bw_(noc_bw), vector_width_(vector_width), l2_sram_sz( 58 | l2_size), l1_sram_sz(l1_size) { 59 | multicasting_factors_ = std::make_shared< 60 | std::list>>(); 61 | } 62 | 63 | bool operator<(std::shared_ptr dp) { 64 | bool ret = false; 65 | if (dp != nullptr) { 66 | switch (target_) { 67 | case OptimizationTarget::Runtime: 68 | ret = runtime_ < dp->runtime_; 69 | break; 70 | case OptimizationTarget::Energy: 71 | ret = energy_ < dp->energy_; 72 | break; 73 | case OptimizationTarget::PerformancePerWatt: 74 | ret = performance_per_energy_ > dp->performance_per_energy_; 75 | break; 76 | } 77 | } 78 | return ret; 79 | } 80 | 81 | void PutMulticastingFactor(std::string dataclass, double factor) { 82 | multicasting_factors_->push_back(std::make_pair(dataclass, factor)); 83 | } 84 | 85 | double GetMulticastingFactor(std::string dataclass) { 86 | double ret = -1; 87 | for(auto& it : *multicasting_factors_) { 88 | if(it.first == dataclass) { 89 | ret = it.second; 90 | break; 91 | } 92 | } 93 | return ret; 94 | } 95 | 96 | void Print() { 97 | std::cout << "" << std::endl; 98 | std::cout << "Estimated runtime: " << runtime_ << std::endl; 99 | std::cout << "Estimated energy: " << energy_ << std::endl; 100 | std::cout << "Estimated area: " << area_ << std::endl; 101 | std::cout << "Estimated power: " << power_ << std::endl; 102 | std::cout << "Number of PEs: " << num_pes_ << std::endl; 103 | std::cout << "NoC bandwidth: " << noc_bw_ << std::endl; 104 | std::cout << "PE vector width: " << vector_width_ << std::endl; 105 | std::cout << "L2 size: " << l2_sram_sz << std::endl; 106 | std::cout << "L1 size: " << l1_sram_sz << std::endl; 107 | } 108 | 109 | }; 110 | // End of class DesignPoint 111 | } 112 | ; 113 | // End of namespace DSE 114 | } 115 | ; 116 | // End of namespace maestro 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_load-generator.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "DFA_neural-network.hpp" 14 | 15 | namespace maestro{ 16 | namespace HET { 17 | class LoadGenerator { 18 | public: 19 | LoadGenerator( 20 | float max_jitter, 21 | std::shared_ptr>> workloads 22 | ): 23 | max_jitter_(max_jitter), 24 | workloads_(workloads) { 25 | 26 | // Random seed for modeling jitter 27 | std::srand(static_cast(std::time(nullptr))); 28 | 29 | assert(workloads->size() > 0); 30 | num_models_ = workloads->size(); 31 | 32 | for(auto it: *workloads) { 33 | int fps_target = it->GetFPS(); 34 | inference_interval_.push_back(1000/fps_target); // Interval in ms 35 | dispatched_frame_ids_.push_back(-1); 36 | } 37 | } 38 | 39 | void Initialize(float ms_to_run) { 40 | for(int model_idx = 0; model_idx < num_models_; model_idx++) { 41 | // The unit of inference_interval_ is ms 42 | int num_total_requests = static_cast(std::floor(ms_to_run / inference_interval_[model_idx])); 43 | num_inferences_each_model_.push_back(num_total_requests); 44 | // std::cout << "[Load Generator] Model " << model_idx << ", num_total_requests = " << num_total_requests << std::endl; 45 | } 46 | } 47 | 48 | std::shared_ptr>> GetNewInferenceRequests(float current_time) { 49 | auto ret = std::make_shared>>(); 50 | 51 | for(int model_idx = 0; model_idx < num_models_; model_idx++) { 52 | float jitter_value = (GenerateRandomNumber() - 0.5) * this->max_jitter_; 53 | 54 | auto next_frame_injection_time = inference_interval_[model_idx] * (dispatched_frame_ids_[model_idx] + 1); 55 | // std::cout << "[Load Generator] Current time: " << current_time << std::endl; 56 | // std::cout << "[Load Generator] Next frame injection time for model " << model_idx << " : " << next_frame_injection_time << std::endl; 57 | if(next_frame_injection_time <= current_time) { 58 | 59 | if(dispatched_frame_ids_[model_idx] != num_inferences_each_model_[model_idx]-1) { 60 | // The deadline does not change based on the jitter 61 | float deadline = inference_interval_[model_idx] * (dispatched_frame_ids_[model_idx] + 2); 62 | auto model = workloads_->at(model_idx); 63 | dispatched_frame_ids_[model_idx] += 1; 64 | float inj_rand_num = GenerateRandomNumber(); 65 | 66 | //std::cout << model->GetName() << ", model_prob = " << model->GetProb() << std::endl; 67 | //std::cout << "inj_rand_num = " << inj_rand_num << std::endl; 68 | if(model->GetProb() > inj_rand_num) { 69 | auto new_inference_request = std::make_shared( 70 | dispatched_frame_ids_[model_idx], 71 | current_time, 72 | deadline, 73 | jitter_value, 74 | model 75 | ); 76 | /* 77 | std::cout << "[Load Generator] Load injection, Model " << model_idx 78 | << ", frame_id : " << dispatched_frame_ids_[model_idx] << ", deadline: " 79 | << deadline << std::endl; 80 | */ 81 | // Add inference request 82 | (*ret)[model->GetName()] = new_inference_request; 83 | } 84 | } 85 | } 86 | } 87 | 88 | return ret; 89 | } 90 | 91 | bool HasRemainingWorks(float current_time) { 92 | bool ret = false; 93 | 94 | // Check if any requests on at least one model is not yet dispatched 95 | for(int model_idx = 0; model_idx < num_models_; model_idx++) { 96 | assert(dispatched_frame_ids_[model_idx] <= num_inferences_each_model_[model_idx]-1); 97 | 98 | if(dispatched_frame_ids_[model_idx] < num_inferences_each_model_[model_idx]-1) { 99 | ret = true; 100 | break; 101 | } 102 | 103 | } 104 | return ret; 105 | } 106 | 107 | protected: 108 | float max_jitter_; 109 | int num_models_; 110 | std::shared_ptr>> workloads_; 111 | 112 | std::vector num_inferences_each_model_; 113 | std::vector dispatched_frame_ids_; 114 | std::vector inference_interval_; 115 | 116 | private: 117 | float GenerateRandomNumber() { 118 | return ((float) std::rand()/RAND_MAX); 119 | } 120 | }; // End of class LoadGenerator 121 | 122 | }; 123 | }; 124 | -------------------------------------------------------------------------------- /reproduce_figure7_data.sh: -------------------------------------------------------------------------------- 1 | 2 | echo "4K PE, Accelerator Style B, 25% probability cascading of gaze estimation - eye segmentation pipeline" 3 | ./maestro --verbose=true \ 4 | --full_buffer=false \ 5 | --model_file='XRbench_evaluation/probability_sweep/VR_gaming_25p.m' \ 6 | --dataflow_file='XRbench_evaluation/dataflows/single/OS.m' \ 7 | --hw_file='XRbench_evaluation/hw_configs/single/Single_4K.m' \ 8 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure7/sched__4K__AccB__OS__VR_gaming_25p.csv' \ 9 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure7/summary__4K__AccB__OS__VR_gaming_25p.csv' 10 | 11 | echo "4K PE, Accelerator Style B, 50% probability cascading of gaze estimation - eye segmentation pipeline" 12 | ./maestro --verbose=true \ 13 | --full_buffer=false \ 14 | --model_file='XRbench_evaluation/probability_sweep/VR_gaming_50p.m' \ 15 | --dataflow_file='XRbench_evaluation/dataflows/single/OS.m' \ 16 | --hw_file='XRbench_evaluation/hw_configs/single/Single_4K.m' \ 17 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure7/sched__4K__AccB__OS__VR_gaming_50p.csv' \ 18 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure7/summary__4K__AccB__OS__VR_gaming_50p.csv' 19 | 20 | echo "4K PE, Accelerator Style B, 75% probability cascading of gaze estimation - eye segmentation pipeline" 21 | ./maestro --verbose=true \ 22 | --full_buffer=false \ 23 | --model_file='XRbench_evaluation/probability_sweep/VR_gaming_75p.m' \ 24 | --dataflow_file='XRbench_evaluation/dataflows/single/OS.m' \ 25 | --hw_file='XRbench_evaluation/hw_configs/single/Single_4K.m' \ 26 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure7/sched__4K__AccB__OS__VR_gaming_75p.csv' \ 27 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure7/summary__4K__AccB__OS__VR_gaming_75p.csv' 28 | 29 | 30 | echo "4K PE, Accelerator Style B, 100% probability cascading of gaze estimation - eye segmentation pipeline" 31 | ./maestro --verbose=true \ 32 | --full_buffer=false \ 33 | --model_file='XRbench_evaluation/probability_sweep/VR_gaming_100p.m' \ 34 | --dataflow_file='XRbench_evaluation/dataflows/single/OS.m' \ 35 | --hw_file='XRbench_evaluation/hw_configs/single/Single_4K.m' \ 36 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure7/sched__4K__AccB__OS__VR_gaming_100p.csv' \ 37 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure7/summary__4K__AccB__OS__VR_gaming_100p.csv' 38 | 39 | 40 | 41 | echo "4K PE, Accelerator Style J, 25% probability cascading of gaze estimation - eye segmentation pipeline" 42 | ./maestro --verbose=true \ 43 | --full_buffer=false \ 44 | --model_file='XRbench_evaluation/probability_sweep/VR_gaming_25p.m' \ 45 | --dataflow_file='XRbench_evaluation/dataflows/dual/WS_OS.m' \ 46 | --hw_file='XRbench_evaluation/hw_configs/dual/Dual_4K.m' \ 47 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure7/sched__4K__AccJ__WS_OS__VR_gaming_25p.csv' \ 48 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure7/summary__4K__AccJ__WS_OS__VR_gaming_25p.csv' 49 | 50 | echo "4K PE, Accelerator Style J, 50% probability cascading of gaze estimation - eye segmentation pipeline" 51 | ./maestro --verbose=true \ 52 | --full_buffer=false \ 53 | --model_file='XRbench_evaluation/probability_sweep/VR_gaming_50p.m' \ 54 | --dataflow_file='XRbench_evaluation/dataflows/dual/WS_OS.m' \ 55 | --hw_file='XRbench_evaluation/hw_configs/dual/Dual_4K.m' \ 56 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure7/sched__4K__AccJ__WS_OS__VR_gaming_50p.csv' \ 57 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure7/summary__4K__AccJ__WS_OS__VR_gaming_50p.csv' 58 | 59 | 60 | echo "4K PE, Accelerator Style J, 75% probability cascading of gaze estimation - eye segmentation pipeline" 61 | ./maestro --verbose=true \ 62 | --full_buffer=false \ 63 | --model_file='XRbench_evaluation/probability_sweep/VR_gaming_75p.m' \ 64 | --dataflow_file='XRbench_evaluation/dataflows/dual/WS_OS.m' \ 65 | --hw_file='XRbench_evaluation/hw_configs/dual/Dual_4K.m' \ 66 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure7/sched__4K__AccJ__WS_OS__VR_gaming_75p.csv' \ 67 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure7/summary__4K__AccJ__WS_OS__VR_gaming_75p.csv' 68 | 69 | 70 | echo "4K PE, Accelerator Style J, 100% probability cascading of gaze estimation - eye segmentation pipeline" 71 | ./maestro --verbose=true \ 72 | --full_buffer=false \ 73 | --model_file='XRbench_evaluation/probability_sweep/VR_gaming_100p.m' \ 74 | --dataflow_file='XRbench_evaluation/dataflows/dual/WS_OS.m' \ 75 | --hw_file='XRbench_evaluation/hw_configs/dual/Dual_4K.m' \ 76 | --XRBench_timeline_output_file_name='XRbench_evaluation/eval_data/figure7/sched__4K__AccJ__WS_OS__VR_gaming_100p.csv' \ 77 | --XRBench_summary_output_file_name='XRbench_evaluation/eval_data/figure7/summary__4K__AccJ__WS_OS__VR_gaming_100p.csv' 78 | -------------------------------------------------------------------------------- /lib/include/user-api/API_configuration.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef API_CONFIGURATION_HPP_ 24 | #define API_CONFIGURATION_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | //#include "option.hpp" 30 | 31 | #include "BASE_base-objects.hpp" 32 | 33 | #include "DFA_tensor.hpp" 34 | #include "DFA_neural-network.hpp" 35 | #include "DFA_cluster-analysis.hpp" 36 | 37 | #include "DSE_hardware_modules.hpp" 38 | 39 | #include "AHW-noc-model.hpp" 40 | 41 | 42 | 43 | namespace maestro { 44 | 45 | class Configuration { 46 | 47 | public: 48 | Configuration(int num_pes, int vector_width, int top_noc_bw, int l1_sram_byte_size, int l2_sram_byte_size) 49 | : num_pes_(num_pes) { 50 | network_= std::make_shared(); 51 | tensors_ = std::make_shared(); 52 | nocs_ = std::make_shared>>(); 53 | cluster_analysis_= std::make_shared>>(); 54 | target_accelerator_ = std::make_shared 55 | (num_pes, vector_width, top_noc_bw, l1_sram_byte_size, l2_sram_byte_size); 56 | 57 | 58 | } 59 | /* 60 | Accelerator (int num_pes, int vector_width, int noc_bw, int l1_sram_byte_size, int l2_sram_byte_size) 61 | : num_pes_(num_pes), vector_width_(vector_width), noc_bw_(noc_bw) { 62 | ReconstructAccelerator(num_pes, vector_width, noc_bw, l1_sram_byte_size, l2_sram_byte_size); 63 | } 64 | */ 65 | std::shared_ptr network_; 66 | std::shared_ptr tensors_; 67 | std::shared_ptr>> cluster_analysis_; 68 | 69 | //Hardware 70 | std::shared_ptr target_accelerator_; 71 | std::shared_ptr>> nocs_; 72 | 73 | int num_pes_; 74 | }; // End of class Configuration 75 | 76 | class ConfigurationV2 { 77 | 78 | public: 79 | ConfigurationV2( 80 | std::string dfsl_file_name, 81 | std::shared_ptr> noc_bw, 82 | std::shared_ptr> noc_latency, 83 | std::shared_ptr> noc_multcast, 84 | int num_pes, 85 | int simd_width, 86 | int top_noc_bw, 87 | int l1_sram_byte_size, 88 | int l2_sram_byte_size) : 89 | dfsl_file_name_(dfsl_file_name), 90 | noc_multcast_(noc_multcast), 91 | noc_latency_(noc_latency), 92 | noc_bw_(noc_bw), 93 | num_pes_(num_pes), 94 | simd_width_(simd_width) { 95 | network_= std::make_shared(); 96 | tensors_ = std::make_shared>>(); 97 | nocs_ = std::make_shared>>(); 98 | cluster_analysis_= std::make_shared>>(); 99 | //TODO: Update NoC setup processes 100 | target_accelerator_ = std::make_shared 101 | (num_pes, simd_width, top_noc_bw, l1_sram_byte_size, l2_sram_byte_size); 102 | } 103 | 104 | std::string dfsl_file_name_; 105 | 106 | std::shared_ptr network_; 107 | 108 | std::shared_ptr>> tensors_; 109 | std::shared_ptr>> cluster_analysis_; 110 | 111 | //Hardware 112 | std::shared_ptr target_accelerator_; 113 | std::shared_ptr>> nocs_; 114 | 115 | std::shared_ptr> noc_multcast_; 116 | std::shared_ptr> noc_latency_; 117 | std::shared_ptr> noc_bw_; 118 | 119 | int num_pes_; 120 | int simd_width_; 121 | }; // End of class Configuration 122 | 123 | 124 | 125 | 126 | }; // End of namespace maestro 127 | 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_logger.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "HET_cost-class.hpp" 12 | 13 | 14 | namespace maestro{ 15 | namespace HET { 16 | 17 | class InferenceLog { 18 | public: 19 | InferenceLog( 20 | std::string model_name, 21 | int input_frame_id, 22 | float injection_time, 23 | float dispatch_time, 24 | float deadline, 25 | float finish_time, 26 | double energy, 27 | bool is_dropped 28 | ) : 29 | model_name_(model_name), 30 | input_frame_id_(input_frame_id), 31 | injection_time_(injection_time), 32 | dispatch_time_(dispatch_time), 33 | deadline_(deadline), 34 | completion_time_(finish_time), 35 | energy_(energy), 36 | is_dropped_(is_dropped) { 37 | } 38 | 39 | float ComputeDelay() { 40 | if(!is_dropped_) { 41 | return (completion_time_ - deadline_); 42 | } 43 | else { 44 | return std::numeric_limits::max(); 45 | } 46 | } 47 | 48 | bool IsDropped() { 49 | return is_dropped_; 50 | } 51 | 52 | std::string GetModelName() { 53 | return model_name_; 54 | } 55 | 56 | double GetEnergy() { 57 | if(is_dropped_) { 58 | return 0.0; 59 | } 60 | else { 61 | return energy_; 62 | } 63 | } 64 | 65 | int GetFrameID() { 66 | return input_frame_id_; 67 | } 68 | 69 | float GetInjectionTime() { 70 | return injection_time_; 71 | } 72 | 73 | float GetDispatchTime() { 74 | return dispatch_time_; 75 | } 76 | 77 | float GetDeadline() { 78 | return deadline_; 79 | } 80 | 81 | float GetCompletionTime() { 82 | return completion_time_; 83 | } 84 | 85 | protected: 86 | std::string model_name_; 87 | int input_frame_id_; 88 | float injection_time_; 89 | float dispatch_time_; 90 | float deadline_; 91 | float completion_time_; 92 | double energy_; 93 | bool is_dropped_; 94 | }; 95 | 96 | class Logger { 97 | public: 98 | Logger(int num_accelerators) : 99 | num_accelerators_(num_accelerators) { 100 | model_wise_log_ = std::make_shared>>>>(); 101 | model_list_ = std::make_shared>(); 102 | acc_wise_log_ = std::make_shared>>>>(); 103 | for(int acc_idx = 0; acc_idx < num_accelerators; acc_idx++) { 104 | auto acc_event_log = std::make_shared>>(); 105 | acc_wise_log_->push_back(acc_event_log); 106 | } 107 | } 108 | 109 | void AddLog( 110 | int acc_id, 111 | std::string model_name, 112 | int input_frame_id, 113 | float injection_time, 114 | float dispatch_time, 115 | float deadline, 116 | float finish_time, 117 | float energy, 118 | bool is_dropped 119 | ) { 120 | auto new_log = std::make_shared( 121 | model_name, 122 | input_frame_id, 123 | injection_time, 124 | dispatch_time, 125 | deadline, 126 | finish_time, 127 | energy, 128 | is_dropped 129 | ); 130 | 131 | //std::cout << "[Logger->AddLog] Generate a new log" << std::endl; 132 | // If logs of the model do not exist, create the log queue for the model 133 | if (model_wise_log_->find(model_name) == model_wise_log_->end()) { 134 | model_list_->push_back(model_name); 135 | (*model_wise_log_)[model_name] = std::make_shared>>(); 136 | //std::cout << "[Logger->AddLog] Register model entry to model_wise_log_" << std::endl; 137 | } 138 | 139 | // Push the log back to the log queue of the model 140 | (*model_wise_log_)[model_name]->push_back(new_log); 141 | //std::cout << "[Logger->AddLog] Insert new log to the model_wise_log_" << std::endl; 142 | //std::cout << "AcceleratorID: " << acc_id << ", acc_wise_log size: " << acc_wise_log_->size() << std::endl; 143 | (*acc_wise_log_)[acc_id]->push_back(new_log); 144 | //std::cout << "[Logger->AddLog] Insert new log to the acc_wise_log_" << std::endl; 145 | } 146 | 147 | std::shared_ptr>> GetModelLog(std::string model_name) { 148 | if (model_wise_log_->find(model_name) != model_wise_log_->end()) { 149 | return model_wise_log_->at(model_name); 150 | } 151 | else { 152 | return nullptr; 153 | } 154 | } 155 | 156 | std::shared_ptr> GetModelList() { 157 | return model_list_; 158 | } 159 | 160 | std::shared_ptr>> GetAccLog(int acc_id) { 161 | if(acc_id >= num_accelerators_) { 162 | return nullptr; 163 | } 164 | return acc_wise_log_->at(acc_id); 165 | } 166 | 167 | protected: 168 | int num_accelerators_; 169 | std::shared_ptr> model_list_; 170 | std::shared_ptr>>>> model_wise_log_; 171 | std::shared_ptr>>>> acc_wise_log_; 172 | }; // End of class Logger 173 | 174 | }; 175 | }; 176 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_scoring-module.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "HET_logger.hpp" 11 | 12 | //#define DEBUG_HET_SCORING_MODULE 13 | 14 | namespace maestro{ 15 | namespace HET { 16 | class ScoringModule { 17 | public: 18 | ScoringModule( 19 | float rt_score_param_k, 20 | float en_score_param_max_en 21 | ) : 22 | rt_score_param_k_(rt_score_param_k), 23 | en_score_param_max_en_(en_score_param_max_en), 24 | is_score_processed_(false) { 25 | 26 | } 27 | 28 | float ComputeScore(std::shared_ptr logger) { 29 | auto model_list = logger->GetModelList(); 30 | auto num_models = model_list->size(); 31 | 32 | auto modelwise_score = std::make_unique>(num_models); 33 | std::fill_n(modelwise_score->begin(), modelwise_score->size(), 0); 34 | 35 | std::map num_dropped_frames; 36 | 37 | ux_scores_ = std::make_shared>(); 38 | rt_scores_ = std::make_shared>>>(); 39 | en_scores_ = std::make_shared>>>(); 40 | 41 | 42 | int model_idx = 0; 43 | for(auto model_name : *model_list) { 44 | auto model_log = logger->GetModelLog(model_name); 45 | num_dropped_frames[model_name] = 0; 46 | 47 | (*rt_scores_)[model_name] = std::make_shared>(); 48 | (*en_scores_)[model_name] = std::make_shared>(); 49 | 50 | for(auto log :*model_log) { 51 | if(log->IsDropped()) { 52 | num_dropped_frames[model_name] = num_dropped_frames[model_name] + 1; 53 | } 54 | else { 55 | auto rt_score = this->ComputeRealtimeScore(log); 56 | auto en_score = this->ComputeEnergyScore(log); 57 | 58 | (*rt_scores_)[model_name]->push_back(rt_score); 59 | (*en_scores_)[model_name]->push_back(en_score); 60 | 61 | modelwise_score->at(model_idx) += rt_score * en_score; 62 | #ifdef DEBUG_HET_SCORING_MODULE 63 | std::cout << "Model " << log->GetModelName() << ", Inference score[" << log->GetFrameID() << "] = " << rt_score * en_score << std::endl; 64 | #endif 65 | } 66 | } // End of for(auto log :*model_log) 67 | model_idx++; 68 | } // End of for(auto model_name : *model_list) 69 | 70 | float overall_score = 0; 71 | 72 | model_idx = 0; 73 | for(auto model_name : *model_list) { 74 | auto model_log = logger->GetModelLog(model_name); 75 | 76 | float frame_drop_rate; 77 | if(model_log->size() != 0) { 78 | frame_drop_rate = static_cast(num_dropped_frames[model_name]) / static_cast(model_log->size()); 79 | } 80 | else { 81 | frame_drop_rate = 1; 82 | } 83 | #ifdef DEBUG_HET_SCORING_MODULE 84 | std::cout << "Model " << model_name << ", frame drop rate = " << frame_drop_rate << std::endl; 85 | #endif 86 | float ux_score = (1-frame_drop_rate); 87 | 88 | (*ux_scores_)[model_name] = ux_score; 89 | 90 | overall_score += (modelwise_score->at(model_idx)/model_log->size()) * ux_score; 91 | model_idx++; 92 | } 93 | 94 | overall_score /= num_models; 95 | overall_score *= 100; 96 | 97 | is_score_processed_ = true; 98 | return overall_score; 99 | } 100 | 101 | std::shared_ptr>>> GetRealTimeScores() { 102 | if(is_score_processed_) { 103 | return rt_scores_; 104 | } 105 | else { 106 | return nullptr; 107 | } 108 | } 109 | 110 | std::shared_ptr>>> GetEnergyScores() { 111 | if(is_score_processed_) { 112 | return en_scores_; 113 | } 114 | else { 115 | return nullptr; 116 | } 117 | } 118 | 119 | std::shared_ptr> GetUserExperienceScores() { 120 | if(is_score_processed_) { 121 | return ux_scores_; 122 | } 123 | else { 124 | return nullptr; 125 | } 126 | } 127 | 128 | protected: 129 | bool is_score_processed_; 130 | float rt_score_param_k_; 131 | float en_score_param_max_en_; 132 | 133 | float max_jitter_; 134 | int base_fps_; 135 | float tick_; 136 | float current_time_; 137 | std::shared_ptr> num_runs_within_base_fps_; 138 | std::shared_ptr cost_class_; 139 | std::shared_ptr>> workloads_; 140 | std::shared_ptr>>> rt_scores_; 141 | std::shared_ptr>>> en_scores_; 142 | std::shared_ptr> ux_scores_; 143 | private: 144 | float ComputeRealtimeScore( 145 | std::shared_ptr inference_log 146 | ) { 147 | auto delay = inference_log->ComputeDelay(); 148 | auto score = 1 / (1 + std::exp(rt_score_param_k_ * delay)); 149 | 150 | return score; 151 | } 152 | 153 | float ComputeEnergyScore( 154 | std::shared_ptr inference_log 155 | ) { 156 | 157 | auto score = (en_score_param_max_en_-inference_log->GetEnergy()) / en_score_param_max_en_; 158 | return score; 159 | } 160 | }; // End of class ScoringModule 161 | 162 | }; 163 | }; 164 | -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_neural-network.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_NEURAL_NETWORK_HPP_ 24 | #define MAESTRO_DFA_NEURAL_NETWORK_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "DFA_layer.hpp" 32 | 33 | namespace maestro{ 34 | namespace DFA { 35 | 36 | class NeuralNetwork { 37 | public: 38 | 39 | class iterator { 40 | private: 41 | std::shared_ptr>> iter_layers_; 42 | public: 43 | 44 | int curr_idx_; 45 | 46 | iterator(std::shared_ptr>> ptr, int idx) : 47 | iter_layers_(ptr), 48 | curr_idx_(idx) { 49 | } 50 | 51 | iterator operator++() { 52 | this->curr_idx_++; 53 | iterator iter = *this; 54 | return iter; 55 | } 56 | 57 | std::shared_ptr& operator*() { 58 | return iter_layers_->at(curr_idx_); 59 | } 60 | 61 | bool operator==(const iterator& rhs) { 62 | return (this->curr_idx_ == rhs.curr_idx_); 63 | } 64 | 65 | bool operator!=(const iterator& rhs) { 66 | return (this->curr_idx_ != rhs.curr_idx_); 67 | } 68 | }; // End of class iterator for class NeuralNetwork 69 | 70 | iterator begin() { 71 | return iterator(layers_, 0); 72 | } 73 | 74 | iterator end() { 75 | return iterator(layers_, layers_->size()); 76 | } 77 | 78 | std::shared_ptr operator [](int idx) { 79 | return GetLayer(idx); 80 | } 81 | 82 | std::shared_ptr at (int idx) { 83 | return GetLayer(idx); 84 | } 85 | 86 | NeuralNetwork() { 87 | layers_ = std::make_shared>>(); 88 | dependency_ = std::make_shared>(); 89 | trigger_probability_ = 1.0f; 90 | } 91 | 92 | NeuralNetwork(std::string name) : 93 | name_(name) { 94 | layers_ = std::make_shared>>(); 95 | trigger_probability_ = 1.0f; 96 | } 97 | 98 | bool operator==(NeuralNetwork& rhs) { 99 | return (this->GetName() == rhs.GetName()); 100 | } 101 | 102 | void SetDependency(std::string depend_on_model_name) { 103 | dependency_->push_back(depend_on_model_name); 104 | } 105 | 106 | bool CheckDependency(std::string model_name) { 107 | return ( 108 | std::any_of( 109 | dependency_->begin(), 110 | dependency_->end(), 111 | [model_name](std::string search_name){return search_name == model_name;}) 112 | ); 113 | } 114 | 115 | std::string GetName() { 116 | return name_; 117 | } 118 | 119 | void SetName(std::string name) { 120 | name_ = name; 121 | } 122 | 123 | int GetFPS() { 124 | return target_fps_; 125 | } 126 | 127 | void SetFPS(int fps) { 128 | target_fps_ = (fps > 0)? fps : 1; 129 | } 130 | 131 | float GetProb() { 132 | return trigger_probability_; 133 | } 134 | 135 | void SetProb(float prob) { 136 | //std::cout << "Setting prob as " << prob << std::endl; 137 | trigger_probability_ = prob; 138 | //std::cout << "Result: " << trigger_probability_ << std::endl; 139 | } 140 | 141 | 142 | void AddLayer(std::shared_ptr new_layer) { 143 | if(new_layer == nullptr) { 144 | std::cout << "Warning: Adding a null ptr" << std::endl; 145 | } 146 | layers_->push_back(new_layer); 147 | } 148 | 149 | int GetNumLayers() { 150 | return layers_->size(); 151 | } 152 | 153 | std::shared_ptr>> GetLayerList() { 154 | return layers_; 155 | } 156 | 157 | std::shared_ptr> GetDependencyList() { 158 | return dependency_; 159 | } 160 | 161 | 162 | protected: 163 | std::string name_; 164 | int target_fps_; 165 | float trigger_probability_; 166 | std::shared_ptr>> layers_; 167 | std::shared_ptr> dependency_; 168 | 169 | private: 170 | std::shared_ptr GetLayer(int idx) { 171 | if(idx < layers_->size()) { 172 | return layers_->at(idx); 173 | } 174 | else { 175 | return nullptr; 176 | } 177 | } 178 | }; // End of class NeuralNetwork 179 | 180 | }; // End of namespace DFA 181 | }; // End of namespace maestro 182 | 183 | #endif 184 | -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_tensor-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_TENSOR_TABLE_HPP_ 24 | #define MAESTRO_DFA_TENSOR_TABLE_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | #include "BASE_maestro-class.hpp" 30 | #include "TL_error-handler.hpp" 31 | 32 | #include "DFA_tensor.hpp" 33 | 34 | namespace maestro { 35 | namespace DFA { 36 | class TensorTable : public MAESTROClass { 37 | public: 38 | /* 39 | * Custom iterator to support "for-each" loop over this data structure 40 | */ 41 | class iterator { 42 | private: 43 | std::shared_ptr>> iter_tensors_; 44 | public: 45 | 46 | int curr_idx_; 47 | 48 | iterator(std::shared_ptr>> ptr, int idx) : 49 | iter_tensors_(ptr), curr_idx_(idx) { 50 | } 51 | 52 | iterator operator++() { 53 | this->curr_idx_++; 54 | iterator iter = *this; 55 | return iter; 56 | } 57 | 58 | std::shared_ptr& operator*() { 59 | return iter_tensors_->at(curr_idx_); 60 | } 61 | 62 | bool operator==(const iterator& rhs) { 63 | return (this->curr_idx_ == rhs.curr_idx_); 64 | } 65 | 66 | bool operator!=(const iterator& rhs) { 67 | return (this->curr_idx_ != rhs.curr_idx_); 68 | } 69 | 70 | }; // End of class iterator for class Directive_table 71 | 72 | iterator begin() { 73 | iterator iter(tensors_, 0); 74 | return iter; 75 | } 76 | 77 | iterator end() { 78 | iterator iter(tensors_, tensors_->size()); 79 | return iter; 80 | } 81 | /***********************************************************************************************/ 82 | 83 | 84 | TensorTable() { 85 | tensors_ = std::make_shared>>(); 86 | } 87 | 88 | std::shared_ptr at (int idx) { 89 | if(idx < tensors_->size()) { 90 | return tensors_->at(idx); 91 | } 92 | else { 93 | return nullptr; 94 | } 95 | } 96 | 97 | std::shared_ptr operator[] (int idx) { 98 | return this->at(idx); 99 | } 100 | 101 | void AddTensor(std::shared_ptr new_tensor) { 102 | tensors_->push_back(new_tensor); 103 | } 104 | 105 | 106 | void AddTensor(std::string tensor_name, DFA::TensorClass tensor_class, DataClass data_class, std::vector correlated_varaibles) { 107 | 108 | std::shared_ptr> corr_vars_to_be_added = std::make_shared>(); 109 | 110 | for(auto var : correlated_varaibles) { 111 | corr_vars_to_be_added->push_back(var); 112 | } 113 | 114 | auto new_tensor = std::make_shared(tensor_name, tensor_class, data_class, corr_vars_to_be_added); 115 | tensors_->push_back(new_tensor); 116 | } 117 | 118 | std::shared_ptr FindTensor(std::string tensor_name) { 119 | std::shared_ptr ret = nullptr; 120 | 121 | for(auto tensor : *tensors_) { 122 | if(tensor->GetTensorName() == tensor_name) { 123 | ret = tensor; 124 | } 125 | } 126 | 127 | return ret; 128 | } 129 | 130 | std::shared_ptr> GetTensorVarsInClass(DFA::TensorClass tensor_class) { 131 | std::shared_ptr> ret = std::make_shared>(); 132 | 133 | for(auto& tensor : *tensors_) { 134 | if(tensor->GetTensorClass() == tensor_class) { 135 | auto corr_var_list = tensor->GetCoupledVariables(); 136 | for(auto var : *corr_var_list) { 137 | ret->push_back(var); 138 | } 139 | } 140 | } 141 | 142 | ret->sort(); 143 | ret->unique(); 144 | 145 | return ret; 146 | } 147 | 148 | std::shared_ptr>> GetTensorsInClass(DFA::TensorClass tensor_class) { 149 | std::shared_ptr>> ret = std::make_shared>>(); 150 | 151 | for(auto& tensor : *tensors_) { 152 | if(tensor->GetTensorClass() == tensor_class) { 153 | ret->push_back(tensor); 154 | } 155 | } 156 | 157 | return ret; 158 | } 159 | 160 | 161 | 162 | protected: 163 | std::shared_ptr>> tensors_; 164 | 165 | }; // End of class TensorTable 166 | }; // End of namespace DFA 167 | }; // End of namespace maestro 168 | 169 | #endif 170 | -------------------------------------------------------------------------------- /lib/include/tools/TL_error-handler.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_TL_ERROR_HANDLER_HPP_ 24 | #define MAESTRO_TL_ERROR_HANDLER_HPP_ 25 | 26 | #include 27 | #include 28 | 29 | namespace maestro { 30 | namespace TL { 31 | 32 | enum class ErrorCode { 33 | NoSpatialMap, 34 | MissingDimension, 35 | NotEnoughSpDim, 36 | DuplicatedDimDefinition, 37 | InvalidCluster, 38 | InvalidClusterLevel, 39 | IllegalClusterConstruction, 40 | IllegalTemporalEdgeSp, 41 | InvalidTemporalEdgeSz, 42 | InvalidDirective, 43 | InvalidDimension, 44 | InvalidAnalysisCase, 45 | EdgeOnSpatialMap, 46 | MultiParallelismInSingleCluster, 47 | MissingNoCForCluster, 48 | NotSupportedLayerType 49 | }; 50 | 51 | class ErrorHandler { 52 | public: 53 | void PrintErrorMsg(ErrorCode error_code, std::string opt, std::string instance_name = "") { 54 | switch(error_code) { 55 | case ErrorCode::NoSpatialMap: { 56 | std::cout << "(Error@ " << instance_name << ") Cluster level: " << opt << ", No spatial map in a cluster" << std::endl; 57 | break; 58 | } 59 | case ErrorCode::MissingDimension: { 60 | std::cout << "(Error@ " << instance_name << ") Dimension " << opt << " not found" << std::endl; 61 | break; 62 | } 63 | case ErrorCode::NotEnoughSpDim: { 64 | std::cout << "(Error@ " << instance_name << ") Dimension " << opt << " is not sufficient for conv windows" << std::endl; 65 | break; 66 | } 67 | case ErrorCode::DuplicatedDimDefinition: { 68 | std::cout << "(Error@ " << instance_name << ") Trying to re-define the operator dimension " << opt << std::endl; 69 | break; 70 | } 71 | case ErrorCode::InvalidCluster: { 72 | std::cout << "(Error@ " << instance_name << ") Cluster level " << opt << " contains directives other than temporal and spatial map" << std::endl; 73 | break; 74 | } 75 | case ErrorCode::IllegalClusterConstruction: { 76 | std::cout << "(Error@ " << instance_name << ") Specified cluster does not cover entire number of PEs" << std::endl; 77 | break; 78 | } 79 | case ErrorCode::InvalidClusterLevel: { 80 | std::cout << "(Error@ " << instance_name << ") Cluster level " << opt << " does not exist" << std::endl; 81 | break; 82 | } 83 | case ErrorCode::IllegalTemporalEdgeSp: { 84 | std::cout << "(Error@ " << instance_name << ") variable " << opt << " is spatially mapped but temporal edge is set" << std::endl; 85 | break; 86 | } 87 | case ErrorCode::InvalidTemporalEdgeSz: { 88 | std::cout << "(Error@ " << instance_name << ") variable " << opt << " does not have edge" << std::endl; 89 | break; 90 | } 91 | case ErrorCode::InvalidDirective: { 92 | std::cout << "(Error@ " << instance_name << ") found an invalid directive on variable " << opt << "." << std::endl; 93 | break; 94 | } 95 | 96 | case ErrorCode::InvalidDimension: { 97 | std::cout << "(Error@ " << instance_name << ") encountered an invalid dimension " << opt << "." << std::endl; 98 | break; 99 | } 100 | 101 | case ErrorCode::InvalidAnalysisCase: { 102 | std::cout << "(Error@ " << instance_name << ") encountered an invalid analysis case. " << std::endl; 103 | break; 104 | } 105 | 106 | case ErrorCode::EdgeOnSpatialMap: { 107 | std::cout << "(Error@ " << instance_name << ") Dataflow cannot have edge on spatial map. Please check the mapping size of spatial map at cluter level " << opt << "." << std::endl; 108 | break; 109 | } 110 | 111 | case ErrorCode::MultiParallelismInSingleCluster: { 112 | std::cout << "(Error@ " << instance_name << ") Found too many spatial maps within a single cluster. Cluster level: " << opt << "." << std::endl; 113 | break; 114 | } 115 | 116 | case ErrorCode::MissingNoCForCluster: { 117 | std::cout << "(Error@ " << instance_name << ") NoC is not defined at cluster level " << opt << "." << std::endl; 118 | break; 119 | } 120 | 121 | case ErrorCode::NotSupportedLayerType: { 122 | std::cout << "(Error@ " << instance_name << ") Not supported layer type. " << std::endl; 123 | break; 124 | } 125 | 126 | default: { 127 | std::cout << "(Error) Error in class " << opt << std::endl; 128 | } 129 | } 130 | 131 | this->TerminateProgram(); 132 | } 133 | 134 | void TerminateProgram() { 135 | exit(-1); 136 | } 137 | 138 | protected: 139 | 140 | }; // End of class ErrorHandler 141 | 142 | }; // End of namespace DFA 143 | }; // End of namespace maestro 144 | 145 | #endif 146 | -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_directive-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_DIRECTIVE_TABLE_HPP_ 24 | #define MAESTRO_DFA_DIRECTIVE_TABLE_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "DFA_analysis-output.hpp" 32 | #include "DFA_directives.hpp" 33 | #include "DFSL_syntax_tokens.hpp" 34 | 35 | namespace maestro { 36 | namespace DFA { 37 | 38 | class DirectiveTable { 39 | public: 40 | 41 | class iterator { 42 | private: 43 | std::shared_ptr>> iter_directives_; 44 | public: 45 | 46 | int curr_idx_; 47 | 48 | iterator(std::shared_ptr>> ptr, int idx) : 49 | iter_directives_(ptr), 50 | curr_idx_(idx) { 51 | 52 | } 53 | 54 | iterator operator++() { 55 | this->curr_idx_++; 56 | iterator iter = *this; 57 | return iter; 58 | } 59 | 60 | std::shared_ptr& operator*() { 61 | return iter_directives_->at(curr_idx_); 62 | } 63 | 64 | bool operator==(const iterator& rhs) { 65 | return (this->curr_idx_ == rhs.curr_idx_); 66 | } 67 | 68 | bool operator!=(const iterator& rhs) { 69 | return (this->curr_idx_ != rhs.curr_idx_); 70 | } 71 | 72 | }; // End of class iterator for class Directive_table 73 | 74 | iterator begin() { 75 | iterator iter(directives_, 0); 76 | return iter; 77 | } 78 | 79 | iterator end() { 80 | iterator iter(directives_, directives_->size()); 81 | return iter; 82 | } 83 | 84 | DirectiveTable() { 85 | directives_ = std::make_shared>>(); 86 | } 87 | 88 | std::shared_ptr at (int idx) { 89 | if(idx < directives_->size()) { 90 | return directives_->at(idx); 91 | } 92 | else { 93 | return nullptr; 94 | } 95 | } 96 | 97 | std::shared_ptr operator[] (int idx) { 98 | return this->at(idx); 99 | } 100 | 101 | void ConvertToInputCentric() { 102 | 103 | int size_S, size_R = 0; 104 | 105 | for(auto& directive : *directives_) { 106 | if(directive->GetVariable() == DFSL::layer_dim_weight_width_) { 107 | size_S = directive->GetSize(); 108 | } 109 | else if(directive->GetVariable() == DFSL::layer_dim_weight_height_) { 110 | size_R = directive->GetSize(); 111 | } 112 | } 113 | 114 | for(auto& directive : *directives_) { 115 | if(directive->GetVariable() == DFSL::layer_dim_output_width_) { 116 | directive->SetVariable(DFSL::layer_dim_input_width_); 117 | directive->SetSize(directive->GetSize() + size_S -1); 118 | } 119 | else if(directive->GetVariable() == DFSL::layer_dim_output_height_) { 120 | directive->SetVariable(DFSL::layer_dim_input_height_); 121 | directive->SetSize(directive->GetSize() + size_R -1); 122 | } 123 | } 124 | } 125 | 126 | std::shared_ptr FindDirective (std::string var) { 127 | std::shared_ptr ret = nullptr; 128 | 129 | for(auto directive : *directives_) { 130 | if(directive->GetVariable() == var) { 131 | return directive; 132 | } 133 | } 134 | 135 | return ret; 136 | } 137 | 138 | int GetDirectiveIdx (std::string var) { 139 | int idx = 0; 140 | for(auto directive : *directives_) { 141 | if(directive->GetVariable() == var) { 142 | return idx; 143 | } 144 | idx++; 145 | } 146 | return idx; 147 | } 148 | 149 | int GetTemporalMapIdx (std::string var) { 150 | int idx = 0; 151 | for(auto directive : *directives_) { 152 | if(directive->GetVariable() == var) { 153 | return idx; 154 | } 155 | if(directive->GetClass() == DFA::directive::DirectiveClass::TemporalMap) { 156 | idx++; 157 | } 158 | } 159 | return idx; 160 | } 161 | 162 | void AddDirectiveFront(std::shared_ptr new_directive) { 163 | directives_->insert(directives_->begin(), new_directive); 164 | } 165 | 166 | 167 | void AddDirective(std::shared_ptr new_directive) { 168 | directives_->push_back(new_directive); 169 | } 170 | 171 | void RemoveDirectiveAt(int idx) { 172 | assert(idx < directives_->size() && idx >= 0); 173 | directives_->erase(directives_->begin() + idx); 174 | } 175 | 176 | void RemoveDirectiveBack() { 177 | directives_->pop_back(); 178 | } 179 | 180 | int size() { 181 | return directives_->size(); 182 | } 183 | 184 | std::string ToString() { 185 | std::string ret = ""; 186 | for(auto& it : *directives_) { 187 | ret = ret + it->ToString(); 188 | ret = ret + "\n"; 189 | } 190 | 191 | return ret; 192 | } 193 | 194 | protected: 195 | std::shared_ptr>> directives_; 196 | 197 | }; // End of class DirectiveTable 198 | 199 | }; // End of namespace DFA 200 | }; // End of namesapce maestro 201 | 202 | #endif 203 | -------------------------------------------------------------------------------- /lib/include/dataflow-specification-language/DFSL_syntax_tokens.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DSL_SYNTAX_TOKENS_HPP_ 24 | #define MAESTRO_DSL_SYNTAX_TOKENS_HPP_ 25 | 26 | #include 27 | 28 | namespace maestro { 29 | 30 | 31 | namespace DFSL { 32 | 33 | /* Common tokens */ 34 | const std::string brace_open_ = "{"; 35 | const std::string brace_close_ = "}"; 36 | const std::string bracket_open_ = "["; 37 | const std::string bracket_close_ = "]"; 38 | 39 | const std::string separator_ = ";"; 40 | const std::string comments_ = "//"; 41 | 42 | /* Neural network and layer Description */ 43 | const std::string network_decl_ = "Network"; 44 | const std::string network_fps_ = "FPS"; 45 | const std::string network_prob_ = "Probability"; 46 | const std::string layer_decl_ = "Layer"; 47 | const std::string layer_type_decl_ = "Type"; 48 | const std::string layer_type_conv2d_ = "CONV"; 49 | const std::string layer_type_residual_ = "RESIDUAL_IDENTITY"; 50 | const std::string layer_type_fc_ = "FC"; 51 | const std::string layer_type_pool_ = "POOL"; 52 | const std::string layer_type_dsconv_ = "DSCONV"; 53 | const std::string layer_type_trconv_ = "TRCONV"; 54 | const std::string layer_type_ngconv_ = "NGCONV"; // Nested grouped convolution (ResNeXt) 55 | const std::string layer_type_lstm_ = "LSTM"; 56 | const std::string layer_stride_decl_ = "Stride"; 57 | 58 | const std::string layer_dim_decl_ = "Dimensions"; 59 | const std::string layer_dim_input_batch_ = "N"; 60 | const std::string layer_dim_group_ = "G"; 61 | const std::string layer_dim_output_channel_ = "K"; 62 | const std::string layer_dim_input_channel_ = "C"; 63 | const std::string layer_dim_weight_height_ = "R"; 64 | const std::string layer_dim_weight_width_ = "S"; 65 | const std::string layer_dim_input_height_ = "Y"; 66 | const std::string layer_dim_input_width_ = "X"; 67 | const std::string layer_dim_output_height_ = "Y'"; 68 | const std::string layer_dim_output_width_ = "X'"; 69 | 70 | 71 | const std::string layer_expansion_factor_decl_ = "ExpansionSize"; 72 | const std::string layer_pooling_size_decl_ = "PoolSize"; 73 | const std::string layer_stride_size_decl_ = "Stride"; 74 | 75 | const std::string layer_dataflow_decl_ = "Dataflow"; 76 | const std::string dataflow_temporal_map_ = "TemporalMap"; 77 | const std::string dataflow_spatial_map_ = "SpatialMap"; 78 | const std::string dataflow_cluster_ = "Cluster"; 79 | 80 | const std::string dataflow_dim_size_indicatior_ = "Sz"; 81 | 82 | const std::string dataflow_cluster_type_logical_ = "L"; 83 | const std::string dataflow_cluster_type_physical_ = "P"; 84 | 85 | 86 | /* Hardware Resource Description */ 87 | const std::string accelerator_decl_ = "Accelerator"; 88 | 89 | // NoC Description 90 | const std::string noc_decl_ = "NoC"; 91 | const std::string noc_bandwidth_decl_ = "Bandwidth"; 92 | const std::string noc_avg_latency_decl_ = "AvgLatency"; 93 | 94 | const std::string offchip_bandwidth_decl_ = "OffchipBandwidth"; 95 | 96 | 97 | // PE Description 98 | const std::string pe_decl_ = "PE"; 99 | const std::string num_pe_decl_ = "NumPEs"; 100 | const std::string vector_width_decl_ = "VectorWidth"; 101 | 102 | const std::string mult_precision_decl_ = "MultPrecision"; 103 | const std::string add_precision_decl_ = "AddPrecision"; 104 | const std::string bfloat_precision_type = "BFLOAT"; 105 | const std::string float_precision_type = "FLOAT"; 106 | const std::string fixed_precision_type = "INT"; 107 | 108 | const std::string fp4_precision = "FP4"; 109 | const std::string fp8_precision = "FP8"; 110 | const std::string fp16_precision = "FP16"; 111 | const std::string fp32_precision = "FP32"; 112 | 113 | const std::string int4_precision = "INT4"; 114 | const std::string int8_precision = "INT8"; 115 | const std::string int16_precision = "INT16"; 116 | const std::string int32_precision = "INT32"; 117 | 118 | 119 | // Tmp for Metabench 120 | const std::string num_pe_identifier_ = "num_pes"; 121 | const std::string offchip_bandwidth_identifier_ = "offchip_bw"; 122 | const std::string top_noc_bw_identifier_ = "top_noc_bw"; 123 | const std::string top_noc_latency_identifier_ = "top_noc_latency"; 124 | const std::string top_noc_multicast_identifier_ = "top_noc_multicast"; 125 | const std::string col_noc_bw_identifier_ = "col_noc_bw"; 126 | const std::string col_noc_latency_identifier_ = "col_noc_latency"; 127 | const std::string col_noc_multicast_identifier_ = "col_noc_multicast"; 128 | const std::string global_shared_mem_identifier_ = "global_shared_memory"; 129 | const std::string pe_local_mem_identifier_ = "PE_local_memory"; 130 | 131 | const std::string true_identifier_ = "True"; 132 | const std::string false_identifier_ = "True"; 133 | 134 | // 135 | 136 | // Buffer Description 137 | const std::string buffer_decl_ = "Buffer"; 138 | const std::string buffer_type_global_ = "GlobalL2"; 139 | const std::string buffer_type_local_ = "LocalL1"; 140 | // const std::string buffer_level_decl_ = "Level:"; 141 | // const std::string buffer_size_decl_ = "Size:"; 142 | 143 | // Dependency Description 144 | 145 | const std::string dependency_decl_ = "Dependency"; 146 | 147 | }; 148 | 149 | } 150 | ; 151 | // End of name space maestro 152 | 153 | #endif 154 | -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_dimension-table.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_DIMENSION_TABLE_HPP_ 24 | #define MAESTRO_DFA_DIMENSION_TABLE_HPP_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "BASE_maestro-class.hpp" 31 | #include "TL_error-handler.hpp" 32 | 33 | #include "DFA_layer.hpp" 34 | #include "DFA_dimension-overlap-info-table.hpp" 35 | 36 | namespace maestro { 37 | namespace DFA { 38 | 39 | const int invalid_size = -1; 40 | 41 | class DimensionTable : public MAESTROClass { 42 | public: 43 | class iterator { 44 | private: 45 | std::map>* map_ptr_; 46 | std::map>::iterator map_iterator_; 47 | public: 48 | 49 | iterator(std::map>* ptr_layerdim_map) : 50 | map_ptr_(ptr_layerdim_map) { 51 | map_iterator_ = ptr_layerdim_map->begin(); 52 | } 53 | 54 | iterator operator++() { 55 | map_iterator_++; 56 | return *this; 57 | /* 58 | this->curr_idx_++; 59 | iterator iter = *this; 60 | return iter; 61 | */ 62 | } 63 | 64 | std::shared_ptr& operator*() { 65 | return map_iterator_->second; 66 | } 67 | 68 | bool operator==(const iterator& rhs) { 69 | return (this->map_iterator_ == rhs.map_iterator_); 70 | } 71 | 72 | bool operator!=(const iterator& rhs) { 73 | return (this->map_iterator_ != rhs.map_iterator_); 74 | } 75 | 76 | void set_end () { 77 | map_iterator_ = map_ptr_->end(); 78 | } 79 | }; // End of class iterator for class Directive_table 80 | 81 | iterator begin() { 82 | iterator iter(&dim_table_); 83 | return iter; 84 | } 85 | 86 | iterator end() { 87 | iterator iter(&dim_table_); 88 | iter.set_end(); 89 | return iter; 90 | } 91 | 92 | 93 | DimensionTable() : 94 | MAESTROClass("Dimension Table") { 95 | dim_overlap_table_ = std::make_shared(); 96 | } 97 | 98 | // Not a good way to use std::map; will remove after update deprecated code 99 | std::shared_ptr at (int idx) { 100 | int count = 0; 101 | 102 | for(auto iter = dim_table_.begin(); iter != dim_table_.end(); iter++) { 103 | if(count == idx) { 104 | return iter->second; 105 | } 106 | count ++; 107 | } 108 | return nullptr; 109 | } 110 | 111 | std::shared_ptr operator[] (int idx) { 112 | return this->at(idx); 113 | } 114 | 115 | bool HasVar(std::string targ) { 116 | return (dim_table_.find(targ) != dim_table_.end()); 117 | } 118 | 119 | int GetSize(std::string targ) { 120 | 121 | if(!this->HasVar(targ)) { 122 | error_handler_->PrintErrorMsg(TL::ErrorCode::MissingDimension, targ); 123 | error_handler_->TerminateProgram(); 124 | } 125 | 126 | return dim_table_[targ]->GetSize(); 127 | } 128 | 129 | int GetOuterStride(std::string targ) { 130 | 131 | if(!this->HasVar(targ)) { 132 | error_handler_->PrintErrorMsg(TL::ErrorCode::MissingDimension, targ); 133 | error_handler_->TerminateProgram(); 134 | } 135 | 136 | return dim_table_[targ]->GetOuterStride(); 137 | 138 | } 139 | 140 | int GetInnerStride(std::string targ) { 141 | 142 | if(!this->HasVar(targ)) { 143 | error_handler_->PrintErrorMsg(TL::ErrorCode::MissingDimension, targ); 144 | error_handler_->TerminateProgram(); 145 | } 146 | 147 | return dim_table_[targ]->GetInnerStride(); 148 | 149 | } 150 | 151 | 152 | void AddDimension(std::shared_ptr new_dimension) { 153 | dim_table_.insert(std::make_pair(new_dimension->GetName(), new_dimension)); 154 | } 155 | 156 | void AddOverlapDimension(std::string reference_dim, std::string sliding_dim) { 157 | dim_overlap_table_->AddOverlapDimension(reference_dim, sliding_dim); 158 | } 159 | 160 | void AddOverlapDimensions(std::shared_ptr>>> overlap_dim_list) { 161 | dim_overlap_table_->AddOverlapDimensions(overlap_dim_list); 162 | } 163 | 164 | void SetOverlapTable (std::shared_ptr new_table) { 165 | dim_overlap_table_ = new_table; 166 | } 167 | 168 | bool IsOverlapped(std::string dim) { 169 | return dim_overlap_table_->IsOverlapped(dim); 170 | } 171 | 172 | bool IsSlidingDim(std::string dim) { 173 | return dim_overlap_table_->IsSlidingDim(dim); 174 | } 175 | 176 | std::string GetOverlappingDim(std::string dim) { 177 | std::string ret; 178 | 179 | ret = dim_overlap_table_->GetCounterPart(dim); 180 | 181 | return ret; 182 | } 183 | 184 | std::shared_ptr GetOverlapTable() { 185 | return dim_overlap_table_; 186 | } 187 | 188 | std::string ToString() { 189 | std::string ret = "Dimension Table contents\n"; 190 | for(auto& it : dim_table_) { 191 | ret += it.second->ToString(); 192 | ret += "\n"; 193 | } 194 | return ret; 195 | } 196 | 197 | protected: 198 | std::map> dim_table_; 199 | 200 | std::shared_ptr dim_overlap_table_; 201 | 202 | }; 203 | }; 204 | }; 205 | #endif 206 | -------------------------------------------------------------------------------- /lib/include/dataflow-analysis/DFA_directives.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (c) 2019 Georgia Instititue of Technology 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | Author : Hyoukjun Kwon (hyoukjun@gatech.edu) 20 | *******************************************************************************/ 21 | 22 | 23 | #ifndef MAESTRO_DFA_DIRECTIVES_HPP_ 24 | #define MAESTRO_DFA_DIRECTIVES_HPP_ 25 | 26 | #include 27 | 28 | #include "DFSL_syntax_tokens.hpp" 29 | 30 | namespace maestro { 31 | namespace DFA { 32 | 33 | namespace directive { 34 | 35 | enum class DirectiveClass{TemporalMap, SpatialMap, Cluster, Invalid}; 36 | enum class ClusterType {Physical, Logical, Invalid}; 37 | 38 | class Directive { 39 | public: 40 | virtual ~Directive() {} 41 | 42 | virtual std::string ToString() { 43 | std::string ret = ""; 44 | return ret; 45 | } 46 | 47 | virtual void SetVariable(std::string new_var) { 48 | 49 | } 50 | 51 | virtual void SetSize(int new_size) { 52 | 53 | } 54 | 55 | virtual void SetOfs(int new_ofs) { 56 | 57 | } 58 | 59 | virtual DirectiveClass GetClass() { 60 | return DirectiveClass::Invalid; 61 | } 62 | 63 | virtual int GetSize() { 64 | return 0; 65 | } 66 | 67 | virtual int GetOfs() { 68 | return 0; 69 | } 70 | 71 | virtual std::string GetVariable() { 72 | return ""; 73 | } 74 | 75 | virtual ClusterType GetAllocType () { 76 | return ClusterType::Invalid; 77 | } 78 | 79 | }; 80 | 81 | class Map : public Directive { 82 | public: 83 | Map(int size, int offset, std::string var) : 84 | size_(size), offset_(offset), variable_(var) { 85 | } 86 | 87 | virtual DirectiveClass GetClass() { 88 | return DirectiveClass::Invalid; 89 | } 90 | 91 | virtual int GetSize() { 92 | return size_; 93 | } 94 | 95 | virtual int GetOfs() { 96 | return offset_; 97 | } 98 | 99 | virtual std::string GetVariable() { 100 | return variable_; 101 | } 102 | 103 | virtual ClusterType GetAllocType () { 104 | return ClusterType::Invalid; 105 | } 106 | 107 | virtual std::string ToString() { 108 | std::string ret = "Map " + variable_; 109 | return ret; 110 | } 111 | 112 | virtual void SetVariable(std::string new_var) { 113 | variable_ = new_var; 114 | } 115 | 116 | virtual void SetSize(int new_size) { 117 | size_ = new_size; 118 | } 119 | 120 | virtual void SetOfs(int new_ofs) { 121 | offset_ = new_ofs; 122 | } 123 | 124 | 125 | protected: 126 | std::string variable_; 127 | int size_; 128 | int offset_; 129 | }; // End of class Map 130 | 131 | class TemporalMap : public Map { 132 | public: 133 | 134 | TemporalMap(int size, int offset, std::string var) : 135 | Map(size, offset, var) { 136 | } 137 | 138 | virtual DirectiveClass GetClass() { 139 | return DirectiveClass::TemporalMap; 140 | } 141 | 142 | virtual int GetSize() { 143 | return size_; 144 | } 145 | 146 | virtual int GetOfs() { 147 | return offset_; 148 | } 149 | 150 | virtual std::string GetVariable() { 151 | return variable_; 152 | } 153 | 154 | virtual std::string ToString() { 155 | std::string ret = "TemporalMap(" + std::to_string(size_) + "," + std::to_string(offset_) + ") " + variable_; 156 | return ret; 157 | } 158 | 159 | virtual void SetVariable(std::string new_var) { 160 | variable_ = new_var; 161 | } 162 | 163 | virtual void SetSize(int new_size) { 164 | size_ = new_size; 165 | } 166 | 167 | virtual void SetOfs(int new_ofs) { 168 | offset_ = new_ofs; 169 | } 170 | 171 | protected: 172 | }; // End of class TemporalMap 173 | 174 | class SpatialMap : public Map { 175 | public: 176 | 177 | SpatialMap(int size, int offset, std::string var) : 178 | Map(size, offset, var) { 179 | } 180 | 181 | virtual DirectiveClass GetClass() { 182 | return DirectiveClass::SpatialMap; 183 | } 184 | 185 | virtual int GetSize() { 186 | return size_; 187 | } 188 | 189 | virtual int GetOfs() { 190 | return offset_; 191 | } 192 | 193 | virtual std::string GetVariable() { 194 | return variable_; 195 | } 196 | 197 | virtual ClusterType GetAllocType () { 198 | return ClusterType::Invalid; 199 | } 200 | 201 | virtual std::string ToString() { 202 | std::string ret = "SpatialMap(" + std::to_string(size_) + "," + std::to_string(offset_) + ") " + variable_; 203 | return ret; 204 | } 205 | 206 | virtual void SetVariable(std::string new_var) { 207 | variable_ = new_var; 208 | } 209 | 210 | virtual void SetSize(int new_size) { 211 | size_ = new_size; 212 | } 213 | 214 | virtual void SetOfs(int new_ofs) { 215 | offset_ = new_ofs; 216 | } 217 | 218 | protected: 219 | }; // End of class SpatialMap 220 | 221 | class Cluster : public Directive { 222 | public: 223 | Cluster(int size, ClusterType type) : size_(size), type_(type) { 224 | } 225 | 226 | virtual DirectiveClass GetClass() { 227 | return DirectiveClass::Cluster; 228 | } 229 | 230 | virtual int GetSize() { 231 | return size_; 232 | } 233 | 234 | virtual int GetOfs() { 235 | return 0; 236 | } 237 | 238 | virtual std::string GetVariable() { 239 | return ""; 240 | } 241 | 242 | virtual ClusterType GetAllocType () { 243 | return type_; 244 | } 245 | 246 | virtual std::string ToString() { 247 | std::string type_str; 248 | if(type_ == ClusterType::Logical) { 249 | type_str = DFSL::dataflow_cluster_type_logical_; 250 | } 251 | else { 252 | type_str = DFSL::dataflow_cluster_type_physical_; 253 | } 254 | std::string ret = "Cluster(" + std::to_string(size_) + "," + type_str + ")"; 255 | return ret; 256 | } 257 | 258 | virtual void SetVariable(std::string new_var) { 259 | } 260 | 261 | virtual void SetSize(int new_size) { 262 | size_ = new_size; 263 | } 264 | 265 | virtual void SetOfs(int new_ofs) { 266 | } 267 | 268 | protected: 269 | int size_; 270 | ClusterType type_ = ClusterType::Logical; 271 | };// End of class Cluster 272 | 273 | }; // End of namespace directive 274 | }; // End of namespace DFA 275 | }; // End of namespace maestro 276 | 277 | #endif 278 | -------------------------------------------------------------------------------- /lib/include/heterogeneous-space-exploration/HET_configuration.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is developed in Facebook as an internship project. 3 | * author: Hyoukjun Kwon (hyoukjunkwon@fb.com) 4 | * manager: Liangzhen Lai and Vikas Chandra 5 | */ 6 | 7 | #ifndef HET_CONFIGURATION_HPP_ 8 | #define HET_CONFIGURATION_HPP_ 9 | 10 | #include 11 | #include 12 | 13 | #include "DFA_cluster-unit.hpp" 14 | #include "DFA_cluster-table.hpp" 15 | 16 | #include "DFA_directive-table.hpp" 17 | 18 | #include "API_configuration.hpp" 19 | 20 | #include "HET_schedule.hpp" 21 | 22 | #include "HET_proccessor-assignment-engine.hpp" 23 | #include "HET_task-ordering-engine.hpp" 24 | #include "HET_time-alignment-engine.hpp" 25 | 26 | 27 | 28 | namespace maestro { 29 | namespace HET { 30 | 31 | 32 | enum class PEPartitioningStrategy {BruteForce, Uniform, NumPEPartitioningStrategies}; 33 | enum class BWPartitioningStrategy {BruteForce, Uniform, NumBWPartitioningStrategies}; 34 | 35 | class HetArchSearchConfig { 36 | public: 37 | std::string model_file_name_; 38 | std::string dataflow_file_name_; 39 | 40 | int num_procs_; 41 | int total_num_pes_; 42 | int pe_search_granul_; 43 | int total_bw_; 44 | int bw_search_granul_; 45 | 46 | int buffer_sz_; 47 | 48 | std::shared_ptr> num_simd_units_; 49 | std::shared_ptr> num_pe_cycles_; 50 | std::shared_ptr>>> noc_bandwidth_; 51 | 52 | BWPartitioningStrategy bw_partitioning_strategy_; 53 | PEPartitioningStrategy pe_partitioning_strategy_; 54 | 55 | ProcessorAssignmentStrategy proc_assignment_strategy_; 56 | TaskOrderingStrategy task_ordering_strategy_; 57 | TimeAlignmentStrategy alignment_strategy_; 58 | int sched_lookahead_depth_ = 10; 59 | 60 | HetArchSearchConfig( 61 | std::string model_file_name, 62 | std::string dataflow_file_name, 63 | int num_procs, 64 | int total_num_pes, 65 | int pe_search_granul, 66 | int total_bw, 67 | int bw_search_granul, 68 | int avg_noc_latency, 69 | std::shared_ptr> num_simd_units, 70 | std::shared_ptr> num_pe_cycles, 71 | std::shared_ptr>>> noc_bandwidth, 72 | ProcessorAssignmentStrategy proc_assignment_strategy, 73 | TaskOrderingStrategy task_ordering_strategy, 74 | TimeAlignmentStrategy alignment_strategy, 75 | int l2_buffer_sz, 76 | int sched_lookahead_depth = 10) : 77 | model_file_name_(model_file_name), 78 | dataflow_file_name_(dataflow_file_name), 79 | num_procs_(num_procs), 80 | total_num_pes_(total_num_pes), 81 | pe_search_granul_(pe_search_granul), 82 | total_bw_(total_bw), 83 | bw_search_granul_(bw_search_granul), 84 | num_simd_units_(num_simd_units), 85 | num_pe_cycles_(num_pe_cycles), 86 | noc_bandwidth_(noc_bandwidth), 87 | proc_assignment_strategy_(proc_assignment_strategy), 88 | task_ordering_strategy_(task_ordering_strategy), 89 | alignment_strategy_(alignment_strategy), 90 | buffer_sz_(l2_buffer_sz * 1024 * 1024), //Unit conversion to MiB 91 | sched_lookahead_depth_(sched_lookahead_depth), 92 | bw_partitioning_strategy_(BWPartitioningStrategy::BruteForce), 93 | pe_partitioning_strategy_(PEPartitioningStrategy::BruteForce) { 94 | } 95 | 96 | HetArchSearchConfig( 97 | std::string model_file_name, 98 | std::string dataflow_file_name, 99 | int num_procs, 100 | int total_num_pes, 101 | int pe_search_granul, 102 | int total_bw, 103 | int bw_search_granul, 104 | int avg_noc_latency, 105 | std::shared_ptr> num_simd_units, 106 | std::shared_ptr> num_pe_cycles, 107 | std::shared_ptr>>> noc_bandwidth, 108 | ProcessorAssignmentStrategy proc_assignment_strategy, 109 | TaskOrderingStrategy task_ordering_strategy, 110 | TimeAlignmentStrategy alignment_strategy, 111 | int l2_buffer_sz, 112 | int sched_lookahead_depth = 10, 113 | BWPartitioningStrategy bw_partitioning_strategy = BWPartitioningStrategy::BruteForce, 114 | PEPartitioningStrategy pe_partitioning_strategy = PEPartitioningStrategy::BruteForce 115 | ) : 116 | model_file_name_(model_file_name), 117 | dataflow_file_name_(dataflow_file_name), 118 | num_procs_(num_procs), 119 | total_num_pes_(total_num_pes), 120 | pe_search_granul_(pe_search_granul), 121 | total_bw_(total_bw), 122 | bw_search_granul_(bw_search_granul), 123 | num_simd_units_(num_simd_units), 124 | num_pe_cycles_(num_pe_cycles), 125 | noc_bandwidth_(noc_bandwidth), 126 | proc_assignment_strategy_(proc_assignment_strategy), 127 | task_ordering_strategy_(task_ordering_strategy), 128 | alignment_strategy_(alignment_strategy), 129 | buffer_sz_(l2_buffer_sz * 1024 * 1024), //Unit conversion to MiB 130 | sched_lookahead_depth_(sched_lookahead_depth), 131 | bw_partitioning_strategy_(bw_partitioning_strategy), 132 | pe_partitioning_strategy_(pe_partitioning_strategy) { 133 | } 134 | 135 | //Copy constructor 136 | HetArchSearchConfig(std::shared_ptr copy_src) { 137 | model_file_name_ = copy_src->model_file_name_; 138 | dataflow_file_name_ = copy_src->dataflow_file_name_; 139 | num_procs_ = copy_src->num_procs_; 140 | total_num_pes_ = copy_src->total_num_pes_; 141 | pe_search_granul_ = copy_src->pe_search_granul_; 142 | total_bw_ = copy_src->total_bw_; 143 | bw_search_granul_ = copy_src->bw_search_granul_; 144 | 145 | buffer_sz_ = copy_src->buffer_sz_; 146 | num_simd_units_ = std::make_shared>(*(copy_src->num_simd_units_)); 147 | num_pe_cycles_ = std::make_shared>(*(copy_src->num_pe_cycles_)); 148 | noc_bandwidth_ = std::make_shared>>>(); // Will not copy this! 149 | proc_assignment_strategy_ = copy_src->proc_assignment_strategy_; 150 | task_ordering_strategy_ = copy_src->task_ordering_strategy_; 151 | alignment_strategy_ = copy_src->alignment_strategy_; 152 | sched_lookahead_depth_ = copy_src->sched_lookahead_depth_; 153 | bw_partitioning_strategy_ = copy_src->bw_partitioning_strategy_; 154 | pe_partitioning_strategy_ = copy_src->pe_partitioning_strategy_; 155 | } 156 | 157 | 158 | /* 159 | auto maestro_config = std::make_shared(num_pes, option.num_alus_per_pe, bw, option.l1_size, option.l2_size); 160 | auto maestro_api = std::make_shared(maestro_config); 161 | */ 162 | 163 | void AddDataflow(std::shared_ptr new_dataflow) { 164 | dataflows_.push_back(new_dataflow); 165 | } 166 | 167 | void FlushDataflow() { 168 | dataflows_.clear(); 169 | } 170 | 171 | int GetNumDataflows() { 172 | return dataflows_.size(); 173 | } 174 | 175 | private: 176 | 177 | std::vector> dataflows_; 178 | 179 | 180 | }; // End of class HetArchSearchConfig 181 | 182 | } // End of namespace HET 183 | } // End of namespace maestro 184 | 185 | #endif 186 | --------------------------------------------------------------------------------