help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ and library optimisations


From: pemo
Subject: Re: g++ and library optimisations
Date: Sun, 13 May 2007 15:36:12 +0100

Paul Pluzhnikov wrote:
> "pemo" <usenetmeister@gmail.com> writes:

<snip>

> Besides, if it's the vector code that she thinks is slow, then she
> should look at he algorithms. For example:
>
>  std::vector<int> v;
> #if 0
>  // commenting this in will remove
>  // about 10 calls to realloc and memcpy in most std::vector
>  implementations. v.resize(1024);
> #endif
>  for (int i = 0; i < 1024; ++i) { v.push_back(i); }

Where is the STL source normally located - can find the vector.h but not the 
cpp?

<snip>

>> 3. Are there debug versions of the standard and STL libraries?
>
> For STL see answer 2.
> It's not clear what you mean by "standard libraries", probably libc.
> There are no Linux distributions that compile libc without
> optimization (in fact, last time I looked, libc couldn't be compiled
> without optimization at all).

<snip>

>> **and** is there an easy way to find what
>> libraries she's linking with - perhaps through asking the linker
>> [rather than following paths]?
>
> Sure: just add '-Wl,-verbose' and it will spit lines like this:

Her g++ [4.1.1 20070105 (Red Hat 4.1.1-51)] didn't understand either of 
those switches - not did gcc [should one use gcc rather than g++?]

>> 5. How can I help her profile her code [and make sense of the
>> results]
>
> Compile with '-pg', run the exe (on a smaller test case), then use
> 'gprof' to analyze the results.
>
> Note that there are some significant deficiencies in 'gprof'.
> Some other choices are listed here:
>
>  http://bitwagon.com/tsprof/tsprof.html#Features
>
> She might also have 'sysprof' installed, which has pretty nice and
> intuitive GUI, though interpreting results is sometimes tricky.
>
> Note that correct profiling is a bit of "black art", best performed
> by someone who can examine and understand what the compiler did
> (and why) at the assembly level, and understands what inlining,
> loop unrolling, etc. mean.

-pg seemed to work, but nothing seemed to be generated. running gprof, it 
couldn't find gmon sometimes, or a.out when the app was compiled via gcc.

> Lastly, if she is on Linux/x86 or Linux/x86_64, she might get some
> significant speedup with Intel 'icc' (or not).

No icc installed it seems.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]