Global data synchronization mode
Global data synchronization mode
Description
App Configuration Pane: Memory
Configuration Objects: coder.MexCodeConfig
The Global data synchronization mode parameter specifies when the code generator synchronizes global data between the MEX function workspace and the MATLAB® workspace. The parameter also specifies when the code generator verifies that constant global values are consistent between the MEX function workspace and the MATLAB workspace.
By default, the code generator enforces maximum consistency between MATLAB and the generated MEX function by synchronizing global data when MEX function execution begins, when MEX function execution ends, and after extrinsic function calls. It also verifies the consistency of constant global data between the generated MEX function and MATLAB when MEX function execution begins and after extrinsic function calls.
If you partially or completely disable global synchronization, the code generator produces less code and the MEX function might execute more quickly. However, if you disable global synchronization and the MATLAB code modifies global data, global data can differ between the MEX function and MATLAB.
Settings
At MEX-function entry, exit and extrinsic callsThis value is the default value.
The code generator synchronizes global data when MEX function execution begins, when MEX function execution ends, and after extrinsic function calls. The code generator checks constant global data at MEX function entry and after extrinsic calls. If the constant global values in the MATLAB workspace are inconsistent with the constant global values in the MEX function workspace, the MEX function ends with an error.
If most extrinsic function calls in the MATLAB code modify global data, but a few do not, you can use this setting in conjunction with the
coder.extrinsicoption"-sync:off"to turn off global synchronization and global constant checking for specific functions that do not use global data.At MEX-function entry and exitThe code generator synchronizes global data when MEX function execution begins and when MEX function execution ends. The code generator does not synchronize global data after extrinsic function calls. The code generator checks constant global data at MEX function entry. The code generator does not check constant global data after extrinsic function calls. If the constant global values in the MATLAB workspace are inconsistent with the constant global values in the MEX function workspace, the MEX function ends with an error.
If most extrinsic function calls do not modify global data, but a few do, you can use this setting in conjunction with the
coder.extrinsicoption"-sync:on"to turn on global synchronization and global constant checking for specific functions that use global data.DisabledThe code generator does not synchronize global data between MATLAB and the generated MEX function. The code generator does not check constant global data between MATLAB and the generated MEX function. Before you use this setting, verify that your MEX function does not interact with MATLAB global data. Otherwise, the MATLAB and the MEX function global workspaces can differ.
When you select this setting, the code generator ignores the
coder.extrinsicoptions"-sync:on"and"-sync:off"options.
Programmatic Use
Property:
GlobalDataSyncMethod |
Values: 'SyncAlways' |
'SyncAtEntryAndExits' | 'NoSync' |
Default:
'SyncAlways' |
Version History
Introduced in R2011a