|
From: Matthew W. <mw...@al...> - 2013-02-21 04:48:29
|
Hi Folks,
I have been working on a new valgrind tool and want to get feedback on
approach and chances for getting this rolled into the distribution. If
this has potential, I'd like to get feedback on ideas for user options, etc.
I'm calling the tool "xprof" (prefix "xp"). It is an execution profiler.
The context for tool use is the following:
The user develops code on his desktop computer, but the downstream
target is an embedded real-time application. He develops the code
in a (physics based) simulation of the target environment. For
example, he develops a a fuel-injection algorithm for an automobile
engine. Early in the project the embedded real-time group wants an
estimate of the CPU utilization of his algorithm. The algorithm is
difficult to run without the context of the enviroment simulation,
so he has trouble answering this question. Typically, he can only
make crude estimates. Enter valgrind/xprof. This tool would allow
the user to quickly provide a better CPU loading estimate within
his simulation environment by providing cycle count estimates of
specified regions of code. We are not after exact clock counts, but
something better than crude flop estimates.
Here is the demo program and output from running the xprof tool:
/* demo1.c - demo program using xprof */
#include <stdio.h>
#include "../vg_xprof.h"
double
foo(double x, double y)
{
double t;
t = (3.0 + x)/(9.4 + y);
return t;
}
volatile unsigned long counter1;
int
main()
{
int i, difs[10];
unsigned long prev, vals[10];
double z;
counter1 = 0;
VG_XPROF_SET_COUNTER(&counter1);
prev = 0;
for (i = 0; i < 10; i++) {
z = foo(1.2, 3.6);
vals[i] = counter1;
difs[i] = counter1 - prev;
prev = counter1;
}
for (i = 0; i < 10; i++) {
printf("count: %lu\t", vals[i]);
printf("delta: %d\n", difs[i]);
}
}
mwette$ valgrind -tool xprof demo1
count: 88 delta: 88
count: 197 delta: 109
count: 306 delta: 109
count: 415 delta: 109
count: 524 delta: 109
count: 633 delta: 109
count: 742 delta: 109
count: 851 delta: 109
count: 960 delta: 109
count: 1069 delta: 109
|