Topic
6 replies Latest Post - ‏2009-03-05T10:53:23Z by poulacou
poulacou
poulacou
10 Posts
ACCEPTED ANSWER

Pinned topic xlc : what différence between O2 and O0 optimization

‏2009-02-25T16:20:12Z |
I don't understand why my source C++ code don't compile quickly in O2 optimization.

in O2 : 8 hours.
in O0 : 10 seconds.

What are the intrinsic option of O2 more than O0 ?

It's a source code that provide from the free library mico.
it's about 5000 lines.

I check with some options to suppress the inlining...
Updated on 2009-03-05T10:53:23Z at 2009-03-05T10:53:23Z by poulacou
  • SystemAdmin
    SystemAdmin
    706 Posts
    ACCEPTED ANSWER

    Re: xlc : what différence between O2 and O0 optimization

    ‏2009-02-26T16:18:37Z  in response to poulacou
    8 hours at just -O2 ??!

    That's quite a bit.. we've got complex SPECcpu2006 workloads that don't take that long at -O4 and -O5.

    What Linux level are you running on?

    And which XLC version are you using?
    • poulacou
      poulacou
      10 Posts
      ACCEPTED ANSWER

      Re: xlc : what différence between O2 and O0 optimization

      ‏2009-02-27T08:59:03Z  in response to SystemAdmin
      I'm on a SLES 10 SP 1
      power 5
      xlc 9.0

      
      date ; xlC_r -I./include -I../idl -O2 -g -q64 -qminimaltoc -qpic -D_REENTRANT -D_GNU_SOURCE -c ir.cc -o ir.o -qmaxmem=-1 ; date
      

      
      Thu Feb 26 17:50:13 CET 2009 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<ObjVar<CORBA::AbstractInterfaceDef> *,std::vector<ObjVar<CORBA::AbstractInterfaceDef>,std::allocator<ObjVar<CORBA::AbstractInterfaceDef> > > > >(__normal_iterator<ObjVar<CORBA::AbstractInterfaceDef> *,std::vector<ObjVar<CORBA::AbstractInterfaceDef>,std::allocator<ObjVar<CORBA::AbstractInterfaceDef> > > >, __normal_iterator<ObjVar<CORBA::AbstractInterfaceDef> *,std::vector<ObjVar<CORBA::AbstractInterfaceDef>,std::allocator<ObjVar<CORBA::AbstractInterfaceDef> > > >, __false_type) could not be inlined into std::_Destroy<__gnu_cxx::__normal_iterator<ObjVar<CORBA::AbstractInterfaceDef> *,std::vector<ObjVar<CORBA::AbstractInterfaceDef>,std::allocator<ObjVar<CORBA::AbstractInterfaceDef> > > > >(__normal_iterator<ObjVar<CORBA::AbstractInterfaceDef> *,std::vector<ObjVar<CORBA::AbstractInterfaceDef>,std::allocator<ObjVar<CORBA::AbstractInterfaceDef> > > >, __normal_iterator<ObjVar<CORBA::AbstractInterfaceDef> *,std::vector<ObjVar<CORBA::AbstractInterfaceDef>,std::allocator<ObjVar<CORBA::AbstractInterfaceDef> > > >). 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > > >(__normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > >, __normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > >, __false_type) could not be inlined into std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > >::operator=(
      
      const vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > &). 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<ObjVar<CORBA::LocalInterfaceDef> *,std::vector<ObjVar<CORBA::LocalInterfaceDef>,std::allocator<ObjVar<CORBA::LocalInterfaceDef> > > > >(__normal_iterator<ObjVar<CORBA::LocalInterfaceDef> *,std::vector<ObjVar<CORBA::LocalInterfaceDef>,std::allocator<ObjVar<CORBA::LocalInterfaceDef> > > >, __normal_iterator<ObjVar<CORBA::LocalInterfaceDef> *,std::vector<ObjVar<CORBA::LocalInterfaceDef>,std::allocator<ObjVar<CORBA::LocalInterfaceDef> > > >, __false_type) could not be inlined into std::_Destroy<__gnu_cxx::__normal_iterator<ObjVar<CORBA::LocalInterfaceDef> *,std::vector<ObjVar<CORBA::LocalInterfaceDef>,std::allocator<ObjVar<CORBA::LocalInterfaceDef> > > > >(__normal_iterator<ObjVar<CORBA::LocalInterfaceDef> *,std::vector<ObjVar<CORBA::LocalInterfaceDef>,std::allocator<ObjVar<CORBA::LocalInterfaceDef> > > >, __normal_iterator<ObjVar<CORBA::LocalInterfaceDef> *,std::vector<ObjVar<CORBA::LocalInterfaceDef>,std::allocator<ObjVar<CORBA::LocalInterfaceDef> > > >). 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<CORBA::Container::Description *,std::vector<CORBA::Container::Description,std::allocator<CORBA::Container::Description> > > >(__normal_iterator<CORBA::Container::Description *,std::vector<CORBA::Container::Description,std::allocator<CORBA::Container::Description> > >, __normal_iterator<CORBA::Container::Description *,std::vector<CORBA::Container::Description,std::allocator<CORBA::Container::Description> > >, __false_type) could not be inlined into std::_Destroy<__gnu_cxx::__normal_iterator<CORBA::Container::Description *,std::vector<CORBA::Container::Description,std::allocator<CORBA::Container::Description> > > >(__normal_iterator<CORBA::Container::Description *,std::vector<CORBA::Container::Description,std::allocator<CORBA::Container::Description> > >, __normal_iterator<CORBA::Container::Description *,std::vector<CORBA::Container::Description,std::allocator<CORBA::Container::Description> > >). 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<ObjVar<CORBA::ValueDef> *,std::vector<ObjVar<CORBA::ValueDef>,std::allocator<ObjVar<CORBA::ValueDef> > > > >(__normal_iterator<ObjVar<CORBA::ValueDef> *,std::vector<ObjVar<CORBA::ValueDef>,std::allocator<ObjVar<CORBA::ValueDef> > > >, __normal_iterator<ObjVar<CORBA::ValueDef> *,std::vector<ObjVar<CORBA::ValueDef>,std::allocator<ObjVar<CORBA::ValueDef> > > >, __false_type) could not be inlined into std::_Destroy<__gnu_cxx::__normal_iterator<ObjVar<CORBA::ValueDef> *,std::vector<ObjVar<CORBA::ValueDef>,std::allocator<ObjVar<CORBA::ValueDef> > > > >(__normal_iterator<ObjVar<CORBA::ValueDef> *,std::vector<ObjVar<CORBA::ValueDef>,std::allocator<ObjVar<CORBA::ValueDef> > > >, __normal_iterator<ObjVar<CORBA::ValueDef> *,std::vector<ObjVar<CORBA::ValueDef>,std::allocator<ObjVar<CORBA::ValueDef> > > >). 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<CORBA::String_var *,std::vector<CORBA::String_var,std::allocator<CORBA::String_var> > > >(__normal_iterator<CORBA::String_var *,std::vector<CORBA::String_var,std::allocator<CORBA::String_var> > >, __normal_iterator<CORBA::String_var *,std::vector<CORBA::String_var,std::allocator<CORBA::String_var> > >, __false_type) could not be inlined into std::_Destroy<__gnu_cxx::__normal_iterator<CORBA::String_var *,std::vector<CORBA::String_var,std::allocator<CORBA::String_var> > > >(__normal_iterator<CORBA::String_var *,std::vector<CORBA::String_var,std::allocator<CORBA::String_var> > >, __normal_iterator<CORBA::String_var *,std::vector<CORBA::String_var,std::allocator<CORBA::String_var> > >). 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<ObjVar<CORBA::InterfaceDef> *,std::vector<ObjVar<CORBA::InterfaceDef>,std::allocator<ObjVar<CORBA::InterfaceDef> > > > >(__normal_iterator<ObjVar<CORBA::InterfaceDef> *,std::vector<ObjVar<CORBA::InterfaceDef>,std::allocator<ObjVar<CORBA::InterfaceDef> > > >, __normal_iterator<ObjVar<CORBA::InterfaceDef> *,std::vector<ObjVar<CORBA::InterfaceDef>,std::allocator<ObjVar<CORBA::InterfaceDef> > > >, __false_type) could not be inlined into std::_Destroy<__gnu_cxx::__normal_iterator<ObjVar<CORBA::InterfaceDef> *,std::vector<ObjVar<CORBA::InterfaceDef>,std::allocator<ObjVar<CORBA::InterfaceDef> > > > >(__normal_iterator<ObjVar<CORBA::InterfaceDef> *,std::vector<ObjVar<CORBA::InterfaceDef>,std::allocator<ObjVar<CORBA::InterfaceDef> > > >, __normal_iterator<ObjVar<CORBA::InterfaceDef> *,std::vector<ObjVar<CORBA::InterfaceDef>,std::allocator<ObjVar<CORBA::InterfaceDef> > > >). 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > > >(__normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > >, __normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > >, __false_type) could not be inlined into std::_Destroy<__gnu_cxx::__normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > > >(__normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > >, __normal_iterator<ObjVar<CORBA::ExceptionDef> *,std::vector<ObjVar<CORBA::ExceptionDef>,std::allocator<ObjVar<CORBA::ExceptionDef> > > >). 1500-029: (W) WARNING: subprogram std::__destroy_aux<__gnu_cxx::__normal_iterator<CORBA::Initializer *,std::vector<CORBA::Initializer,std::allocator<CORBA::Initializer> > > >(__normal_iterator<CORBA::Initializer *,std::vector<CORBA::Initializer,std::allocator<CORBA::Initializer> > >, __normal_iterator<CORBA::Initializer *,std::vector<CORBA::Initializer,std::allocator<CORBA::Initializer> > >, __false_type) could not be inlined into std::_Destroy<__gnu_cxx::__normal_iterator<CORBA::Initializer *,std::vector<CORBA::Initializer,std::allocator<CORBA::Initializer> > > >(__normal_iterator<CORBA::Initializer *,std::vector<CORBA::Initializer,std::allocator<CORBA::Initializer> > >, __normal_iterator<CORBA::Initializer *,std::vector<CORBA::Initializer,std::allocator<CORBA::Initializer> > >). 1501-201: (W) Maximum number of common component diagnostics, 10  has been exceeded. Fri Feb 27 00:56:05 CET 2009
      
      • SystemAdmin
        SystemAdmin
        706 Posts
        ACCEPTED ANSWER

        Re: xlc : what différence between O2 and O0 optimization

        ‏2009-03-03T19:11:07Z  in response to poulacou
        So I pushed this question over to the C/C++ forum

        http://www-949.ibm.com/software/rational/cafe/thread/1893?tstart=0

        In essence, the compiler team is going to need more details..

        The response from the other forum.. (where the compiler team hangs out..)

        Optimization will generally increase the compiler requirements in terms
        of system resources and compile time. Many of the algorithms used during
        optimization are exponential in nature, so very large translation units
        may introduce this type of issues.

        Something to note with C plus plus is that due to template instantiation or
        inlining the amount of code the compiler must optimize may not be proportional
        to the size of the source file being compiled.

        Generally, the strategy to enable optimization in this type of situations
        is to split the file into multiple smaller files. I realize that this may
        not be feasible on all situations, and I must admit that these numbers seem
        extreme, so if you want to pursue this further please get in contact with
        IBM service to determine exactly what may be happening on this specific situation.
  • SystemAdmin
    SystemAdmin
    706 Posts
    ACCEPTED ANSWER

    Re: xlc : what différence between O2 and O0 optimization

    ‏2009-03-03T20:44:02Z  in response to poulacou
    An increase from 10 seconds to 8 hours going from O0 to O2 is unacceptable. A more typical increase is 5x to 20x.

    If you'll either report this problem as a performance PMR or contact me directly at ianm@ca.ibm.com, and are willing to send your source code (reduced if necessary, obfuscated if necessary, and under our standard service non-disclosure agreement if necessary), we'll investigate. I expect we can make a dramatic difference once we understand what's happening.

    From the information you provided it looks like at O2 a lot of inlining of template functions is being done, so internally the code may be much bigger than what you provided to the compiler, but an increase from seconds to hours really needs to be fixed.

    If others have similar problems, please report them and help us help you.

    - Ian McIntosh
    xlC/xlc/xlf Compiler Optimization Team
  • SystemAdmin
    SystemAdmin
    706 Posts
    ACCEPTED ANSWER

    Re: xlc : what différence between O2 and O0 optimization

    ‏2009-03-04T15:58:49Z  in response to poulacou
    One thing to try in cases with slow compile is to remove the "-qmaxmem=-1".

    Why? Several optimizations (eg, MRA Partial Redundancy Elimination and CSXCM Common Subexpression Elimination and Code Motion) can use a lot of memory and time keeping track of expressions. Removing the "-qmaxmem=-1" will have two consequences. The externally visible one is that for some functions you will get a message that increasing the maxmem value may give better optimization. In most cases the improvement will be minor. The internal consequence is that in complicated functions the optimization (eg, MRA or CSXCM) will work on a single loop nest or single loop instead of the whole function, and will skip loops that are too large. Either way, those optimizations use time proportional to either Expressions x Blocks or Expressions x Blocks x Blocks time. Reducing the maxmem makes the optimization look at just part of the function at a time, making both E and B smaller, so you get either Loops x smallerExpressions x smallerBlocks or Loops x smallerExpressions x smallerBlocks x smallerBlocks time.

    Why are there two formulas for the time? The first applies to "reducible" loops and the second to "irreducible" ones. The important difference for C++ programs is that any iostream operations (eg, "cout << x") inside a loop (after inlining) will make it irreducible. From the inlining warning messages you listed I strongly suspect that that's what caused your problem.

    Knowing whether that's the case or not could help guide our changes in future compiler versions. We have made some improvements to this in xlC version 10. If you can't submit a PMR or send your program, please at least let us know exactly which version of the compiler you're using.
  • poulacou
    poulacou
    10 Posts
    ACCEPTED ANSWER

    Re: xlc : what différence between O2 and O0 optimization

    ‏2009-03-05T10:53:23Z  in response to poulacou
    • first : billburos, thank you for your help

    • Ian McIntosh : I'll send you a mail with this test case. There is not need a NDA, it's a open source.
    I could also open a PMR

    ttyl