diff --git a/software/apps/baremetal/axpy_i32/main.c b/software/apps/baremetal/axpy_i32/main.c index aa91733ea..c391ba040 100644 --- a/software/apps/baremetal/axpy_i32/main.c +++ b/software/apps/baremetal/axpy_i32/main.c @@ -47,7 +47,7 @@ int main() { mempool_stop_benchmark(); // Verify results - mempool_check_q32(l1_Y, l2_Z, array_N, 0, 0); + mempool_check_i32(l1_Y, l2_Z, array_N, 0, 0); mempool_barrier(num_cores); return 0; diff --git a/software/apps/baremetal/cfft_radix2_q16/main.c b/software/apps/baremetal/cfft_radix2_q16/main.c index 5a66c37d3..e23fb929e 100644 --- a/software/apps/baremetal/cfft_radix2_q16/main.c +++ b/software/apps/baremetal/cfft_radix2_q16/main.c @@ -70,7 +70,7 @@ int main() { mempool_stop_benchmark(); #endif - mempool_check_q16(l1_pSrc, l2_pRes, 2 * N_CSAMPLES, TOLERANCE, 0); + mempool_check_i16(l1_pSrc, l2_pRes, 2 * N_CSAMPLES, TOLERANCE, 0); mempool_barrier(num_cores); return 0; } diff --git a/software/apps/baremetal/cfft_radix4_q16/main.c b/software/apps/baremetal/cfft_radix4_q16/main.c index a4d9f887d..08ed80e9b 100644 --- a/software/apps/baremetal/cfft_radix4_q16/main.c +++ b/software/apps/baremetal/cfft_radix4_q16/main.c @@ -227,7 +227,7 @@ int main() { printf("02: END COMPUTATION\n"); } - mempool_check_q16(pRes, l2_pRes, 2 * N_CSAMPLES, TOLERANCE, 0); + mempool_check_i16(pRes, l2_pRes, 2 * N_CSAMPLES, TOLERANCE, 0); mempool_barrier(num_cores); return 0; } diff --git a/software/apps/baremetal/chest_q16/main.c b/software/apps/baremetal/chest_q16/main.c index eecac204a..498c60260 100644 --- a/software/apps/baremetal/chest_q16/main.c +++ b/software/apps/baremetal/chest_q16/main.c @@ -62,7 +62,7 @@ int main() { #endif /* Check */ - mempool_check_q16(l1_HEST, l2_HEST, 2 * N_TX * N_RX, 0, 0); + mempool_check_i16(l1_HEST, l2_HEST, 2 * N_TX * N_RX, 0, 0); mempool_barrier(num_cores); return 0; } diff --git a/software/apps/baremetal/matmul_i16/main.c b/software/apps/baremetal/matmul_i16/main.c index 894489ae1..a2b554dfa 100644 --- a/software/apps/baremetal/matmul_i16/main.c +++ b/software/apps/baremetal/matmul_i16/main.c @@ -46,7 +46,7 @@ int main() { mempool_barrier(num_cores); // Verify results - mempool_check_q32(l1_C, l2_C, matrix_M * matrix_P, 0, 0); + mempool_check_i32(l1_C, l2_C, matrix_M * matrix_P, 0, 0); mempool_barrier(num_cores); return 0; } diff --git a/software/apps/baremetal/matmul_i32/main.c b/software/apps/baremetal/matmul_i32/main.c index 94b250306..3713dcabe 100644 --- a/software/apps/baremetal/matmul_i32/main.c +++ b/software/apps/baremetal/matmul_i32/main.c @@ -46,7 +46,7 @@ int main() { mempool_barrier(num_cores); // Verify results - mempool_check_q32(l1_C, l2_C, matrix_M * matrix_P, 0, 0); + mempool_check_i32(l1_C, l2_C, matrix_M * matrix_P, 0, 0); mempool_barrier(num_cores); return 0; } diff --git a/software/apps/baremetal/matmul_i8/main.c b/software/apps/baremetal/matmul_i8/main.c index 63a24418e..3aa99a4e6 100644 --- a/software/apps/baremetal/matmul_i8/main.c +++ b/software/apps/baremetal/matmul_i8/main.c @@ -46,7 +46,7 @@ int main() { mempool_barrier(num_cores); // Verify results - mempool_check_q32(l1_C, l2_C, matrix_M * matrix_P, 0, 0); + mempool_check_i32(l1_C, l2_C, matrix_M * matrix_P, 0, 0); mempool_barrier(num_cores); return 0; } diff --git a/software/kernels/baremetal/mempool_checks.h b/software/kernels/baremetal/mempool_checks.h index d680764c1..110acec90 100644 --- a/software/kernels/baremetal/mempool_checks.h +++ b/software/kernels/baremetal/mempool_checks.h @@ -12,7 +12,7 @@ @param[in] TOL floating point tolerance @return none */ -void mempool_check_q32(int32_t *__restrict__ pRes, int32_t *__restrict__ pExp, +void mempool_check_i32(int32_t *__restrict__ pRes, int32_t *__restrict__ pExp, uint32_t NEL, int32_t TOL, bool verbose) { uint32_t core_id = mempool_get_core_id(); int32_t error; @@ -41,7 +41,7 @@ void mempool_check_q32(int32_t *__restrict__ pRes, int32_t *__restrict__ pExp, @param[in] TOL floating point tolerance @return none */ -void mempool_check_q16(int16_t *__restrict__ pRes, int16_t *__restrict__ pExp, +void mempool_check_i16(int16_t *__restrict__ pRes, int16_t *__restrict__ pExp, uint32_t NEL, int16_t TOL, bool verbose) { uint32_t core_id = mempool_get_core_id(); int16_t error; @@ -53,7 +53,36 @@ void mempool_check_q16(int16_t *__restrict__ pRes, int16_t *__restrict__ pExp, error = (int16_t)(exp - res); bool print = ((error > TOL) || (error < (-TOL))) | verbose; if (print) { - printf("CHECK(%d): EXP = %08X - RESP = %08X\n", i, exp, res); + printf("CHECK(%d): EXP = %04X - RESP = %04X\n", i, exp, res); + ERRORS++; + } + } + printf("%d ERRORS out of %d CHECKS\n", ERRORS, NEL); + } + return; +} + +/** + @brief Check for i8 kernels. + @param[in] pRes points to the result + @param[in] pExp points to the expected result + @param[in] NEL number of elements to check + @param[in] TOL floating point tolerance + @return none +*/ +void mempool_check_i8(int8_t *__restrict__ pRes, int8_t *__restrict__ pExp, + uint32_t NEL, int16_t TOL, bool verbose) { + uint32_t core_id = mempool_get_core_id(); + int16_t error; + if (core_id == 0) { + uint32_t ERRORS = 0; + for (uint32_t i = 0; i < NEL; i++) { + int16_t exp = (int8_t)pExp[i]; + int16_t res = (int8_t)pRes[i]; + error = (int8_t)(exp - res); + bool print = ((error > TOL) || (error < (-TOL))) | verbose; + if (print) { + printf("CHECK(%d): EXP = %02X - RESP = %02X\n", i, exp, res); ERRORS++; } }