Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

What is the purpose of "Using [Q]ipoN to Create Multiple Object Files"

mikeitexpert
New Contributor II
836 Views

I am trying to better understand IPO compiler options and the way they would impact program optimization. I just need some confirmation of my understanding as brought to your attention below: 

1) I know that IPO takes care variety of optimization techniques which I don't know much about ( including Address-taken analysis, Array dimension padding, Alias analysis, etc ...). Is there any documentation or perhaps a reference book briefly discussing each of these optimization techniques??? I just need to better understand them so as to better optimize my code and also my coding style. 

2) The IPO option Qipois meant to control the number of object files for link-time compilation. For small application it would be a single file. Though for large applications, the number of object files could be up to number of source files. 

I am just curious what is the use of this option? Just for the sake argument, let say we have large application with a lot of source files, would this option help speed up the compilation time? In other words, would this option help find a trade off between optimization and compilation time? Let me know if other ... 

Many thanks for any clue/elaboration ... 

mikeitexpert_0-1617500545551.png

 

0 Kudos
1 Solution
Viet_H_Intel
Moderator
747 Views

I don't think ipoN speeds up the compilation time, but rather speeds up link time.

Let's say that your application has 10 source files, you compile with -ipo and then at link time, compiler will be invoked a final time, loading those 10 mock objects into memory for optimizations. So far so good because application is small.

But if you have a large application, which contains hundred or thousand source files. And you compile with ipo then hundred or thousands mock objects will be created, then at link time, all mock objects will be loaded to memory for final optimization. This will be significantly slow, and if we don't have enough memory, swap memory usage happens and could result in out-of-memory error.

By specify -ipoN, the compiler will create N object files, which helps reduce the link-time and possible avoiding out-of-memory problem. The drawback is that you may not get the best performance since the compiler can't perform optimization across entire application.

 

Thanks,

 

View solution in original post

0 Kudos
6 Replies
ShivaniK_Intel
Moderator
793 Views

Hi,

 

Thanks for reaching out to us.

Interprocedural optimization (IPO) is a collection of compiler techniques used in computer programming to improve performance in programs containing many frequently used functions of small or medium length. IPO differs from other compiler optimization because it analyzes the entire program, other optimizations look at only a single function or even a single block of code.

IPO seeks to reduce or eliminate duplicate calculations, inefficient use of memory, and simplifying iterative sequences such as loops. If there is a call to another routine that occurs within a loop, IPO analysis may determine that it is best to inline that. Additionally, IPO may re-order the routines for better memory layout and locality.

 

IPO may also include typical compiler optimizations on a whole-program level, for example, dead code elimination (DCE), which removes code that is never executed. To accomplish this, the compiler tests for branches that are never taken and remove the code in that branch. IPO also tries to ensure better use of constants. Modern compilers offer IPO as an option at compile-time. The actual IPO process may occur at any step between the human-readable source code and producing a finished executable binary program.

 

Multi-file compilation uses the [Q]ipo option and results in one or more mock object files rather than normal object files.

Mock object files: As each source file is compiled with IPO, the compiler stores an intermediate representation (IR) of the source code in a mock object file. The mock object files contain the IR instead of the normal object code. Mock object files can be ten times or larger than the size of normal object files. During the IPO compilation phase, only the mock object files are visible.

 

You can refer to the below link for detailed information.

https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/optimization-and-programming-guide/interprocedural-optimization-ipo.html

 

Thanks & Regards

Shivani

 

0 Kudos
mikeitexpert
New Contributor II
781 Views

Thanks

I would appreciate if you can kindly elaborate further comments on the 2nd question. 

Regards

0 Kudos
ShivaniK_Intel
Moderator
756 Views

Hi,


We are working on it internally. We will get back to you soon.


Thanks & Regards

Shivani


0 Kudos
Viet_H_Intel
Moderator
748 Views

I don't think ipoN speeds up the compilation time, but rather speeds up link time.

Let's say that your application has 10 source files, you compile with -ipo and then at link time, compiler will be invoked a final time, loading those 10 mock objects into memory for optimizations. So far so good because application is small.

But if you have a large application, which contains hundred or thousand source files. And you compile with ipo then hundred or thousands mock objects will be created, then at link time, all mock objects will be loaded to memory for final optimization. This will be significantly slow, and if we don't have enough memory, swap memory usage happens and could result in out-of-memory error.

By specify -ipoN, the compiler will create N object files, which helps reduce the link-time and possible avoiding out-of-memory problem. The drawback is that you may not get the best performance since the compiler can't perform optimization across entire application.

 

Thanks,

 

0 Kudos
Viet_H_Intel
Moderator
721 Views

Hi,


Is is OK for us to close this thread?


Thanks,

Viet



0 Kudos
Viet_H_Intel
Moderator
703 Views

This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.

Thanks,


0 Kudos
Reply