Consider how your application objectives, such as efficiency or debugging, map to code generation options in a model configuration set. Parameters that you set in the Configuration Parameters dialog box specify the behavior of a model in simulation and the code generated for the model.
Before generating code, or as part of the code generation process, you can use the Code Generation Advisor to review a model. When you choose to review a model before generating code, you specify which model, subsystem, or referenced model the Code Generation Advisor reviews. When you choose to review a model as part of the code generation process, the Code Generation Advisor reviews the entire system. The Code Generation Advisor uses the information presented in Recommended Settings Summary for Model Configuration Parameters to determine the parameter values that meet your objectives. To configure objectives for a model with an ERT-based target, see Configure Model for Code Generation Objectives Using Code Generation Advisor.
Setting a code generation objective, and then running the Code Generation Advisor provides information on how to meet the code generation objective for your model. The Code Generation Advisor does not alter the generated code. You can use the Code Generation Advisor to make the suggested changes to your model. The generated code is changed only after you modify your model and regenerate code. When you use the Code Generation Advisor to set the code generation objective and check your model, the generated code includes comments identifying which objective you specified, the checks the Code Generation Advisor ran on the model, and the results of running the checks.
If a model uses a configuration reference, you can run the Code Generation Advisor to review your configuration parameter settings. However, the Code Generation Advisor cannot modify the configuration parameter settings.
Depending on the type of application that your model represents, you are likely to have specific high-level code generation objectives. For example, debugging might be more critical than efficient execution. If you have a specific objective, you can quickly configure your model to meet that objective by selecting from these code generation objectives:
Execution efficiency — Configure code generation settings to achieve fast execution time.
Debugging — Configure code generation settings to debug the code generation build process.
For a list of objectives that are available for models with ERT-based targets, see High-Level Code Generation Objectives.
This example shows how to use the Code Generation Advisor to check and configure your model to meet code generation objectives:
On the C Code tab, click C/C++ Code Advisor.
In the System Selector window, select the model or subsystem that you want to review, and then click OK.
In the Code Generation Advisor, on the Code Generation Objectives pane, select a code generation objective from the drop-down list (GRT-based targets). As you select objectives, on the left pane, the Code Generation Advisor updates the list of checks it will run on your model. If your model is configured with an ERT-based target, more objectives are available.
Click Run Selected Checks to run the checks listed in the left pane of the Code Generation Advisor.
In the Code Generation Advisor window, review the results for Check model configuration settings against code generation objectives by selecting it from the left pane. The results for that check are displayed in the right pane.
Check model configuration settings against code generation objectives triggers a warning for these issues:
Parameters are set to values other than the value recommended for the specified code generation objective.
The selected code generation objective differs from the objective set in the model.
Click Modify Parameters to set:
Parameters to the value recommended for the specified code generation objective.
Code generation objective in the model to the objective specified in the Code Generation Advisor.
In the Code Generation Advisor window, review the results for the remaining checks by selecting them from the left pane. The results for the checks display in the right pane.
After reviewing the check results, you can choose to fix warnings and failures, as described in Fix a Model Advisor Check Warning or Failure.
When you specify a the execution efficiency objective, the Code Generation Advisor includes additional checks. When you make changes to one of these additional checks, previous check results can potentially become invalid and need to be rerun.
This example shows how to check and configure the code generation objectives in the Configuration Parameters dialog box:
Open the Configuration Parameters dialog box and select Code Generation.
Select or confirm selection of a System target file.
Specify the objective using the Select objectives drop-down list.
Click Check Model to run the model checks.
In the System Selector window, select the model or subsystem that you want to review, and then click OK. The Code Generation Advisor dialog box opens. The Code Generation Advisor uses the code generation objective to determine which model checks to run.
On the left pane, the Code Generation Advisor lists the checks run on the model and the results. Click each warning to see the suggestions for changes that you can make to your model to pass the check.
Determine which changes to make to your model. On the right pane of the Code Generation Advisor, follow the instructions listed for each check to modify the model.