Is the entire Simulink model compiled into the _top_vm.bc and _top_vm.ll files when using JIT acceleration ?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to reach a conclusion on whether we can repeat a Simulink simulation exactly between two different workstations, even though the Simulink models, parameterisations, and configurations and initial states are set to be identical at the start of the Simulink simulations. Both workstations are using the exact same installation of MATLAB 64-bit (MATLAB Version: 9.11.0.2207237 (R2021b) Update 6). I can repeat the runs exactly, and get the same answers exactly, from day to day, if I stay on ONE workstation, but if I move to a different workstation, I then get answers which are different (but repeatable on that workstation).
The results do not seem to be affected by the choice of JIT acceleration (or not), nor the choice of allowing MATLAB to use >1 thread, compared to forcing it to 1 thread.
I think I am at a similar position to these two threads:
- https://uk.mathworks.com/matlabcentral/answers/1600765-different-results-on-different-computers-matlab-2021b-64-bit-windows-64-bit-both-intel-chips#answer_852250
- https://uk.mathworks.com/matlabcentral/answers/130493-how-come-i-get-different-output-answers-with-the-same-matlab-version-the-same-code-installed-on-two?s_tid=srchtitle
Except that I don't have any problem in MATLAB (the pre-simulation MATLAB script parts produce bitwise perfect matches between runs across all workstations). All my simulation differences seem to start only when Simulink begins its model execution (and the logged signal differences diverge right from timestep 0.0, between different workstations).
To try and understand, I have been comparing the MATLAB workspaces and all the cache, slxc etc. files I can find, saved down at the instant just BEFORE the simulation starts, and looking for bitwise perfect matches (or not).
One of the important pairs of files is in the _slprj\accel\YourModel directory, and these appear to be a pair of files that are "VMLL" files; some kind of intermediate between C code and assembler language.
- YourModel_top_vm.bc
- YourModel_top_vm.ll
The .bc file is binary and the .ll file is human readable.
I can see that both these files are bitwise IDENTICAL for all my runs, across the different workstations, even though the final SImulation results differ between workstations.
So my question is, how much of the total Simulink model is encapsulated in that VMLL code (.bc and .ll files) ? Is it the WHOLE model? In that case, what I have proved is that down to the level of VMLL, the simulations ARE identical, and ONLY the final assembly language step and/or CPU hardware is the root cause of all the differences. However, if the VMLL code (.bc and .ll files) only contains code that covers PART of the model, then I haven't really proved anything?
I am using fixed-step simulation with discete solver and no continuous states.
0 comentarios
Respuestas (1)
Amal Raj
el 19 de Feb. de 2024
Hey Andrew. The `_top_vm.bc` and `_top_vm.ll` files generated during JIT acceleration in Simulink contain the compiled intermediate representation of your model. If these files are identical across workstations but simulation results differ, the variation likely occurs during execution, influenced by hardware or system-level factors. Since you're using a fixed-step discrete solver, deterministic behavior is expected, but differences in floating-point arithmetic or CPU architecture can cause discrepancies. To achieve exact repeatability, ensure all model settings, data types, external inputs, and initial conditions are consistent. For more deterministic execution environments, consider using specialized tools like Simulink Real-Time or HDL Coder. If discrepancies persist, MathWorks support may provide deeper insights into the causes.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!