Hello~
I am trying to using the libpfm to augment a run-time monitoring
mechanism per thread into a multi-threaded application.
I have already scanned through the self_smpl_multi.c and coding this
mechanism accordingly.
However, the result from the pmd is always zero.
I have already tried some couple ways to fix this but no use.
Could anybody give me a hints here?
Here is my source code:
At the first time I would set up the parameters needed by the libpfm,
because this part is in a function which could be called several times
by each threads.
if(firsttime){
firsttime = false;
memset(&ov, 0, sizeof(struct over_args));
if(pfm_find_full_event("L2_RQSTS:SELF",&ov.inp.pfp_events[0])
!= PFMLIB_SUCCESS)
fprintf(stderr,"pfm_get_full_event error!!\n");
if(pfm_find_full_event("UNHALTED_CORE_CYCLES",&ov.inp.pfp_events[1])
!= PFMLIB_SUCCESS)
fprintf(stderr,"pfm_get_full_event error!!\n");
ov.inp.pfp_event_count = 2;
ov.inp.pfp_dfl_plm = PFM_PLM3;
ov.inp.pfp_flags = 0;
fd = pfm_create_context(&ov.ctx, NULL, NULL, 0);
if(fd < 0)
fprintf(stderr,"pfm_create_context failed\n");
ov.fd = fd;
ov.tid = (pid_t)syscall(SYS_gettid);
ov.self = pthread_self();
detect_unavail_pmcs(fd, &ov.inp.pfp_unavail_pmcs);
if(pfm_dispatch_events(&ov.inp, NULL, &ov.outp, NULL) != PFMLIB_SUCCESS)
fprintf(stderr,"pfm_dispatch_events failed\n");
for(i = 0;i < ov.outp.pfp_pmc_count; i++){
ov.pc[i].reg_num = ov.outp.pfp_pmcs[i].reg_num;
ov.pc[i].reg_value = ov.outp.pfp_pmcs[i].reg_value;
}
for(i = 0;i < ov.outp.pfp_pmd_count; i++)
ov.pd[i].reg_num = ov.outp.pfp_pmds[i].reg_num;
if(pfm_write_pmcs(fd, ov.pc, ov.outp.pfp_pmc_count))
fprintf(stderr,"pfm_write_pmc failed\n");
if(pfm_write_pmds(fd, ov.pd, ov.outp.pfp_pmd_count))
fprintf(stderr,"pfm_write_pmd failed\n");
ov.load_arg.load_pid = (pid_t)syscall(SYS_gettid);
if(pfm_load_context(fd, &ov.load_arg) != 0)
fprintf(stderr,"pfm_load_context\n");
}
After setting up the first time, I called the function I want to
monitor with pfm_self_start each time.
if(pfm_self_start(fd))
fprintf(stderr,"pfm_self_start error\n");
t_next = t->execute(); // This is the function I want to monitor.
if(pfm_self_stop(fd))
fprintf(stderr,"pfm_self_stop error\n");
fprintf(stderr,"This task's L2 references is %d\n", ov.pd[0].reg_num);
However, I got all zero in ov.pd[0].reg_num.
the ov and fd are the internal static variables of threads.
Any help would be grateful.
Thanks for reading this question.
Dennis
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
perfmon2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel