328 lines
7.6 KiB
Rust
328 lines
7.6 KiB
Rust
use crate::pim::{operation::PimOperand, vector::F16x1};
|
|
use nalgebra::SVector;
|
|
use pim_isa::{File, Instruction, Kernel};
|
|
|
|
pub const KERNEL_X1: Kernel = Kernel([
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 0 },
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 0 },
|
|
dst: File::GrfB { index: 0 },
|
|
aam: false,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 0 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::EXIT,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
]);
|
|
|
|
pub const KERNEL_X2: Kernel = Kernel([
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 0 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 1 },
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 0 },
|
|
dst: File::GrfB { index: 0 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 1 },
|
|
dst: File::GrfB { index: 1 },
|
|
aam: false,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 0 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 1 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::EXIT,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
]);
|
|
|
|
pub const KERNEL_X3: Kernel = Kernel([
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 0 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 1 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 2 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 3 },
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 0 },
|
|
dst: File::GrfB { index: 0 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 1 },
|
|
dst: File::GrfB { index: 1 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 2 },
|
|
dst: File::GrfB { index: 2 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 3 },
|
|
dst: File::GrfB { index: 3 },
|
|
aam: false,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 0 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 1 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 2 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 3 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::EXIT,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
]);
|
|
|
|
pub const KERNEL_X4: Kernel = Kernel([
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 0 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 1 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 2 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 3 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 4 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 5 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 6 },
|
|
},
|
|
Instruction::MOV {
|
|
src: File::Bank,
|
|
dst: File::GrfA { index: 7 },
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 0 },
|
|
dst: File::GrfB { index: 0 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 1 },
|
|
dst: File::GrfB { index: 1 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 2 },
|
|
dst: File::GrfB { index: 2 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 3 },
|
|
dst: File::GrfB { index: 3 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 4 },
|
|
dst: File::GrfB { index: 4 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 5 },
|
|
dst: File::GrfB { index: 5 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 6 },
|
|
dst: File::GrfB { index: 6 },
|
|
aam: false,
|
|
},
|
|
Instruction::ADD {
|
|
src0: File::Bank,
|
|
src1: File::GrfA { index: 7 },
|
|
dst: File::GrfB { index: 7 },
|
|
aam: false,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 0 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 1 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 2 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 3 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 4 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 5 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 6 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::FILL {
|
|
src: File::GrfB { index: 7 },
|
|
dst: File::Bank,
|
|
},
|
|
Instruction::EXIT,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
Instruction::NOP,
|
|
]);
|
|
|
|
pub fn execute<const R: usize, const BLOCKS: usize>(
|
|
a: &SVector<F16x1, R>,
|
|
b: &SVector<F16x1, R>,
|
|
c: &mut SVector<F16x1, R>,
|
|
dummy: &impl PimOperand,
|
|
) {
|
|
a.fixed_rows_with_step::<BLOCKS>(0, 256)
|
|
.iter()
|
|
.for_each(|entry| entry.execute_read());
|
|
b.fixed_rows_with_step::<BLOCKS>(0, 256)
|
|
.iter()
|
|
.for_each(|entry| entry.execute_read());
|
|
c.fixed_rows_with_step_mut::<BLOCKS>(0, 256)
|
|
.iter_mut()
|
|
.for_each(|entry| entry.execute_write());
|
|
|
|
dummy.execute_read();
|
|
}
|