Inter-Procedural Optimization

Inter-Procedural Optimization

I recently made some runtime experients with and without IPO. Some parts of my code are stored in static libs during compilation. By reading the manual I have seen that the problem with -ipo and static libs can be solved with the additional option -ipo_obj. This works fine, linking with IPO works, I see the IPO messages coming up in my terminal window during the linking stage and the program runs.

I want to know if during the second IPO stage (linking the code) the members of these static libs receive the same optimisation (inlining, etc) like every normal source code file of my program. There are no IPO messages for the library members in the window like this one for a normal file:

IPO: using IR for ../conmain/neuanreg.o

Is it possible, that the lib members do not receive the required optimization?

Regards,
Michael

publicaciones de 2 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

There is a long section in the user guide which tries to explain the subtleties of using IPO with libraries and with real object files.
IPO works best when you compile the whole program, or at least the most time consuming parts, without static libraries. The compile step produces intermediate language files, instead of true object files. The link step then calls the compiler for a second pass over these intermediate language files before performing the link. Because intermediate language files are available for all or most of the program, the compiler is able to do inlining and other optimizations across files over the whole program.
However, static libraries need true object files, not intermediate language files (you don't know how they may be linked). -ipo_obj allows you to create these. However, when these object files are linked, it is no longer possible to re-invoke the compiler to inline them into other parts of the program, or do other optimizations. Any optimization must be done BEFORE the object modules are placed in the library. It is possible to create object modules which have already been optimized using IPO. One way to do this is by using the option -ipo_c . However, if you wish to preserve the independence of the various subroutines and functions in the library, so that you can link or update them independently, then clearly you cannot use IPO, which makes them dependent on each other. You would need to choose which routines to merge into a single object file, and which you wanted to keep separate and independent.

In any case, if you do the second (usually, the link)step of IPO on a separate command line from the first compile step, it is essential to realise that this is reinvoking the compiler, and therefore you must respecify all the same command line optimization options (such as -ipo, -xW, -O3, -openmp etc) as on the original command line.
To recap for your original question, real object modules created with -ipo_obj and then placed in a library, will not be recompiled and will not be further optimized when that library is linked to your program, as explained above.

Martyn

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya