scalesim package
Subpackages
- scalesim.compute package
- Submodules
- scalesim.compute.operand_matrix module
operand_matrix
operand_matrix.calc_filter_elem_addr()
operand_matrix.calc_ifmap_elem_addr()
operand_matrix.calc_ofmap_elem_addr()
operand_matrix.create_filter_matrix()
operand_matrix.create_ifmap_matrix()
operand_matrix.create_ofmap_matrix()
operand_matrix.create_operand_matrices()
operand_matrix.get_all_operand_matrix()
operand_matrix.get_filter_matrix()
operand_matrix.get_filter_matrix_part()
operand_matrix.get_ifmap_matrix()
operand_matrix.get_ifmap_matrix_part()
operand_matrix.get_ofmap_matrix()
operand_matrix.get_ofmap_matrix_part()
operand_matrix.set_params()
- scalesim.compute.systolic_compute_is module
skew_matrix()
systolic_compute_is
systolic_compute_is.create_demand_matrices()
systolic_compute_is.create_filter_demand_mat()
systolic_compute_is.create_filter_prefetch_mat()
systolic_compute_is.create_ifmap_demand_mat()
systolic_compute_is.create_ifmap_prefetch_mat()
systolic_compute_is.create_ofmap_demand_mat()
systolic_compute_is.create_prefetch_matrices()
systolic_compute_is.get_avg_compute_utilization()
systolic_compute_is.get_avg_mapping_efficiency()
systolic_compute_is.get_demand_matrices()
systolic_compute_is.get_filter_demand_mat()
systolic_compute_is.get_filter_prefetch_mat()
systolic_compute_is.get_filter_requests()
systolic_compute_is.get_ifmap_demand_mat()
systolic_compute_is.get_ifmap_prefetch_mat()
systolic_compute_is.get_ifmap_requests()
systolic_compute_is.get_ofmap_demand_mat()
systolic_compute_is.get_ofmap_requests()
systolic_compute_is.get_prefetch_matrices()
systolic_compute_is.set_params()
- scalesim.compute.systolic_compute_os module
skew_matrix()
systolic_compute_os
systolic_compute_os.create_demand_matrices()
systolic_compute_os.create_filter_demand_mat()
systolic_compute_os.create_filter_prefetch_mat()
systolic_compute_os.create_ifmap_demand_mat()
systolic_compute_os.create_ifmap_prefetch_mat()
systolic_compute_os.create_ofmap_demand_mat()
systolic_compute_os.create_prefetch_matrices()
systolic_compute_os.get_avg_compute_utilization()
systolic_compute_os.get_avg_mapping_efficiency()
systolic_compute_os.get_demand_matrices()
systolic_compute_os.get_filter_demand_mat()
systolic_compute_os.get_filter_prefetch_mat()
systolic_compute_os.get_filter_requests()
systolic_compute_os.get_ifmap_demand_mat()
systolic_compute_os.get_ifmap_prefetch_mat()
systolic_compute_os.get_ifmap_requests()
systolic_compute_os.get_ofmap_demand_mat()
systolic_compute_os.get_ofmap_requests()
systolic_compute_os.get_prefetch_matrices()
systolic_compute_os.set_params()
- scalesim.compute.systolic_compute_ws module
skew_matrix()
systolic_compute_ws
systolic_compute_ws.create_demand_matrices()
systolic_compute_ws.create_filter_demand_mat()
systolic_compute_ws.create_filter_prefetch_mat()
systolic_compute_ws.create_ifmap_demand_mat()
systolic_compute_ws.create_ifmap_prefetch_mat()
systolic_compute_ws.create_ofmap_demand_mat()
systolic_compute_ws.create_prefetch_matrices()
systolic_compute_ws.get_avg_compute_utilization()
systolic_compute_ws.get_avg_mapping_efficiency()
systolic_compute_ws.get_demand_matrices()
systolic_compute_ws.get_filter_demand_mat()
systolic_compute_ws.get_filter_prefetch_mat()
systolic_compute_ws.get_filter_requests()
systolic_compute_ws.get_ifmap_demand_mat()
systolic_compute_ws.get_ifmap_prefetch_mat()
systolic_compute_ws.get_ifmap_requests()
systolic_compute_ws.get_ofmap_demand_mat()
systolic_compute_ws.get_ofmap_requests()
systolic_compute_ws.get_prefetch_matrices()
systolic_compute_ws.set_params()
- Module contents
- scalesim.memory package
- Submodules
- scalesim.memory.double_buffered_scratchpad_mem module
double_buffered_scratchpad
double_buffered_scratchpad.get_dram_trace_matrices()
double_buffered_scratchpad.get_filter_dram_details()
double_buffered_scratchpad.get_filter_dram_trace_matrix()
double_buffered_scratchpad.get_filter_sram_start_stop_cycles()
double_buffered_scratchpad.get_filter_sram_trace_matrix()
double_buffered_scratchpad.get_ifmap_dram_details()
double_buffered_scratchpad.get_ifmap_dram_trace_matrix()
double_buffered_scratchpad.get_ifmap_sram_start_stop_cycles()
double_buffered_scratchpad.get_ifmap_sram_trace_matrix()
double_buffered_scratchpad.get_ofmap_dram_details()
double_buffered_scratchpad.get_ofmap_dram_trace_matrix()
double_buffered_scratchpad.get_ofmap_sram_start_stop_cycles()
double_buffered_scratchpad.get_ofmap_sram_trace_matrix()
double_buffered_scratchpad.get_sram_trace_matrices()
double_buffered_scratchpad.get_stall_cycles()
double_buffered_scratchpad.get_total_compute_cycles()
double_buffered_scratchpad.print_filter_dram_trace()
double_buffered_scratchpad.print_filter_sram_trace()
double_buffered_scratchpad.print_ifmap_dram_trace()
double_buffered_scratchpad.print_ifmap_sram_trace()
double_buffered_scratchpad.print_ofmap_dram_trace()
double_buffered_scratchpad.print_ofmap_sram_trace()
double_buffered_scratchpad.reset_buffer_states()
double_buffered_scratchpad.service_filter_reads()
double_buffered_scratchpad.service_ifmap_reads()
double_buffered_scratchpad.service_memory_requests()
double_buffered_scratchpad.service_memory_requests_old()
double_buffered_scratchpad.service_ofmap_writes()
double_buffered_scratchpad.set_params()
double_buffered_scratchpad.set_read_buf_prefetch_matrices()
- scalesim.memory.read_buffer module
read_buffer
read_buffer.active_buffer_hit()
read_buffer.get_external_access_start_stop_cycles()
read_buffer.get_hit_latency()
read_buffer.get_latency()
read_buffer.get_num_accesses()
read_buffer.get_trace_matrix()
read_buffer.new_prefetch()
read_buffer.prefetch_active_buffer()
read_buffer.prepare_hashed_buffer()
read_buffer.print_trace()
read_buffer.reset()
read_buffer.service_reads()
read_buffer.set_fetch_matrix()
read_buffer.set_params()
- scalesim.memory.read_buffer_estimate_bw module
ReadBufferEstimateBw
ReadBufferEstimateBw.check_hit()
ReadBufferEstimateBw.complete_all_prefetches()
ReadBufferEstimateBw.get_external_access_start_stop_cycles()
ReadBufferEstimateBw.get_hit_latency()
ReadBufferEstimateBw.get_latency()
ReadBufferEstimateBw.get_num_accesses()
ReadBufferEstimateBw.get_trace_matrix()
ReadBufferEstimateBw.manage_prefetches()
ReadBufferEstimateBw.prefetch()
ReadBufferEstimateBw.print_trace()
ReadBufferEstimateBw.service_reads()
ReadBufferEstimateBw.set_params()
- scalesim.memory.read_port module
- scalesim.memory.write_buffer module
write_buffer
write_buffer.append_to_trace_mat()
write_buffer.empty_all_buffers()
write_buffer.empty_drain_buf()
write_buffer.get_external_access_start_stop_cycles()
write_buffer.get_free_space()
write_buffer.get_num_accesses()
write_buffer.get_trace_matrix()
write_buffer.print_trace()
write_buffer.reset()
write_buffer.service_writes()
write_buffer.set_params()
write_buffer.store_to_trace_mat_cache()
- scalesim.memory.write_port module
- Module contents
- scalesim.utilities package
- Submodules
- scalesim.utilities.scalesim_report module
ScalesimReport
ScalesimReport.get_compute_cycles_all_layer()
ScalesimReport.get_sram_ifmap_reads_all_layer()
ScalesimReport.get_sram_ifmap_reads_single_layer()
ScalesimReport.get_total_cycles_single_layer()
ScalesimReport.load_bandwidth_report_data()
ScalesimReport.load_compute_report_data()
ScalesimReport.load_data()
ScalesimReport.load_detail_report_data()
- Module contents
Submodules
scalesim.scale module
scalesim.scale_config module
scalesim.scale_sim module
- class scalesim.scale_sim.scalesim(save_disk_space=False, verbose=True, config='', topology='', input_type_gemm=False)[source]
Bases:
object
The top level class for the SCALE-Sim v2 simulator Provides methods for setting parameters, running sims, and generating results
- get_total_cycles()[source]
Method to get the total cycles (stalls + compute) for the workload once the simulation is completed
- Returns:
Total cycles
- print_run_configs()[source]
Method to print the banner of input parameters for verbose scalesim runs
- Returns:
None
- run_once()[source]
Method to run the simulation once with preset config and topology objects
- Returns:
None
scalesim.simulator module
- class scalesim.simulator.simulator[source]
Bases:
object
Class which runs the simulations and manages generated data across various layers
- generate_reports()[source]
Method to generate the report files for scalesim run if the runs are already completed. For each layer, this method collects the report data from single_layer_sim objects and then prints them out into COMPUTE_REPORT.csv, BANDWIDTH_REPORT.csv, and DETAILED_ACCESS_REPORT.csv files.
- Returns:
None
- get_total_cycles()[source]
Method which aggregates the total cycles (both compute and stall) across all the layers for the given workload.
- Returns:
Total runtime in cycles across all layers
- Return type:
int
- run()[source]
Method to run scalesim simulation for all layers. This method first runs compute and memory simulations for each layer and gathers the required stats. Once the simulation runs are done, it gathers the stats from single_layer_sim objects and calls generate_report() method to create the report files. If save_trace flag is set, then layer wise traces are saved as well.
- Returns:
None
- set_params(config_obj=<scalesim.scale_config.scale_config object>, topo_obj=<scalesim.topology_utils.topologies object>, top_path='./', verbosity=True, save_trace=True)[source]
Method to set the run parameters including inputs and parameters for housekeeping.
- Parameters:
config_obj – Object of scalesim.scale_config which is used to lookup the architecture and run parameters set by the user
topo_obj – Object of scalesim.topologies which is used to obtain the workload dimensions
top_path – Path where the generated logs and traces will be saved
verbosity – Flag to indicate verbosity of runs. If set to False, no output is generated on console
save_trace – Flag to indicate if cycle accurate traces needs to be saved
- Returns:
None
scalesim.single_layer_sim module
- class scalesim.single_layer_sim.single_layer_sim[source]
Bases:
object
Class which runs the simulation for a single layer and generates report data
- calc_report_data()[source]
Method to generate the report data for a single layer if the run is already completed. This method collects and calculates the data for compute, bandwidth and detail reports.
- Returns:
None
- get_bandwidth_report_items()[source]
Method to calculate data for the bandwidth report if not already done.
- Returns:
List of SRAM and DRAM bandwidths for the bandwidth report
- get_compute_report_items()[source]
Method to calculate data for the compute report if not already done.
- Returns:
List of data items for the compute report
- get_detail_report_items()[source]
Method to calculate data for the detailed report if not already done.
- Returns:
List of data items for the detailed report
- run()[source]
Method to run scalesim simulation for a single layer. This method first runs the compute part to generate operand, prefetch and demand matrices in order. After that, it runs the memory simulation using the demand matrices.
- Returns:
None
- save_traces(top_path)[source]
Method to save SRAM and DRAM traces for ifmap, filter and ofmap matrices.
- Parameters:
top_path – Path where the generated traces will be saved
- Returns:
None
- set_memory_system(mem_sys_obj=<scalesim.memory.double_buffered_scratchpad_mem.double_buffered_scratchpad object>)[source]
- set_params(layer_id=0, config_obj=<scalesim.scale_config.scale_config object>, topology_obj=<scalesim.topology_utils.topologies object>, verbose=True)[source]
Method to set the run parameters for housekeeping.
- Parameters:
layer_id – Layer number of the workload
config_obj – Object of scalesim.scale_config which is used to lookup the architecture and run parameters set by the user
topology_obj – Object of scalesim.topologies which is used to obtain the workload dimensions
verbose – Flag to indicate verbosity of runs. If set to False, no output is generated on console
- Returns:
None
scalesim.topology_utils module
- class scalesim.topology_utils.topologies[source]
Bases:
object
Class which contains the methods to preprocess the data from topology file (.csv format) before doing compute simulation.
- append_layer_entry(entry, toponame='')[source]
Method to append data of a single layer to the array containing data of all the layers. This method also calls topo_calc_hyperparams method to calculate the hyperparameters.
- Parameters:
entry – List containing dimensions(int data type) of the workload layer and its name
toponame – Name of the workload
- Returns:
None
- append_topo_arrays(layer_name, elems)[source]
Method to append the layer dimensions in int data type and layer name to the topo_arrays variable. This method also checks that the filter dimensions do not exceed the ifmap dimensions.
- Parameters:
layer_name – Name of the workload layer
elems – List of elements containing dimensions of the workload layer
- Returns:
None
- append_topo_entry_from_list(layer_entry_list=[])[source]
Method to append the layer dimensions in int data type and layer name.
- Parameters:
layer_entry_list – List of elements containing dimensions and name of the workload layer
- Returns:
None
- calc_spatio_temporal_params(df='os', layer_id=0)[source]
Method to calculate spatio-temporal parameters (S_r, S_c and T) based on the dataflow. (Refer the scalesim paper for more info)
- Parameters:
df – Name of the dataflow (input, output or weight stationary)
layer_id – Layer number of the workload
- Returns:
spatio-temporal parameters (S_r, S_c and T)
- get_all_mac_ops()[source]
Method to get the total number of mac operations of all the layer if hyper-parameters are calculated. If not, calculate the hyper-parameters first.
- Returns:
Total number of mac operations of all the layers
- get_current_topo_name()[source]
Method to get the name of the workload if available. If not, print an error message.
- Returns:
Name of the workload
- get_layer_filter_dims(layer_id=0)[source]
Method to get the filter dimensions of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Filter height and width
- get_layer_id_from_name(layer_name='')[source]
Method to get layer number from the given layer name if available. If not, print an error message.
- Parameters:
layer_name – Name of the layer
- Returns:
Layer number of the workload
- get_layer_ifmap_dims(layer_id=0)[source]
Method to get the ifmap dimensions of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Ifmap height and width
- get_layer_mac_ops(layer_id=0)[source]
Method to get the number of mac operations of the layer if hyper-parameters are calculated. If not, calculate the hyper-parameters first.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Number of mac operations of the layer
- get_layer_name(layer_id=0)[source]
Method to get the layer name from the given layer number if available. If not, print an error message.
- Parameters:
layer_name – Layer number of the workload
- Returns:
Name of the layer
- get_layer_names()[source]
Method to get the names of all the layers in the workload. If not, print an error message.
- Returns:
Names of all the layers
- get_layer_num_channels(layer_id=0)[source]
Method to get the number of channels of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
:return:Number of channels
- get_layer_num_filters(layer_id=0)[source]
Method to get the number of filters of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Number of filters
- get_layer_num_ofmap_px(layer_id=0)[source]
Method to get the number of ofmap pixels of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Number of ofmap pixels
- get_layer_ofmap_dims(layer_id=0)[source]
Method to get the ofmap dimensions of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Ofmap height and width
- get_layer_params(layer_id=0)[source]
Method to get the parameters of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Parameters of the layer
- get_layer_strides(layer_id=0)[source]
Method to get the strides of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Strides (both horizontal and vertical) of the convolution
- get_layer_window_size(layer_id=0)[source]
Method to get the convolution window size of the layer if available. If not, print an error message.
- Parameters:
layer_id – Layer number of the workload
- Returns:
Convolution window size
- get_num_layers()[source]
Method to get the number of layers of the workload if available. If not, print an error message.
- Returns:
Number of layers of the workload
- get_spatiotemporal_dims(layer_id=0, df='')[source]
Method to get the spatio-temporal dimensions (S_r, S_c, T) of the layer if spatio-temporal parameters are calculated. If not, calculate the spatio-temporal parameters first. (refer to the scalesim paper for more info)
- Parameters:
layer_id – Layer number of the workload
df – Name of the dataflow (input, output or weight stationary)
- Returns:
Spatio-temporal dimensions of the layer (S_r, S_c, T)
- get_transformed_mnk_dimensions()[source]
Method to get M, N and K parameters for all the layers. These are GEMM parameters in which an input matrix of dimensions MxN is multiplied to a filter matrix of dimensions NxK.
- Returns:
M, N and K parameters array
- load_arrays(topofile='')[source]
Method to read the topology file and collect names and dimensions of all the workload layers.
- Parameters:
topofile – Name of the topology file
- Returns:
None
- load_layer_params_from_list(layer_name, elems_list=[])[source]
Method to load layer parameters from the given layer name and element list.
- Parameters:
layer_name – Name of the workload layer
elem_list – List of elements containing dimensions of the workload layer
- Returns:
None
- set_spatio_temporal_params()[source]
Method to calculate spatio-temporal parameters (S_r, S_c and T) for all the layers
- Returns:
None