Support for passing hints to optimizer

Support for passing hints to optimizer

ereisch's picture

Is it possible (or are plans in the works) to support passing hints to the optimizer, in a manner similar to gcc's "__builtin_expect()" function?

 

Also, on a somewhat related note, is there a reliable manner in which to get the compiler to print out optimization feedback during the compilation stage?  When I upgraded to 2011 a few years ago, I noticed it would sometimes print out this information during the compile, but there didn't appear to be (or I couldn't find) a direct compiler flag to get this information out.  The reason for this is we would like to get more detail on what exactly the compiler is modifying/unrolling/reordering, such that we can alter the code where appropriate so we can pick up some of these gains in lower levels of optimization, or perhaps find good candidates for OpenMP directives.

 

Thanks

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Steve Lionel (Intel)'s picture

We do actually have a lot of directives for giving hints to the optimizer, but for this one, as is suggested for gcc, we'd recommend using profile-guided optimization. We don't have an explicit directive like __builtin_expect.

There are many levels of optimization report available. See -opt-report and -vec-report.

Steve
Tim Prince's picture

 __builtin_expect offers only near-0 and near-100% probability and wouldn't necessarily offer much over placing the favored branch in the if and unfavored in the else of if..then..else..endif.  Traditionally, the platform would favor forward conditional jump not-taken and backward jump taken, in the absence of profile guided or static profiling information.  Static profiling information may be placed in the asm file, if you choose to generate it.  Until recently, vectorization directives like VECTOR ALWAYS and omp simd would in effect request high priority for either branch when possible.

Steve Lionel (Intel)'s picture

I'll also comment that the hardware branch predictors have gotten very good...

Steve

Login to leave a comment.