From b5ac2e8f925424a12b20c6d72a4bb23c59d8be41 Mon Sep 17 00:00:00 2001 From: xiaoling-yi Date: Mon, 30 Sep 2024 13:11:39 +0200 Subject: [PATCH 1/3] inline start csr & start streamer-gemm together --- .../sw/apps/snax-gemmx/src/snax-gemmx.c | 6 ++--- .../sw/snax/gemmx/include/snax-gemmx-lib.h | 23 +++++++++++++++++-- .../sw/snax/gemmx/src/snax-gemmx-lib.c | 6 ----- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/target/snitch_cluster/sw/apps/snax-gemmx/src/snax-gemmx.c b/target/snitch_cluster/sw/apps/snax-gemmx/src/snax-gemmx.c index 10405511e..3a22cd595 100644 --- a/target/snitch_cluster/sw/apps/snax-gemmx/src/snax-gemmx.c +++ b/target/snitch_cluster/sw/apps/snax-gemmx/src/snax-gemmx.c @@ -79,9 +79,6 @@ int main() { delta_local_d32, bypassSIMD, transposed_A, transposed_B, channel_en_C); - // Set CSR to start Streamer for conv2d - set_gemmx_streamer_start(); - // Set GEMMX configuration CSR uint32_t subtraction_setting = gen_subtraction_config(subtraction_a, subtraction_b); @@ -97,6 +94,9 @@ int main() { shared_multiplier5, shared_multiplier6, shared_multiplier7, M * N, bypassSIMD); + // Set CSR to start Streamer for conv2d + set_gemmx_streamer_start(); + // Set CSR to start GEMM set_gemmx_start(); diff --git a/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h b/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h index 1b9b58280..c9c2b288c 100644 --- a/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h +++ b/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h @@ -7,6 +7,7 @@ #include #include "snrt.h" #include "stdint.h" +#include "streamer_csr_addr_map.h" #pragma once @@ -76,7 +77,25 @@ void set_gemmx_streamer_csr( int32_t transpose_B, int32_t channel_en_C); // Set CSR to start STREAMER -void set_gemmx_streamer_start(); +inline void set_gemmx_streamer_start() { csrw_ss(STREAMER_START_CSR, 1); } + +#define GEMMX_CSR_ADDR_BASE (STREAMER_PERFORMANCE_COUNTER_CSR + 1) +#define T_BOUND_K (GEMMX_CSR_ADDR_BASE + 0) +#define T_BOUND_N (GEMMX_CSR_ADDR_BASE + 1) +#define T_BOUND_M (GEMMX_CSR_ADDR_BASE + 2) + +#define SUBTRACTIONS (GEMMX_CSR_ADDR_BASE + 3) + +#define SIMD_CSR0 (GEMMX_CSR_ADDR_BASE + 4) +#define SIMD_CSR1 (GEMMX_CSR_ADDR_BASE + 5) +#define SIMD_CSR2 (GEMMX_CSR_ADDR_BASE + 6) + +#define TEMPORAL_LOOP_BOUND (GEMMX_CSR_ADDR_BASE + 7) +#define BYPASS_SIMD (GEMMX_CSR_ADDR_BASE + 8) + +#define GEMMX_START (GEMMX_CSR_ADDR_BASE + 9) +#define GEMMX_BUSY (GEMMX_CSR_ADDR_BASE + 10) +#define GEMMX_PERFORMANCE_COUNTER (GEMMX_CSR_ADDR_BASE + 11) // Set GEMM configuration CSR void set_gemmx_csr(int tempLoop0, int tempLoop1, int tempLoop2, @@ -89,7 +108,7 @@ void set_gemmx_csr(int tempLoop0, int tempLoop1, int tempLoop2, uint32_t temporal_loop_bound, uint32_t bypassSIMD); // Set CSR to start GEMM -void set_gemmx_start(); +inline void set_gemmx_start() { csrw_ss(GEMMX_START, 1); } // Poll until Streamer and GEMM accelerator finish void wait_gemmx_and_streamer(); diff --git a/target/snitch_cluster/sw/snax/gemmx/src/snax-gemmx-lib.c b/target/snitch_cluster/sw/snax/gemmx/src/snax-gemmx-lib.c index 0d5302672..52d1c78b7 100644 --- a/target/snitch_cluster/sw/snax/gemmx/src/snax-gemmx-lib.c +++ b/target/snitch_cluster/sw/snax/gemmx/src/snax-gemmx-lib.c @@ -165,9 +165,6 @@ void set_gemmx_streamer_csr( #endif } -// Set CSR to start STREAMER -void set_gemmx_streamer_start() { csrw_ss(STREAMER_START_CSR, 1); } - // Set GEMM configuration CSR void set_gemmx_csr(int tempLoop0, int tempLoop1, int tempLoop2, int subtractions, uint32_t csr0, uint32_t csr1, @@ -209,9 +206,6 @@ void set_gemmx_csr(int tempLoop0, int tempLoop1, int tempLoop2, csrw_ss(BYPASS_SIMD, bypassSIMD); } -// Set CSR to start GEMM -void set_gemmx_start() { csrw_ss(GEMMX_START, 1); } - // Stall until Streamer and GEMM accelerator finish void wait_gemmx_and_streamer() { csrw_ss(STREAMER_START_CSR, 0); From a31f539afb6626c9d76b219879f5b100a0272923 Mon Sep 17 00:00:00 2001 From: xiaoling-yi Date: Mon, 30 Sep 2024 14:20:40 +0200 Subject: [PATCH 2/3] revert change in macro for gemmx --- .../sw/snax/gemmx/include/snax-gemmx-lib.h | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h b/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h index c9c2b288c..471903023 100644 --- a/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h +++ b/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h @@ -79,23 +79,33 @@ void set_gemmx_streamer_csr( // Set CSR to start STREAMER inline void set_gemmx_streamer_start() { csrw_ss(STREAMER_START_CSR, 1); } -#define GEMMX_CSR_ADDR_BASE (STREAMER_PERFORMANCE_COUNTER_CSR + 1) -#define T_BOUND_K (GEMMX_CSR_ADDR_BASE + 0) -#define T_BOUND_N (GEMMX_CSR_ADDR_BASE + 1) -#define T_BOUND_M (GEMMX_CSR_ADDR_BASE + 2) +#define T_BOUND_K (STREAMER_PERFORMANCE_COUNTER_CSR + 1) +#define T_BOUND_N (T_BOUND_K + 1) +#define T_BOUND_M (T_BOUND_N + 1) -#define SUBTRACTIONS (GEMMX_CSR_ADDR_BASE + 3) +#define SUBTRACTIONS (T_BOUND_M + 1) -#define SIMD_CSR0 (GEMMX_CSR_ADDR_BASE + 4) -#define SIMD_CSR1 (GEMMX_CSR_ADDR_BASE + 5) -#define SIMD_CSR2 (GEMMX_CSR_ADDR_BASE + 6) +#define SIMD_CSR0 (SUBTRACTIONS + 1) +#define SIMD_CSR1 (SIMD_CSR0 + 1) -#define TEMPORAL_LOOP_BOUND (GEMMX_CSR_ADDR_BASE + 7) -#define BYPASS_SIMD (GEMMX_CSR_ADDR_BASE + 8) +#define SIMD_SHARED_BITPACKED_SHIFT0 (SIMD_CSR1 + 1) +#define SIMD_SHARED_BITPACKED_SHIFT1 (SIMD_SHARED_BITPACKED_SHIFT0 + 1) -#define GEMMX_START (GEMMX_CSR_ADDR_BASE + 9) -#define GEMMX_BUSY (GEMMX_CSR_ADDR_BASE + 10) -#define GEMMX_PERFORMANCE_COUNTER (GEMMX_CSR_ADDR_BASE + 11) +#define SIMD_SHARED_MULTIPLIER0 (SIMD_SHARED_BITPACKED_SHIFT1 + 1) +#define SIMD_SHARED_MULTIPLIER1 (SIMD_SHARED_MULTIPLIER0 + 1) +#define SIMD_SHARED_MULTIPLIER2 (SIMD_SHARED_MULTIPLIER1 + 1) +#define SIMD_SHARED_MULTIPLIER3 (SIMD_SHARED_MULTIPLIER2 + 1) +#define SIMD_SHARED_MULTIPLIER4 (SIMD_SHARED_MULTIPLIER3 + 1) +#define SIMD_SHARED_MULTIPLIER5 (SIMD_SHARED_MULTIPLIER4 + 1) +#define SIMD_SHARED_MULTIPLIER6 (SIMD_SHARED_MULTIPLIER5 + 1) +#define SIMD_SHARED_MULTIPLIER7 (SIMD_SHARED_MULTIPLIER6 + 1) + +#define TEMPORAL_LOOP_BOUND (SIMD_SHARED_MULTIPLIER7 + 1) +#define BYPASS_SIMD (TEMPORAL_LOOP_BOUND + 1) + +#define GEMMX_START (BYPASS_SIMD + 1) +#define GEMMX_BUSY (GEMMX_START + 1) +#define GEMMX_PERFORMANCE_COUNTER (GEMMX_BUSY + 1) // Set GEMM configuration CSR void set_gemmx_csr(int tempLoop0, int tempLoop1, int tempLoop2, From 74fe383a499044f83ccc436e17ed9e63d77caf57 Mon Sep 17 00:00:00 2001 From: xiaoling-yi Date: Mon, 30 Sep 2024 14:31:22 +0200 Subject: [PATCH 3/3] revert change in macro for gemmx --- .../sw/snax/gemmx/include/snax-gemmx-lib.h | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h b/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h index 471903023..63242c35d 100644 --- a/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h +++ b/target/snitch_cluster/sw/snax/gemmx/include/snax-gemmx-lib.h @@ -79,34 +79,6 @@ void set_gemmx_streamer_csr( // Set CSR to start STREAMER inline void set_gemmx_streamer_start() { csrw_ss(STREAMER_START_CSR, 1); } -#define T_BOUND_K (STREAMER_PERFORMANCE_COUNTER_CSR + 1) -#define T_BOUND_N (T_BOUND_K + 1) -#define T_BOUND_M (T_BOUND_N + 1) - -#define SUBTRACTIONS (T_BOUND_M + 1) - -#define SIMD_CSR0 (SUBTRACTIONS + 1) -#define SIMD_CSR1 (SIMD_CSR0 + 1) - -#define SIMD_SHARED_BITPACKED_SHIFT0 (SIMD_CSR1 + 1) -#define SIMD_SHARED_BITPACKED_SHIFT1 (SIMD_SHARED_BITPACKED_SHIFT0 + 1) - -#define SIMD_SHARED_MULTIPLIER0 (SIMD_SHARED_BITPACKED_SHIFT1 + 1) -#define SIMD_SHARED_MULTIPLIER1 (SIMD_SHARED_MULTIPLIER0 + 1) -#define SIMD_SHARED_MULTIPLIER2 (SIMD_SHARED_MULTIPLIER1 + 1) -#define SIMD_SHARED_MULTIPLIER3 (SIMD_SHARED_MULTIPLIER2 + 1) -#define SIMD_SHARED_MULTIPLIER4 (SIMD_SHARED_MULTIPLIER3 + 1) -#define SIMD_SHARED_MULTIPLIER5 (SIMD_SHARED_MULTIPLIER4 + 1) -#define SIMD_SHARED_MULTIPLIER6 (SIMD_SHARED_MULTIPLIER5 + 1) -#define SIMD_SHARED_MULTIPLIER7 (SIMD_SHARED_MULTIPLIER6 + 1) - -#define TEMPORAL_LOOP_BOUND (SIMD_SHARED_MULTIPLIER7 + 1) -#define BYPASS_SIMD (TEMPORAL_LOOP_BOUND + 1) - -#define GEMMX_START (BYPASS_SIMD + 1) -#define GEMMX_BUSY (GEMMX_START + 1) -#define GEMMX_PERFORMANCE_COUNTER (GEMMX_BUSY + 1) - // Set GEMM configuration CSR void set_gemmx_csr(int tempLoop0, int tempLoop1, int tempLoop2, int subtractions, uint32_t csr0, uint32_t csr1,