This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VM: Be careful,Correction of possible errors in dsplib source code

Part Number: TDA4VM
When I use the source code of dsplib to speed up matrix operations, I find that when I use DSPF_ dp_ mat_ mul_ Gemm got wrong results when multiplying the matrix C=C+A * B. So I tried to analyze the code and made corrections. My code can be used to replace it if you need it. Note that the size of the matrix column and column must be a multiple of 2。I don't know if there is any problem with my change. At least there is no problem with the current test results
source code:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void DSPF_dp_mat_mul_gemm(double *x1, double const a, const int r1, const int c1,
double *x2, const int c2, double *restrict y)
{
int i, j, k, xoff1, xoff2;
double sum0, sum1, sum2, sum3;
double x00, x01, y00, y01, y10, y11, x10, x11;
double *ptr_x, *ptr_y, *restrict y1, *restrict y2;
_nassert(r1 > 0);
_nassert(c1 > 0);
_nassert(c2 > 0);
_nassert((int)x1 % 8 == 0);
_nassert((int)x2 % 8 == 0);
_nassert((int)y % 8 == 0);
_nassert(c1 % 2 == 0 );
_nassert(r1 % 2 == 0 );
_nassert(c2 % 2 == 0 );
#pragma MUST_ITERATE(1,,)
for (j = 0; j < c2; j+=2) {
xoff2 = j * c1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Modified code:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void DSPF_dp_mat_mul_gemm_test(double *x1,double const a, const int r1,
const int c1, double *x2, const int c2,
double *restrict y) {
int i, j, k, xoff1, xoff2;
double sum0, sum1, sum2, sum3;
double x00, x01, y00, y01, y10, y11, x10, x11;
double *ptr_x, *ptr_y, *y1, *y2;
_nassert(r1 > 0);
_nassert(c1 > 0);
_nassert(c2 > 0);
_nassert((int)x1 % 8 == 0);
_nassert((int)x2 % 8 == 0);
_nassert((int)y % 8 == 0);
_nassert(c1 % 2 == 0 );
_nassert(r1 % 2 == 0 );
_nassert(c2 % 2 == 0 );
#pragma MUST_ITERATE(1,,)
for (j = 0; j < c2; j+=2) {
xoff2 = j;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

x 出现错误。请重试或与管理员联系。