Gaudi Framework, version v23r9

Home   Generated: Thu Jul 18 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
PfmCodeAnalyser Class Reference

#include <PfmCodeAnalyser.h>

Collaboration diagram for PfmCodeAnalyser:
Collaboration graph
[legend]

Public Member Functions

void start ()
 
void stop ()
 
void stop_init ()
 

Static Public Member Functions

static PfmCodeAnalyserInstance (const char *event0="UNHALTED_CORE_CYCLES", unsigned int cmask_v0=0, bool inv_v0=false, const char *event1="", unsigned int cmask_v1=0, bool inv_v1=false, const char *event2="", unsigned int cmask_v2=0, bool inv_v2=false, const char *event3="", unsigned int cmask_v3=0, bool inv_v3=false)
 

Private Member Functions

 PfmCodeAnalyser (const char *event0, unsigned int cmask_v0, bool inv_v0, const char *event1, unsigned int cmask_v1, bool inv_v1, const char *event2, unsigned int cmask_v2, bool inv_v2, const char *event3, unsigned int cmask_v3, bool inv_v3)
 
 PfmCodeAnalyser (PfmCodeAnalyser const &)
 
PfmCodeAnalyseroperator= (PfmCodeAnalyser const &)
 
 ~PfmCodeAnalyser ()
 

Private Attributes

int used_counters_number
 
int nehalem
 
pfmlib_input_param_t inp
 
pfmlib_output_param_t outp
 
pfarg_ctx_t ctx
 
pfarg_pmd_t pd [NUM_PMDS]
 
pfarg_pmc_t pc [NUM_PMCS]
 
pfarg_load_t load_arg
 
int fd
 
char event_str [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVT_NAME_LEN]
 
