开发者

Will this technique reduce the MATLAB realtime workshop coder compilation time?

My workplace use MATLAB and sub-products Simulink, Realtime workshop (RTW), RTW Embedded Coder. We have a large simulink model that is compiled to C then to an object file for loading onto the embedded target. The whole compilation process takes ~3h which is quite long, it's mostly the compilation and linking of the C files produced from the simulink model.

Removing one particular subsystem reduces the compilation time down to 30mins, and since this subsystem doesn't change very often I plan to code this in C and then into MEX a开发者_运维技巧nd use the MEX file in the main model.

Will the technique reduce the compilation time? Is there another technique I should be looking into?

EDIT: I think the solution will be roughly: Generate C from the offending subsystem Compile this to some kind of object, library Include this in the model (but I'm not interested in simulation, it has inputs only) Include this in the build process, presumably linking after compiling the rest of the code


You could try to put the offending subsystem into another model and use Model Reference. You can convert a subsystem to a Model block using Simulink.SubSystem.convertToModelReference.

Model Reference has incremental code generation, so as long as the model doesn't change, Simulink won't regenerate or recompile the code for the referenced model.


I don't think what you suggest will reduce compilation time, since you seem to imply that the majority of the time is spent compiling the generated source files i.e. it is the C compiler that's slowing things down, not Simulink.

If you create a mex file (S-Function) from that subsystem your options are to either make an inlined S-Function or a non-inlined one. Unless the subsystem you're converting is fairly trivial (and I'm guessing it's not) you'll want to choose the former option, since the latter is severely limited. However, in both cases, your C compiler will still have compile source files. In the inlined case these will be source files spit out by the TLC you've written, and in the other it'll be the source files you compiled to created the S-Function itself.

A solution I can think of is to duplicate the functionality of the offending subsystem in C and use the embedded target's compiler to generate a static library. Also, create an inlined S-Function that mimics this subsystem in simulation. In the TLC file for this S-Function you would just ask Simulink to include the appropriate header file for the static library and then make function calls that reference the library. This saves the compiler from having to recompile the source during every model build.

You'll also need to figure out how to pass the linker a directive to link to the static library when building the model (assuming the code generation process automatically invokes the embedded compiler to build the code).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