Will this technique reduce the compilation time of the MATLAB master-time encoder?

My use in the workplace is MATLAB and the routines Simulink, Realtime workshop (RTW), RTW Embedded Coder. We have a large simulink model that is compiled in C, then into an object file to load into the built-in target. The whole compilation process takes ~ 3 hours, which is quite a long time, mainly compiling and linking C files created using the simulink model.

Removing one specific subsystem reduces compilation time to 30 minutes, and since this subsystem does not change very often, I plan to encode it in C and then in MEX and use the MEX file in the main model.

Will the technique reduce compilation time? Is there any other method I should look at?

EDIT: I think the solution would be something like this: Generate C from the matching subsystem Compile this for some object, library Include this in the model (but I'm not interested in the simulation, it only has input) Include this in the build process, presumably linking after compiling the rest of the code

+6
source share
2 answers

You can try to place the client system in another model and use the link to the model. You can convert a subsystem to a model block using Simulink.SubSystem.convertToModelReference .

The link to the model contains incremental code generation, so until the model changes, Simulink will not regenerate or recompile the code for the specified model.

+3
source

I don’t think that what you offer will reduce compilation time, since you seem to imply that most of the time is spent collecting the generated source files, i.e. it’s a C compiler that slows down, not Simulink.

If you create a mex (S-Function) file from this subsystem, your options should either be inlined S-Function, or non-inlined one. If the subsystem you are converting is rather trivial (and I assume that it is not), you will want to choose the former option, since the latter is very limited. However, in both cases, your C compiler will still compile the source files. In the inlined case, these will be the source files written by the TLC that you wrote, and in the other, the source files that you compiled to create the S-function itself.

The solution I can think of is to duplicate the functionality of the falling subsystem in C and use the built-in target compiler to create a static library. In addition, create a built-in S-function that mimics this subsystem in a simulation. In the TLC file for this S function, you simply ask Simulink to include the corresponding header file for the static library, and then make function calls that reference the library. This eliminates the need for the compiler to recompile the source during each build of the model.

You also need to figure out how to pass the linker a directive to link to the static library when building the model (assuming that the code generation process automatically calls the built-in compiler to build the code).

0
source

Source: https://habr.com/ru/post/894731/


All Articles