Question

I need to write a C program (for a school assignment to determine cache size). I have used clock() as a means of getting timing info. But was told that might lead to inaccurate results.

So I was thinking of using other libraries, introduced in recent labs, perf or papi, to record performance. But the way we used them was via command line:

perf stat ./test 

I think its possible to use perf in the app? I am new to C, more used to higher level languages like Python/JS/Java etc. So I think I need to create a make file, include the library etc. Also what functions do I have?

I saw http://www.rzg.mpg.de/computing/hardware/BGP/perf.html

libperf.a
    perf library for MPI programs.
libperfhpm.a
    Use perf instrumentation to call hpmtoolkit.
libperfdummy.a
    Provides dummies for the perf instrumentation. You can link against this library to avoid the perf overhead in production runs.

Which do I use? Its not a MPI program. Then how do I use it actually? I am using C and gcc. This looks like compilation but ... whats mpixlf90

mpixlf90_r -o tperf tperf.f -L/usr/local/lib -lperf
Was it helpful?

Solution

There are lots of performance analysis tools (which provide information about running time, memory consumption) for C and C++ programs, some of which are,

  1. Valgrind

  2. Google Perf Tools

Hope this is what you are looking for!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top