-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscale_sim.h
More file actions
118 lines (89 loc) · 2.95 KB
/
scale_sim.h
File metadata and controls
118 lines (89 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef _scale_sim_h
#define _scale_sim_h
#include <string>
#include <iostream>
#include "simulator.h"
#include "scale_config.h"
#include "topology_utils.h"
class ScaleSim
{
public:
ScaleSim(bool verbose, char* config, char* topology, bool input_type_gemm);
void set_params(char* config_file, char* topology_file);
void run_scale(char* top_path);
private:
void run_once();
void print_run_configs();
Config *config;
Topology *topology;
Simulator *simulator;
char* config_file;
char* topology_file;
bool read_gemm_inputs;
char* top_path;
bool verbose_flag = false;
bool run_done_flag = false;
bool logs_generated_flag = false;
};
ScaleSim::ScaleSim(bool verbose, char* config_file, char* topology_file, bool input_type_gemm)
{
this->verbose_flag = verbose;
this->read_gemm_inputs = input_type_gemm;
config = new Config();
topology = new Topology();
simulator = new Simulator();
run_done_flag = false;
logs_generated_flag = false;
this->set_params(config_file, topology_file);
}
void ScaleSim::set_params(char* config_file, char* topology_file)
{
this->config_file = config_file;
this->topology_file = topology_file;
config->read_conf_file(this->config_file);
topology->load_arrays(config, this->topology_file, config->is_prefetch_demand());
}
void ScaleSim::run_scale(char* top_path)
{
this->top_path = top_path;
simulator->set_params(config, topology, top_path, verbose_flag);
this->run_once();
}
void ScaleSim::run_once()
{
if (verbose_flag)
{
print_run_configs();
}
this->simulator->run();
run_done_flag = true;
logs_generated_flag = true;
if (verbose_flag)
{
printf("************ SCALE SIM Run Complete ****************\n");
}
}
void ScaleSim::print_run_configs()
{
string df_string = "Output Stationary";
string df = this->config->get_dataflow();
if (df == "ws")
df_string = "Weight Stationary";
else if (df == "is")
df_string = "Input Stationary";
printf("====================================================\n");
printf("******************* SCALE SIM **********************\n");
printf("====================================================\n");
auto array_dims = this->config->get_array_dims();
printf("Array Size: \t %ld X %ld \n", array_dims.arr_h, array_dims.arr_w);
auto mem_sizes = this->config->get_mem_sizes();
printf("SRAM IFMAP (kB): \t%ld\n", mem_sizes.ifmap_kb);
printf("SRAM Filter (kB): \t%ld\n", mem_sizes.filter_kb);
printf("SRAM OFMAP (kB): \t%ld\n", mem_sizes.ofmap_kb);
printf("Dataflow: \t%s\n", df_string.c_str());
printf("CSV file path: \t%s\n", this->config->get_topology_path().c_str());
printf("Number of Remote Memory Banks: \t%ld\n", this->config->get_mem_banks());
printf("Bandwidth: \t%ld\n", this->config->get_bandwidth());
printf("====================================================\n");
}
#endif