Linking BLAS to Simulink S-Function.
10 views (last 30 days)
Show older comments
Hello everyone,
I am currently trying to link the BLAS library to a Simulink S-Function.
If I understood MathWorks documentation, Matlab already has the Blas (and Lapack) library in its folder in matroot\extern\lib\win64\microsoft. I developed an example, implementing an FIR filter, whose coefficients are the S-Function Block parameter. To generate and build the S-Function and TLC file, I used the S-Function Builder block. I specified libmwblas.lib as additional library, and blas.h as additional header. In the mdlOutputs function in make use of the ddot blas function.
Here is the generated Outputs_wrapper function
void sfcn_FIR_BLAS_Outputs_wrapper(const real_T *u0,
real_T *y0,
void **pW,
const int16_T *filterOrder, const int_T p_width0,
const real_T *coefficients, const int_T p_width1)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
mwSignedIndex one = 1;
double *prevIn = (double *)pW[0];
memmove(prevIn + 1, prevIn, sizeof(double)*filterOrder[0]);
memcpy(prevIn, u0, sizeof(double));
y0[0] = ddot(filterOrder, prevIn, &one, coefficients, &one);
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
The S-Function builds without any error at this point. Then it gets weird, when running the model, sometimes, Matlab crashes. I'd say 1 out of 3 Run makes Matlab crash. The rest of the time, the output of the block is totally correct. Do you have any idea where this problem come from ? And how can I solve it ?
This model is then ment to be executed on a target PC on Simulink Real-Time. So I tried to built an executable for the model and run it in external mode. The executable gets built, but when trying to lauch it, windows throws an error : "libmwblas.dll". I can't figure out why, as I already have the static library "libmwblas.lib" in matlab installation path.
Do you have any idea how to solve this other issue ? (Maybe the two are linked).
Thanks,
Igor
0 Comments
Answers (0)
See Also
Categories
Find more on Simulink Coder 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!