Introduce workload markings

This commit is contained in:
2024-02-25 23:04:56 +01:00
parent a13de61081
commit 4285189e17
13 changed files with 130 additions and 124 deletions

View File

@@ -26,10 +26,10 @@ pub extern "C" fn main() {
let matrix = SMatrix::<F16x1, ROWS, COLUMNS>::zeros(); let matrix = SMatrix::<F16x1, ROWS, COLUMNS>::zeros();
let input_vector = SVector::<F16x1, COLUMNS>::zeros(); let input_vector = SVector::<F16x1, COLUMNS>::zeros();
for _ in 0..10 { pim_os::m5op::exit(0);
let output_vector = matrix * input_vector; let output_vector = matrix * input_vector;
core::hint::black_box(output_vector); core::hint::black_box(output_vector);
} pim_os::m5op::exit(0);
writeln!(Uart0, "Done").unwrap(); writeln!(Uart0, "Done").unwrap();
} }

View File

@@ -15,10 +15,10 @@ pub extern "C" fn main() {
let matrix = SMatrix::<F16x1, ROWS, COLUMNS>::zeros(); let matrix = SMatrix::<F16x1, ROWS, COLUMNS>::zeros();
let mut input_vector = SVector::<F16x1, COLUMNS>::zeros(); let mut input_vector = SVector::<F16x1, COLUMNS>::zeros();
for _ in 0..5 { pim_os::m5op::exit(0);
input_vector = matrix * input_vector; input_vector = matrix * input_vector;
core::hint::black_box(input_vector); core::hint::black_box(input_vector);
} pim_os::m5op::exit(0);
writeln!(Uart0, "Done").unwrap(); writeln!(Uart0, "Done").unwrap();
} }

View File

@@ -26,11 +26,11 @@ pub extern "C" fn main() {
let b = SVector::<F16x1, ROWS>::zeros(); let b = SVector::<F16x1, ROWS>::zeros();
let s = F16x1::zero(); let s = F16x1::zero();
for _ in 0..10 { pim_os::m5op::exit(0);
let a_s = a * s; let a_s = a * s;
let c = a_s.component_mul(&b); let c = a_s.component_mul(&b);
core::hint::black_box(c); core::hint::black_box(c);
} pim_os::m5op::exit(0);
writeln!(Uart0, "Done").unwrap(); writeln!(Uart0, "Done").unwrap();
} }

View File

@@ -24,10 +24,10 @@ pub extern "C" fn main() {
let a = SVector::<F16x1, ROWS>::zeros(); let a = SVector::<F16x1, ROWS>::zeros();
let b = SVector::<F16x1, ROWS>::zeros(); let b = SVector::<F16x1, ROWS>::zeros();
for _ in 0..10 { pim_os::m5op::exit(0);
let c = a + b; let c = a + b;
core::hint::black_box(c); core::hint::black_box(c);
} pim_os::m5op::exit(0);
writeln!(Uart0, "Done").unwrap(); writeln!(Uart0, "Done").unwrap();
} }

View File

@@ -24,10 +24,10 @@ pub extern "C" fn main() {
let a = SVector::<F16x1, ROWS>::zeros(); let a = SVector::<F16x1, ROWS>::zeros();
let b = SVector::<F16x1, ROWS>::zeros(); let b = SVector::<F16x1, ROWS>::zeros();
for _ in 0..10 { pim_os::m5op::exit(0);
let c = a.component_mul(&b); let c = a.component_mul(&b);
core::hint::black_box(c); core::hint::black_box(c);
} pim_os::m5op::exit(0);
writeln!(Uart0, "Done").unwrap(); writeln!(Uart0, "Done").unwrap();
} }

View File

