Coder not replacing CMSIS library
Show older comments
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
Answers (2)
Jose Cazarin
on 7 Feb 2020
Edited: Jose Cazarin
on 7 Feb 2020
0 votes
Darshan Ramakant Bhat
on 11 Feb 2020
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')
Categories
Find more on ARM Cortex-M Processors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!