Jump to content
  • Advertisement
Sign in to follow this  
Void

Profile Guide Optimization

This topic is 3685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I'm wondering if anyone gotten PGO to work. I'm facing the exact same issue as this guy http://forums.msdn.microsoft.com/de-DE/vcgeneral/thread/9c9dcc46-1e02-4520-84d7-d86cefae58f8/
Quote:
I'm trying to build our application using Profile-Guided Optimization in an automated fashion. Our build system already has support for gcc's PGO, so it wasn't a huge effort to make it work with VC++. I'm able to build everything with -GL and link with -LTCG: PGINSTRUMENT, and run the app to generate profiling data, and then run a second pass re-linking things with -LTCG: PGOPTIMIZE, and most of my DLLs link just fine. However, I get to the largest component in my system, which links multiple object files and static libraries together into one DLL, and the linker fails with the error "fatal error C1307: program has been edited since profile data was collected LINK : fatal error LNK1257: code generation failed". I looked at the build log, and the compiler is not run at all in the second build pass, so none of the objects or static libraries should have changed. Linking with -LTCG: PGUPDATE does work, but it gives me tons of warnings about functions that don't have data in the pgd file. These seem to all be functions from my static libraries. Is there a way to get the linker to give me more information about what it thinks has changed?

Share this post


Link to post
Share on other sites
Advertisement
So what exactly is your question?

We use PGO. It works exactly as it should.

I don't know what your tools are doing, but they're probably doing something wrong.

Does it work for you when you do the process manually?

Is it a clean build, meaning all the profiling files, intermediate files, and output files deleted before the tool runs the first time? Is the tool REALLY building and running using only the files generated from the first run, and REALLY storing everything in the expected place?

Share this post


Link to post
Share on other sites
Q: When I briefly tried PGO and it made my code run slower(not talking about the guided run, but after optimizations were applied), is this supposed to even be possible?

Share this post


Link to post
Share on other sites
Yes. All the files were deleted and cleanly rebuilt.

These are the manual steps I did by following this article

http://msdn.microsoft.com/en-us/library/aa289170.aspx

1. Rebuild with /LTCG:pginstrument. It generates the pgd as expected.
2. Run the exe. It generates the pgc file as expected
3. Compile with /LTCG:pgoptimize. Here it tries to link and fails.

1>------ Build started: Project: Client, Configuration: Release Win32 ------
1>Linking...
1>Merging XXXXX!1.pgc
1>Generating code
1>fatal error C1307: program has been edited since profile data was collected
1>LINK : fatal error LNK1257: code generation failed

The solution has 3 projects, 2 static libraries, and 1 .exe.

The compiler flags are

/O2 /GL /I "." /I ".." /I "../.." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Yu"XXXXPCH.h" /Fp"Release\XXXX.pch" /Fo"Release\\" /Fd"Release\vc80.pdb" /W3 /nologo /c /Zi /TP /FI "XXXXPCH.h" /errorReport:prompt
With -Zm300 for a large PCH

Linker is

/OUT:"..\bin\XXXX.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"Release\XXXXX.exe.intermediate.manifest" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "..\release\YYYYY.lib" "..\release\ZZZZZZ.lib"

I just changed the program names with XXXX,YYYY, and ZZZZ. There are about 10 other libries linked using #pragma comment. (Note, I changed the linker back to /LTCG here)

For the auto step, I did the same thing.

1. Build->Profile Guided Optimization->Instrument. Causes a rebuild
2. Build->Profile Guided Optimization->Run Instrunmented/Optimized Application
3. Build->Profile Guided Optimization->Optimize. Same linker error as above.

Perhaps I can ask how your project is setup differently or any steps I did wrongly.

It seems possible to get slower performance on how the profile is generated. I used the Update function and indeed got slower.

Share this post


Link to post
Share on other sites
Quote:
Original post by AndyPandyV2
Q: When I briefly tried PGO and it made my code run slower(not talking about the guided run, but after optimizations were applied), is this supposed to even be possible?


Yes, if the training input does not reflect typical input.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!