@@ -67,12 +67,14 @@ pub extern "C" fn main() {
{ {
pim::state::set_bank_mode(BankMode::PimAllBank); pim::state::set_bank_mode(BankMode::PimAllBank);
pim_os::m5op::exit(0);
gemv::execute( gemv::execute(
pim_matrix.as_ref(), pim_matrix.as_ref(),
interleaved_input_vector.as_ref(), interleaved_input_vector.as_ref(),
output_partial_sum_vector.as_mut(), output_partial_sum_vector.as_mut(),
dummy.as_ref(), dummy.as_ref(),
); );
pim_os::m5op::exit(0);
pim::state::set_bank_mode(BankMode::SingleBank); pim::state::set_bank_mode(BankMode::SingleBank);
} }

View File

@@ -38,35 +38,33 @@ pub extern "C" fn main() {
let dummy = Box::new(0); let dummy = Box::new(0);
for _ in 0..5 { let interleaved_input_vector = Box::new(interleaved_array::Vector::from(input_vector.clone()));
let interleaved_input_vector =
Box::new(interleaved_array::Vector::from(input_vector.clone()));
// Verify everything is correctly initialized before PIM operation // Verify everything is correctly initialized before PIM operation
barrier::dsb(barrier::SY); barrier::dsb(barrier::SY);
// Execute kernel // Execute kernel
{ {
pim::state::set_bank_mode(BankMode::PimAllBank); pim::state::set_bank_mode(BankMode::PimAllBank);
gemv::execute( gemv::execute(
pim_matrix.as_ref(), pim_matrix.as_ref(),
interleaved_input_vector.as_ref(), interleaved_input_vector.as_ref(),
output_partial_sum_vector.as_mut(), output_partial_sum_vector.as_mut(),
dummy.as_ref(), dummy.as_ref(),
); );
pim::state::set_bank_mode(BankMode::SingleBank); pim::state::set_bank_mode(BankMode::SingleBank);
}
let output_vector = SVector::<F16x1, ROWS>::from_fn(|r, _| {
output_partial_sum_vector[r]
.0
.iter()
.fold(F16x1::zero(), |acc, val| acc + *val)
});
core::hint::black_box(output_vector);
} }
let output_vector = SVector::<F16x1, ROWS>::from_fn(|r, _| {
output_partial_sum_vector[r]
.0
.iter()
.fold(F16x1::zero(), |acc, val| acc + *val)
});
core::hint::black_box(output_vector);
writeln!(Uart0, "Done").unwrap(); writeln!(Uart0, "Done").unwrap();
} }

View File

