benchmarking my code

P

Philipp Kraus

Hi,

I'm developing on some numeric algorithms some with MPI support on the
boost-lib.
I would like to benchmark some object methods. I can create a timer with
"boost::mpi::timer" for get time on all cluster nodes.

Is there any solution to get the time profile on seperated function or methods?
I need only the information whitch functions are the "slowest"

Thanks for help

Phil
 
V

Victor Bazarov

Philipp said:
I'm developing on some numeric algorithms some with MPI support on the
boost-lib.
I would like to benchmark some object methods. I can create a timer with
"boost::mpi::timer" for get time on all cluster nodes.

Is there any solution to get the time profile on seperated function or
methods?
I need only the information whitch functions are the "slowest"

Get a real tool - a profiler. They are OS-specific. Linux has gprof,
VTune. Windows has LTProf, AQtime, VTune, GlowCode, etc. Mac... I
don't know what Mac's got. In most of them you can profile your
functions selectively. Don't reinvent the wheel, no matter how much
appealing it might sound to you.

V
 
P

Philipp Kraus

Get a real tool - a profiler. They are OS-specific. Linux has gprof,
VTune. Windows has LTProf, AQtime, VTune, GlowCode, etc. Mac... I
don't know what
Mac's got. In most of them you can profile your functions selectively.
Don't reinvent the wheel, no matter how much appealing it might sound
to yo

Damn, I'm developing under OS X and than I port the code to a gui-less
Gentoo Linux cluster. Is there any kind of solution to check the
function with boost-only precompiler options?

Thx

Phil
 
V

Victor Bazarov

Philipp said:
Damn, I'm developing under OS X and than I port the code to a gui-less
Gentoo Linux cluster. Is there any kind of solution to check the
function with boost-only precompiler options?

I don't know, sorry. I know, however, that Boost has online forums
where you can probably ask for more assistance (wink-wink).

V
 
A

Anthony Delroy

Damn, I'm developing under OS X and than I port the code to a gui-less
Gentoo Linux cluster.

Ok, but why "Damn"?
Is there any kind of solution to check the
function with boost-only precompiler options?

I can't make any sense of that question at all. What do you mean by
"Check the function"? And "boost-only precompiler options"...
compilation includes a "preprocessor" step, but what is a
"precompiler" supposed to be in the normal C++ tool chain? And "boost-
only" - if you mean the boost C++ library - it's got nothing to do
with the use of profiling tools.

I suggest you start by seeing if your compiler includes support for
profiling. For example, with the GNU C++ compiler you can specify the
"-pg" switch, and when your executable completes it will write out a
"gmon.out" file that you can inspect with the gprof tool ala "gprof
<executable_name> gmon.out". If that's unavailable or proves
insufficient, then consider getting something more heavyweight.

Sometimes it's easier/better to simply sample elapsed time between
specific points in your program (e.g. delta of Solaris gethrtime()
gethrvtime() values). You can easily build little logarithmic
histograms by recording the most significant bit in the elapsed time
(for example, quickly obtained using the bsrl instruction on x86),
calculate totals and averages etc.. Standard deviations are more
problematic, as they require keeping all the samples which may require
dynamic allocation and have a larger impact on performance.

Cheers,
Tony
 
P

Philipp Kraus

I can't make any sense of that question at all. What do you mean by
"Check the function"? And "boost-only precompiler options"...
compilation includes a "preprocessor" step, but what is a
"precompiler" supposed to be in the normal C++ tool chain? And "boost-
only" - if you mean the boost C++ library - it's got nothing to do
with the use of profiling tools.

I had hoped that the boost has a function to measure how the execution time
of functions. Since I have a lot of matrices that are not sparse and
alter the functions of
almost every element, I would like to know where I can optimize.
I was thinking of spending it is a statement about the time, like:

#timestart
myfunction( matrix );
#writeout time

I suggest you start by seeing if your compiler includes support for
profiling. For example, with the GNU C++ compiler you can specify the
"-pg" switch, and when your executable completes it will write out a
"gmon.out" file that you can inspect with the gprof tool ala "gprof
<executable_name> gmon.out". If that's unavailable or proves
insufficient, then consider getting something more heavyweight.

I had tested the -pg switch but It seems that a bug in OS X Leopard, because
there is no out-file created.

Thanks

Phil
 
A

Anthony Delroy

I had hoped that the boost has a function to measure how the execution time
of functions. Since I have a lot of matrices that are not sparse and
alter the functions of
almost every element, I would like to know where I can optimize.
I was thinking of spending it is a statement about the time, like:

#timestart
myfunction( matrix );
#writeout time

I see. Check out http://www.boost.org/doc/libs/1_42_0/libs/timer/timer.htm
I had tested the -pg switch but It seems that a bug in OS X Leopard, because
there is no out-file created.

That's strange. I've never used OS X. My quick web search found
other people with the same problem, but nobody explaining a
solution....

Best of luck with it,
Tony
 
J

Jorgen Grahn

Damn, I'm developing under OS X and than I port the code to a gui-less
Gentoo Linux cluster.

Gui or not, Gentoo or not, cluster or not doesn't matter.

You are short on relevant details, but if you use g++ on Mac, you
surely use gprof just like on Linux or any other Unix. Or simply use the
time(1) command to see how much time a process uses from start to end,
if that suits you better.

If you use some other compiler, it surely comes with a profiler, too.

/Jorgen
 
M

Matteo

You are short on relevant details, but if you use g++ on Mac, you
surely use gprof just like on Linux or any other Unix.  Or simply use the
time(1) command to see how much time a process uses from start to end,
if that suits you better.

If you use some other compiler, it surely comes with a profiler, too.

/Jorgen
On the Mac, your options are to use the Shark sampling profiler, or
Saturn (more like gprof), both provided by Apple, but requires a
separate, free download (google "CHUD download"). I have experience
with Shark, and it's pretty nice. You don't need -pg (but -g is a good
idea!). It will display (approximate) time per line, cache misses,
system traces, etc.

Saturn is probably more what the OP is looking for, and more like
gprof (which I gather will not work on Intel macs). To use Saturn,
compile with -finstrument-functions and link with -lSaturn (DON'T use -
pg). It will more accurately report time spent in functions. I have
little experience with it (just playing with it now). It will slow
down your executables a fair bit, so if the OP is looking for actual
timing information (as opposed to looking for bottlenecks, etc.),
using either Shark, or instrumenting each function with a timer would
be the way to go.

-matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,295
Latest member
EmilG1510

Latest Threads

Top