ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
test_mmult.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "dsp_common.h"
#include "dspm_mult.h"
Include dependency graph for test_mmult.c:

Go to the source code of this file.

Macros

#define M   4
#define N   8
#define K   16

Functions

void xt_iss_profile_disable ()
void xt_iss_profile_enable ()
void test_mmult ()

Variables

const int m = 4
const int n = 8
const int k = 16
float A [4][8]
float B [8][16]
float C [4][16]
float C_compare [4][16]

Macro Definition Documentation

◆ K

#define K   16

Definition at line 14 of file test_mmult.c.

Referenced by ekf::UpdateRef().

◆ M

#define M   4

Definition at line 12 of file test_mmult.c.

◆ N

Function Documentation

◆ test_mmult()

void test_mmult ( )

Definition at line 25 of file test_mmult.c.

26{
27
28 float *A_ptr = (float *)A;
29 float *B_ptr = (float *)B;
30 float *C_ptr = (float *)C;
31 float *Cc_ptr = (float *)C_compare;
32
33 for (int i = 0 ; i < m * n; i++) {
34 A_ptr[i] = i;
35 B_ptr[i] = i;
36 }
37 for (int i = 0 ; i < m ; i++) {
38 for (int j = 0 ; j < k ; j++) {
39 C_compare[i][j] = 0;
40 for (int s = 0 ; s < n ; s++) {
41 C_compare[i][j] += A[i][s] * B[s][j];
42 }
43 C[i][j] = -1;
44 }
45 }
47 dspm_mult_f32_ae32(A_ptr, B_ptr, Cc_ptr, m, n, k);
48 dspm_mult_f32_aes3(A_ptr, B_ptr, C_ptr, m, n, k);
50
51 for (int i = 0 ; i < m ; i++) {
52 for (int j = 0 ; j < k ; j++) {
53 printf("[%i][%i] calc=%f, expected =%f\n", i, j, C[i][j], C_compare[i][j]);
54 }
55 }
56 // Compare and check results
57 for (int i = 0 ; i < m * k ; i++) {
58 if (Cc_ptr[i] != C_ptr[i]) {
59 printf("Error - C_ptr= %f, Cc_ptr= %f \n", C_ptr[i], Cc_ptr[i]);
60 return;
61 }
62 }
63
64 printf("Test Pass!\n");
65}
esp_err_t dspm_mult_f32_aes3(const float *A, const float *B, float *C, int m, int n, int k)
esp_err_t dspm_mult_f32_ae32(const float *A, const float *B, float *C, int m, int n, int k)
float C[4][16]
Definition test_mmult.c:22
void xt_iss_profile_disable()
const int m
Definition test_mmult.c:16
float B[8][16]
Definition test_mmult.c:21
float C_compare[4][16]
Definition test_mmult.c:23
float A[4][8]
Definition test_mmult.c:20
const int n
Definition test_mmult.c:17
const int k
Definition test_mmult.c:18
void xt_iss_profile_enable()

References A, B, C, C_compare, dspm_mult_f32_ae32(), dspm_mult_f32_aes3(), k, m, n, xt_iss_profile_disable(), and xt_iss_profile_enable().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xt_iss_profile_disable()

void xt_iss_profile_disable ( )
extern

Referenced by test_mmult().

Here is the caller graph for this function:

◆ xt_iss_profile_enable()

void xt_iss_profile_enable ( )
extern

Referenced by test_mmult().

Here is the caller graph for this function:

Variable Documentation

◆ A

◆ B

◆ C

◆ C_compare

float C_compare[4][16]

Definition at line 23 of file test_mmult.c.

Referenced by test_mmult().

◆ k

◆ m

◆ n