Embedded Coder Bug: Not using return value of code-generated "Prelookup" function
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm having an issue with some code generated by Embedded Coder. For some reason, my model's main loop calls the prelookup function plook_u32d_linckpag() but does not use the return value.
The function declaration is as follows:
extern uint32_T plook_u32d_linckpag(real_T u, const real_T bp[], uint32_T
maxIndex, uint32_T *prevIndex);
Has anyone seen behavior like this before?
While I'm here, I'm also seeing the model's main loop setting every element of an array to zero right before an if-statement that checks if one of these array elements is nonzero to execute another block of code.
Is this an artifact of optimization? I've tried debugging the Target Language Compiler but I don't think I'm getting anywhere.
0 个评论
采纳的回答
Abhishek Kumar Singh
2024-2-23
Hi Gabriel,
Regarding the unused return value from the prelookup function, I assume you have already checked the model configuration, ensured the correct model setup, and also tried code generation with the 'Interpolation Using Prelookup' block. The most probable cause seems to be dead code elimination. The optimization process employed by Embedded Coder might have determined that the return value does not affect the program's behavior and thus removed its usage.
As for the issue of array initialization, there could be two reasons: either the Embedded Coder is initializing the array before entering the conditional logic for determinism reasons, or, as you suggested, it is an artifact of optimization. You can check the code generation settings related to initialization and data handling.
Investigating these points may help to pinpoint the problem. Of course, the nuances of each model can shed more light on such issues, making them easier to unravel.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!