Remove timing instrumentation from user-sample.c

This commit is contained in:
2026-06-26 00:34:44 +08:00
parent 8bc3d42ac6
commit 115466353d

View File

@@ -13,7 +13,6 @@
#include <stdint.h> #include <stdint.h>
#include <common_func.h> #include <common_func.h>
#include <confreg_time.h>
#include <dma.h> #include <dma.h>
/* ─── Configurable group count (default 10 for fast local testing) ─── */ /* ─── Configurable group count (default 10 for fast local testing) ─── */
@@ -23,8 +22,6 @@
/* ─── BSP globals ─────────────────────────────────────────────────── */ /* ─── BSP globals ─────────────────────────────────────────────────── */
unsigned long UART_BASE = 0xbf000000; unsigned long UART_BASE = 0xbf000000;
unsigned long CONFREG_TIMER_BASE = 0xbf20f100;
unsigned long CONFREG_CLOCKS_PER_SEC = 50000000L;
unsigned long CORE_CLOCKS_PER_SEC = 33000000L; unsigned long CORE_CLOCKS_PER_SEC = 33000000L;
/* ─── Memory layout ────────────────────────────────────────────────── */ /* ─── Memory layout ────────────────────────────────────────────────── */
@@ -111,7 +108,7 @@ int main(void)
if (MATMUL_GROUP_NUM <= 0) return 0; if (MATMUL_GROUP_NUM <= 0) return 0;
volatile uint32_t *extram = (volatile uint32_t *)EXTRAM_BASE_UNCACHED; volatile uint32_t *extram = (volatile uint32_t *)EXTRAM_BASE_UNCACHED;
uint32_t crc, t_prologue, t_mainloop, t_epilogue; uint32_t crc;
int g; int g;
// Ping-Pong Register Address Arrays (Physical for DMA) // Ping-Pong Register Address Arrays (Physical for DMA)
@@ -129,17 +126,14 @@ int main(void)
REG_WR(MATMUL_CRC, 0); // 复位硬件 CRC32 为 0xFFFFFFFF REG_WR(MATMUL_CRC, 0); // 复位硬件 CRC32 为 0xFFFFFFFF
/* ── Prologue: 第0组数据初始化 ────────────────────────── */ /* ── Prologue: 第0组数据初始化 ────────────────────────── */
t_prologue = get_ns();
// DMA Ch0: 从 ExtRAM 将 Group 0 的 A、B (128 bytes) 搬入 IP 的 Bank 0 // DMA Ch0: 从 ExtRAM 将 Group 0 的 A、B (128 bytes) 搬入 IP 的 Bank 0
dma_start_transfer(0, EXTRAM_PHYS_AB(0), phys_bank_AB[0], 128, 10); dma_start_transfer(0, EXTRAM_PHYS_AB(0), phys_bank_AB[0], 128, 10);
wait_dma_done_intr(0); wait_dma_done_intr(0);
// 启动 IP Bank 0 计算 // 启动 IP Bank 0 计算
REG_WR(MATMUL_CTRL, ctrl_start[0]); REG_WR(MATMUL_CTRL, ctrl_start[0]);
t_prologue = get_ns() - t_prologue;
/* ── Main Loop: 硬件完全流水线 (Overlapped Execution) ──── */ /* ── Main Loop: 硬件完全流水线 (Overlapped Execution) ──── */
t_mainloop = get_ns();
// 在 g 循环中: // 在 g 循环中:
// IP 正在计算 prev_bank (g-1) // IP 正在计算 prev_bank (g-1)
// DMA_CH0 正在加载 cur_bank (g) // DMA_CH0 正在加载 cur_bank (g)
@@ -168,28 +162,20 @@ int main(void)
// 6. 立即启动当前组在 IP 中的计算 // 6. 立即启动当前组在 IP 中的计算
REG_WR(MATMUL_CTRL, ctrl_start[cur_bank]); REG_WR(MATMUL_CTRL, ctrl_start[cur_bank]);
} }
t_mainloop = get_ns() - t_mainloop;
/* ── Epilogue: 收尾最后一组 ───────────────────────────── */ /* ── Epilogue: 收尾最后一组 ───────────────────────────── */
t_epilogue = get_ns();
wait_matmul_done_intr(); // 等待最后一次计算完成 wait_matmul_done_intr(); // 等待最后一次计算完成
wait_dma_done_intr(1); // 确保之前的 DMA CH1 空闲 wait_dma_done_intr(1); // 确保之前的 DMA CH1 空闲
// DMA CH1 将最后一组结果写回 // DMA CH1 将最后一组结果写回
dma_start_transfer(1, phys_bank_C[(MATMUL_GROUP_NUM - 1) % 2], EXTRAM_PHYS_C(MATMUL_GROUP_NUM - 1), 192, 20); dma_start_transfer(1, phys_bank_C[(MATMUL_GROUP_NUM - 1) % 2], EXTRAM_PHYS_C(MATMUL_GROUP_NUM - 1), 192, 20);
wait_dma_done_intr(1); wait_dma_done_intr(1);
t_epilogue = get_ns() - t_epilogue;
/* ── Read hardware CRC32 result ──────────────────────────── */ /* ── Read hardware CRC32 result ──────────────────────────── */
crc = REG_RD(MATMUL_CRC); crc = REG_RD(MATMUL_CRC);
/* ── Final markers ────────────────────────────────────────── */ /* ── Final markers ────────────────────────────────────────── */
printf("MATMUL_CRC32=%08lx\n", (unsigned long)crc); printf("MATMUL_CRC32=%08lx\n", (unsigned long)crc);
printf("TIME_PROLOGUE=%lu\n", (unsigned long)t_prologue);
printf("TIME_LOOP=%lu\n", (unsigned long)t_mainloop);
printf("TIME_LOOP_PER=%lu\n", (unsigned long)(t_mainloop / MATMUL_GROUP_NUM));
printf("TIME_EPILOGUE=%lu\n", (unsigned long)t_epilogue);
printf("TIME_TOTAL=%lu\n", (unsigned long)(t_prologue + t_mainloop + t_epilogue));
printf("MATMUL_DONE\n"); printf("MATMUL_DONE\n");
return 0; return 0;