# Coder not replacing CMSIS library

2 ビュー (過去 30 日間)
Jose Cazarin 2020 年 2 月 7 日

Hello! Im trying to use Matlab coder to generate C code for an ARM M4 device
The problem is: coder is not replacing basic matrix operations with the optimized functions of the CMSIS library
I know the replacement is working because some square root operations were in fact being replaced.
I have an example code:
function C = my_matrix_multiply(A, B)%#codegen
C = A*B;
my_sqrt = sqrt(A);
end
The script that is calling this function is
A = [3 3 3;3 3 3;3 3 3];
B = A;
C = my_matrix_multiply(single(A), single(B));
And the generated code is:
void my_matrix_multiply(const float A[9], const float B[9], float C[9])
{
int k;
float f;
float f1;
float x[9];
int i;
float f2;
for (k = 0; k < 3; k++) {
f = A[k + 3];
f1 = A[k + 6];
for (i = 0; i < 3; i++) {
C[k + 3 * i] = (A[k] * B[3 * i] + f * B[3 * i + 1]) + f1 * B[3 * i + 2];
}
}
for (k = 0; k < 9; k++) {
x[k] = A[k];
}
for (k = 0; k < 9; k++) {
mw_arm_sqrt_f32(x[k], &f2);
x[k] = f2;
}
}
I would expect for the coder to replace the loop where it is making the multiplication by the function arm_mult_f32 (or the mw_arm_mult_f32 defined)
Is there anything I'm missing here?
I'm attaching the .prj file for the project

サインインしてコメントする。

### 回答 (2 件)

Jose Cazarin 2020 年 2 月 7 日

I just realized that the arm_mult_f32 is a function to multiply vectors not matrices, sorry for the confusion, I mean the function arm_mat_mult_f32.
But now I realized that this function is not in the header file mw_cmsis.h created by the coder. Looks like that whenever some piece of code is replaced by the call of a CMSIS library function this header is generated with all the supported functions from the CMSIS library, and there's no functions for matrix multiplication in this file. Does this mean that the Coder doesn't support replacing code for matrix multiplications?
Thanks!

#### 0 件のコメント

サインインしてコメントする。

Darshan Ramakant Bhat 2020 年 2 月 11 日
According to this page, https://au.mathworks.com/help/supportpkg/armcortexm/ug/supported-cmsis-functions.html the matrix multiply is not supported. You can run below command to bring up replacement library and check the support
>>crviewer('ARM Cortex-M')

サインインしてコメントする。

R2019b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by