Skip to content

Commit d93bf59

Browse files
committed
refactor: update configuration management
1 parent dae731d commit d93bf59

File tree

18 files changed

+316
-250
lines changed

18 files changed

+316
-250
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
target/
22
Cargo.lock
33
build/
4+
m5out/
45

5-
.json
6+
*.json

bebop/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
m5out
1+

bebop/bin/bebop.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bebop::simulator::config::config::load_and_merge_configs;
1+
use bebop::simulator::config::config::load_configs;
22
use bebop::simulator::utils::log::init_log;
33
use bebop::simulator::Simulator;
44
use clap::Parser;
@@ -60,12 +60,12 @@ fn main() -> std::io::Result<()> {
6060

6161
let args = Args::parse();
6262

63-
// 获取bebop文件夹路径(CARGO_MANIFEST_DIR
63+
// Get bebop folder path (CARGO_MANIFEST_DIR)
6464
let bebop_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
6565
let bebop_root = bebop_root.join("..").to_path_buf();
6666

67-
// 加载并合并配置
68-
let app_config = load_and_merge_configs(
67+
// Load and merge configuration
68+
let app_config = load_configs(
6969
args.config_file.as_deref(),
7070
&bebop_root,
7171
args.quiet,
@@ -80,8 +80,6 @@ fn main() -> std::io::Result<()> {
8080
args.gem5_mode.as_deref(),
8181
)?;
8282

83-
// 从AppConfig直接创建Simulator
8483
let mut simulator = Simulator::from_app_config(&app_config)?;
85-
8684
simulator.run()
8785
}

bebop/src/arch/buckyball/bmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn init_bmt(num_vbanks: u64, num_pbanks: u64) {
2222
*BANK_MAP_TABLE.lock().unwrap() = Some(state);
2323
}
2424

25-
/// 分配物理 bank
25+
/// Allocate physical bank
2626
pub fn allocate_bank(vbank_id: u64, num_pbanks: u64) -> Option<Vec<u64>> {
2727
let mut state_opt = BANK_MAP_TABLE.lock().unwrap();
2828
if let Some(ref mut state) = *state_opt {
@@ -50,7 +50,7 @@ pub fn allocate_bank(vbank_id: u64, num_pbanks: u64) -> Option<Vec<u64>> {
5050
None
5151
}
5252

53-
/// 释放虚拟 bank
53+
/// Free virtual bank
5454
pub fn free_bank(vbank_id: u64) -> bool {
5555
let mut state_opt = BANK_MAP_TABLE.lock().unwrap();
5656
if let Some(ref mut state) = *state_opt {
@@ -65,7 +65,7 @@ pub fn free_bank(vbank_id: u64) -> bool {
6565
false
6666
}
6767

68-
/// 查询虚拟 bank 对应的物理 bank 列表
68+
/// Query physical bank list corresponding to virtual bank
6969
pub fn get_pbank_ids(vbank_id: u64) -> Option<Vec<u64>> {
7070
let state_opt = BANK_MAP_TABLE.lock().unwrap();
7171
if let Some(ref state) = *state_opt {
@@ -75,7 +75,7 @@ pub fn get_pbank_ids(vbank_id: u64) -> Option<Vec<u64>> {
7575
}
7676
}
7777

78-
/// 查询物理 bank 被哪个虚拟 bank 占用
78+
/// Query which virtual bank occupies the physical bank
7979
pub fn get_vbank_id(pbank_id: u64) -> Option<u64> {
8080
let state_opt = BANK_MAP_TABLE.lock().unwrap();
8181
if let Some(ref state) = *state_opt {

bebop/src/arch/gemmini/gemmini.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,16 @@ impl Gemmini {
10481048

10491049
self.state.c_stride = new_c_stride;
10501050
self.state.a_stride = new_a_stride;
1051+
1052+
log::info!(
1053+
"GEMMINI: config_ex - set mode to {:?}, activation to {:?}, sys shift to {:?}, sys acc shift to {:?}, a transpose to {:?}, b transpose to {:?}",
1054+
new_mode,
1055+
new_act,
1056+
new_sys_shift,
1057+
new_sys_acc_shift,
1058+
new_a_transpose,
1059+
new_b_transpose
1060+
);
10511061
} else if (rs1 & 0b11) == 1 {
10521062
// config_mvin: configure load pipeline
10531063
let state_id = ((rs1 >> 3) & 0x3) as usize;
@@ -1059,6 +1069,15 @@ impl Gemmini {
10591069
if self.state.pixels_per_rows[state_id] == 0 {
10601070
self.state.pixels_per_rows[state_id] = 1;
10611071
}
1072+
1073+
log::info!(
1074+
"GEMMINI: config_ld - set load stride to {:?} (rs2=0x{:x}), load block stride to {:?}, load scale to {:?}, pixels per rows to {:?}",
1075+
rs2,
1076+
rs2,
1077+
self.state.load_block_strides[state_id],
1078+
self.state.load_scales[state_id],
1079+
self.state.pixels_per_rows[state_id]
1080+
);
10621081
} else if (rs1 & 0b11) == 2 {
10631082
// config_mvout: configure store pipeline
10641083
self.state.store_stride = rs2 & 0xFFFFFFFF;
@@ -1085,6 +1104,22 @@ impl Gemmini {
10851104
self.state.pool_pocols = ((rs1 >> 40) & 0xFF) as u8;
10861105
self.state.pool_orows = ((rs1 >> 48) & 0xFF) as u8;
10871106
self.state.pool_ocols = ((rs1 >> 56) & 0xFF) as u8;
1107+
1108+
log::info!(
1109+
"GEMMINI: config_st - set store stride to {:?}, activation to {:?}, acc shift to {:?}, pool stride to {:?}, pool size to {:?}, pool upad to {:?}, pool lpad to {:?}, pool out dim to {:?}, pool porows to {:?}, pool pocols to {:?}, pool orows to {:?}, pool ocols to {:?}",
1110+
rs2 & 0xFFFFFFFF,
1111+
new_act,
1112+
f32::from_bits(new_acc_shift as u32),
1113+
self.state.pool_stride,
1114+
self.state.pool_size,
1115+
self.state.pool_upad,
1116+
self.state.pool_lpad,
1117+
self.state.pool_out_dim,
1118+
self.state.pool_porows,
1119+
self.state.pool_pocols,
1120+
self.state.pool_orows,
1121+
self.state.pool_ocols
1122+
);
10881123
} else if (rs1 & 0b11) == 3 {
10891124
// config_norm: configure norm pipeline
10901125
self.state.norm_stat_id = ((rs1 >> 8) & 0xFF) as u8;
@@ -1093,6 +1128,14 @@ impl Gemmini {
10931128
self.state.igelu_qc = ((rs2 >> 32) & 0xFFFFFFFF) as AccT;
10941129
self.state.qln2 = ((rs1 >> 32) & 0xFFFFFFFF) as AccT;
10951130
}
1131+
1132+
log::info!(
1133+
"GEMMINI: config_norm - set norm stat id to {:?}, igelu qb to {:?}, igelu qc to {:?}, qln2 to {:?}",
1134+
self.state.norm_stat_id,
1135+
self.state.igelu_qb,
1136+
self.state.igelu_qc,
1137+
self.state.qln2
1138+
);
10961139
}
10971140
}
10981141

@@ -1325,26 +1368,62 @@ impl Gemmini {
13251368
self.state.loop_ws_pad_I = (rs1 & 0xFFFF) as u16;
13261369
self.state.loop_ws_pad_J = ((rs1 >> 16) & 0xFFFF) as u16;
13271370
self.state.loop_ws_pad_K = ((rs1 >> 32) & 0xFFFF) as u16;
1371+
1372+
log::info!(
1373+
"GEMMINI: loop_ws_config_bounds - set loop ws I to {:?}, loop ws J to {:?}, loop ws K to {:?}, loop ws pad I to {:?}, loop ws pad J to {:?}, loop ws pad K to {:?}",
1374+
self.state.loop_ws_I,
1375+
self.state.loop_ws_J,
1376+
self.state.loop_ws_K,
1377+
self.state.loop_ws_pad_I,
1378+
self.state.loop_ws_pad_J,
1379+
self.state.loop_ws_pad_K
1380+
);
13281381
}
13291382

13301383
pub fn loop_ws_config_addrs_AB(&mut self, rs1: RegT, rs2: RegT) {
13311384
self.state.loop_ws_A = rs1;
13321385
self.state.loop_ws_B = rs2;
1386+
1387+
log::info!(
1388+
"GEMMINI: loop_ws_config_addrs_AB - set loop ws A to {:?}, loop ws B to {:?}",
1389+
self.state.loop_ws_A,
1390+
self.state.loop_ws_B
1391+
);
13331392
}
13341393

13351394
pub fn loop_ws_config_addrs_DC(&mut self, rs1: RegT, rs2: RegT) {
13361395
self.state.loop_ws_D = rs1;
13371396
self.state.loop_ws_C = rs2;
1397+
1398+
log::info!(
1399+
"GEMMINI: loop_ws_config_addrs_DC - set loop ws D to {:?}, loop ws C to {:?}",
1400+
self.state.loop_ws_D,
1401+
self.state.loop_ws_C
1402+
);
13381403
}
13391404

13401405
pub fn loop_ws_config_strides_AB(&mut self, rs1: RegT, rs2: RegT) {
13411406
self.state.loop_ws_A_stride = rs1;
13421407
self.state.loop_ws_B_stride = rs2;
1408+
1409+
log::info!(
1410+
"GEMMINI: loop_ws_config_strides_AB - set loop ws A stride to {:?}, loop ws B stride to {:?}",
1411+
self.state.loop_ws_A_stride,
1412+
self.state.loop_ws_B_stride
1413+
);
13431414
}
13441415

13451416
pub fn loop_ws_config_strides_DC(&mut self, rs1: RegT, rs2: RegT) {
13461417
self.state.loop_ws_D_stride = rs1;
13471418
self.state.loop_ws_C_stride = rs2;
1419+
1420+
log::info!(
1421+
"GEMMINI: loop_ws_config_strides_DC - set loop ws D stride to {:?} (0x{:x}), loop ws C stride to {:?} (0x{:x})",
1422+
self.state.loop_ws_D_stride,
1423+
self.state.loop_ws_D_stride,
1424+
self.state.loop_ws_C_stride,
1425+
self.state.loop_ws_C_stride
1426+
);
13481427
}
13491428

13501429
pub fn loop_ws(&mut self, rs1: RegT, rs2: RegT) {

bebop/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub mod arch;
22
pub mod simulator;
33

4-
pub use simulator::sim::mode::{ArchType, SimConfig};
4+
pub use simulator::sim::mode::ArchType;
55
pub use simulator::utils::log;

0 commit comments

Comments
 (0)