@@ -19,17 +19,17 @@ use pim_os::{
}; };
#[cfg(feature = "X1")] #[cfg(feature = "X1")]
const ROWS: usize = 128;
#[cfg(feature = "X2")]
const ROWS: usize = 256; const ROWS: usize = 256;
#[cfg(feature = "X3")] #[cfg(feature = "X2")]
const ROWS: usize = 512; const ROWS: usize = 512;
#[cfg(feature = "X4")] #[cfg(feature = "X3")]
const ROWS: usize = 1024; const ROWS: usize = 1024;
#[cfg(feature = "X4")]
const ROWS: usize = 2048;
const ELEMENTS_PER_BANK: usize = 16; const ELEMENTS_PER_BANK: usize = 16;
const BANKS: usize = 16; const BANKS: usize = 16;
const BLOCKS: usize = ROWS / (ELEMENTS_PER_BANK * BANKS); const BLOCKS: usize = ROWS / (ELEMENTS_PER_BANK * BANKS);
@@ -73,6 +73,7 @@ pub extern "C" fn main() {
{ {
pim::state::set_bank_mode(BankMode::PimAllBank); pim::state::set_bank_mode(BankMode::PimAllBank);
pim_os::m5op::exit(0);
haxpy::execute::<ROWS, BLOCKS>( haxpy::execute::<ROWS, BLOCKS>(
&a.0, &a.0,
&b.0, &b.0,
@@ -80,6 +81,7 @@ pub extern "C" fn main() {
&mut c.0, &mut c.0,
dummy.as_ref(), dummy.as_ref(),
); );
pim_os::m5op::exit(0);
pim::state::set_bank_mode(BankMode::SingleBank); pim::state::set_bank_mode(BankMode::SingleBank);
} }

View File

@@ -67,7 +67,9 @@ pub extern "C" fn main() {
{ {
pim::state::set_bank_mode(BankMode::PimAllBank); pim::state::set_bank_mode(BankMode::PimAllBank);
pim_os::m5op::exit(0);
vadd::execute::<ROWS, BLOCKS>(&a.0, &b.0, &mut c.0, dummy.as_ref()); vadd::execute::<ROWS, BLOCKS>(&a.0, &b.0, &mut c.0, dummy.as_ref());
pim_os::m5op::exit(0);
pim::state::set_bank_mode(BankMode::SingleBank); pim::state::set_bank_mode(BankMode::SingleBank);
} }

View File

@@ -67,7 +67,9 @@ pub extern "C" fn main() {
{ {
pim::state::set_bank_mode(BankMode::PimAllBank); pim::state::set_bank_mode(BankMode::PimAllBank);
pim_os::m5op::exit(0);
vmul::execute::<ROWS, BLOCKS>(&a.0, &b.0, &mut c.0, dummy.as_ref()); vmul::execute::<ROWS, BLOCKS>(&a.0, &b.0, &mut c.0, dummy.as_ref());
pim_os::m5op::exit(0);
pim::state::set_bank_mode(BankMode::SingleBank); pim::state::set_bank_mode(BankMode::SingleBank);
} }

View File

@@ -13,13 +13,13 @@ pub const KERNEL_X1: Kernel = Kernel([
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 0 }, src1: File::SrfA { index: 0 },
src2: File::SrfA { index: 0 }, src2: File::GrfA { index: 0 },
dst: File::GrfB { index: 0 }, dst: File::GrfA { index: 0 },
aam: false, aam: false,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 0 }, src: File::GrfA { index: 0 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::EXIT, Instruction::EXIT,
@@ -67,24 +67,24 @@ pub const KERNEL_X2: Kernel = Kernel([
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 0 }, src1: File::SrfA { index: 0 },
src2: File::SrfA { index: 0 }, src2: File::GrfA { index: 0 },
dst: File::GrfB { index: 0 }, dst: File::GrfA { index: 0 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 1 }, src1: File::SrfA { index: 1 },
src2: File::SrfA { index: 1 }, src2: File::GrfA { index: 1 },
dst: File::GrfB { index: 1 }, dst: File::GrfA { index: 1 },
aam: false, aam: false,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 0 }, src: File::GrfA { index: 0 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 1 }, src: File::GrfA { index: 1 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::EXIT, Instruction::EXIT,
@@ -137,46 +137,46 @@ pub const KERNEL_X3: Kernel = Kernel([
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 0 }, src1: File::SrfA { index: 0 },
src2: File::SrfA { index: 0 }, src2: File::GrfA { index: 0 },
dst: File::GrfB { index: 0 }, dst: File::GrfA { index: 0 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 1 }, src1: File::SrfA { index: 1 },
src2: File::SrfA { index: 1 }, src2: File::GrfA { index: 1 },
dst: File::GrfB { index: 1 }, dst: File::GrfA { index: 1 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 2 }, src1: File::SrfA { index: 2 },
src2: File::SrfA { index: 2 }, src2: File::GrfA { index: 2 },
dst: File::GrfB { index: 2 }, dst: File::GrfA { index: 2 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 3 }, src1: File::SrfA { index: 3 },
src2: File::SrfA { index: 3 }, src2: File::GrfA { index: 3 },
dst: File::GrfB { index: 3 }, dst: File::GrfA { index: 3 },
aam: false, aam: false,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 0 }, src: File::GrfA { index: 0 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 1 }, src: File::GrfA { index: 1 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 2 }, src: File::GrfA { index: 2 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 3 }, src: File::GrfA { index: 3 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::EXIT, Instruction::EXIT,
@@ -239,90 +239,90 @@ pub const KERNEL_X4: Kernel = Kernel([
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 0 }, src1: File::SrfA { index: 0 },
src2: File::SrfA { index: 0 }, src2: File::GrfA { index: 0 },
dst: File::GrfB { index: 0 }, dst: File::GrfA { index: 0 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 1 }, src1: File::SrfA { index: 1 },
src2: File::SrfA { index: 1 }, src2: File::GrfA { index: 1 },
dst: File::GrfB { index: 1 }, dst: File::GrfA { index: 1 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 2 }, src1: File::SrfA { index: 2 },
src2: File::SrfA { index: 2 }, src2: File::GrfA { index: 2 },
dst: File::GrfB { index: 2 }, dst: File::GrfA { index: 2 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 3 }, src1: File::SrfA { index: 3 },
src2: File::SrfA { index: 3 }, src2: File::GrfA { index: 3 },
dst: File::GrfB { index: 3 }, dst: File::GrfA { index: 3 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 4 }, src1: File::SrfA { index: 4 },
src2: File::SrfA { index: 4 }, src2: File::GrfA { index: 4 },
dst: File::GrfB { index: 4 }, dst: File::GrfA { index: 4 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 5 }, src1: File::SrfA { index: 5 },
src2: File::SrfA { index: 5 }, src2: File::GrfA { index: 5 },
dst: File::GrfB { index: 5 }, dst: File::GrfA { index: 5 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 6 }, src1: File::SrfA { index: 6 },
src2: File::SrfA { index: 6 }, src2: File::GrfA { index: 6 },
dst: File::GrfB { index: 6 }, dst: File::GrfA { index: 6 },
aam: false, aam: false,
}, },
Instruction::MAD { Instruction::MAD {
src0: File::Bank, src0: File::Bank,
src1: File::GrfA { index: 7 }, src1: File::SrfA { index: 7 },
src2: File::SrfA { index: 7 }, src2: File::GrfA { index: 7 },
dst: File::GrfB { index: 7 }, dst: File::GrfA { index: 7 },
aam: false, aam: false,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 0 }, src: File::GrfA { index: 0 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 1 }, src: File::GrfA { index: 1 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 2 }, src: File::GrfA { index: 2 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 3 }, src: File::GrfA { index: 3 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 4 }, src: File::GrfA { index: 4 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 5 }, src: File::GrfA { index: 5 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 6 }, src: File::GrfA { index: 6 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::FILL { Instruction::FILL {
src: File::GrfB { index: 7 }, src: File::GrfA { index: 7 },
dst: File::Bank, dst: File::Bank,
}, },
Instruction::EXIT, Instruction::EXIT,

View File

@@ -24,7 +24,7 @@ pub extern "C" fn entry() -> ! {
unsafe { main() } unsafe { main() }
m5op::exit(); m5op::exit(0);
loop { loop {
compiler_fence(Ordering::SeqCst); compiler_fence(Ordering::SeqCst);

View File

@@ -3,24 +3,24 @@ use core::arch::global_asm;
global_asm!(include_str!("m5op.s")); global_asm!(include_str!("m5op.s"));
extern "C" { extern "C" {
fn m5_exit(); fn m5_exit(delay_ns: u64);
fn m5_reset_stats(); fn m5_reset_stats(delay_ns: u64, period_ns: u64);
fn m5_dump_stats(); fn m5_dump_stats(delay_ns: u64, period_ns: u64);
fn m5_dump_reset_stats(); fn m5_dump_reset_stats(delay_ns: u64, period_ns: u64);
} }
pub fn exit() { pub fn exit(delay_ns: u64) {
unsafe { m5_exit() } unsafe { m5_exit(delay_ns) }
} }
pub fn reset_stats() { pub fn reset_stats(delay_ns: u64, period_ns: u64) {
unsafe { m5_reset_stats() } unsafe { m5_reset_stats(delay_ns, period_ns) }
} }
pub fn dump_stats() { pub fn dump_stats(delay_ns: u64, period_ns: u64) {
unsafe { m5_dump_stats() } unsafe { m5_dump_stats(delay_ns, period_ns) }
} }
pub fn dump_reset_stats() { pub fn dump_reset_stats(delay_ns: u64, period_ns: u64) {
unsafe { m5_dump_reset_stats() } unsafe { m5_dump_reset_stats(delay_ns, period_ns) }
} }