I am exploring utilizing compiler flags to improve the speed of compiled code in Dymola 2019 FD01. I started out with:
Advanced.Define.GlobalOptimizations=2;
which is equivalent to /Og and it improved model speed by 100%!
I was looking into how I can set some other flags for visual studio using the "Custom options" group a shown below but they don't seem to do anything. I even tried the "Visual Studio Custom" option along with the flags and the model speed is the same as the un-optimized code. Setting /Og in the compiler section doesn't seem to do the same thing as the GlobalOptimizations flag.
I would appreciate it if someone could shed some light on what is the correct way to set compiler flags in Dymola.
The default Advanced.Define.GlobalOptimizations=0;
turns off global optimizations - that's why you either need to set Advanced.Define.GlobalOptimizations=2;
or enable it with custom options and set Advanced.Define.GlobalOptimizations=1;
.
The downside of global optimizations is that the compilation time may increase substantially, which explains why it is off as default.
Link-time code generation (compiler option /GL
and linker option /LTCG
) does in practice provide no effect for dymosim, since the entire model code is in one module - and thus is already available for the optimizer.
(There are multiple modules for other things due to compiler limitations.)