Skip to content

Commit

Permalink
[software] Rename check functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mbertuletti committed Nov 25, 2024
1 parent 9c6f8c8 commit a76f158
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion software/apps/baremetal/axpy_i32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion software/apps/baremetal/cfft_radix2_q16/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion software/apps/baremetal/cfft_radix4_q16/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion software/apps/baremetal/chest_q16/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion software/apps/baremetal/matmul_i16/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion software/apps/baremetal/matmul_i32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion software/apps/baremetal/matmul_i8/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
35 changes: 32 additions & 3 deletions software/kernels/baremetal/mempool_checks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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++;
}
}
Expand Down

0 comments on commit a76f158

Please sign in to comment.