Add support for EVEN/ODD PIM configuration
This commit is contained in:
@@ -6,6 +6,9 @@ edition = "2021"
|
||||
[lib]
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[features]
|
||||
shared_pim_units = []
|
||||
|
||||
[dependencies]
|
||||
cxx = "1.0.110"
|
||||
env_logger = "0.10.1"
|
||||
|
||||
@@ -12,7 +12,7 @@ mod ffi {
|
||||
extern "Rust" {
|
||||
type PimVM;
|
||||
|
||||
fn new_pim_vm(num_pim_units: u32) -> Box<PimVM>;
|
||||
fn new_pim_vm(num_banks: u32) -> Box<PimVM>;
|
||||
fn reset(&mut self);
|
||||
fn apply_config(&mut self, config: &str);
|
||||
fn bank_mode(&self) -> BankMode;
|
||||
@@ -93,7 +93,13 @@ impl PimVM {
|
||||
}
|
||||
}
|
||||
|
||||
fn new_pim_vm(num_pim_units: u32) -> Box<PimVM> {
|
||||
fn new_pim_vm(num_banks: u32) -> Box<PimVM> {
|
||||
let num_pim_units = if cfg!(feature = "shared_pim_units") {
|
||||
num_banks / 2
|
||||
} else {
|
||||
num_banks
|
||||
};
|
||||
|
||||
Box::new(PimVM {
|
||||
pim_units: vec![PimUnit::default(); num_pim_units as _],
|
||||
pim_config: PimConfig {
|
||||
@@ -110,16 +116,26 @@ impl PimVM {
|
||||
pub fn execute_read(&mut self, bank_index: u32, address: u32, bank_data: &[u8]) {
|
||||
assert_eq!(bank_data.len(), BURST_LENGTH);
|
||||
|
||||
let pim_unit = &mut self.pim_units[bank_index as usize];
|
||||
let pim_unit_index = if cfg!(feature = "shared_pim_units") {
|
||||
bank_index / 2
|
||||
} else {
|
||||
bank_index
|
||||
};
|
||||
|
||||
let pim_unit = &mut self.pim_units[pim_unit_index as usize];
|
||||
|
||||
let mut inst = self.pim_config.kernel.0[pim_unit.pc as usize];
|
||||
|
||||
log::debug!(
|
||||
"PimUnit {pim_unit_index} Execute PC {}: {inst:?}",
|
||||
pim_unit.pc
|
||||
);
|
||||
|
||||
pim_unit.pc += 1;
|
||||
|
||||
let aam_grf_a_index = (address >> GRF_A_BIT_OFFSET) & 0b111;
|
||||
let aam_grf_b_index = (address >> GRF_B_BIT_OFFSET) & 0b111;
|
||||
|
||||
log::debug!("PimUnit {bank_index} Execute PC {}: {inst:?}", pim_unit.pc);
|
||||
|
||||
// The JUMP instruction is zero-cycle and not actually executed
|
||||
while let Instruction::JUMP { offset, count } = inst {
|
||||
pim_unit.jump_counter = match pim_unit.jump_counter {
|
||||
@@ -135,7 +151,7 @@ impl PimVM {
|
||||
}
|
||||
|
||||
pim_unit.pc = new_pc as _;
|
||||
log::debug!("PimUnit {bank_index} New PC {new_pc}: {inst:?}");
|
||||
log::debug!("PimUnit {pim_unit_index} New PC {new_pc}: {inst:?}");
|
||||
}
|
||||
|
||||
inst = self.pim_config.kernel.0[pim_unit.pc as usize];
|
||||
@@ -289,21 +305,27 @@ impl PimVM {
|
||||
.try_into()
|
||||
.unwrap();
|
||||
|
||||
log::debug!("{data0:?}\n{data1:?}\n{data2:?}\n{product:?}\n{sum:?}");
|
||||
log::debug!("{data0:?}, {data1:?}, {data2:?}, {product:?}, {sum:?}");
|
||||
PimVM::store(dst, pim_unit, &sum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn execute_write(&mut self, bank_index: u32) -> [u8; BURST_LENGTH] {
|
||||
let pim_unit = &mut self.pim_units[bank_index as usize];
|
||||
let pim_unit_index = if cfg!(feature = "shared_pim_units") {
|
||||
bank_index / 2
|
||||
} else {
|
||||
bank_index
|
||||
};
|
||||
|
||||
let pim_unit = &mut self.pim_units[pim_unit_index as usize];
|
||||
|
||||
let current_pc = pim_unit.pc;
|
||||
pim_unit.pc += 1;
|
||||
|
||||
let inst = &self.pim_config.kernel.0[current_pc as usize];
|
||||
|
||||
log::debug!("PimUnit {bank_index} Execute PC {current_pc}: {inst:?}");
|
||||
log::debug!("PimUnit {pim_unit_index} Execute PC {current_pc}: {inst:?}");
|
||||
|
||||
let data = match inst {
|
||||
Instruction::FILL { src, dst } => {
|
||||
@@ -317,6 +339,8 @@ impl PimVM {
|
||||
panic!("Unsupported dst operand: {dst:?}")
|
||||
}
|
||||
|
||||
log::debug!("Store {data:?}");
|
||||
|
||||
data
|
||||
}
|
||||
_ => panic!("Unsupported instruction for write: {inst:?}"),
|
||||
|
||||
Reference in New Issue
Block a user