How do I control and customize compiler options such as optimization settings for the simulation-based Real-Time Workshop compilations of Simulink Accelerator, RSIM and the Model Reference Simulation Target (R14SP2)?

11 views (last 30 days)
In particular, one common issue is needing to modify compiler heap limit as per the following error message:
fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 May 2010
The Real-Time Workshop (RTW) build process is used by several simulation-based targets. In general, modifying the Template Makefile (TMF) being used by a target is the most fundamental approach to customizing compiler options. If available, alternative approaches to controlling the compiler options based on the target are described below.
Note: If using a version prior to R14SP2, refer to the Related Solution listed below.
___________________________________
Simulink Accelerator:
WIN32 Platform:
You can modify the "mexopts.bat" file located in your "prefdir" to control compiler options.
1. Run:
mex -setup
to select the desired compiler.
2. Edit the "mexopts.bat" file:
edit(rtw_alt_pathname(fullfile(prefdir,'mexopts.bat')))
3. Adjust the following lines as desired:
set COMPFLAGS=-c -Zp8 -G5 -GR -W3 -DMATLAB_MEX_FILE -nologo
set OPTIMFLAGS=/MD -O2 -Oy- -DNDEBUG
UNIX/MAC Platforms:
1. You can use the make command property of the Real-Time Workshop page of the Configuration Parameters dialog to customize the OPT_OPTS compiler optimizations setting. For example:
make_rtw OPT_OPTS="-fPIC"
(Note: The Real-Time Workshop page will not be visible if you do not own a license to Real-Time Workshop. The Simulink Accelerator does not require a Real-Time Workshop license).
Alternatively, on any platform, you can edit the Template Makefile (TMF), located in:
$MATLAB\rtw\c\accel\*.tmf
(where $MATLAB is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB command prompt.)
Use the file corresponding to the compiler you are using:
accel_vc.tmf for MSVC
accel_lcc.tmf for LCC
accel _unix.tmf for UNIX hosts (including Mac)
You can also copy the TMF file to the current working directory and make changes to the copy. The file in the current directory will be used in the build process before the file in directory mentioned above.
___________________________________
Model Reference Simulation Target (used for Model blocks):
1. You must edit the Template Makefile (TMF):
$MATLAB\rtw\c\modelref\*.tmf
(where $MATLAB is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB command prompt.)
Use the file corresponding to the compiler you are using:
modelrefsim_vc.tmf for MSVC
modelrefsim_lcc.tmf for LCC
modelrefsim_unix.tmf for UNIX hosts (including Mac)
You can also copy the TMF file to the current working directory and make changes to the copy. The file in the current directory will be used in the build process before the file in directory mentioned above.
2. Set the 'OPTS' to the desired compiler options. For example:
# General User Options
OPTS = -Zm200
3. Add a line to set the optimization variable, OPT_OPTS, to desired value:
  1. General User Options
OPTS =
OPT_OPTS = -O3
___________________________________
Rapid Simulation (RSIM) Target:
1. Use the make command property of the RTW page of the Configuration Parameters dialog to customize the compiler options for RSIM. For example:
make_rtw OPTS="-Zm200" OPT_OPTS="-O3"
Alternatively, you can do the following:
1a. Follow the same approach as described for Model Reference Simulation target using the files in:
$MATLAB\rtw\c\rsim\*.tmf
(where $MATLAB is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB command prompt.)
Use the file corresponding to the compiler you are using:
rsim_intel.tmf for Intel compiler
rsim_lcc.tmf for LCC compiler
rsim_unix.tmf for gcc compiler
rsim_vc.tmf for MSVC compiler
rsim_bc.tmf for Borland compiler
rsim_watc.tmf for Watcom compiler
You can also copy the TMF file to the current working directory and make changes to the copy. The file in the current directory will be used in the build process before the file in directory mentioned above.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!