How to force Embedded Coder to unroll the generated for loop of "For Each Subsystem" in generated code?

5 visualizzazioni (ultimi 30 giorni)
I am using for each subsystem to simulate and generate the embedded code for embedded hardware.
I have attached the simple example of For Each Subsystem and generated code.
I tried different Code generation Optimazation settings to unroll the loop in generated code but I am unable to solve it.
I tried also different values for loop unrolling threshold but this does not help or may be I am doing something wrong.
Does anyone know how to solve this issue?
Thank you.

Risposte (1)

Harsh
Harsh il 22 Apr 2025
Hi @SG,
The code generator unrolls loops when the number of iterations is below the threshold set in "Loop unrolling threshold" in advanced parameters. In the attached "For_Each_Subsystem_Example", there are iterations present in the for loop. Therefore you can set the value for "Loop unrolling threshold" as 4. There are two ways to do this:
  • Go to "Code Generation" > "Optimization" > "Advanced Parameters" and set the "Loop unrolling threshold" as 4.
  • Use the "set_param" function in command line.
set_param('For_Each_Example', 'RollThreshold', 4)
Here's how the generated code looks like after optimization -

Categorie

Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by