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

Profile Guided Guide For Dummies???

lawcoperamail_com
761 Views

Hello everyone:

Could some one please provide an idiots guide to profile guided optimization with Intel C 11 (.083)? So far it's done nothing more than frustrate the heck outta me. I have to build with -prof-gen first. Then when I run it's slower as it profiles my code. Then I wanna get rid of -prof-gen and replace it with -prof-use. When I do so, I'm getting linking errors. Here's a small selection of some of the last errors I got:

----------------------------------------------------------------------------------------------------------------

Linking console executable: bin/Release/TestICD
ipo: warning #11010: file format not recognized for ../Lib/Release/libICD.a, possible linker script
ipo: warning #11020: unresolved _Z9uPlotCharlhhmm
Referenced in /tmp/ipo_icpcCHfeI9.o
ipo: warning #11020: unresolved _Z7ICDModePcb
Referenced in /tmp/ipo_icpcCHfeI9.o
ipo: warning #11020: unresolved pICDScreen
Referenced in /tmp/ipo_icpcCHfeI9.o
ipo: warning #11020: unresolved ICDErrorString
Referenced in /tmp/ipo_icpcCHfeI9.o
ipo: remark #11001: performing single-file optimizations
ipo: remark #11005: generating object file /tmp/ipo_icpcCHfeI9.o
/tmp/ipo_icpcCHfeI9.o: In function `main':
/tmp/ipo_icpcCHfeI9.c:(.text+0x42): undefined reference to `__kmpc_begin'
/tmp/ipo_icpcCHfeI9.c:(.text+0x4c): undefined reference to `__kmpc_global_thread_num'
/tmp/ipo_icpcCHfeI9.c:(.text+0x69): undefined reference to `ICDMode(char*, bool)'
/tmp/ipo_icpcCHfeI9.c:(.text+0x176): undefined reference to `pICDScreen'
/tmp/ipo_icpcCHfeI9.c:(.text+0x18c): undefined reference to `pICDScreen'
/tmp/ipo_icpcCHfeI9.c:(.text+0x1d4): undefined reference to `uPlotChar(long, unsigned char, unsigned char, unsigned long, unsigned long)'
/tmp/ipo_icpcCHfeI9.c:(.text+0x372): undefined reference to `pICDScreen'
/tmp/ipo_icpcCHfeI9.c:(.text+0x39c): undefined reference to `__kmpc_end'
/tmp/ipo_icpcCHfeI9.c:(.text+0x402): undefined reference to `__kmpc_end'
/tmp/ipo_icpcCHfeI9.c:(.text+0x410): undefined reference to `ICDErrorString'
Process terminated with status 1 (0 minutes, 2 seconds)
0 errors, 0 warnings

----------------------------------------------------------------------------------------------------------------

Clearly I don't know what I'm doing! I have read the compiler doc's, but I'm too stupid to make any sence out of it.

I just know that it's not as simple as I thought. Why can't I just use-prof-use all the time? If I wanna feed the compiler fresh profile data, I'll generate some (add -prof-gen).

I'm using Ubuntu(8.10) working with Code Blocks(8.02). More details available upon request!

Thanks in advance

0 Kudos
13 Replies
TimP
Honored Contributor III
761 Views
It looks as if some of your source code failed to build (look for earlier errors).
Also, it looks as if you turned on -parallel or -openmp in part of your build, but not at link time.
Maybe you are trying too many steps at once. Get your build working without so many options (including no -prof-use), then add one at a time.
0 Kudos
Om_S_Intel
Employee
761 Views
Quoting - tim18
It looks as if some of your source code failed to build (look for earlier errors).
Also, it looks as if you turned on -parallel or -openmp in part of your build, but not at link time.
Maybe you are trying too many steps at once. Get your build working without so many options (including no -prof-use), then add one at a time.

There is "Profile-Guided Optimizations Overview" and " Profile-Guided Optimization (PGO) Quick Reference" topics in Intel C++ compiler documentatiom. You may use these as starting point.

As tim mentioned, you need to fix the compilation errors first.

0 Kudos
lawcoperamail_com
761 Views
Quoting - tim18
It looks as if some of your source code failed to build (look for earlier errors).
Also, it looks as if you turned on -parallel or -openmp in part of your build, but not at link time.
Maybe you are trying too many steps at once. Get your build working without so many options (including no -prof-use), then add one at a time.

There is "Profile-Guided Optimizations Overview" and " Profile-Guided Optimization (PGO) Quick Reference" topics in Intel C++ compiler documentatiom. You may use these as starting point.

As tim mentioned, you need to fix the compilation errors first.

Humm. I have already done as suggested and got it to build just fine. The way I see it is you build with -prof-gen first. That does work and I can see the drop files from the profiler after a run. Then I change it to just -prof-use and that's when I get in to troubles. Yes there was an error before something about a missing .dyn file or something. I saw some -prof-genx and -prof-dir and -prof-this-and-that in the docs, but I'm still not getting the picture. I wonder if I need to use a -prof-dir to put my PGO data in one place for the compiler? I am building several projects from different directories. Last time I tried -prof-dir the compiler threw me an error. The directory did exist, so I must have the syntax wrong. What does it look like?

"-openmp" is another story. When I add it in code:blocks, it's magically gone next time I look! Does openmp goto the linker? Or does openmp require something else set to the linker?

Thanks for the replies. Overall I'm in love with the compiler. My only beef so far is PGO. I'm new to the whole thing and I just need a little shove in the right direction i guess.

0 Kudos
Om_S_Intel
Employee
761 Views

Humm. I have already done as suggested and got it to build just fine. The way I see it is you build with -prof-gen first. That does work and I can see the drop files from the profiler after a run. Then I change it to just -prof-use and that's when I get in to troubles. Yes there was an error before something about a missing .dyn file or something. I saw some -prof-genx and -prof-dir and -prof-this-and-that in the docs, but I'm still not getting the picture. I wonder if I need to use a -prof-dir to put my PGO data in one place for the compiler? I am building several projects from different directories. Last time I tried -prof-dir the compiler threw me an error. The directory did exist, so I must have the syntax wrong. What does it look like?

"-openmp" is another story. When I add it in code:blocks, it's magically gone next time I look! Does openmp goto the linker? Or does openmp require something else set to the linker?

Thanks for the replies. Overall I'm in love with the compiler. My only beef so far is PGO. I'm new to the whole thing and I just need a little shove in the right direction i guess.


You may try the following steps:

1. Use compiler option prof-gen prof-dir profile-directory to build application. You will need to use complete path name of profile directory.
2. Run the application with test data. Now you should be able to see the .dyn files in profile directory.
3. Clean the object files.
4. Use prof-use prof-dir profile-directory to build application again. The compiler will use profile information available in .dyn files and will the the profile information and will use it.
5. You need to make progress step by step. Hence I would suggest building the application first for single thread execution. Later you can enable multithreading.
6. The compiler option prof_gen disables the optimization in the application. So when you use prof-use you may get undefined symbols during link. This happens due to inlining. If you get these errors then you will need to the errors.

Om
0 Kudos
lawcoperamail_com
761 Views

You may try the following steps:

1. Use compiler option prof-gen prof-dir profile-directory to build application. You will need to use complete path name of profile directory.
2. Run the application with test data. Now you should be able to see the .dyn files in profile directory.
3. Clean the object files.
4. Use prof-use prof-dir profile-directory to build application again. The compiler will use profile information available in .dyn files and will the the profile information and will use it.
5. You need to make progress step by step. Hence I would suggest building the application first for single thread execution. Later you can enable multithreading.
6. The compiler option prof_gen disables the optimization in the application. So when you use prof-use you may get undefined symbols during link. This happens due to inlining. If you get these errors then you will need to the errors.

Om

"get undefined symbols during link. This happens due to inlining. If you get these errors then you will need to the errors." <- Yes I'm getting linker errors all the time with it. I also get them if I use IPO or "inline at compilers discretion". I'm completely lost on this. If the compiler is inlining my routines I don't understand what I can do to help the linker. Can some one please help me out on this??? I always do a complete rebuild when I modify any compiler options on any of my projects. (Well recently anyway with the problems I've been having!)

1. Use compiler option prof-gen prof-dir profile-directory to build application. You will need to use complete path name of profile directory. Ok, I thought PGO was a release thing. Now I wonder if I should build my debugs with prof_gen on. I read somewhere that the profiler merges the data of each run. Then build a release with prof_use on. I'd probably wanna delete the profile data once in a while to get rid of old useless results as my app evolves. Does that sound about right?

BTW, I must apologize. The original errors that I posted were indeed errors from trying use OpenMP. I posted the wrong set of errors. I won't post my inlining related errors- I'm sure we've all seen enough of them!

Thanks again.

0 Kudos
TimP
Honored Contributor III
761 Views
PGO is a wasted effort in the debugging stages. As the profile data are taken with optimizations disabled, it doesn't matter when you change optimizations (unlike certain other compilers). prof_use attempts to use profile data across source changes, discarding stuff which has been made invalid by source line changes. It doesn't necessarily get that right, so you do want to discard stale data. Also, it's probably not good to have multiple profile data files from one run and just one each from others, if you are trying to optimize for various runs. To some extent, PGO optimizes branches for a particular data set (at the expense of others).
0 Kudos
lawcoperamail_com
761 Views
Quoting - tim18
PGO is a wasted effort in the debugging stages. As the profile data are taken with optimizations disabled, it doesn't matter when you change optimizations (unlike certain other compilers). prof_use attempts to use profile data across source changes, discarding stuff which has been made invalid by source line changes. It doesn't necessarily get that right, so you do want to discard stale data. Also, it's probably not good to have multiple profile data files from one run and just one each from others, if you are trying to optimize for various runs. To some extent, PGO optimizes branches for a particular data set (at the expense of others).

Cool. Thank you kindly for your help on that.

Can anyone say why I'm getting undefined functions by the linker? I was asking about it a couple posts ago.

0 Kudos
Om_S_Intel
Employee
761 Views

Cool. Thank you kindly for your help on that.

Can anyone say why I'm getting undefined functions by the linker? I was asking about it a couple posts ago.


Your application is refereing to these functions. These may be in a different library that you have not supplied to linker. You may need to include sutable library in the link command to get this resolved.

Om
0 Kudos
lawcoperamail_com
761 Views

Cool. Thank you kindly for your help on that.

Can anyone say why I'm getting undefined functions by the linker? I was asking about it a couple posts ago.


Your application is refereing to these functions. These may be in a different library that you have not supplied to linker. You may need to include sutable library in the link command to get this resolved.

Om

Nah, I wish It was that simple. All the undefined functions come from other static libraries that I'm building right along side my app. It all compiles fine until I try compiling with any options that involve inlining. Then they mysteriously go missing. (Even on a complete rebuild of everything.) This is frustrating to me because some of the routines that went missing are indeed ones that could really benefit from being inlined. I've never had problems with inlining on any other compiler before. I'd still like to get this resolved.

I appreciate all the help so far though. Thanks!

0 Kudos
TimP
Honored Contributor III
761 Views
I believe there is an option to control whether a separate copy of the function is retained during in-lining. Unfortunately, my memory fails me this early in the morning, and I don't easily find it in the docs. Basically, you must make the compiler aware of use of the function at sites other than where it is in-lined.
I don't see this as a PGO issue, except to the extent that PGO may promote in-lining, so people may not notice the question buried in a thread about PGO. prof-gen disables in-lining, so the problem wouldn't show up in that phase.
In the past, many compilers never removed a function during in-lining, so as to avoid this issue. If the issue remains difficult, you might submit a reproducer problem report on premier.intel.com, in case others have as much difficulty as I imagining your build setup and how it might pose difficulties.
0 Kudos
lawcoperamail_com
761 Views
Quoting - tim18
I believe there is an option to control whether a separate copy of the function is retained during in-lining. Unfortunately, my memory fails me this early in the morning, and I don't easily find it in the docs. Basically, you must make the compiler aware of use of the function at sites other than where it is in-lined.
I don't see this as a PGO issue, except to the extent that PGO may promote in-lining, so people may not notice the question buried in a thread about PGO. prof-gen disables in-lining, so the problem wouldn't show up in that phase.
In the past, many compilers never removed a function during in-lining, so as to avoid this issue. If the issue remains difficult, you might submit a reproducer problem report on premier.intel.com, in case others have as much difficulty as I imagining your build setup and how it might pose difficulties.

Thanks Tim, I really appreciate your help on this. Here's a few options I found. Wonder if one of these are what you were thinking about?:

-----------------------------------------------------------------------

-ipo_c Generate a multi-file object file (ipo_out.o)

-ipo_S Generate a multi-file assembly file (ipo_out.s)

Modify the behavior of IP:

-ip_no_inlining
Disable full and partial inlining (requires -ip or -ipo)

-ip_no_pinlining
Disable partial inlining (requires -ip or -ipo)

-ipo_obj Force generation of real object files (requires -ipo)
----------------------------------------------------------------------

I stumbled upon these and more options at:

http://lmee.univ-evry.fr/~cros/cluster/cluster_evry/intel/icc_man.html

There are some mentioned that I don't recall seeing in the intel docs.

All this is just starting to confuse the heck outta me! All I really want to do is see what my performance is like with "-fast"( "Enable -xP -O3 -ipo -no-prec-div -static" ), or -Ob1/Ob2 ('Inlining"). Any of those cause my linker errors. I'd be happy to"submit a reproducer problem report on premier.intel.com", in a few days if someone can't help me out here. I'm still hopeful that it's something simple. I've decided to abort mission, and get back to work on my project in the time being. I'm far from a release...I've been like a kid in a candy store with this compiler. I've been drooling over it for years. Now that I'm on linux I get to play for free, so I'm more than happy overall! It's just that this compiler is like a super hero to me, and it's letting me down a with this inlining thing. Even though I'm unable to build with some of the more exciting optimizations, it's still on par with GNU C/C++.

Good stuff, Thanks!

0 Kudos
TimP
Honored Contributor III
761 Views
As you are using -fast, -ipo_obj looks like a candidate. If you weren't expecting useful performance gains from ipo, I would say solve your problem by eliminating -ipo and disabling inlining if necessary. As I said, I fear your question is n't getting enough attention, being buried under the title you have chosen.
0 Kudos
lawcoperamail_com
761 Views
Quoting - tim18
As you are using -fast, -ipo_obj looks like a candidate. If you weren't expecting useful performance gains from ipo, I would say solve your problem by eliminating -ipo and disabling inlining if necessary. As I said, I fear your question is n't getting enough attention, being buried under the title you have chosen.

Haha, I have gotten off topic here haven't I? Ok, I'm just gonna forget about it. When I'm ready to build a release I'll be back to bug everyone in new discussion with a better title.

Thanks you to all. I'm on my way (for)now...!

0 Kudos
Reply