Hi Nasser

I'm assuming pcp is a typo in your mail.

The hardware counters are exposed using libcpc. So please #include <libcpc.h> in your source code and have the "-lcpc" option when you compile.

Regarding the correct access to the counters.

man cpc_getcpuver(3CPC) says...
NOTES
     The  cpc_getcpuver(),   cpc_getcciname(),   cpc_getcpuref(),
     cpc_getusage(),  cpc_getnpic(),  and  cpc_walk_names() func-
     tions exist for binary compatibility only. Source containing
     these  functions  will  not  compile.  These  functions  are
     obsolete and might be removed in a future release.  Applica-
     tions   should   use   cpc_cciname(3CPC),  cpc_cpuref(3CPC),
     cpc_npic(3CPC), and cpc_npic(3CPC) instead.

and man cpc_bind_event(3CPC) says...
NOTES
     The  cpc_bind_event(),  cpc_take_sample(),  and   cpc_rele()
     functions  exist  for binary compatibility only. Source con-
     taining these functions will not  compile.  These  functions
     are  obsolete  and  might  be  removed  in a future release.
     Applications     should      use      cpc_bind_curlwp(3CPC),
     cpc_set_sample(3CPC), and cpc_unbind(3CPC) instead.

man cpc_bind_curlwp(3CPC) contains two examples on how to use the current cpc interfaces.

More detailed examples that use this interface are cputrack(1) and cpustat(1M). See http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/cpc/

/kuriakose

Nasser Ghazali wrote:
I am going to use some hardware counter functions using libpcp library. The machine I am using is a UltraSPARC T2000 (Niagara) machine, using Open Solaris 11.
The code is:

#include <pcplib.h>
      :
int cpc_cpuver;
cpc_event_t cpc_event;
char *cpc_arg="pic0=IC_miss,pic1=Instr_cnt";
     :
cpc_cpuver=cpc_getcpuver();
cpc_take_sample(&cpc_event);
   :



This error raise while i am going to compile my code:
       error: aggregate ‘cpc_event_t event’ has incomplete type and cannot be 
defined

When I add this part manually into my code :

typedef struct _cpc_event {
   int ce_cpuver;
   hrtime_t ce_hrt;
   uint64_t ce_tick;
  uint64_t ce_pic[2];
  uint64_t ce_pcr;
} cpc_event_t ; then I can compile and run it but still there is a problem. Most of the times cpc_getcpuver() return -1 and so other functions don't work anymore.
 I guess I am using wrong header file or something like that. Would you please 
help me to fix it?
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to