perfctr questions
Mikael,
I'm trying to test your performance counters stuff, but I can't get it to do anything remotely useful! Probably just me.
I have a very hard time understanding things like:
* perfex -e 0x00039000/0x04000204@0x8000000C some_program
*
* Explanation: Program IQ_CCCR0 with required flags, ESCR select 4 * (== CRU_ESCR0), and Enable. Program CRU_ESCR0 with event 2 * (instr_retired), NBOGUSNTAG, CPL>0. Map this event to IQ_COUNTER0 * (0xC) with fast RDPMC enabled.
I'd love to author a small perfctr howto for people like me who just want to know if their code is thrashing the cache.
Do you have a pointer to tools that do this, or, how to calculate these 0x00039000 numbers for perfex? I can't find anything relevant. The best information I found is in the 'hardmeter' sources.
I tried one very basic thing, perfex -e 0x00410005 ./null which I hoped would measure unaligned memory accesses, but I can't get this counter raised from 0. null.c:
int main(int argc, char **argv)
{
char room[12];
int i, n;
for(n=0;n<1000000;++n) {
i=*((int*)(room+n%4));
}
printf("%d\n", i);
}I'm on a Pentium M, 2.6.7-mm5. Not even sure if an Pentium M will measure cache misses though.
Thanks
Signature · 2 lines
http://www.PowerDNS.com Open source, database driven DNS Software http://lartc.org Linux Advanced Routing & Traffic Control HOWTO
Quoted 2 lines · bert hubert
I'm trying to test your performance counters stuff, but I can't get it to do anything remotely useful! Probably just me.
No, it's just obscure.
You have three options for now. The first is to read the Intel or AMD CPU performance counter docs, which I don't recommend, because that kind of thing is never fun.
The second is to build a library called PAPI, which includes a command called papiex that provides a less intimidating performance counter interface. However, building PAPI with a not-quite-the-same version of perfctr is a bit daunting, so I don't recommend that, either.
Your third option is to build a version of perfex that I've hacked on, but not had time to finish up and submit to Mikael. I've attached it as a tarball. This includes a man page that makes the usage less scary, and it also accepts (gasp) textual arguments instead of hex strings. I've tested it on P6, Pentium M and AMD64 chips.
<b
Signature · 3 lines
Bryan O'Sullivan Software Tools PathScale, Inc.
Bryan,
Thanks for your quick reply!
Quoted 3 lines · Bryan O'Sullivan
called papiex that provides a less intimidating performance counter interface. However, building PAPI with a not-quite-the-same version of perfctr is a bit daunting, so I don't recommend that, either.
pepiex doesn't build for me, I was actually trying that already. It tries to take over pthreads, which I think breaks. PAPI does look nice though.
Quoted 5 lines
Your third option is to build a version of perfex that I've hacked on, but not had time to finish up and submit to Mikael. I've attached it as a tarball. This includes a man page that makes the usage less scary, and it also accepts (gasp) textual arguments instead of hex strings. I've tested it on P6, Pentium M and AMD64 chips.
Ah, cool - seems to have bitrotted somewhat, perfctr_*_event_* appear no longer to exist in perfctr 2.7.3.
In any case, your manpage inspired some command lines that at least appear to generate numbers, thanks.
But we're obviously not there yet.
Signature · 2 lines
http://www.PowerDNS.com Open source, database driven DNS Software http://lartc.org Linux Advanced Routing & Traffic Control HOWTO
Quoted 2 lines · Bryan O'Sullivan
Quoted 2 lines
I'm trying to test your performance counters stuff, but I can't get it to do anything remotely useful! Probably just me.
Ok, it is working. This is a plot of the number of L2 Address Strobes counted while scanning a buffer of x bytes: http://ds9a.nl/tmp/strobes.png
Quoted 1 line
From dmesg:
CPU: L1 I cache: 32K, L1 D cache: 32K
Note the sharp rise at 32768 bytes!
int main(int argc, char **argv)
{
char *memory;
int len=atoi(argv[1]);
memory=malloc(len);
int n, count;
for(count=0;count<10000;++count)
for(n=1;n<len;++n) {
memory[n]++;
}
}Script:
for a in $(seq 30000 10 35000) ; do perfex -o log -e 0x00410021 ./null $a ; echo -n "$a " ; tail -1 log | awk '{print $3}'; done > line
The '21' stands for P6_L2_ADS.
Cool stuff!
Regards,
bert
Signature · 2 lines
http://www.PowerDNS.com Open source, database driven DNS Software http://lartc.org Linux Advanced Routing & Traffic Control HOWTO