From 6cae7117267cbabeeffac139be858fd5afa0be4e Mon Sep 17 00:00:00 2001 From: Yunhao Deng Date: Mon, 2 Sep 2024 12:36:43 +0200 Subject: [PATCH] Bug Fix --- .../src/snax-test-integration.c | 57 +++++++++---------- target/sim/sw/sim_elf.yaml | 2 +- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/target/sim/sw/device/apps/snax/snax-test-integration/src/snax-test-integration.c b/target/sim/sw/device/apps/snax/snax-test-integration/src/snax-test-integration.c index c31ecac2c..4ca19a5c6 100644 --- a/target/sim/sw/device/apps/snax/snax-test-integration/src/snax-test-integration.c +++ b/target/sim/sw/device/apps/snax/snax-test-integration/src/snax-test-integration.c @@ -14,31 +14,31 @@ #include "snrt.h" int8_t* tcdm0_start_addr; int8_t* tcdm1_start_addr; -int main(){ +int main() { int err = 0; // First set the addr of cluster 0 // tcdm0_start_addr = (int8_t*)0x10000000; // tcdm1_start_addr = (int8_t*)0x10100000; - if(snrt_cluster_idx()==0){ - if(snrt_is_dm_core()){ + if (snrt_cluster_idx() == 0) { + if (snrt_is_dm_core()) { tcdm0_start_addr = (int8_t*)snrt_cluster_base_addrl(); printf("The C0 TCDM ADDR is %p \n", tcdm0_start_addr); } } snrt_global_barrier(); - if(snrt_cluster_idx()==1){ - if(snrt_is_dm_core()){ + if (snrt_cluster_idx() == 1) { + if (snrt_is_dm_core()) { tcdm1_start_addr = (int8_t*)snrt_cluster_base_addrl(); printf("The C1 TCDM ADDR is %p \n", tcdm1_start_addr); } } snrt_global_barrier(); // C0 Load the data from l3 -> l1 - if(snrt_cluster_idx()==0){ - if (snrt_is_dm_core()){ + if (snrt_cluster_idx() == 0) { + if (snrt_is_dm_core()) { printf("[C0] Start to load data from %p\n", test_data); - snrt_dma_start_1d(tcdm0_start_addr,test_data,length_data); + snrt_dma_start_1d(tcdm0_start_addr, test_data, length_data); snrt_dma_wait_all(); } } @@ -46,52 +46,51 @@ int main(){ snrt_global_barrier(); // Thenc C1 fetches data from C0 - if(snrt_cluster_idx()==1){ - if (snrt_is_dm_core()){ + if (snrt_cluster_idx() == 1) { + if (snrt_is_dm_core()) { printf("[C1] Load data from C0 TCDM %p\n", tcdm0_start_addr); - snrt_dma_start_1d(tcdm1_start_addr,tcdm0_start_addr,length_data); + snrt_dma_start_1d(tcdm1_start_addr, tcdm0_start_addr, length_data); snrt_dma_wait_all(); } - } // wait the C1 is done snrt_global_barrier(); // Start to check - if(snrt_cluster_idx()==0){ - - if (snrt_cluster_core_idx()==0){ + if (snrt_cluster_idx() == 0) { + if (snrt_cluster_core_idx() == 0) { printf("C0 Checking the results\n"); - for (int i = 0; i < length_data; i++){ - if(tcdm0_start_addr[i] != test_data[i]){ - err ++; + for (int i = 0; i < length_data; i++) { + if (tcdm0_start_addr[i] != test_data[i]) { + err++; printf("C0 data is incorrect!\n"); printf("tcdm0[%d]=%d, test_data[%d]=%d\n", i, - tcdm0_start_addr[i], i, test_data[i]); + tcdm0_start_addr[i], i, test_data[i]); + return -1; } } } } snrt_global_barrier(); - if(snrt_cluster_idx()==1){ - - if (snrt_cluster_core_idx()==0){ + if (snrt_cluster_idx() == 1) { + if (snrt_cluster_core_idx() == 0) { printf("C1 Checking the results\n"); - for (int i = 0; i < length_data; i++){ - if(tcdm1_start_addr[i] != test_data[i]){ - err ++; + for (int i = 0; i < length_data; i++) { + if (tcdm1_start_addr[i] != test_data[i]) { + err++; printf("C1 data is incorrect!\n"); printf("tcdm0[%d]=%d, test_data[%d]=%d\n", i, - tcdm1_start_addr[i], i, test_data[i]); + tcdm1_start_addr[i], i, test_data[i]); + return -1; } } } } snrt_global_barrier(); - if(snrt_cluster_idx()==0){ - if(snrt_is_dm_core()){ - printf("Checking all done! No error!\n"); + if (snrt_cluster_idx() == 0) { + if (snrt_is_dm_core()) { + printf("Checking all done! No error!\n"); } } diff --git a/target/sim/sw/sim_elf.yaml b/target/sim/sw/sim_elf.yaml index 4aa8e7c97..5bc17bc7d 100644 --- a/target/sim/sw/sim_elf.yaml +++ b/target/sim/sw/sim_elf.yaml @@ -3,4 +3,4 @@ # SPDX-License-Identifier: Apache-2.0 runs: - - elf: sw/apps/offload/build/offload-snax-test-integration.elf + - elf: apps/offload/build/offload-snax-test-integration.elf