perf(matmul): strip ALL timing — zero get_ns() calls, zero TIME_* output
Removed: - confreg_time.h and common_func.h includes - All get_ns() calls (6 in prologue/loop/epilogue boundaries) - All timing variables (t_prologue, t_mainloop, t_epilogue) - All TIME_* printf markers - Unused extram pointer and stdbool.h Only essential output remains: MATMUL_START, MATMUL_CRC32, MATMUL_DONE
This commit is contained in:
@@ -11,11 +11,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <common_func.h>
|
|
||||||
#include <confreg_time.h>
|
|
||||||
#include <dma.h>
|
#include <dma.h>
|
||||||
|
|
||||||
/* ─── Configurable group count (default 5000) ──────────────────────── */
|
/* ─── Configurable group count (default 5000) ──────────────────────── */
|
||||||
@@ -68,14 +65,13 @@ int main(void)
|
|||||||
if (MATMUL_GROUP_NUM <= 0) return 0;
|
if (MATMUL_GROUP_NUM <= 0) return 0;
|
||||||
|
|
||||||
/* ── Hot-path local volatile pointers (one-time addr calc) ──────── */
|
/* ── Hot-path local volatile pointers (one-time addr calc) ──────── */
|
||||||
volatile uint32_t *extram = (volatile uint32_t *)EXTRAM_BASE_UNCACHED;
|
|
||||||
volatile uint32_t *mat_status = (volatile uint32_t *)MATMUL_STATUS;
|
volatile uint32_t *mat_status = (volatile uint32_t *)MATMUL_STATUS;
|
||||||
volatile uint32_t *mat_ctrl = (volatile uint32_t *)MATMUL_CTRL;
|
volatile uint32_t *mat_ctrl = (volatile uint32_t *)MATMUL_CTRL;
|
||||||
volatile uint32_t *mat_crc = (volatile uint32_t *)MATMUL_CRC;
|
volatile uint32_t *mat_crc = (volatile uint32_t *)MATMUL_CRC;
|
||||||
volatile dma_ch_regs_t *ch0 = DMA_CH(0);
|
volatile dma_ch_regs_t *ch0 = DMA_CH(0);
|
||||||
volatile dma_ch_regs_t *ch1 = DMA_CH(1);
|
volatile dma_ch_regs_t *ch1 = DMA_CH(1);
|
||||||
|
|
||||||
uint32_t crc, t_prologue, t_mainloop, t_epilogue;
|
uint32_t crc;
|
||||||
int g, bank;
|
int g, bank;
|
||||||
|
|
||||||
// Ping-Pong Register Address Arrays (Physical for DMA)
|
// Ping-Pong Register Address Arrays (Physical for DMA)
|
||||||
@@ -93,7 +89,6 @@ int main(void)
|
|||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
* PROLOGUE: Load group 0 → Bank 0, start IP, pre-fire group 1
|
* PROLOGUE: Load group 0 → Bank 0, start IP, pre-fire group 1
|
||||||
* ═══════════════════════════════════════════════════════════════ */
|
* ═══════════════════════════════════════════════════════════════ */
|
||||||
t_prologue = get_ns();
|
|
||||||
|
|
||||||
// DMA Ch0: Load group 0 A+B (128 bytes) → IP Bank 0
|
// DMA Ch0: Load group 0 A+B (128 bytes) → IP Bank 0
|
||||||
ch0->SRC_ADDR = EXTRAM_PHYS_AB(0);
|
ch0->SRC_ADDR = EXTRAM_PHYS_AB(0);
|
||||||
@@ -116,8 +111,6 @@ int main(void)
|
|||||||
ch0->CTRL = DMA_CTRL_VAL;
|
ch0->CTRL = DMA_CTRL_VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
t_prologue = get_ns() - t_prologue;
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
* MAIN LOOP: Fully-pipelined — pre-fire DMA load at loop tail
|
* MAIN LOOP: Fully-pipelined — pre-fire DMA load at loop tail
|
||||||
*
|
*
|
||||||
@@ -130,7 +123,6 @@ int main(void)
|
|||||||
* Ch1: | store g-1 | | store g |
|
* Ch1: | store g-1 | | store g |
|
||||||
* IP : | compute g | | compute g+1 |
|
* IP : | compute g | | compute g+1 |
|
||||||
* ═══════════════════════════════════════════════════════════════ */
|
* ═══════════════════════════════════════════════════════════════ */
|
||||||
t_mainloop = get_ns();
|
|
||||||
bank = 1; // cur_bank for iteration g=1; prev_bank = bank ^ 1
|
bank = 1; // cur_bank for iteration g=1; prev_bank = bank ^ 1
|
||||||
|
|
||||||
for (g = 1; g < MATMUL_GROUP_NUM; g++) {
|
for (g = 1; g < MATMUL_GROUP_NUM; g++) {
|
||||||
@@ -175,12 +167,10 @@ int main(void)
|
|||||||
// Toggle bank for next iteration
|
// Toggle bank for next iteration
|
||||||
bank ^= 1;
|
bank ^= 1;
|
||||||
}
|
}
|
||||||
t_mainloop = get_ns() - t_mainloop;
|
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
* EPILOGUE: Flush the final group
|
* EPILOGUE: Flush the final group
|
||||||
* ═══════════════════════════════════════════════════════════════ */
|
* ═══════════════════════════════════════════════════════════════ */
|
||||||
t_epilogue = get_ns();
|
|
||||||
|
|
||||||
// Wait for last IP computation
|
// Wait for last IP computation
|
||||||
while (!(*mat_status & STATUS_DONE)) {}
|
while (!(*mat_status & STATUS_DONE)) {}
|
||||||
@@ -198,18 +188,10 @@ int main(void)
|
|||||||
while (!(ch1->STATUS & STATUS_DONE_BIT)) {}
|
while (!(ch1->STATUS & STATUS_DONE_BIT)) {}
|
||||||
ch1->STATUS = STATUS_DONE_BIT;
|
ch1->STATUS = STATUS_DONE_BIT;
|
||||||
|
|
||||||
t_epilogue = get_ns() - t_epilogue;
|
|
||||||
|
|
||||||
/* ── Read hardware CRC32 ──────────────────────────────────── */
|
/* ── Read hardware CRC32 ──────────────────────────────────── */
|
||||||
crc = *mat_crc;
|
crc = *mat_crc;
|
||||||
|
|
||||||
/* ── Standard markers (required by test harness) ────────────── */
|
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user