BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px;
}Dear All,
I am a newbie to use perfmon2 interface but have a considerable
experience in using Oprofile as a system-wide profiler. I am trying
to get the same measurement using perfmon just to analyze the two
tools performance with respect to my experiment.
I have installed perfmon2 library and pfmon on AMD 64 Opetron box
running 2.6.29 linux kernel. Using the samples, I am able to collect
the performance counter values for one event (my hardware can support
up to 4 events), I have two main queries:
1. It is strange that when I increase the number of events to
monitor, pfm_read_pmds given me error, whe I do 'perror' it gives me
message as "Invalid Argument."
2. I tried to enable system-wide option using the same code, it does
not even load the context, 'perror' returns same error message.
Please find the code below, I am using simple dense matrix
multiplication as the code to monitor at the instance.
----------------------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
#include
#define MAX 500
int main(){
int a[MAX],b[MAX],c[MAX];
int i,j,k=0;
char name[50];
pfarg_ctx_t ctx;
int fd,tid;
pfarg_load_t load;
pfarg_pmd_t pd[2];
pfarg_pmc_t pc[2];
pfmlib_input_param_t inp;
pfmlib_output_param_t outp;
if (pfm_initialize() != PFMLIB_SUCCESS){
printf("nCan't initialize libraryn");
exit(1);
}
memset(pd, 0, sizeof(pd));
memset(pc, 0,sizeof(pc));
memset(&ctx, 0, sizeof(ctx));
memset(&load, 0, sizeof(load));
memset(&inp, 0, sizeof(inp));
memset(&outp, 0, sizeof(outp));
if(pfm_find_event("cpu_clk_unhalted",
&inp.pfp_events[0].event) == PFMLIB_ERR_NOTFOUND)
printf("ncpu_clk_unhalted not foundn");
//if(pfm_find_event("data_cache_accesses",
&inp.pfp_events[1].event) == PFMLIB_ERR_NOTFOUND)
// printf("ndata_cache_accesses not foundn");
inp.pfp_flags |= PFMLIB_PFP_SYSTEMWIDE;
inp.pfp_dfl_plm |= PFM_PLM3 | PFM_PLM0;
inp.pfp_event_count = 1; // 2
if(pfm_dispatch_events(&inp, NULL, &outp, NULL) !=
PFMLIB_SUCCESS) {
perror("nCan't perform dispatchn");
exit(1);
}
for(i=0;i < outp.pfp_pmc_count; i++) {
pc[i].reg_num = outp.pfp_pmcs[i].reg_num;
pc[i].reg_value = outp.pfp_pmcs[i].reg_value;
}
for(i=0; i < outp.pfp_pmd_count; i++) {
pd[i].reg_num = outp.pfp_pmds[i].reg_num;
pd[i].reg_value = 0;
}
ctx.ctx_flags |= PFM_FL_SYSTEM_WIDE;
fd = pfm_create_context(&ctx, NULL, 0, 0);
if(fd == -1) {
perror("nCan't create pfm contextn");
exit(1);
}
if(pfm_write_pmcs(fd, pc, outp.pfp_pmc_count) == -1){
perror("nCan't perform write to pmcsn");
exit(1);
}
if(pfm_write_pmds(fd, pd, 1) == -1) {
perror("nCan't perform write to pmdsn");
exit(1);
}
load.load_pid = getpid();
if(pfm_load_context(fd, &load) == -1) {
perror("nCan't load contextn");
exit(1);
}
pfm_start(fd, NULL);
for(i=0; i < MAX; i++) {
a[i] = b[i] = 1;
c[i] = 0;
}
for(k = 0; k < MAX; k++) {
for(i=0; i < MAX; i++) {
for(j=0; j < MAX; j++)
c[i] += a[i] * b[j];
}
}
pfm_stop(fd);
if(pfm_read_pmds(fd, pd, inp.pfp_event_count) == -1){
perror("nCan't read pmdsn");
exit(1);
}
for(i = 0; i < inp.pfp_event_count; i++){
bzero(name,sizeof(name));
pfm_find_full_event(name,&inp.pfp_events[i]);
printf("n[ %s ] - %llu", name, pd[i].reg_value);
}
close(fd);
return 0;
}
--------------------------------------------------------------------------------------
Your help in resolving this problem is highly appreciable!
Thanks & Regards!
Ata E Husain Bohra
University at Buffalo,
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel