Share Simulink Cache Files for Faster Simulation - MATLAB & Simulink (original) (raw)
Simulink® cache files contain build artifacts that can speed up simulation and code generation. To generate these build artifacts and automatically package them in Simulink cache files, perform one of these actions:
- Update the diagram for a model hierarchy that contains models referenced in accelerator mode
- Simulate a model hierarchy that contains models referenced in accelerator mode
- Simulate a top model in accelerator or rapid accelerator mode
- Generate code for a model or model hierarchy
The second time that you perform any of these actions, Simulink builds only the out-of-date files as long as the ****Rebuild** configuration parameter is set to If changes detected
(default) or If changes in known dependencies detected
. With fewer files to build, the actions complete faster.
Note
While you can avoid all referenced model rebuilds by setting the**Rebuild configuration parameter toNever
, using this setting can produce invalid simulation results.
Team members and continuous integration (CI) systems can generate Simulink cache files for models that you use. To reduce the time it takes when you build those models for the first time, you can copy the corresponding Simulink cache files to your local folder specified by the ****Simulation cache folder** preference. Simulink extracts any Simulink cache file contents that differ from the contents on disk. If Simulink generates or updates the build artifacts on disk, it locally updates the corresponding Simulink cache files.
You can identify a Simulink cache file by its .slxc
extension. Its file name matches the name of the corresponding model.
Inspect Simulink Cache File Contents
Simulink cache files can contain multiple types of build artifacts, including:
- Accelerator targets
- Rapid accelerator targets
- Model reference simulation targets
- Variable usage information
- C and C++ code generation targets (Simulink Coder™, Embedded Coder®)
- PLC code generation targets (Simulink PLC Coder™) (since R2025a)
- Model representations (Simulink Design Verifier™)
- Web views (Simulink Report Generator™)
Simulink cache files accumulate build artifacts for multiple platforms and Simulink releases.
To learn what a specific Simulink cache file contains, open the report by double-clicking the file.
Alternatively, to get the contents of the Simulink cache file in a MATLAB® table, use the slxcinfo function. For example, suppose you have a Simulink cache file for a model named CounterAlgorithm
.
slxcinfo("CounterAlgorithm.slxc")
ans =
3×5 table
Model Release Platform Target Compiler
__________________ ________ ________ ________________________________________ _____________________________
"CounterAlgorithm" "R2025a" "all" "Variable usage information" ""
"CounterAlgorithm" "R2025a" "win64" "Model reference simulation target" "MinGW64 Compiler (C) v8.1.0"
"CounterAlgorithm" "R2025a" "win64" "grt | Model reference | Model specific" "MinGW64 Compiler (C) v8.1.0"
You can reuse build artifacts that support the platform, compiler, and release that you use. Some build artifacts do not require a compiler. Suppose you use a Windows® machine, a MinGW® compiler, and the R2025a Simulink release. From the Simulink cache file for CounterAlgorithm
, you can reuse the simulation and code generation targets under R2025a : win64 and the variable usage information under R2025a : all platforms. A team member that uses a Linux® machine and R2025a can reuse only the variable usage information underR2025a : all platforms.
A Simulink cache file accumulates build artifacts for the release in which it was created and later releases. Suppose you create a Simulink cache file in R2025a. You would not be able to use that Simulink cache file in R2024b.
Use Simulink Cache Files
While most teams can benefit from using Simulink cache files, a development environment with these features is best suited for using Simulink cache files.
- A model hierarchy that contains many referenced models.
- A top model that simulates in accelerator or rapid accelerator mode, causing Simulink to generate a simulation target for the top model and all referenced models.
- A standardized platform, compiler, and Simulink release for the entire development team.
- Relative paths or consistent absolute paths, which you specify with the**Include directories** configuration parameter, for the entire development team.
- A source control system, such as Git™, that manages design files. See Git in MATLAB.
Note
Since Simulink cache files are derived files, you should not manage them under source control. Even if you share Simulink cache files by storing them in a source control system, you cannot diff or merge different versions of these files. - A CI system, such as Jenkins®, which periodically builds the latest version of the model hierarchy using a pool of parallel workers.
Note
To avoid unnecessary rebuilds for simulation and coder targets that use custom code, map the CI system directories to named volumes or symbolic links that are the same in team member sandboxes. For example, have the CI system and team members store custom code in a mapped directory such asB:\path\customcode
.
In this development environment, you interact with files in the source control system and build archive.
To reduce the amount of time that you spend updating simulation targets, follow these steps.
- Pull the latest version of all design files from the source control system.
- Copy the latest version of all Simulink cache files from the build archive and place them in your**Simulation cache folder.
- Open the top model and simulate it.
Simulink extracts the required build artifacts from the Simulink cache files. The simulation completes without rebuilding any models as long as the models have not changed since the most recent build completed by the CI system.
Note
To unpack the simulation and code generation targets from the Simulink cache files without updating, simulating, or generating code for the model hierarchy, use the slxcunpack function. - Change a model and simulate the model hierarchy again.
Simulink rebuilds the necessary models and updates the local copy of the corresponding Simulink cache file. - Commit the updated model to the source control system. You do not commit the Simulink cache file, which is a derived file.
Check for Simulink Cache Files in Projects
When you create a project from a top model, the project includes the corresponding Simulink cache files for the model and its referenced models.
To view Simulink cache file dependencies in a model hierarchy, in the MATLAB Toolstrip, on the Project tab, in theTools gallery, click Dependency Analyzer.
For more information, see Perform Impact Analysis with a Project.
See Also
Topics
- Choose Simulation Modes for Model Hierarchies
- Manage Simulation Targets for Referenced Models
- Simulink Cache Files for Incremental Code Generation (Simulink Coder)
- Reduce Update Time for Referenced Models by Using Parallel Builds
- Share Simulink Cache File for Faster Analysis (Simulink Design Verifier)
- Share Structured Text Code by Using Simulink Cache Files (Simulink PLC Coder)