bool inv [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
 
unsigned int cmask [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
 
pfmlib_core_input_param_t params
 
pfmlib_nhm_input_param_t nhm_params
 
int ret
 
unsigned i
 
unsigned long sum [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
 
unsigned count
 
unsigned overhead_avg [MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
 

Detailed Description

Definition at line 22 of file PfmCodeAnalyser.h.

Constructor & Destructor Documentation

PfmCodeAnalyser::PfmCodeAnalyser ( const char *  event0,
unsigned int  cmask_v0,
bool  inv_v0,
const char *  event1,
unsigned int  cmask_v1,
bool  inv_v1,
const char *  event2,
unsigned int  cmask_v2,
bool  inv_v2,
const char *  event3,
unsigned int  cmask_v3,
bool  inv_v3 
)
private

Definition at line 64 of file PfmCodeAnalyser.h.

{
int ax,bx,cx,dx;
cpuid(1,ax,bx,cx,dx);
int sse4_2_mask = 1 << 20;
nehalem = cx & sse4_2_mask;
strcpy(event_str[0], event0);
strcpy(event_str[1], event1);
strcpy(event_str[2], event2);
strcpy(event_str[3], event3);
cmask[0] = cmask_v0;
cmask[1] = cmask_v1;
cmask[2] = cmask_v2;
cmask[3] = cmask_v3;
inv[0] = inv_v0;
inv[1] = inv_v1;
inv[2] = inv_v2;
inv[3] = inv_v3;
{
if(strlen(event_str[i])>0) used_counters_number++;
}
for(int i=0; i<used_counters_number; i++)
{
sum[i] = 0;
}
count = 0;
{
printf("Cannot initialize perfmon!!\nExiting...\n");
exit(0);
}
while(count<3)
{
start();
}
for(int i=0; i<used_counters_number; i++)
{
sum[i] = 0;
}
count = 0;
while(count<10)
{
start();
}
for(int i=0; i<used_counters_number; i++)
{
sum[i] = 0;
}
count = 0;
}
PfmCodeAnalyser::PfmCodeAnalyser ( PfmCodeAnalyser const &  )
private
PfmCodeAnalyser::~PfmCodeAnalyser ( )
private

Definition at line 255 of file PfmCodeAnalyser.h.

{
for(int i=0; i<used_counters_number; i++)
{
printf("Event: %s\nTotal count:%lu\nNumber of counts:%u\nAverage count:%f\nOverhead removed:%u\n", event_str[i], sum[i], count, (double)sum[i]/count, overhead_avg[i]);
}
}

Member Function Documentation

PfmCodeAnalyser & PfmCodeAnalyser::Instance ( const char *  event0 = "UNHALTED_CORE_CYCLES",
unsigned int  cmask_v0 = 0,
bool  inv_v0 = false,
const char *  event1 = "",
unsigned int  cmask_v1 = 0,
bool  inv_v1 = false,
const char *  event2 = "",
unsigned int  cmask_v2 = 0,
bool  inv_v2 = false,
const char *  event3 = "",
unsigned int  cmask_v3 = 0,
bool  inv_v3 = false 
)
static

Definition at line 124 of file PfmCodeAnalyser.h.

{
static PfmCodeAnalyser theSingleton(event0, cmask_v0, inv_v0, event1, cmask_v1, inv_v1, event2, cmask_v2, inv_v2, event3, cmask_v3, inv_v3);
return theSingleton;
}
PfmCodeAnalyser& PfmCodeAnalyser::operator= ( PfmCodeAnalyser const &  )
private
void PfmCodeAnalyser::start ( )

Definition at line 135 of file PfmCodeAnalyser.h.

{
memset(&ctx,0, sizeof(ctx));
memset(&inp,0, sizeof(inp));
memset(&outp,0, sizeof(outp));
memset(pd, 0, sizeof(pd));
memset(pc, 0, sizeof(pc));
memset(&load_arg, 0, sizeof(load_arg));
memset(&params, 0, sizeof(params));
for(int i=0; i<used_counters_number; i++)
{
{
fprintf(stderr, "ERROR: cannot find event: %s\naborting...\n", event_str[i]);
exit(1);
}
}
for(int i=0; i<used_counters_number; i++)
{
if(inv[i])
{
}
if(cmask[i]>0)
{
(params.pfp_core_counters[i]).cnt_mask = cmask[i];
(nhm_params.pfp_nhm_counters[i]).cnt_mask = cmask[i];
}
}
if(nehalem)
{
}
else
{
}
{
fprintf(stderr, "ERROR: cannot dispatch events: %s\naborting...\n", pfm_strerror(ret));
exit(1);
}
for(unsigned int i=0; i<outp.pfp_pmc_count; i++)
{
}
for(unsigned int i=0; i<outp.pfp_pmd_count; i++)
{
pd[i].reg_value = 0;
}
fd = pfm_create_context(&ctx, NULL, 0, 0);
if(fd == -1)
{
fprintf(stderr, "ERROR: Context not created\naborting...\n");
exit(1);
}
{
fprintf(stderr, "ERROR: Could not write pmcs\naborting...\n");
exit(1);
}
{
fprintf(stderr, "ERROR: Could not write pmds\naborting...\n");
exit(1);
}
load_arg.load_pid = getpid();
{
fprintf(stderr, "ERROR: Could not load context\naborting...\n");
exit(1);
}
pfm_start(fd, NULL);
}
void PfmCodeAnalyser::stop ( )

Definition at line 221 of file PfmCodeAnalyser.h.

{
{
fprintf(stderr, "ERROR: Could not read pmds\naborting...\n");
exit(1);
}
for(int i=0; i<used_counters_number; i++)
{
}
count++;
close(fd);
}
void PfmCodeAnalyser::stop_init ( )

Definition at line 238 of file PfmCodeAnalyser.h.

{
{
fprintf(stderr, "ERROR: Could not read pmds\naborting...\n");
exit(1);
}
for(int i=0; i<used_counters_number; i++)
{
sum[i] += (pd[i].reg_value);
}
count++;
close(fd);
}

Member Data Documentation

unsigned int PfmCodeAnalyser::cmask[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
private

Definition at line 36 of file PfmCodeAnalyser.h.

unsigned PfmCodeAnalyser::count
private

Definition at line 42 of file PfmCodeAnalyser.h.

pfarg_ctx_t PfmCodeAnalyser::ctx
private

Definition at line 29 of file PfmCodeAnalyser.h.

char PfmCodeAnalyser::event_str[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS][MAX_EVT_NAME_LEN]
private

Definition at line 34 of file PfmCodeAnalyser.h.

int PfmCodeAnalyser::fd
private

Definition at line 33 of file PfmCodeAnalyser.h.

unsigned PfmCodeAnalyser::i
private

Definition at line 40 of file PfmCodeAnalyser.h.

pfmlib_input_param_t PfmCodeAnalyser::inp
private

Definition at line 27 of file PfmCodeAnalyser.h.

bool PfmCodeAnalyser::inv[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
private

Definition at line 35 of file PfmCodeAnalyser.h.

pfarg_load_t PfmCodeAnalyser::load_arg
private

Definition at line 32 of file PfmCodeAnalyser.h.

int PfmCodeAnalyser::nehalem
private

Definition at line 26 of file PfmCodeAnalyser.h.

pfmlib_nhm_input_param_t PfmCodeAnalyser::nhm_params
private

Definition at line 38 of file PfmCodeAnalyser.h.

pfmlib_output_param_t PfmCodeAnalyser::outp
private

Definition at line 28 of file PfmCodeAnalyser.h.

unsigned PfmCodeAnalyser::overhead_avg[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
private

Definition at line 43 of file PfmCodeAnalyser.h.

pfmlib_core_input_param_t PfmCodeAnalyser::params
private

Definition at line 37 of file PfmCodeAnalyser.h.

pfarg_pmc_t PfmCodeAnalyser::pc[NUM_PMCS]
private

Definition at line 31 of file PfmCodeAnalyser.h.

pfarg_pmd_t PfmCodeAnalyser::pd[NUM_PMDS]
private

Definition at line 30 of file PfmCodeAnalyser.h.

int PfmCodeAnalyser::ret
private

Definition at line 39 of file PfmCodeAnalyser.h.

unsigned long PfmCodeAnalyser::sum[MAX_NUMBER_OF_PROGRAMMABLE_COUNTERS]
private

Definition at line 41 of file PfmCodeAnalyser.h.

int PfmCodeAnalyser::used_counters_number
private

Definition at line 25 of file PfmCodeAnalyser.h.


The documentation for this class was generated from the following file:

Generated at Thu Jul 18 2013 12:18:11 for Gaudi Framework, version v23r9 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004