Use m5ops instructions

This commit is contained in:
2024-01-13 18:41:08 +01:00
parent ec8ae87aaa
commit 283b9e74a3
3 changed files with 35 additions and 62 deletions

View File

@@ -0,0 +1,23 @@
#![no_std]
#![no_main]
extern crate alloc;
use core::fmt::Write;
use nalgebra::SMatrix;
use pim_os::{pim::vector::F16x1, uart::Uart0};
#[no_mangle]
pub extern "C" fn main() {
let matrices0 = [SMatrix::<F16x1, 8, 8>::zeros(); 512];
let matrices1 = [SMatrix::<F16x1, 8, 8>::zeros(); 512];
for _ in 0..100 {
for i in 0..512 {
let matrix2 = matrices0[i] * matrices1[i];
core::hint::black_box(matrix2);
}
}
writeln!(Uart0, "Done").unwrap();
}

View File

@@ -1,4 +1,3 @@
use aarch64_cpu::asm::barrier;
use core::arch::global_asm;
global_asm!(include_str!("m5op.s"));
@@ -25,61 +24,3 @@ pub fn dump_stats() {
pub fn dump_reset_stats() {
unsafe { m5_dump_reset_stats() }
}
// const M5OPS_ADDR: u64 = 0x10010000;
// const EXIT_ADDR: *const u64 = (M5OPS_ADDR + (0x21 << 8)) as _;
// const DUMP_STATS_ADDR: *const u64 = (M5OPS_ADDR + (0x40 << 8)) as _;
// const RESET_STATS_ADDR: *const u64 = (M5OPS_ADDR + (0x41 << 8)) as _;
// const DUMP_RESET_STATS_ADDR: *const u64 = (M5OPS_ADDR + (0x42 << 8)) as _;
// const WORK_BEGIN_ADDR: *const u64 = (M5OPS_ADDR + (0x5A << 8)) as _;
// const WORK_END_ADDR: *const u64 = (M5OPS_ADDR + (0x5B << 8)) as _;
// // const CHECKPOINT_ADDR: *const u64 = (M5OPS_ADDR + (0x43 << 8)) as _;
// pub fn exit() {
// unsafe {
// core::ptr::read_volatile(EXIT_ADDR);
// }
// barrier::dsb(barrier::SY);
// }
// pub fn dump_stats() {
// unsafe {
// core::ptr::read_volatile(DUMP_STATS_ADDR);
// }
// barrier::dsb(barrier::SY);
// }
// pub fn reset_stats() {
// unsafe {
// core::ptr::read_volatile(RESET_STATS_ADDR);
// }
// barrier::dsb(barrier::SY);
// }
// pub fn dump_reset_stats() {
// unsafe {
// core::ptr::read_volatile(DUMP_RESET_STATS_ADDR);
// }
// barrier::dsb(barrier::SY);
// }
// pub fn work_begin() {
// unsafe {
// core::ptr::read_volatile(WORK_BEGIN_ADDR);
// }
// barrier::dsb(barrier::SY);
// }
// pub fn work_end() {
// unsafe {
// core::ptr::read_volatile(WORK_END_ADDR);
// }
// barrier::dsb(barrier::SY);
// }

View File

@@ -1,5 +1,8 @@
use aarch64_cpu::asm::barrier;
use core::{arch::asm, ptr::write_volatile};
use core::{
arch::asm,
ptr::{addr_of_mut, write_volatile},
};
#[link_section = ".pim_config"]
static mut PIM_CONFIG_REGION: [u8; 0x4000] = [0; 0x4000];
@@ -8,11 +11,17 @@ pub fn write(s: &str) {
unsafe {
let mut index = 0;
for &byte in s.as_bytes() {
write_volatile((&mut PIM_CONFIG_REGION as *mut u8).offset(index), byte as _);
write_volatile(
(addr_of_mut!(PIM_CONFIG_REGION) as *mut u8).offset(index),
byte as _,
);
barrier::dsb(barrier::SY);
index += 1;
}
write_volatile((&mut PIM_CONFIG_REGION as *mut u8).offset(index), b'\0');
write_volatile(
(addr_of_mut!(PIM_CONFIG_REGION) as *mut u8).offset(index),
b'\0',
);
// PIM_CONFIG_REGION[..s.len()].copy_from_slice(s.as_bytes());
// PIM_CONFIG_REGION[s.len()] = b'\0';