Filter löschen
Filter löschen

c++ function in the mex (S) function is much faster than linux terminal

1 Ansicht (letzte 30 Tage)
Hi guys. I am testing my c++ code using software in the loop (SIL) test.
When i compare computation time of c++ code execution in the S-function and c++ code execution in the linux terminal,
Former is much faster than latter.
Both used the same compiler (g++) and c++ libraries ( eigen and CLP)
It is hard to figure out how it works and there is no info about this.

Akzeptierte Antwort

Gaurav Vinay
Gaurav Vinay am 28 Nov. 2022
The execution in linux terminal tends to be slower when compared to a S-function since S-functions are already in the binary form of the model, however in SIL the binary gets generated on execution.
Although the SIL simulation happens on the binary generated, the code is generated for the entire model blocks when run on a Linux terminal. This is generally the main cause for the additional execution time.
For a model with S-function, mex files are used, which is already in binary form. Hence there is no generation of blocks into binary again during execution which speeds up the compilation time.
For more information on SIL Simulations, go through the following link:-
Although there is a difference in execution time, the time gap will reduce on subsequent runs of the test in a Linux Terminal as the Binary generated will be cached.
  1 Kommentar
seongjoo thunder
seongjoo thunder am 29 Nov. 2022
Thank you. I also omitted the compiler option -O2 or -O3. I really appreciate your kindness

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Compiler SDK finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by