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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Gaurav Vinay
Gaurav Vinay el 28 de Nov. de 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 comentario
seongjoo thunder
seongjoo thunder el 29 de Nov. de 2022
Thank you. I also omitted the compiler option -O2 or -O3. I really appreciate your kindness

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Compiler SDK en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by