Embedded Coder Bug: Not using return value of code-generated "Prelookup" function
2 views (last 30 days)
Show older comments
Gabriel Aaron
on 15 Feb 2024
Edited: Walter Roberson
on 23 Feb 2024
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 Comments
Accepted Answer
Abhishek Kumar Singh
on 23 Feb 2024
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.
More Answers (0)
See Also
Categories
Find more on Deployment, Integration, and Supported Hardware 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!