All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pfm_gen_analysis.cpp File Reference
#include <ctype.h>
#include <cxxabi.h>
#include <fcntl.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <zlib.h>
#include <algorithm>
#include <list>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <dirent.h>
#include <errno.h>
Include dependency graph for pfm_gen_analysis.cpp:

Go to the source code of this file.

Classes

class  PipeReader
 
class  FileInfo
 
struct  FileInfo::CacheItem
 
struct  FileInfo::CacheItemComparator
 
class  S_module
 

Macros

#define CORE_L2_MISS_CYCLES   200
 
#define CORE_L2_HIT_CYCLES   14.5
 
#define CORE_L1_DTLB_MISS_CYCLES   10
 
#define CORE_LCP_STALL_CYCLES   6
 
#define CORE_UNKNOWN_ADDR_STORE_CYCLES   5
 
#define CORE_OVERLAPPING_CYCLES   6
 
#define CORE_SPAN_ACROSS_CACHE_LINE_CYCLES   20
 
#define I7_L1_DTLB_WALK_COMPLETED_CYCLES   35
 
#define I7_L1_ITLB_WALK_COMPLETED_CYCLES   35
 
#define I7_L2_HIT_CYCLES   6
 
#define I7_L3_UNSHARED_HIT_CYCLES   35
 
#define I7_OTHER_CORE_L2_HIT_CYCLES   60
 
#define I7_OTHER_CORE_L2_HITM_CYCLES   75
 
#define I7_L3_MISS_LOCAL_DRAM_HIT_CYCLES   225
 
#define I7_L3_MISS_REMOTE_DRAM_HIT_CYCLES   360
 
#define I7_L3_MISS_REMOTE_CACHE_HIT_CYCLES   180
 
#define I7_IFETCH_L3_MISS_LOCAL_DRAM_HIT   200
 
#define I7_IFETCH_L3_MISS_REMOTE_DRAM_HIT   350
 
#define I7_IFETCH_L2_MISS_L3_HIT_NO_SNOOP   35
 
#define I7_IFETCH_L2_MISS_L3_HIT_SNOOP   60
 
#define I7_IFETCH_L2_MISS_L3_HITM   75
 
#define I7_IFETCH_L3_MISS_REMOTE_CACHE_FWD   180
 
#define MAX_MODULES   1000
 
#define EXPECTED_CPI   0.25
 
#define MAX_FILENAME_LENGTH   1024
 
#define MAX_SAMPLE_INDEX_LENGTH   10000
 
#define MAX_SYM_LENGTH   15000
 
#define MAX_SYM_MOD_LENGTH   20000
 
#define MAX_LIB_LENGTH   5000
 
#define MAX_LIB_MOD_LENGTH   7000
 
#define MAX_SIMPLE_SYM_LENGTH   300
 
#define MAX_SIMPLE_SYM_MOD_LENGTH   500
 
#define MAX_SIMPLE_LIB_LENGTH   300
 
#define MAX_SIMPLE_LIB_MOD_LENGTH   500
 
#define MAX_LINE_LENGTH   20000
 
#define MAX_EVENT_NAME_LENGTH   150
 
#define MAX_MODULE_NAME_LENGTH   250
 
#define MAX_VALUE_STRING_LENGTH   250
 
#define MAX_ARCH_NAME_LENGTH   20
 
#define MAX_CMASK_STR_LENGTH   5
 
#define MAX_INV_STR_LENGTH   5
 
#define MAX_SP_STR_LENGTH   50
 
#define PIPE_BUFFER_LENGTH   1000
 

Functions

bool skipWhitespaces (const char *srcbuffer, const char **destbuffer)
 
bool skipString (const char *strptr, const char *srcbuffer, const char **dstbuffer)
 
void init_core_caa_events ()
 
void init_nhm_caa_events ()
 
bool check_for_core_caa_events ()
 
bool check_for_nhm_caa_events ()
 
void init_core_caa_events_displ ()
 
void calc_core_deriv_values (double totalCycles)
 
void init_nhm_caa_events_displ ()
 
void calc_nhm_deriv_values (double totalCycles)
 
void html_special_chars (const char *s, char *s_mod)
 
const char * func_name (const char *demangled_symbol)
 
void put_S_module (S_module *cur_module, const char *dir)
 
int read_S_file (const char *dir, const char *filename)
 
int read_S_events (const char *dir, const char *filename)
 
int finalize_S_html_pages (const char *dir)
 
int read_C_file (const char *dir, const char *filename)
 
void put_C_header (FILE *fp, std::vector< std::string > &columns)
 
void put_C_modules (FILE *fp, std::vector< std::string > &columns)
 
void put_C_footer (FILE *fp)
 
void put_C_header_csv (FILE *fp, std::vector< std::string > &columns)
 
void put_C_modules_csv (FILE *fp, std::vector< std::string > &columns)
 
double normalize (std::string field, double value, double normalizeTo)
 
void calc_post_deriv_values ()
 
double getTotalCycles ()
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

#define CORE_L1_DTLB_MISS_CYCLES   10

Definition at line 40 of file pfm_gen_analysis.cpp.

#define CORE_L2_HIT_CYCLES   14.5

Definition at line 39 of file pfm_gen_analysis.cpp.

#define CORE_L2_MISS_CYCLES   200

Definition at line 38 of file pfm_gen_analysis.cpp.

#define CORE_LCP_STALL_CYCLES   6

Definition at line 41 of file pfm_gen_analysis.cpp.

#define CORE_OVERLAPPING_CYCLES   6

Definition at line 43 of file pfm_gen_analysis.cpp.

#define CORE_SPAN_ACROSS_CACHE_LINE_CYCLES   20

Definition at line 44 of file pfm_gen_analysis.cpp.

#define CORE_UNKNOWN_ADDR_STORE_CYCLES   5

Definition at line 42 of file pfm_gen_analysis.cpp.

#define EXPECTED_CPI   0.25

Definition at line 65 of file pfm_gen_analysis.cpp.

#define I7_IFETCH_L2_MISS_L3_HIT_NO_SNOOP   35

Definition at line 58 of file pfm_gen_analysis.cpp.

#define I7_IFETCH_L2_MISS_L3_HIT_SNOOP   60

Definition at line 59 of file pfm_gen_analysis.cpp.

#define I7_IFETCH_L2_MISS_L3_HITM   75

Definition at line 60 of file pfm_gen_analysis.cpp.

#define I7_IFETCH_L3_MISS_LOCAL_DRAM_HIT   200

Definition at line 56 of file pfm_gen_analysis.cpp.

#define I7_IFETCH_L3_MISS_REMOTE_CACHE_FWD   180

Definition at line 61 of file pfm_gen_analysis.cpp.

#define I7_IFETCH_L3_MISS_REMOTE_DRAM_HIT   350

Definition at line 57 of file pfm_gen_analysis.cpp.

#define I7_L1_DTLB_WALK_COMPLETED_CYCLES   35

Definition at line 47 of file pfm_gen_analysis.cpp.

#define I7_L1_ITLB_WALK_COMPLETED_CYCLES   35

Definition at line 48 of file pfm_gen_analysis.cpp.

#define I7_L2_HIT_CYCLES   6

Definition at line 49 of file pfm_gen_analysis.cpp.

#define I7_L3_MISS_LOCAL_DRAM_HIT_CYCLES   225

Definition at line 53 of file pfm_gen_analysis.cpp.

#define I7_L3_MISS_REMOTE_CACHE_HIT_CYCLES   180

Definition at line 55 of file pfm_gen_analysis.cpp.

#define I7_L3_MISS_REMOTE_DRAM_HIT_CYCLES   360

Definition at line 54 of file pfm_gen_analysis.cpp.

#define I7_L3_UNSHARED_HIT_CYCLES   35

Definition at line 50 of file pfm_gen_analysis.cpp.

#define I7_OTHER_CORE_L2_HIT_CYCLES   60

Definition at line 51 of file pfm_gen_analysis.cpp.

#define I7_OTHER_CORE_L2_HITM_CYCLES   75

Definition at line 52 of file pfm_gen_analysis.cpp.

#define MAX_ARCH_NAME_LENGTH   20

Definition at line 81 of file pfm_gen_analysis.cpp.

#define MAX_CMASK_STR_LENGTH   5

Definition at line 82 of file pfm_gen_analysis.cpp.

#define MAX_EVENT_NAME_LENGTH   150

Definition at line 78 of file pfm_gen_analysis.cpp.

#define MAX_FILENAME_LENGTH   1024

Definition at line 67 of file pfm_gen_analysis.cpp.

#define MAX_INV_STR_LENGTH   5

Definition at line 83 of file pfm_gen_analysis.cpp.

#define MAX_LIB_LENGTH   5000

Definition at line 71 of file pfm_gen_analysis.cpp.

#define MAX_LIB_MOD_LENGTH   7000

Definition at line 72 of file pfm_gen_analysis.cpp.

#define MAX_LINE_LENGTH   20000

Definition at line 77 of file pfm_gen_analysis.cpp.

#define MAX_MODULE_NAME_LENGTH   250

Definition at line 79 of file pfm_gen_analysis.cpp.

#define MAX_MODULES   1000

Definition at line 63 of file pfm_gen_analysis.cpp.

#define MAX_SAMPLE_INDEX_LENGTH   10000

Definition at line 68 of file pfm_gen_analysis.cpp.

#define MAX_SIMPLE_LIB_LENGTH   300

Definition at line 75 of file pfm_gen_analysis.cpp.

#define MAX_SIMPLE_LIB_MOD_LENGTH   500

Definition at line 76 of file pfm_gen_analysis.cpp.

#define MAX_SIMPLE_SYM_LENGTH   300

Definition at line 73 of file pfm_gen_analysis.cpp.

#define MAX_SIMPLE_SYM_MOD_LENGTH   500

Definition at line 74 of file pfm_gen_analysis.cpp.

#define MAX_SP_STR_LENGTH   50

Definition at line 84 of file pfm_gen_analysis.cpp.

#define MAX_SYM_LENGTH   15000

Definition at line 69 of file pfm_gen_analysis.cpp.

#define MAX_SYM_MOD_LENGTH   20000

Definition at line 70 of file pfm_gen_analysis.cpp.

#define MAX_VALUE_STRING_LENGTH   250

Definition at line 80 of file pfm_gen_analysis.cpp.

#define PIPE_BUFFER_LENGTH   1000

Definition at line 86 of file pfm_gen_analysis.cpp.

Function Documentation

void calc_core_deriv_values ( double  totalCycles)

Definition at line 469 of file pfm_gen_analysis.cpp.

470 {
471  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
472  {
473  (it->second)["Total Cycles"] = (it->second)["UNHALTED_CORE_CYCLES"];
474  (it->second)["Stalled Cycles"] = (it->second)["RS_UOPS_DISPATCHED CMASK=1 INV=1"];
475  (it->second)["L2 Miss Impact"] = (it->second)["MEM_LOAD_RETIRED:L2_LINE_MISS"] * CORE_L2_MISS_CYCLES;
476  (it->second)["L2 Hit Impact"] = ((it->second)["MEM_LOAD_RETIRED:L1D_LINE_MISS"] - (it->second)["MEM_LOAD_RETIRED:L2_LINE_MISS"]) * CORE_L2_HIT_CYCLES;
477  (it->second)["L1 DTLB Miss Impact"] = (it->second)["MEM_LOAD_RETIRED:DTLB_MISS"] * CORE_L1_DTLB_MISS_CYCLES;
478  (it->second)["LCP Stalls Impact"] = (it->second)["ILD_STALL"] * CORE_LCP_STALL_CYCLES;
479  (it->second)["Loads Blocked by Unknown Address Store Impact"] = (it->second)["LOAD_BLOCK:STA"] * CORE_UNKNOWN_ADDR_STORE_CYCLES;
480  (it->second)["Loads Overlapped with Stores Impact"] = (it->second)["LOAD_BLOCK:OVERLAP_STORE"] * CORE_OVERLAPPING_CYCLES;
481  (it->second)["Loads Spanning across Cache Lines Impact"] = (it->second)["LOAD_BLOCK:UNTIL_RETIRE"] * CORE_SPAN_ACROSS_CACHE_LINE_CYCLES;
482  (it->second)["Store-Fwd Stalls Impact"] = (it->second)["Loads Blocked by Unknown Address Store Impact"] + (it->second)["Loads Overlapped with Stores Impact"] + (it->second)["Loads Spanning across Cache Lines Impact"];
483  (it->second)["Counted Stalled Cycles"] = (it->second)["L2 Miss Impact"] + (it->second)["L2 Hit Impact"] + (it->second)["LCP Stalls Impact"] + (it->second)["L1 DTLB Miss Impact"] + (it->second)["Store-Fwd Stalls Impact"];
484  (it->second)["Instructions Retired"] = (it->second)["INSTRUCTIONS_RETIRED"];
485  (it->second)["ITLB Miss Rate in %"] = ((it->second)["ITLB_MISS_RETIRED"]/(it->second)["INSTRUCTIONS_RETIRED"])*100;
486  (it->second)["Branch Instructions"] = (it->second)["BRANCH_INSTRUCTIONS_RETIRED"];
487  (it->second)["Load Instructions"] = (it->second)["INST_RETIRED:LOADS"];
488  (it->second)["Store Instructions"] = (it->second)["INST_RETIRED:STORES"];
489  (it->second)["Other Instructions"] = (it->second)["INST_RETIRED:OTHER"] - (it->second)["SIMD_COMP_INST_RETIRED:PACKED_SINGLE:PACKED_DOUBLE"] - (it->second)["BRANCH_INSTRUCTIONS_RETIRED"];
490  (it->second)["% of Mispredicted Branches"] = ((it->second)["MISPREDICTED_BRANCH_RETIRED"]/(it->second)["BRANCH_INSTRUCTIONS_RETIRED"])*100;
491  (it->second)["Packed SIMD Computational Instructions"] = (it->second)["SIMD_COMP_INST_RETIRED:PACKED_SINGLE:PACKED_DOUBLE"];
492  (it->second)["Counted Instructions Retired"] = (it->second)["Branch Instructions"] + (it->second)["Load Instructions"] + (it->second)["Store Instructions"] + (it->second)["Other Instructions"] + (it->second)["Packed SIMD Computational Instructions"];
493  (it->second)["CPI"] = (it->second)["UNHALTED_CORE_CYCLES"]/(it->second)["INSTRUCTIONS_RETIRED"];
494 
495  double localPerformanceImprovement = (it->second)["CPI"]/EXPECTED_CPI;
496  double cyclesAfterImprovement = (it->second)["UNHALTED_CORE_CYCLES"]/localPerformanceImprovement;
497  double totalCyclesAfterImprovement = totalCycles-(it->second)["UNHALTED_CORE_CYCLES"]+cyclesAfterImprovement;
498  (it->second)["iMargin"] = 100-(totalCyclesAfterImprovement/totalCycles)*100;
499 
500  (it->second)["% of Total Cycles"] = (it->second)["RS_UOPS_DISPATCHED CMASK=1 INV=1"]*100/(it->second)["UNHALTED_CORE_CYCLES"];
501  (it->second)["L2 Miss % of counted Stalled Cycles"] =(it->second)["L2 Miss Impact"]*100/(it->second)["Counted Stalled Cycles"];
502  (it->second)["L2 Hit % of counted Stalled Cycles"] =(it->second)["L2 Hit Impact"]*100/(it->second)["Counted Stalled Cycles"];
503  (it->second)["L1 DTLB Miss % of counted Stalled Cycles"] =(it->second)["L1 DTLB Miss Impact"]*100/(it->second)["Counted Stalled Cycles"];
504  (it->second)["LCP Stalls % of counted Stalled Cycles"] =(it->second)["LCP Stalls Impact"]*100/(it->second)["Counted Stalled Cycles"];
505  (it->second)["Store-Fwd Stalls % of counted Stalled Cycles"] =(it->second)["Store-Fwd Stalls Impact"]*100/(it->second)["Counted Stalled Cycles"];
506  (it->second)["Loads Blocked % of Store-Fwd Stalls Cycles"] =(it->second)["Loads Blocked by Unknown Address Store Impact"]*100/(it->second)["Store-Fwd Stalls Impact"];
507  (it->second)["Loads Overlapped % of Store-Fwd Stalls Cycles"] =(it->second)["Loads Overlapped with Stores Impact"]*100/(it->second)["Store-Fwd Stalls Impact"];
508  (it->second)["Loads Spanning % of Store-Fwd Stalls Cycles"] =(it->second)["Loads Spanning across Cache Lines Impact"]*100/(it->second)["Store-Fwd Stalls Impact"];
509 
510  (it->second)["Load % of all Instructions"] =(it->second)["INST_RETIRED:LOADS"]*100/(it->second)["Counted Instructions Retired"];
511  (it->second)["Store % of all Instructions"] =(it->second)["INST_RETIRED:STORES"]*100/(it->second)["Counted Instructions Retired"];
512  (it->second)["Branch % of all Instructions"] =(it->second)["BRANCH_INSTRUCTIONS_RETIRED"]*100/(it->second)["Counted Instructions Retired"];
513  (it->second)["Packed SIMD % of all Instructions"] =(it->second)["SIMD_COMP_INST_RETIRED:PACKED_SINGLE:PACKED_DOUBLE"]*100/(it->second)["Counted Instructions Retired"];
514  (it->second)["Other % of all Instructions"] =(it->second)["Other Instructions"]*100/(it->second)["Counted Instructions Retired"];
515  }
516 }
#define CORE_UNKNOWN_ADDR_STORE_CYCLES
#define CORE_LCP_STALL_CYCLES
#define EXPECTED_CPI
#define CORE_L1_DTLB_MISS_CYCLES
#define CORE_OVERLAPPING_CYCLES
struct GAUDI_API map
Parametrisation class for map-like implementation.
#define CORE_SPAN_ACROSS_CACHE_LINE_CYCLES
#define CORE_L2_MISS_CYCLES
#define CORE_L2_HIT_CYCLES
void calc_nhm_deriv_values ( double  totalCycles)

Definition at line 624 of file pfm_gen_analysis.cpp.

625 {
626  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
627  {
628  (it->second)["Total Cycles"] = (it->second)["CPU_CLK_UNHALTED:THREAD_P"];
629 
630  (it->second)["L2 Hit Impact"] = (it->second)["MEM_LOAD_RETIRED:L2_HIT"] * I7_L2_HIT_CYCLES;
631  (it->second)["L3 Unshared Hit Impact"] = (it->second)["MEM_LOAD_RETIRED:L3_UNSHARED_HIT"] * I7_L3_UNSHARED_HIT_CYCLES;
632  if((it->second)["MEM_LOAD_RETIRED:OTHER_CORE_L2_HIT_HITM"]>(it->second)["MEM_UNCORE_RETIRED:OTHER_CORE_L2_HITM"])
633  {
634  (it->second)["L2 Other Core Hit Impact"] = ((it->second)["MEM_LOAD_RETIRED:OTHER_CORE_L2_HIT_HITM"] - (it->second)["MEM_UNCORE_RETIRED:OTHER_CORE_L2_HITM"])* I7_OTHER_CORE_L2_HIT_CYCLES;
635  }
636  else
637  {
638  (it->second)["L2 Other Core Hit Impact"] = 0.0;
639  }
640  (it->second)["L2 Other Core Hit Modified Impact"] = (it->second)["MEM_UNCORE_RETIRED:OTHER_CORE_L2_HITM"] * I7_OTHER_CORE_L2_HITM_CYCLES;
641  (it->second)["L3 Miss -> Local DRAM Hit Impact"] = (it->second)["MEM_UNCORE_RETIRED:LOCAL_DRAM"] * I7_L3_MISS_LOCAL_DRAM_HIT_CYCLES;
642  (it->second)["L3 Miss -> Remote DRAM Hit Impact"] = (it->second)["MEM_UNCORE_RETIRED:REMOTE_DRAM"] * I7_L3_MISS_REMOTE_DRAM_HIT_CYCLES;
643  (it->second)["L3 Miss -> Remote Cache Hit Impact"] = (it->second)["MEM_UNCORE_RETIRED:REMOTE_CACHE_LOCAL_HOME_HIT"] * I7_L3_MISS_REMOTE_CACHE_HIT_CYCLES;
644  (it->second)["L3 Miss -> Total Impact"] = (it->second)["L3 Miss -> Local DRAM Hit Impact"] + (it->second)["L3 Miss -> Remote DRAM Hit Impact"] + (it->second)["L3 Miss -> Remote Cache Hit Impact"];
645  (it->second)["L1 DTLB Miss Impact"] = (it->second)["DTLB_LOAD_MISSES:WALK_COMPLETED"] * I7_L1_DTLB_WALK_COMPLETED_CYCLES;
646  (it->second)["Counted Stalled Cycles due to Load Ops"] = (it->second)["L3 Miss -> Total Impact"] + (it->second)["L2 Hit Impact"] + (it->second)["L1 DTLB Miss Impact"] + (it->second)["L3 Unshared Hit Impact"] + (it->second)["L2 Other Core Hit Modified Impact"] + (it->second)["L2 Other Core Hit Impact"];
647  (it->second)["Cycles spent during DIV & SQRT Ops"] = (it->second)["ARITH:CYCLES_DIV_BUSY"];
648  (it->second)["Total Counted Stalled Cycles"] = (it->second)["Counted Stalled Cycles due to Load Ops"] + (it->second)["Cycles spent during DIV & SQRT Ops"];
649  (it->second)["Stalled Cycles"] = (it->second)["Total Counted Stalled Cycles"]; //TO BE FIXED when UOPS_EXECUTED:0x3f is fixed!!
650  (it->second)["% of Total Cycles"] = (it->second)["Stalled Cycles"] * 100 / (it->second)["CPU_CLK_UNHALTED:THREAD_P"]; //TO BE FIXED!! see above
651  (it->second)["L3 Miss % of Load Stalls"] = (it->second)["L3 Miss -> Total Impact"] * 100 / (it->second)["Counted Stalled Cycles due to Load Ops"];
652  (it->second)["L2 Hit % of Load Stalls"] = (it->second)["L2 Hit Impact"] * 100 / (it->second)["Counted Stalled Cycles due to Load Ops"];
653  (it->second)["L1 DTLB Miss % of Load Stalls"] = (it->second)["L1 DTLB Miss Impact"] * 100 / (it->second)["Counted Stalled Cycles due to Load Ops"];
654  (it->second)["L3 Unshared Hit % of Load Stalls"] = (it->second)["L3 Unshared Hit Impact"] * 100 / (it->second)["Counted Stalled Cycles due to Load Ops"];
655  (it->second)["L2 Other Core Hit % of Load Stalls"] = (it->second)["L2 Other Core Hit Impact"] * 100 / (it->second)["Counted Stalled Cycles due to Load Ops"];
656  (it->second)["L2 Other Core Hit Modified % of Load Stalls"] = (it->second)["L2 Other Core Hit Modified Impact"] * 100 / (it->second)["Counted Stalled Cycles due to Load Ops"];
657  (it->second)["DIV & SQRT Ops % of counted Stalled Cycles"] = (it->second)["Cycles spent during DIV & SQRT Ops"] * 100 / (it->second)["Total Counted Stalled Cycles"];
658 
659  (it->second)["Cycles IFETCH served by Local DRAM"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:LOCAL_DRAM"] * I7_IFETCH_L3_MISS_LOCAL_DRAM_HIT;
660  (it->second)["Cycles IFETCH served by L3 (Modified)"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:OTHER_CORE_HITM"] * I7_IFETCH_L2_MISS_L3_HITM;
661  (it->second)["Cycles IFETCH served by L3 (Clean Snoop)"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:OTHER_CORE_HIT_SNP"] * I7_IFETCH_L2_MISS_L3_HIT_SNOOP;
662  (it->second)["Cycles IFETCH served by Remote L2"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:REMOTE_CACHE_FWD"] * I7_IFETCH_L3_MISS_REMOTE_CACHE_FWD;
663  (it->second)["Cycles IFETCH served by Remote DRAM"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:REMOTE_DRAM"] * I7_IFETCH_L3_MISS_REMOTE_DRAM_HIT;
664  (it->second)["Cycles IFETCH served by L3 (No Snoop)"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:UNCORE_HIT"] * I7_IFETCH_L2_MISS_L3_HIT_NO_SNOOP;
665  (it->second)["Total L2 IFETCH miss Impact"] = (it->second)["Cycles IFETCH served by Local DRAM"] + (it->second)["Cycles IFETCH served by L3 (Modified)"] + (it->second)["Cycles IFETCH served by L3 (Clean Snoop)"] + (it->second)["Cycles IFETCH served by Remote L2"] + (it->second)["Cycles IFETCH served by Remote DRAM"] + (it->second)["Cycles IFETCH served by L3 (No Snoop)"];
666  (it->second)["Local DRAM IFECTHes % Impact"] = (it->second)["Cycles IFETCH served by Local DRAM"] * 100 / (it->second)["Total L2 IFETCH miss Impact"];
667  (it->second)["L3 (Modified) IFECTHes % Impact"] = (it->second)["Cycles IFETCH served by L3 (Modified)"] * 100 / (it->second)["Total L2 IFETCH miss Impact"];
668  (it->second)["L3 (Clean Snoop) IFECTHes % Impact"] = (it->second)["Cycles IFETCH served by L3 (Clean Snoop)"] * 100 / (it->second)["Total L2 IFETCH miss Impact"];
669  (it->second)["Remote L2 IFECTHes % Impact"] = (it->second)["Cycles IFETCH served by Remote L2"] * 100 / (it->second)["Total L2 IFETCH miss Impact"];
670  (it->second)["Remote DRAM IFECTHes % Impact"] = (it->second)["Cycles IFETCH served by Remote DRAM"] * 100 / (it->second)["Total L2 IFETCH miss Impact"];
671  (it->second)["L3 (No Snoop) IFECTHes % Impact"] = (it->second)["Cycles IFETCH served by L3 (No Snoop)"] * 100 / (it->second)["Total L2 IFETCH miss Impact"];
672  (it->second)["Total L2 IFETCH misses"] = (it->second)["L2_RQSTS:IFETCH_MISS"];
673  (it->second)["% of IFETCHes served by Local DRAM"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:LOCAL_DRAM"] * 100 / (it->second)["L2_RQSTS:IFETCH_MISS"];
674  (it->second)["% of IFETCHes served by L3 (Modified)"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:OTHER_CORE_HITM"] * 100 / (it->second)["L2_RQSTS:IFETCH_MISS"];
675  (it->second)["% of IFETCHes served by L3 (Clean Snoop)"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:OTHER_CORE_HIT_SNP"] * 100 / (it->second)["L2_RQSTS:IFETCH_MISS"];
676  (it->second)["% of IFETCHes served by Remote L2"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:REMOTE_CACHE_FWD"] * 100 / (it->second)["L2_RQSTS:IFETCH_MISS"];
677  (it->second)["% of IFETCHes served by Remote DRAM"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:REMOTE_DRAM"] * 100 / (it->second)["L2_RQSTS:IFETCH_MISS"];
678  (it->second)["% of IFETCHes served by L3 (No Snoop)"] = (it->second)["OFFCORE_RESPONSE_0:DMND_IFETCH:UNCORE_HIT"] * 100 / (it->second)["L2_RQSTS:IFETCH_MISS"];
679  (it->second)["% of L2 IFETCH misses"] = (it->second)["L2_RQSTS:IFETCH_MISS"] * 100 / ((it->second)["L2_RQSTS:IFETCH_MISS"] + (it->second)["L2_RQSTS:IFETCH_HIT"]);
680  (it->second)["L1 ITLB Miss Impact"] = (it->second)["ITLB_MISSES:WALK_COMPLETED"] * I7_L1_ITLB_WALK_COMPLETED_CYCLES;
681 
682  (it->second)["Total Branch Instructions Executed"] = (it->second)["BR_INST_EXEC:ANY"];
683  (it->second)["% of Mispredicted Branches"] = (it->second)["BR_MISP_EXEC:ANY"] * 100 / (it->second)["BR_INST_EXEC:ANY"];
684  (it->second)["Direct Near Calls % of Total Branches Executed"] = (it->second)["BR_INST_EXEC:DIRECT_NEAR_CALL"] * 100 / (it->second)["Total Branch Instructions Executed"];
685  (it->second)["Indirect Near Calls % of Total Branches Executed"] = (it->second)["BR_INST_EXEC:INDIRECT_NEAR_CALL"] * 100 / (it->second)["Total Branch Instructions Executed"];
686  (it->second)["Indirect Near Non-Calls % of Total Branches Executed"] = (it->second)["BR_INST_EXEC:INDIRECT_NON_CALL"] * 100 / (it->second)["Total Branch Instructions Executed"];
687  (it->second)["All Near Calls % of Total Branches Executed"] = (it->second)["BR_INST_EXEC:NEAR_CALLS"] * 100 / (it->second)["Total Branch Instructions Executed"];
688  (it->second)["All Non Calls % of Total Branches Executed"] = (it->second)["BR_INST_EXEC:NON_CALLS"] * 100 / (it->second)["Total Branch Instructions Executed"];
689  (it->second)["All Returns % of Total Branches Executed"] = (it->second)["BR_INST_EXEC:RETURN_NEAR"] * 100 / (it->second)["Total Branch Instructions Executed"];
690  (it->second)["Total Branch Instructions Retired"] = (it->second)["BR_INST_RETIRED:ALL_BRANCHES"];
691  (it->second)["Conditionals % of Total Branches Retired"] = (it->second)["BR_INST_RETIRED:CONDITIONAL"] * 100 / (it->second)["Total Branch Instructions Retired"];
692  (it->second)["Near Calls % of Total Branches Retired"] = (it->second)["BR_INST_RETIRED:NEAR_CALL"] * 100 / (it->second)["Total Branch Instructions Retired"];
693 
694  (it->second)["Instruction Starvation % of Total Cycles"] = ((it->second)["UOPS_ISSUED:ANY CMASK=1 INV=1"] - (it->second)["RESOURCE_STALLS:ANY"])* 100 / (it->second)["CPU_CLK_UNHALTED:THREAD_P"];
695  (it->second)["% of Total Cycles spent handling FP exceptions"] = (it->second)["UOPS_DECODED:MS CMASK=1"]* 100 / (it->second)["CPU_CLK_UNHALTED:THREAD_P"];
696  (it->second)["# of Instructions per Call"] = (it->second)["INST_RETIRED:ANY_P"] / (it->second)["BR_INST_EXEC:NEAR_CALLS"];
697 
698  (it->second)["Instructions Retired"] = (it->second)["INST_RETIRED:ANY_P"];
699  (it->second)["ITLB Miss Rate in %"] = ((it->second)["ITLB_MISS_RETIRED"] / (it->second)["INST_RETIRED:ANY_P"]) * 100;
700 
701  (it->second)["Branch Instructions"] = (it->second)["BR_INST_RETIRED:ALL_BRANCHES"];
702  (it->second)["Load Instructions"] = (it->second)["MEM_INST_RETIRED:LOADS"];
703  (it->second)["Store Instructions"] = (it->second)["MEM_INST_RETIRED:STORES"];
704  (it->second)["Other Instructions"] = (it->second)["Instructions Retired"] - (it->second)["MEM_INST_RETIRED:LOADS"] - (it->second)["MEM_INST_RETIRED:STORES"] - (it->second)["BR_INST_RETIRED:ALL_BRANCHES"];
705  (it->second)["Packed UOPS Retired"] = (it->second)["SSEX_UOPS_RETIRED:PACKED_DOUBLE"] + (it->second)["SSEX_UOPS_RETIRED:PACKED_SINGLE"];
706  (it->second)["CPI"] = (it->second)["CPU_CLK_UNHALTED:THREAD_P"] / (it->second)["INST_RETIRED:ANY_P"];
707 
708  double localPerformanceImprovement = (it->second)["CPI"]/EXPECTED_CPI;
709  double cyclesAfterImprovement = (it->second)["CPU_CLK_UNHALTED:THREAD_P"]/localPerformanceImprovement;
710  double totalCyclesAfterImprovement = totalCycles-(it->second)["CPU_CLK_UNHALTED:THREAD_P"]+cyclesAfterImprovement;
711  (it->second)["iMargin"] = 100-(totalCyclesAfterImprovement/totalCycles)*100;
712 
713  (it->second)["Load % of all Instructions"] = (it->second)["MEM_INST_RETIRED:LOADS"] * 100 / (it->second)["INST_RETIRED:ANY_P"];
714  (it->second)["Store % of all Instructions"] = (it->second)["MEM_INST_RETIRED:STORES"] * 100 / (it->second)["INST_RETIRED:ANY_P"];
715  (it->second)["Branch % of all Instructions"] = (it->second)["BR_INST_RETIRED:ALL_BRANCHES"] * 100 / (it->second)["INST_RETIRED:ANY_P"];
716  (it->second)["Other % of all Instructions"] = (it->second)["Other Instructions"] * 100 / (it->second)["INST_RETIRED:ANY_P"];
717 
718  (it->second)["Packed % of all UOPS Retired"] = (it->second)["Packed UOPS Retired"] * 100 / (it->second)["UOPS_RETIRED:ANY"];
719  }
720 }
#define I7_L3_UNSHARED_HIT_CYCLES
#define I7_L3_MISS_REMOTE_DRAM_HIT_CYCLES
#define I7_IFETCH_L2_MISS_L3_HITM
#define EXPECTED_CPI
#define I7_IFETCH_L3_MISS_REMOTE_CACHE_FWD
#define I7_OTHER_CORE_L2_HITM_CYCLES
#define I7_L1_ITLB_WALK_COMPLETED_CYCLES
struct GAUDI_API map
Parametrisation class for map-like implementation.
#define I7_L2_HIT_CYCLES
#define I7_L3_MISS_LOCAL_DRAM_HIT_CYCLES
#define I7_OTHER_CORE_L2_HIT_CYCLES
#define I7_L3_MISS_REMOTE_CACHE_HIT_CYCLES
#define I7_IFETCH_L2_MISS_L3_HIT_NO_SNOOP
#define I7_L1_DTLB_WALK_COMPLETED_CYCLES
#define I7_IFETCH_L3_MISS_LOCAL_DRAM_HIT
#define I7_IFETCH_L3_MISS_REMOTE_DRAM_HIT
#define I7_IFETCH_L2_MISS_L3_HIT_SNOOP
void calc_post_deriv_values ( )

Definition at line 1687 of file pfm_gen_analysis.cpp.

1688 {
1689  if(nehalem)
1690  {
1691  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
1692  {
1693  double simdnorm = 1. - normalize("Packed % of all UOPS Retired", (it->second)["Packed % of all UOPS Retired"], 1);
1694  double misspnorm = normalize("% of Mispredicted Branches", (it->second)["% of Mispredicted Branches"], 1);
1695  double stallnorm = normalize("Stalled Cycles", (it->second)["Stalled Cycles"], 1);
1696  (it->second)["iFactor"] = stallnorm*(simdnorm + misspnorm + stallnorm);
1697  }
1698  }
1699  else
1700  {
1701  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
1702  {
1703  double simdnorm = 1. - normalize("Packed SIMD % of all Instructions", (it->second)["Packed SIMD % of all Instructions"], 1);
1704  double misspnorm = normalize("% of Mispredicted Branches", (it->second)["% of Mispredicted Branches"], 1);
1705  double stallnorm = normalize("Stalled Cycles", (it->second)["Stalled Cycles"], 1);
1706  (it->second)["iFactor"] = stallnorm*(simdnorm + misspnorm + stallnorm);
1707  }
1708  }
1709 }
double normalize(std::string field, double value, double normalizeTo)
struct GAUDI_API map
Parametrisation class for map-like implementation.
bool check_for_core_caa_events ( )

Definition at line 393 of file pfm_gen_analysis.cpp.

394 {
395  for(std::vector<std::string>::const_iterator it=core_caa_events.begin(); it!=core_caa_events.end(); ++it)
396  {
397  if(find(C_events.begin(), C_events.end(), (*it))==C_events.end())
398  {
399  fprintf(stderr, "ERROR: Cannot find event %s!!!\naborting...\n", (*it).c_str());
400  return false;
401  }
402  }
403  return true;
404 }
bool check_for_nhm_caa_events ( )

Definition at line 406 of file pfm_gen_analysis.cpp.

407 {
408  for(std::vector<std::string>::const_iterator it=nhm_caa_events.begin(); it!=nhm_caa_events.end(); ++it)
409  {
410  if(find(C_events.begin(), C_events.end(), (*it))==C_events.end())
411  {
412  fprintf(stderr, "ERROR: Cannot find event %s!!!\naborting...\n", (*it).c_str());
413  return false;
414  }
415  }
416  return true;
417 }
int finalize_S_html_pages ( const char *  dir)

Definition at line 1472 of file pfm_gen_analysis.cpp.

1473 {
1474  for(std::map<std::string, unsigned int>::const_iterator i = modules_tot_samples.begin(); i != modules_tot_samples.end(); i++)
1475  {
1476  char module_filename[MAX_FILENAME_LENGTH];
1477  strcpy(module_filename, dir);
1478  strcat(module_filename, "/HTML/");
1479  strcat(module_filename, (i->first).c_str());
1480  strcat(module_filename, ".html");
1481  FILE *module_file = fopen(module_filename, "a");
1482  if(module_file == NULL)
1483  {
1484  fprintf(stderr, "ERROR: Unable to append to file: %s\naborting...\n", module_filename);
1485  exit(1);
1486  }
1487  fprintf(module_file, "</body>\n</html>\n");
1488  if(fclose(module_file))
1489  {
1490  fprintf(stderr, "ERROR: Cannot close file %s!!!\naborting...\n", module_filename);
1491  exit(1);
1492  }
1493  }
1494  return 0;
1495 }
#define MAX_FILENAME_LENGTH
list i
Definition: ana.py:128
const char* func_name ( const char *  demangled_symbol)

Definition at line 855 of file pfm_gen_analysis.cpp.

856 {
857  char *operator_string_begin = const_cast<char *>(strstr(demangled_symbol, "operator"));
858  if(operator_string_begin != NULL)
859  {
860  char *operator_string_end = operator_string_begin+8;
861  while(*operator_string_end == ' ') operator_string_end++;
862  if(strstr(operator_string_end, "delete[]")==operator_string_end)
863  {
864  operator_string_end+=8;
865  *operator_string_end='\0';
866  }
867  else if(strstr(operator_string_end, "delete")==operator_string_end)
868  {
869  operator_string_end+=6;
870  *operator_string_end='\0';
871  }
872  else if(strstr(operator_string_end, "new[]")==operator_string_end)
873  {
874  operator_string_end+=5;
875  *operator_string_end='\0';
876  }
877  else if(strstr(operator_string_end, "new")==operator_string_end)
878  {
879  operator_string_end+=3;
880  *operator_string_end='\0';
881  }
882  else if(strstr(operator_string_end, ">>=")==operator_string_end)
883  {
884  operator_string_end+=3;
885  *operator_string_end='\0';
886  }
887  else if(strstr(operator_string_end, "<<=")==operator_string_end)
888  {
889  operator_string_end+=3;
890  *operator_string_end='\0';
891  }
892  else if(strstr(operator_string_end, "->*")==operator_string_end)
893  {
894  operator_string_end+=3;
895  *operator_string_end='\0';
896  }
897  else if(strstr(operator_string_end, "<<")==operator_string_end)
898  {
899  operator_string_end+=2;
900  *operator_string_end='\0';
901  }
902  else if(strstr(operator_string_end, ">>")==operator_string_end)
903  {
904  operator_string_end+=2;
905  *operator_string_end='\0';
906  }
907  else if(strstr(operator_string_end, ">=")==operator_string_end)
908  {
909  operator_string_end+=2;
910  *operator_string_end='\0';
911  }
912  else if(strstr(operator_string_end, "<=")==operator_string_end)
913  {
914  operator_string_end+=2;
915  *operator_string_end='\0';
916  }
917  else if(strstr(operator_string_end, "==")==operator_string_end)
918  {
919  operator_string_end+=2;
920  *operator_string_end='\0';
921  }
922  else if(strstr(operator_string_end, "!=")==operator_string_end)
923  {
924  operator_string_end+=2;
925  *operator_string_end='\0';
926  }
927  else if(strstr(operator_string_end, "|=")==operator_string_end)
928  {
929  operator_string_end+=2;
930  *operator_string_end='\0';
931  }
932  else if(strstr(operator_string_end, "&=")==operator_string_end)
933  {
934  operator_string_end+=2;
935  *operator_string_end='\0';
936  }
937  else if(strstr(operator_string_end, "^=")==operator_string_end)
938  {
939  operator_string_end+=2;
940  *operator_string_end='\0';
941  }
942  else if(strstr(operator_string_end, "%=")==operator_string_end)
943  {
944  operator_string_end+=2;
945  *operator_string_end='\0';
946  }
947  else if(strstr(operator_string_end, "/=")==operator_string_end)
948  {
949  operator_string_end+=2;
950  *operator_string_end='\0';
951  }
952  else if(strstr(operator_string_end, "*=")==operator_string_end)
953  {
954  operator_string_end+=2;
955  *operator_string_end='\0';
956  }
957  else if(strstr(operator_string_end, "-=")==operator_string_end)
958  {
959  operator_string_end+=2;
960  *operator_string_end='\0';
961  }
962  else if(strstr(operator_string_end, "+=")==operator_string_end)
963  {
964  operator_string_end+=2;
965  *operator_string_end='\0';
966  }
967  else if(strstr(operator_string_end, "&&")==operator_string_end)
968  {
969  operator_string_end+=2;
970  *operator_string_end='\0';
971  }
972  else if(strstr(operator_string_end, "||")==operator_string_end)
973  {
974  operator_string_end+=2;
975  *operator_string_end='\0';
976  }
977  else if(strstr(operator_string_end, "[]")==operator_string_end)
978  {
979  operator_string_end+=2;
980  *operator_string_end='\0';
981  }
982  else if(strstr(operator_string_end, "()")==operator_string_end)
983  {
984  operator_string_end+=2;
985  *operator_string_end='\0';
986  }
987  else if(strstr(operator_string_end, "++")==operator_string_end)
988  {
989  operator_string_end+=2;
990  *operator_string_end='\0';
991  }
992  else if(strstr(operator_string_end, "--")==operator_string_end)
993  {
994  operator_string_end+=2;
995  *operator_string_end='\0';
996  }
997  else if(strstr(operator_string_end, "->")==operator_string_end)
998  {
999  operator_string_end+=2;
1000  *operator_string_end='\0';
1001  }
1002  else if(strstr(operator_string_end, "<")==operator_string_end)
1003  {
1004  operator_string_end+=1;
1005  *operator_string_end='\0';
1006  }
1007  else if(strstr(operator_string_end, ">")==operator_string_end)
1008  {
1009  operator_string_end+=1;
1010  *operator_string_end='\0';
1011  }
1012  else if(strstr(operator_string_end, "~")==operator_string_end)
1013  {
1014  operator_string_end+=1;
1015  *operator_string_end='\0';
1016  }
1017  else if(strstr(operator_string_end, "!")==operator_string_end)
1018  {
1019  operator_string_end+=1;
1020  *operator_string_end='\0';
1021  }
1022  else if(strstr(operator_string_end, "+")==operator_string_end)
1023  {
1024  operator_string_end+=1;
1025  *operator_string_end='\0';
1026  }
1027  else if(strstr(operator_string_end, "-")==operator_string_end)
1028  {
1029  operator_string_end+=1;
1030  *operator_string_end='\0';
1031  }
1032  else if(strstr(operator_string_end, "*")==operator_string_end)
1033  {
1034  operator_string_end+=1;
1035  *operator_string_end='\0';
1036  }
1037  else if(strstr(operator_string_end, "/")==operator_string_end)
1038  {
1039  operator_string_end+=1;
1040  *operator_string_end='\0';
1041  }
1042  else if(strstr(operator_string_end, "%")==operator_string_end)
1043  {
1044  operator_string_end+=1;
1045  *operator_string_end='\0';
1046  }
1047  else if(strstr(operator_string_end, "^")==operator_string_end)
1048  {
1049  operator_string_end+=1;
1050  *operator_string_end='\0';
1051  }
1052  else if(strstr(operator_string_end, "&")==operator_string_end)
1053  {
1054  operator_string_end+=1;
1055  *operator_string_end='\0';
1056  }
1057  else if(strstr(operator_string_end, "|")==operator_string_end)
1058  {
1059  operator_string_end+=1;
1060  *operator_string_end='\0';
1061  }
1062  else if(strstr(operator_string_end, ",")==operator_string_end)
1063  {
1064  operator_string_end+=1;
1065  *operator_string_end='\0';
1066  }
1067  else if(strstr(operator_string_end, "=")==operator_string_end)
1068  {
1069  operator_string_end+=1;
1070  *operator_string_end='\0';
1071  }
1072  return operator_string_begin;
1073  }
1074  char *end_of_demangled_name = const_cast<char *>(strrchr(demangled_symbol, ')'));
1075  if(end_of_demangled_name != NULL)
1076  {
1077  int pars = 1;
1078  char c;
1079  while(pars>0 && end_of_demangled_name!=demangled_symbol)
1080  {
1081  c = *(--end_of_demangled_name);
1082  if(c==')')
1083  {
1084  pars++;
1085  }
1086  else if(c=='(')
1087  {
1088  pars--;
1089  }
1090  }
1091  }
1092  else
1093  {
1094  return demangled_symbol;
1095  }
1096  char *end_of_func_name = end_of_demangled_name;
1097  if(end_of_func_name != NULL)
1098  {
1099  *end_of_func_name = '\0';
1100  char c = *(--end_of_func_name);
1101  if(c=='>')
1102  {
1103  int pars = 1;
1104  while(pars>0 && end_of_func_name!=demangled_symbol)
1105  {
1106  c = *(--end_of_func_name);
1107  if(c=='>')
1108  {
1109  pars++;
1110  }
1111  else if(c=='<')
1112  {
1113  pars--;
1114  }
1115  }
1116  *end_of_func_name = '\0';
1117  }
1118  c = *(--end_of_func_name);
1119  while(isalnum(c) || c=='_' || c=='~')
1120  {
1121  c = *(--end_of_func_name);
1122  }
1123  return ++end_of_func_name;
1124  }
1125  return demangled_symbol;
1126 }
tuple c
Definition: gaudirun.py:341
double getTotalCycles ( )

Definition at line 1715 of file pfm_gen_analysis.cpp.

1716 {
1717  double sum=0;
1718  if(nehalem)
1719  {
1720  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
1721  {
1722  sum += (it->second)["CPU_CLK_UNHALTED:THREAD_P"];
1723  }
1724  }
1725  else
1726  {
1727  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
1728  {
1729  sum += (it->second)["UNHALTED_CORE_CYCLES"];
1730  }
1731  }
1732  return sum;
1733 }
double sum(double x, double y, double z)
struct GAUDI_API map
Parametrisation class for map-like implementation.
void html_special_chars ( const char *  s,
char *  s_mod 
)

Definition at line 821 of file pfm_gen_analysis.cpp.

822 {
823  int n = strlen(s);
824  *s_mod = '\0';
825  for (int i=0; i < n; i++)
826  {
827  switch(s[i])
828  {
829  case '<':
830  strcat(s_mod, "&lt;");
831  break;
832  case '>':
833  strcat(s_mod, "&gt;");
834  break;
835  case '&':
836  strcat(s_mod, "&amp;");
837  break;
838  case '"':
839  strcat(s_mod, "&quot;");
840  break;
841  default:
842  char to_app[2];
843  to_app[0]=s[i];
844  to_app[1]='\0';
845  strcat(s_mod, to_app);
846  break;
847  }
848  }
849  return;
850 }
string s
Definition: gaudirun.py:210
list i
Definition: ana.py:128
void init_core_caa_events ( )

Definition at line 323 of file pfm_gen_analysis.cpp.

324 {
325  core_caa_events.push_back("BRANCH_INSTRUCTIONS_RETIRED");
326  core_caa_events.push_back("ILD_STALL");
327  core_caa_events.push_back("INST_RETIRED:LOADS");
328  core_caa_events.push_back("INST_RETIRED:OTHER");
329  core_caa_events.push_back("INST_RETIRED:STORES");
330  core_caa_events.push_back("INSTRUCTIONS_RETIRED");
331  core_caa_events.push_back("LOAD_BLOCK:OVERLAP_STORE");
332  core_caa_events.push_back("LOAD_BLOCK:STA");
333  core_caa_events.push_back("LOAD_BLOCK:UNTIL_RETIRE");
334  core_caa_events.push_back("MEM_LOAD_RETIRED:DTLB_MISS");
335  core_caa_events.push_back("MEM_LOAD_RETIRED:L1D_LINE_MISS");
336  core_caa_events.push_back("MEM_LOAD_RETIRED:L2_LINE_MISS");
337  core_caa_events.push_back("MISPREDICTED_BRANCH_RETIRED");
338  //core_caa_events.push_back("RS_UOPS_DISPATCHED");
339  //core_caa_events.push_back("RS_UOPS_DISPATCHED CMASK=1");
340  core_caa_events.push_back("RS_UOPS_DISPATCHED CMASK=1 INV=1");
341  core_caa_events.push_back("SIMD_COMP_INST_RETIRED:PACKED_SINGLE:PACKED_DOUBLE");
342  core_caa_events.push_back("UNHALTED_CORE_CYCLES");
343  //core_caa_events.push_back("UOPS_RETIRED:ANY");
344  //core_caa_events.push_back("UOPS_RETIRED:FUSED");
345  //core_caa_events.push_back("IDLE_DURING_DIV");
346 }
void init_core_caa_events_displ ( )

Definition at line 419 of file pfm_gen_analysis.cpp.

420 {
421  core_caa_events_displ.push_back("Total Cycles");
422  core_caa_events_displ.push_back("Stalled Cycles");
423  core_caa_events_displ.push_back("% of Total Cycles");
424  core_caa_events_displ.push_back("Instructions Retired");
425  core_caa_events_displ.push_back("CPI");
426  core_caa_events_displ.push_back("");
427  core_caa_events_displ.push_back("iMargin");
428  core_caa_events_displ.push_back("iFactor");
429  core_caa_events_displ.push_back("");
430  core_caa_events_displ.push_back("Counted Stalled Cycles");
431  core_caa_events_displ.push_back("");
432  core_caa_events_displ.push_back("L2 Miss Impact");
433  core_caa_events_displ.push_back("L2 Miss % of counted Stalled Cycles");
434  core_caa_events_displ.push_back("");
435  core_caa_events_displ.push_back("L2 Hit Impact");
436  core_caa_events_displ.push_back("L2 Hit % of counted Stalled Cycles");
437  core_caa_events_displ.push_back("");
438  core_caa_events_displ.push_back("L1 DTLB Miss Impact");
439  core_caa_events_displ.push_back("L1 DTLB Miss % of counted Stalled Cycles");
440  core_caa_events_displ.push_back("");
441  core_caa_events_displ.push_back("LCP Stalls Impact");
442  core_caa_events_displ.push_back("LCP Stalls % of counted Stalled Cycles");
443  core_caa_events_displ.push_back("");
444  core_caa_events_displ.push_back("Store-Fwd Stalls Impact");
445  core_caa_events_displ.push_back("Store-Fwd Stalls % of counted Stalled Cycles");
446  core_caa_events_displ.push_back("");
447  core_caa_events_displ.push_back("Loads Blocked by Unknown Address Store Impact");
448  core_caa_events_displ.push_back("Loads Blocked % of Store-Fwd Stalls Cycles");
449  core_caa_events_displ.push_back("Loads Overlapped with Stores Impact");
450  core_caa_events_displ.push_back("Loads Overlapped % of Store-Fwd Stalls Cycles");
451  core_caa_events_displ.push_back("Loads Spanning across Cache Lines Impact");
452  core_caa_events_displ.push_back("Loads Spanning % of Store-Fwd Stalls Cycles");
453  core_caa_events_displ.push_back("");
454  core_caa_events_displ.push_back("Load Instructions");
455  core_caa_events_displ.push_back("Load % of all Instructions");
456  core_caa_events_displ.push_back("Store Instructions");
457  core_caa_events_displ.push_back("Store % of all Instructions");
458  core_caa_events_displ.push_back("Branch Instructions");
459  core_caa_events_displ.push_back("Branch % of all Instructions");
460  core_caa_events_displ.push_back("Packed SIMD Computational Instructions");
461  core_caa_events_displ.push_back("Packed SIMD % of all Instructions");
462  core_caa_events_displ.push_back("Other Instructions");
463  core_caa_events_displ.push_back("Other % of all Instructions");
464  core_caa_events_displ.push_back("");
465  core_caa_events_displ.push_back("ITLB Miss Rate in %");
466  core_caa_events_displ.push_back("% of Mispredicted Branches");
467 }
void init_nhm_caa_events ( )

Definition at line 348 of file pfm_gen_analysis.cpp.

349 {
350  nhm_caa_events.push_back("ARITH:CYCLES_DIV_BUSY");
351  nhm_caa_events.push_back("BR_INST_EXEC:ANY");
352  nhm_caa_events.push_back("BR_INST_EXEC:DIRECT_NEAR_CALL");
353  nhm_caa_events.push_back("BR_INST_EXEC:INDIRECT_NEAR_CALL");
354  nhm_caa_events.push_back("BR_INST_EXEC:INDIRECT_NON_CALL");
355  nhm_caa_events.push_back("BR_INST_EXEC:NEAR_CALLS");
356  nhm_caa_events.push_back("BR_INST_EXEC:NON_CALLS");
357  nhm_caa_events.push_back("BR_INST_EXEC:RETURN_NEAR");
358  nhm_caa_events.push_back("BR_INST_RETIRED:ALL_BRANCHES");
359  nhm_caa_events.push_back("BR_INST_RETIRED:CONDITIONAL");
360  nhm_caa_events.push_back("BR_INST_RETIRED:NEAR_CALL");
361  nhm_caa_events.push_back("BR_MISP_EXEC:ANY");
362  nhm_caa_events.push_back("CPU_CLK_UNHALTED:THREAD_P");
363  nhm_caa_events.push_back("DTLB_LOAD_MISSES:WALK_COMPLETED");
364  nhm_caa_events.push_back("INST_RETIRED:ANY_P");
365  nhm_caa_events.push_back("ITLB_MISSES:WALK_COMPLETED");
366  nhm_caa_events.push_back("L2_RQSTS:IFETCH_HIT");
367  nhm_caa_events.push_back("L2_RQSTS:IFETCH_MISS");
368  nhm_caa_events.push_back("MEM_INST_RETIRED:LOADS");
369  nhm_caa_events.push_back("MEM_INST_RETIRED:STORES");
370  nhm_caa_events.push_back("MEM_LOAD_RETIRED:L2_HIT");
371  nhm_caa_events.push_back("MEM_LOAD_RETIRED:L3_MISS");
372  nhm_caa_events.push_back("MEM_LOAD_RETIRED:L3_UNSHARED_HIT");
373  nhm_caa_events.push_back("MEM_LOAD_RETIRED:OTHER_CORE_L2_HIT_HITM");
374  nhm_caa_events.push_back("MEM_UNCORE_RETIRED:LOCAL_DRAM");
375  nhm_caa_events.push_back("MEM_UNCORE_RETIRED:OTHER_CORE_L2_HITM");
376  nhm_caa_events.push_back("MEM_UNCORE_RETIRED:REMOTE_CACHE_LOCAL_HOME_HIT");
377  nhm_caa_events.push_back("MEM_UNCORE_RETIRED:REMOTE_DRAM");
378  nhm_caa_events.push_back("OFFCORE_RESPONSE_0:DMND_IFETCH:LOCAL_DRAM");
379  nhm_caa_events.push_back("OFFCORE_RESPONSE_0:DMND_IFETCH:OTHER_CORE_HITM");
380  nhm_caa_events.push_back("OFFCORE_RESPONSE_0:DMND_IFETCH:OTHER_CORE_HIT_SNP");
381  nhm_caa_events.push_back("OFFCORE_RESPONSE_0:DMND_IFETCH:REMOTE_CACHE_FWD");
382  nhm_caa_events.push_back("OFFCORE_RESPONSE_0:DMND_IFETCH:REMOTE_DRAM");
383  nhm_caa_events.push_back("OFFCORE_RESPONSE_0:DMND_IFETCH:UNCORE_HIT");
384  nhm_caa_events.push_back("RESOURCE_STALLS:ANY");
385  nhm_caa_events.push_back("SSEX_UOPS_RETIRED:PACKED_DOUBLE");
386  nhm_caa_events.push_back("SSEX_UOPS_RETIRED:PACKED_SINGLE");
387  nhm_caa_events.push_back("UOPS_DECODED:MS CMASK=1");
388  nhm_caa_events.push_back("UOPS_ISSUED:ANY CMASK=1 INV=1");
389  nhm_caa_events.push_back("ITLB_MISS_RETIRED");
390  nhm_caa_events.push_back("UOPS_RETIRED:ANY");
391 }
void init_nhm_caa_events_displ ( )

Definition at line 518 of file pfm_gen_analysis.cpp.

519 {
520  nhm_caa_events_displ.push_back("Total Cycles");
521  nhm_caa_events_displ.push_back("Instructions Retired");
522  nhm_caa_events_displ.push_back("CPI");
523  nhm_caa_events_displ.push_back("");
524  nhm_caa_events_displ.push_back("iMargin");
525  nhm_caa_events_displ.push_back("iFactor");
526  nhm_caa_events_displ.push_back("");
527  nhm_caa_events_displ.push_back("Stalled Cycles");
528  nhm_caa_events_displ.push_back("% of Total Cycles");
529  nhm_caa_events_displ.push_back("Total Counted Stalled Cycles");
530  nhm_caa_events_displ.push_back("");
531  nhm_caa_events_displ.push_back("Instruction Starvation % of Total Cycles");
532  nhm_caa_events_displ.push_back("# of Instructions per Call");
533  nhm_caa_events_displ.push_back("% of Total Cycles spent handling FP exceptions");
534  nhm_caa_events_displ.push_back("");
535  nhm_caa_events_displ.push_back("Counted Stalled Cycles due to Load Ops");
536  nhm_caa_events_displ.push_back("");
537  nhm_caa_events_displ.push_back("L2 Hit Impact");
538  nhm_caa_events_displ.push_back("L2 Hit % of Load Stalls");
539  nhm_caa_events_displ.push_back("");
540  nhm_caa_events_displ.push_back("L3 Unshared Hit Impact");
541  nhm_caa_events_displ.push_back("L3 Unshared Hit % of Load Stalls");
542  nhm_caa_events_displ.push_back("");
543  nhm_caa_events_displ.push_back("L2 Other Core Hit Impact");
544  nhm_caa_events_displ.push_back("L2 Other Core Hit % of Load Stalls");
545  nhm_caa_events_displ.push_back("");
546  nhm_caa_events_displ.push_back("L2 Other Core Hit Modified Impact");
547  nhm_caa_events_displ.push_back("L2 Other Core Hit Modified % of Load Stalls");
548  nhm_caa_events_displ.push_back("");
549  nhm_caa_events_displ.push_back("L3 Miss -> Local DRAM Hit Impact");
550  nhm_caa_events_displ.push_back("L3 Miss -> Remote DRAM Hit Impact");
551  nhm_caa_events_displ.push_back("L3 Miss -> Remote Cache Hit Impact");
552  nhm_caa_events_displ.push_back("L3 Miss -> Total Impact");
553  nhm_caa_events_displ.push_back("L3 Miss % of Load Stalls");
554  nhm_caa_events_displ.push_back("");
555  nhm_caa_events_displ.push_back("L1 DTLB Miss Impact");
556  nhm_caa_events_displ.push_back("L1 DTLB Miss % of Load Stalls");
557  nhm_caa_events_displ.push_back("");
558  nhm_caa_events_displ.push_back("Cycles spent during DIV & SQRT Ops");
559  nhm_caa_events_displ.push_back("DIV & SQRT Ops % of counted Stalled Cycles");
560  nhm_caa_events_displ.push_back("");
561  nhm_caa_events_displ.push_back("Total L2 IFETCH misses");
562  nhm_caa_events_displ.push_back("% of L2 IFETCH misses");
563  nhm_caa_events_displ.push_back("");
564  nhm_caa_events_displ.push_back("% of IFETCHes served by Local DRAM");
565  nhm_caa_events_displ.push_back("% of IFETCHes served by L3 (Modified)");
566  nhm_caa_events_displ.push_back("% of IFETCHes served by L3 (Clean Snoop)");
567  nhm_caa_events_displ.push_back("% of IFETCHes served by Remote L2");
568  nhm_caa_events_displ.push_back("% of IFETCHes served by Remote DRAM");
569  nhm_caa_events_displ.push_back("% of IFETCHes served by L3 (No Snoop)");
570  nhm_caa_events_displ.push_back("");
571  nhm_caa_events_displ.push_back("Total L2 IFETCH miss Impact");
572  nhm_caa_events_displ.push_back("");
573  nhm_caa_events_displ.push_back("Cycles IFETCH served by Local DRAM");
574  nhm_caa_events_displ.push_back("Local DRAM IFECTHes % Impact");
575  nhm_caa_events_displ.push_back("");
576  nhm_caa_events_displ.push_back("Cycles IFETCH served by L3 (Modified)");
577  nhm_caa_events_displ.push_back("L3 (Modified) IFECTHes % Impact");
578  nhm_caa_events_displ.push_back("");
579  nhm_caa_events_displ.push_back("Cycles IFETCH served by L3 (Clean Snoop)");
580  nhm_caa_events_displ.push_back("L3 (Clean Snoop) IFECTHes % Impact");
581  nhm_caa_events_displ.push_back("");
582  nhm_caa_events_displ.push_back("Cycles IFETCH served by Remote L2");
583  nhm_caa_events_displ.push_back("Remote L2 IFECTHes % Impact");
584  nhm_caa_events_displ.push_back("");
585  nhm_caa_events_displ.push_back("Cycles IFETCH served by Remote DRAM");
586  nhm_caa_events_displ.push_back("Remote DRAM IFECTHes % Impact");
587  nhm_caa_events_displ.push_back("");
588  nhm_caa_events_displ.push_back("Cycles IFETCH served by L3 (No Snoop)");
589  nhm_caa_events_displ.push_back("L3 (No Snoop) IFECTHes % Impact");
590  nhm_caa_events_displ.push_back("");
591  nhm_caa_events_displ.push_back("Total Branch Instructions Executed");
592  nhm_caa_events_displ.push_back("% of Mispredicted Branches");
593  nhm_caa_events_displ.push_back("");
594  nhm_caa_events_displ.push_back("Direct Near Calls % of Total Branches Executed");
595  nhm_caa_events_displ.push_back("Indirect Near Calls % of Total Branches Executed");
596  nhm_caa_events_displ.push_back("Indirect Near Non-Calls % of Total Branches Executed");
597  nhm_caa_events_displ.push_back("All Near Calls % of Total Branches Executed");
598  nhm_caa_events_displ.push_back("All Non Calls % of Total Branches Executed");
599  nhm_caa_events_displ.push_back("All Returns % of Total Branches Executed");
600  nhm_caa_events_displ.push_back("");
601  nhm_caa_events_displ.push_back("Total Branch Instructions Retired");
602  nhm_caa_events_displ.push_back("Conditionals % of Total Branches Retired");
603  nhm_caa_events_displ.push_back("Near Calls % of Total Branches Retired");
604  nhm_caa_events_displ.push_back("");
605  nhm_caa_events_displ.push_back("L1 ITLB Miss Impact");
606  nhm_caa_events_displ.push_back("ITLB Miss Rate in %");
607  nhm_caa_events_displ.push_back("");
608  nhm_caa_events_displ.push_back("Branch Instructions");
609  nhm_caa_events_displ.push_back("Branch % of all Instructions");
610  nhm_caa_events_displ.push_back("");
611  nhm_caa_events_displ.push_back("Load Instructions");
612  nhm_caa_events_displ.push_back("Load % of all Instructions");
613  nhm_caa_events_displ.push_back("");
614  nhm_caa_events_displ.push_back("Store Instructions");
615  nhm_caa_events_displ.push_back("Store % of all Instructions");
616  nhm_caa_events_displ.push_back("");
617  nhm_caa_events_displ.push_back("Other Instructions");
618  nhm_caa_events_displ.push_back("Other % of all Instructions");
619  nhm_caa_events_displ.push_back("");
620  nhm_caa_events_displ.push_back("Packed UOPS Retired");
621  nhm_caa_events_displ.push_back("Packed % of all UOPS Retired");
622 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 1738 of file pfm_gen_analysis.cpp.

1739 {
1740  if(argc<2 || argc>4)
1741  {
1742  printf("\n\nUsage: %s DIRECTORY [--caa] [--csv]\n\n", argv[0]);
1743  exit(1);
1744  }
1745 
1746  bool caa = false;
1747  bool csv = false;
1748  for(int i=2; i<argc; i++)
1749  {
1750  if(!strcmp(argv[i], "--caa")) caa = true;
1751  if(!strcmp(argv[i], "--csv")) csv = true;
1752  }
1753 
1754  char dir[MAX_FILENAME_LENGTH];
1755  strcpy(dir, argv[1]);
1756  if(!csv)
1757  {
1758  strcat(dir, "/HTML");
1759  int res = mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
1760  if(res!=0)
1761  {
1762  fprintf(stderr, "ERROR: Cannot create directory %s\naborting...\n", dir);
1763  exit(1);
1764  }
1765  }
1766 
1767  DIR *dp;
1768  struct dirent *dirp;
1769  int num_of_modules = 0;
1770  if((dp = opendir(argv[1]))==NULL)
1771  {
1772  printf("Error(%d) opening %s\n", errno, argv[1]);
1773  return errno;
1774  }
1775  while((dirp = readdir(dp))!=NULL)
1776  {
1777  if(strstr(dirp->d_name, "_S_")!=NULL && strstr(dirp->d_name, ".txt.gz")!=NULL && !csv)
1778  {
1779  if(read_S_events(argv[1], dirp->d_name))
1780  {
1781  fprintf(stderr, "ERROR: Cannot read file %s\naborting...\n", dirp->d_name);
1782  exit(1);
1783  }
1784  }
1785  }
1786  closedir(dp);
1787  sort(S_events.begin(), S_events.end());
1788  if((dp = opendir(argv[1]))==NULL)
1789  {
1790  printf("Error(%d) opening %s\n", errno, argv[1]);
1791  return errno;
1792  }
1793  while((dirp = readdir(dp))!=NULL)
1794  {
1795  if(strstr(dirp->d_name, "_S_")!=NULL && strstr(dirp->d_name, ".txt.gz")!=NULL && !csv)
1796  {
1797  if(read_S_file(argv[1], dirp->d_name))
1798  {
1799  fprintf(stderr, "ERROR: Cannot read file %s\naborting...\n", dirp->d_name);
1800  exit(1);
1801  }
1802  }
1803  else if(strstr(dirp->d_name, "_C_")!=NULL && strstr(dirp->d_name, ".txt")!=NULL)
1804  {
1805  int res = read_C_file(argv[1], dirp->d_name);
1806  if(res>num_of_modules)
1807  {
1808  num_of_modules = res;
1809  }
1810  }
1811  }
1812  closedir(dp);
1813 
1814  if(!csv)
1815  {
1816  if(finalize_S_html_pages(argv[1]))
1817  {
1818  fprintf(stderr, "ERROR: Cannot finalize HTML pages!!!\naborting...\n");
1819  exit(1);
1820  }
1821  }
1822 
1823  char filepath[MAX_FILENAME_LENGTH];
1824  bzero(filepath, MAX_FILENAME_LENGTH);
1825  if(!csv) sprintf(filepath, "%s/HTML/index.html", argv[1]);
1826  else sprintf(filepath, "%s/results.csv", argv[1]);
1827  FILE *fp = fopen(filepath, "w");
1828  if(fp == NULL)
1829  {
1830  fprintf(stderr, "ERROR: Cannot create file index.html!!!\naborting...\n");
1831  exit(1);
1832  }
1833 
1834  if(caa)
1835  {
1836  double totalCycles;
1837  if(!nehalem)
1838  {
1841  {
1842  fprintf(stderr, "(core) ERROR: One or more events for CAA missing!\naborting...\n");
1843  exit(1);
1844  }
1846  totalCycles = getTotalCycles();
1847  calc_core_deriv_values(totalCycles);
1849  if(!csv)
1850  {
1851  put_C_header(fp, core_caa_events_displ);
1852  put_C_modules(fp, core_caa_events_displ);
1853  }
1854  else
1855  {
1856  put_C_header_csv(fp, core_caa_events_displ);
1857  put_C_modules_csv(fp, core_caa_events_displ);
1858  }
1859  }
1860  else
1861  {
1864  {
1865  fprintf(stderr, "(nehalem) ERROR: One or more events for CAA missing!\naborting...\n");
1866  exit(1);
1867  }
1869  totalCycles = getTotalCycles();
1870  calc_nhm_deriv_values(totalCycles);
1872  if(!csv)
1873  {
1874  put_C_header(fp, nhm_caa_events_displ);
1875  put_C_modules(fp, nhm_caa_events_displ);
1876  }
1877  else
1878  {
1879  put_C_header_csv(fp, nhm_caa_events_displ);
1880  put_C_modules_csv(fp, nhm_caa_events_displ);
1881  }
1882  }
1883  if(!csv) put_C_footer(fp);
1884  fclose(fp);
1885  }
1886  else
1887  {
1888  if(!csv)
1889  {
1890  put_C_header(fp, C_events);
1891  put_C_modules(fp, C_events);
1892  put_C_footer(fp);
1893  }
1894  else
1895  {
1896  put_C_header_csv(fp, C_events);
1897  put_C_modules_csv(fp, C_events);
1898  }
1899  fclose(fp);
1900  }
1901  if(!csv)
1902  {
1903  char src[MAX_FILENAME_LENGTH];
1904  char dst[MAX_FILENAME_LENGTH];
1905  sprintf(src, "sorttable.js");
1906  sprintf(dst, "%s/HTML/sorttable.js", argv[1]);
1907  int fd_src = open(src, O_RDONLY);
1908  if(fd_src == -1)
1909  {
1910  fprintf(stderr, "ERROR: Cannot open file \"%s\"!\naborting...\n", src);
1911  exit(1);
1912  }
1913  int fd_dst = open(dst, O_WRONLY|O_CREAT|O_TRUNC, 0644);
1914  if(fd_dst == -1)
1915  {
1916  fprintf(stderr, "ERROR: Cannot open file \"%s\" (%s)!\naborting...\n", dst, strerror(errno));
1917  exit(1);
1918  }
1919  char c;
1920  while(read(fd_src, &c, 1))
1921  {
1922  write(fd_dst, &c, 1);
1923  }
1924  close(fd_dst);
1925  close(fd_src);
1926  }
1927  return 0;
1928 }
GAUDI_API long argc()
Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
Definition: System.cpp:526
void put_C_footer(FILE *fp)
void init_core_caa_events_displ()
tuple c
Definition: gaudirun.py:341
void put_C_modules(FILE *fp, std::vector< std::string > &columns)
list argv
Definition: gaudirun.py:192
void init_core_caa_events()
int read_S_file(const char *dir, const char *filename)
bool check_for_nhm_caa_events()
void calc_post_deriv_values()
void calc_nhm_deriv_values(double totalCycles)
void init_nhm_caa_events_displ()
int finalize_S_html_pages(const char *dir)
void put_C_header(FILE *fp, std::vector< std::string > &columns)
void init_nhm_caa_events()
void calc_core_deriv_values(double totalCycles)
int read_S_events(const char *dir, const char *filename)
#define MAX_FILENAME_LENGTH
void put_C_header_csv(FILE *fp, std::vector< std::string > &columns)
bool check_for_core_caa_events()
double getTotalCycles()
void put_C_modules_csv(FILE *fp, std::vector< std::string > &columns)
list i
Definition: ana.py:128
int read_C_file(const char *dir, const char *filename)
double normalize ( std::string  field,
double  value,
double  normalizeTo 
)

Definition at line 1666 of file pfm_gen_analysis.cpp.

1667 {
1668  double max = 0;
1669  double counter_value;
1670  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
1671  {
1672  counter_value = (it->second)[field];
1673  if(max < counter_value) max = counter_value;
1674  }
1675  if(value>0 && max>0 && normalizeTo>0)
1676  {
1677  return 1.*value/max*normalizeTo;
1678  }
1679  else return 0;
1680 }
struct GAUDI_API map
Parametrisation class for map-like implementation.
void put_C_footer ( FILE *  fp)

Definition at line 1619 of file pfm_gen_analysis.cpp.

1620 {
1621  fprintf(fp, "</table>\n</body>\n</html>\n");
1622  return;
1623 }
void put_C_header ( FILE *  fp,
std::vector< std::string > &  columns 
)

Definition at line 1565 of file pfm_gen_analysis.cpp.

1566 {
1567  fprintf(fp, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
1568  fprintf(fp, "<html>\n");
1569  fprintf(fp, "<head>\n");
1570  fprintf(fp, "<title>\n");
1571  fprintf(fp, "Analysis Result\n");
1572  fprintf(fp, "</title>\n");
1573  fprintf(fp, "<script src=\"sorttable.js\"></script>\n");
1574  fprintf(fp, "<style>\ntable.sortable thead {\nbackground-color:#eee;\ncolor:#666666;\nfont-weight:bold;\ncursor:default;\nfont-family:courier;\n}\n</style>\n");
1575  fprintf(fp, "</head>\n");
1576  fprintf(fp, "<body link=\"black\">\n");
1577  fprintf(fp, "<h1>RESULTS:</h1><br/>Click for detailed symbol view...<p/>\n");
1578  fprintf(fp, "<table class=\"sortable\" cellpadding=\"5\">\n");
1579  fprintf(fp, "<tr>\n");
1580  fprintf(fp, "<th>MODULE NAME</th>\n");
1581  for(std::vector<std::string>::const_iterator it = columns.begin(); it != columns.end(); ++it)
1582  {
1583  if(strlen(it->c_str())==0) fprintf(fp, "<th bgcolor=\"#FFFFFF\">&nbsp;</th>\n");
1584  else fprintf(fp, "<th>%s</th>\n", (*it).c_str());
1585  }
1586  fprintf(fp, "</tr>\n");
1587  return;
1588 }
void put_C_header_csv ( FILE *  fp,
std::vector< std::string > &  columns 
)

Definition at line 1625 of file pfm_gen_analysis.cpp.

1626 {
1627  fprintf(fp, "MODULE NAME");
1628  for(std::vector<std::string>::const_iterator it = columns.begin(); it != columns.end(); ++it)
1629  {
1630  if(strlen(it->c_str())==0) {}
1631  else fprintf(fp, ",%s", (*it).c_str());
1632  }
1633  fprintf(fp, "\n");
1634  return;
1635 }
void put_C_modules ( FILE *  fp,
std::vector< std::string > &  columns 
)

Definition at line 1590 of file pfm_gen_analysis.cpp.

1591 {
1592  int index = 0;
1593  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
1594  {
1595  if(index%2) fprintf(fp, "<tr bgcolor=\"#FFFFCC\">\n");
1596  else fprintf(fp, "<tr bgcolor=\"#CCFFCC\">\n");
1597  fprintf(fp, "<td style=\"font-family:monospace;font-size:large;color:Black\"><a href=\"%s.html\">%s</a></td>\n", (it->first).c_str(), (it->first).c_str());
1598  for(std::vector<std::string>::const_iterator jt = columns.begin(); jt != columns.end(); ++jt)
1599  {
1600  if(strlen(jt->c_str())==0)
1601  {
1602  fprintf(fp, "<td bgcolor=\"#FFFFFF\">&nbsp;</td>");
1603  }
1604  else
1605  {
1606  if((it->second).find(*jt) == (it->second).end())
1607  {
1608  fprintf(stderr, "ERROR: Cannot find derivate value \"%s\"!!!\naborting...\n", (*jt).c_str());
1609  exit(1);
1610  }
1611  fprintf(fp, "<td style=\"font-family:monospace;font-size:large;color:DarkBlue\" align=\"right\">%.2f</td>\n", (it->second)[*jt]);
1612  }
1613  }
1614  fprintf(fp, "</tr>\n");
1615  index++;
1616  }
1617 }
struct GAUDI_API map
Parametrisation class for map-like implementation.
tuple end
Definition: IOTest.py:101
void put_C_modules_csv ( FILE *  fp,
std::vector< std::string > &  columns 
)

Definition at line 1637 of file pfm_gen_analysis.cpp.

1638 {
1639  for(std::map<std::string, std::map<std::string, double> >::iterator it = C_modules.begin(); it != C_modules.end(); ++it)
1640  {
1641  fprintf(fp, "%s", (it->first).c_str()) ;
1642  for(std::vector<std::string>::const_iterator jt = columns.begin(); jt != columns.end(); ++jt)
1643  {
1644  if(strlen(jt->c_str())==0) {}
1645  else
1646  {
1647  if((it->second).find(*jt) == (it->second).end())
1648  {
1649  fprintf(stderr, "ERROR: Cannot find derivate value \"%s\"!!!\naborting...\n", (*jt).c_str());
1650  exit(1);
1651  }
1652  fprintf(fp, ",%.2f", (it->second)[*jt]);
1653  }
1654  }
1655  fprintf(fp, "\n");
1656  }
1657 }
struct GAUDI_API map
Parametrisation class for map-like implementation.
tuple end
Definition: IOTest.py:101
void put_S_module ( S_module cur_module,
const char *  dir 
)

Definition at line 1133 of file pfm_gen_analysis.cpp.

1134 {
1135  char module_name[MAX_MODULE_NAME_LENGTH];
1136  bzero(module_name, MAX_MODULE_NAME_LENGTH);
1137  strcpy(module_name, (cur_module->get_module_name()).c_str());
1138  char module_filename[MAX_FILENAME_LENGTH];
1139  bzero(module_filename, MAX_FILENAME_LENGTH);
1140  strcpy(module_filename, dir);
1141  strcat(module_filename, "/HTML/");
1142  strcat(module_filename, module_name);
1143  strcat(module_filename, ".html");
1144  char event[MAX_EVENT_NAME_LENGTH];
1145  bzero(event, MAX_EVENT_NAME_LENGTH);
1146  strcpy(event, (cur_module->get_event()).c_str());
1147  std::map<std::string, unsigned int>::iterator result = modules_tot_samples.find(cur_module->get_module_name());
1148  FILE *module_file;
1149  if(result == modules_tot_samples.end()) //not found
1150  {
1151  if((!strcmp(event, "UNHALTED_CORE_CYCLES") && !nehalem) || (!strcmp(event, "CPU_CLK_UNHALTED:THREAD_P") && nehalem))
1152  {
1153  modules_tot_samples.insert(std::pair<std::string, unsigned int>(cur_module->get_module_name(), cur_module->get_total_num_samples()));
1154  }
1155  else
1156  {
1157  modules_tot_samples.insert(std::pair<std::string, unsigned int>(cur_module->get_module_name(), 0));
1158  }
1159  module_file = fopen(module_filename, "w");
1160  if(module_file == NULL)
1161  {
1162  fprintf(stderr, "ERROR: Cannot create file %s!!!\naborting...\n", module_filename);
1163  exit(1);
1164  }
1165  fprintf(module_file, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
1166  fprintf(module_file, "<html>\n");
1167  fprintf(module_file, "<head>\n");
1168  fprintf(module_file, "<title>\n");
1169  fprintf(module_file, "%s\n", module_name);
1170  fprintf(module_file, "</title>\n");
1171  fprintf(module_file, "</head>\n");
1172  fprintf(module_file, "<body>\n");
1173  fprintf(module_file, "<h2>%s</h2><br/>Events Sampled:<br/>\n", module_name);
1174  fprintf(module_file, "<ul>\n");
1175  for(std::vector<std::string>::const_iterator it = S_events.begin(); it != S_events.end(); ++it)
1176  {
1177  fprintf(module_file, "<li><a href=\"#%s\">%s</a></li>\n", it->c_str(), it->c_str());
1178  }
1179  fprintf(module_file, "</ul>\n");
1180  }// if(result == modules_tot_samples.end()) //not found
1181  else
1182  {
1183  if((!strcmp(event, "UNHALTED_CORE_CYCLES") && !nehalem) || (!strcmp(event, "CPU_CLK_UNHALTED:THREAD_P") && nehalem))
1184  {
1185  modules_tot_samples[cur_module->get_module_name()] = cur_module->get_total_num_samples();
1186  }
1187  module_file = fopen(module_filename, "a");
1188  }//else:: if(result != modules_tot_samples.end()) //found!!
1189  char event_str[MAX_EVENT_NAME_LENGTH];
1190  bzero(event_str, MAX_EVENT_NAME_LENGTH);
1191  strcpy(event_str, event);
1192  if(cur_module->get_c_mask()>0)
1193  {
1194  sprintf(event_str, "%s CMASK=%d", event_str, cur_module->get_c_mask());
1195  }
1196  if(cur_module->get_inv_mask()>0)
1197  {
1198  sprintf(event_str, "%s INV=%d", event_str, cur_module->get_inv_mask());
1199  }
1200  fprintf(module_file, "<a name=\"%s\"><a>\n", event_str);
1201  fprintf(module_file, "<table cellpadding=\"5\">\n");
1202  fprintf(module_file, "<tr bgcolor=\"#EEEEEE\">\n");
1203  fprintf(module_file, "<th colspan=\"6\" align=\"left\">%s -- cmask: %u -- invmask: %u -- Total Samples: %u -- Sampling Period: %d</th>\n", event, cur_module->get_c_mask(), cur_module->get_inv_mask(), cur_module->get_total_num_samples(), cur_module->get_smpl_period());
1204  fprintf(module_file, "</tr>\n");
1205  fprintf(module_file, "<tr bgcolor=\"#EEEEEE\">\n");
1206  fprintf(module_file, "<th align=\"left\">Samples</th>\n");
1207  fprintf(module_file, "<th align=\"left\">Percentage</th>\n");
1208  fprintf(module_file, "<th align=\"left\">Symbol Name</th>\n");
1209  fprintf(module_file, "<th align=\"left\">Library Name</th>\n");
1210  fprintf(module_file, "<th align=\"left\">Complete Signature</th>\n");
1211  fprintf(module_file, "<th align=\"left\">Library Pathname</th>\n");
1212  fprintf(module_file, "</tr>\n");
1213  for(int j=0; j<20; j++)
1214  {
1215  char sym[MAX_SYM_LENGTH];
1216  char sym_mod[MAX_SYM_MOD_LENGTH];
1217  char lib[MAX_LIB_LENGTH];
1218  char lib_mod[MAX_LIB_MOD_LENGTH];
1219  char simple_sym[MAX_SIMPLE_SYM_LENGTH];
1220  char simple_sym_mod[MAX_SIMPLE_SYM_MOD_LENGTH];
1221  char simple_lib[MAX_SIMPLE_LIB_LENGTH];
1222  char simple_lib_mod[MAX_SIMPLE_LIB_MOD_LENGTH];
1223 
1224  bzero(sym, MAX_SYM_LENGTH);
1225  bzero(sym_mod, MAX_SYM_MOD_LENGTH);
1226  bzero(lib, MAX_LIB_LENGTH);
1227  bzero(lib_mod, MAX_LIB_MOD_LENGTH);
1228  bzero(simple_sym, MAX_SIMPLE_SYM_LENGTH);
1229  bzero(simple_sym_mod, MAX_SIMPLE_SYM_MOD_LENGTH);
1230  bzero(simple_lib, MAX_SIMPLE_LIB_LENGTH);
1231  bzero(simple_lib_mod, MAX_SIMPLE_LIB_MOD_LENGTH);
1232 
1233  char index[MAX_SAMPLE_INDEX_LENGTH];
1234  bzero(index, MAX_SAMPLE_INDEX_LENGTH);
1235  unsigned int value;
1236  bool res = cur_module->get_max(index, &value);
1237  if(!res) break;
1238  char *sym_end = strchr(index, '%');
1239  if(sym_end==NULL) //error
1240  {
1241  fprintf(stderr, "ERROR: Invalid sym and lib name! : %s\naborting...\n", index);
1242  exit(1);
1243  }
1244  strncpy(sym, index, strlen(index)-strlen(sym_end));
1245  strcpy(lib, sym_end+1);
1246  char temp[MAX_SYM_LENGTH];
1247  bzero(temp, MAX_SYM_LENGTH);
1248  strcpy(temp, sym);
1249  strcpy(simple_sym, (func_name(temp)));
1250  if(strrchr(lib, '/')!=NULL && *(strrchr(lib, '/')+1)!='\0')
1251  {
1252  strcpy(simple_lib, strrchr(lib, '/')+1);
1253  }
1254  else
1255  {
1256  strcpy(simple_lib, lib);
1257  }
1258  if(j%2!=0)
1259  {
1260  fprintf(module_file, "<tr bgcolor=\"#FFFFCC\">\n");
1261  }
1262  else
1263  {
1264  fprintf(module_file, "<tr bgcolor=\"#CCFFCC\">\n");
1265  }
1266  fprintf(module_file, "<td style=\"font-family:monospace;font-size:large;color:DarkBlue\">%u</td>\n", value);
1267  fprintf(module_file, "<td style=\"font-family:monospace;font-size:large;color:DarkBlue\">%f%%</td>\n", (((double)(value))/((double)(cur_module->get_total_num_samples())))*100);
1268  html_special_chars(simple_sym, simple_sym_mod);
1269  html_special_chars(simple_lib, simple_lib_mod);
1270  html_special_chars(sym, sym_mod);
1271  html_special_chars(lib, lib_mod);
1272  fprintf(module_file, "<td style=\"font-family:courier;\">%s</td>\n", simple_sym_mod);
1273  fprintf(module_file, "<td style=\"font-family:courier;\">%s</td>\n", simple_lib_mod);
1274  fprintf(module_file, "<td style=\"font-family:courier;\">%s</td>\n", sym_mod);
1275  fprintf(module_file, "<td style=\"font-family:courier;\">%s</td>\n</tr>\n", lib_mod);
1276  }
1277  fprintf(module_file, "</table><br/><br/>\n");
1278  int res = fclose(module_file);
1279  if(res)
1280  {
1281  fprintf(stderr, "ERROR: Cannot close file %s!!!\naborting...\n", module_filename);
1282  exit(1);
1283  }
1284  return;
1285 }
#define MAX_EVENT_NAME_LENGTH
unsigned int get_inv_mask()
const char * func_name(const char *demangled_symbol)
#define MAX_SAMPLE_INDEX_LENGTH
#define MAX_LIB_LENGTH
bool get_max(char *index, unsigned int *value)
#define MAX_SYM_LENGTH
unsigned int get_smpl_period()
#define MAX_SIMPLE_SYM_LENGTH
#define MAX_LIB_MOD_LENGTH
#define MAX_SIMPLE_LIB_MOD_LENGTH
void html_special_chars(const char *s, char *s_mod)
#define MAX_FILENAME_LENGTH
#define MAX_SIMPLE_SYM_MOD_LENGTH
std::string get_event()
unsigned int get_total_num_samples()
#define MAX_MODULE_NAME_LENGTH
#define MAX_SIMPLE_LIB_LENGTH
std::string get_module_name()
#define MAX_SYM_MOD_LENGTH
unsigned int get_c_mask()
int read_C_file ( const char *  dir,
const char *  filename 
)

Definition at line 1501 of file pfm_gen_analysis.cpp.

1502 {
1503  char event[MAX_EVENT_NAME_LENGTH];
1504  char arch[MAX_ARCH_NAME_LENGTH];
1505  char line[MAX_LINE_LENGTH];
1506  char cmask_str[MAX_CMASK_STR_LENGTH];
1507  char inv_str[MAX_INV_STR_LENGTH];
1508  char sp_str[MAX_SP_STR_LENGTH];
1509  char cur_module_name[MAX_MODULE_NAME_LENGTH];
1510  bzero(line, MAX_LINE_LENGTH);
1511  bzero(event, MAX_EVENT_NAME_LENGTH);
1512  bzero(cur_module_name, MAX_MODULE_NAME_LENGTH);
1513  bzero(arch, MAX_ARCH_NAME_LENGTH);
1514  bzero(line, MAX_LINE_LENGTH);
1515  bzero(cmask_str, MAX_CMASK_STR_LENGTH);
1516  bzero(inv_str, MAX_INV_STR_LENGTH);
1517  bzero(sp_str, MAX_SP_STR_LENGTH);
1518  int number_of_modules = 0;
1519  long cur_sum = 0;
1520  int no_of_values = 0;
1521  char path_name[MAX_FILENAME_LENGTH];
1522  bzero(path_name, MAX_FILENAME_LENGTH);
1523  strcpy(path_name, dir);
1524  strcat(path_name, "/");
1525  strcat(path_name, filename);
1526  FILE *fp = fopen(path_name, "r");
1527  fscanf(fp, "%s %s %s %s %s\n", arch, event, cmask_str, inv_str, sp_str);
1528  if(!strcmp(arch, "NHM")) nehalem = true; else nehalem = false;
1529  std::string event_str(event);
1530  if(atoi(cmask_str)>0)
1531  {
1532  event_str += " CMASK=";
1533  event_str += cmask_str;
1534  }
1535  if(atoi(inv_str)>0)
1536  {
1537  event_str += " INV=";
1538  event_str += inv_str;
1539  }
1540  C_events.push_back(event_str);
1541  while(fscanf(fp, "%s\n", line)!=EOF)
1542  {
1543  if(isalpha(line[0])) //module
1544  {
1545  if(number_of_modules>0)
1546  {
1547  C_modules[cur_module_name][event_str]=(double)cur_sum/no_of_values;
1548  cur_sum = 0;
1549  no_of_values = 0;
1550  }
1551  strcpy(cur_module_name, line);
1552  number_of_modules++;
1553  }
1554  else if(isdigit(line[0])) //value
1555  {
1556  cur_sum += strtol(line, NULL, 10);
1557  no_of_values++;
1558  }
1559  }
1560  C_modules[cur_module_name][event_str]=(double)cur_sum/no_of_values; //last module
1561  fclose(fp);
1562  return number_of_modules;
1563 }
#define MAX_EVENT_NAME_LENGTH
#define MAX_ARCH_NAME_LENGTH
#define MAX_LINE_LENGTH
#define MAX_SP_STR_LENGTH
#define MAX_CMASK_STR_LENGTH
#define MAX_FILENAME_LENGTH
#define MAX_INV_STR_LENGTH
#define MAX_MODULE_NAME_LENGTH
int line
Definition: ana.py:50
int read_S_events ( const char *  dir,
const char *  filename 
)

Definition at line 1421 of file pfm_gen_analysis.cpp.

1422 {
1423  char event[MAX_EVENT_NAME_LENGTH];
1424  char arch[MAX_ARCH_NAME_LENGTH];
1425  char line[MAX_LINE_LENGTH];
1426  char cmask_str[MAX_CMASK_STR_LENGTH];
1427  char inv_str[MAX_INV_STR_LENGTH];
1428  char sp_str[MAX_SP_STR_LENGTH];
1429  bzero(line, MAX_LINE_LENGTH);
1430  bzero(event, MAX_EVENT_NAME_LENGTH);
1431  bzero(arch, MAX_ARCH_NAME_LENGTH);
1432  bzero(cmask_str, MAX_CMASK_STR_LENGTH);
1433  bzero(inv_str, MAX_INV_STR_LENGTH);
1434  bzero(sp_str, MAX_SP_STR_LENGTH);
1435  char path_name[MAX_FILENAME_LENGTH];
1436  bzero(path_name, MAX_FILENAME_LENGTH);
1437  strcpy(path_name, dir);
1438  strcat(path_name, "/");
1439  strcat(path_name, filename);
1440  gzFile res_file = gzopen(path_name, "rb");
1441  if(res_file != NULL)
1442  {
1443  bzero(line, MAX_LINE_LENGTH);
1444  gzgets(res_file, line, MAX_LINE_LENGTH);
1445  if(line[strlen(line)-1]=='\n') line[strlen(line)-1]='\0';
1446  bzero(event, MAX_EVENT_NAME_LENGTH);
1447  sscanf(line, "%s %s %s %s %s\n", arch, event, cmask_str, inv_str, sp_str);
1448  std::string event_str(event);
1449  if(atoi(cmask_str)>0)
1450  {
1451  event_str += " CMASK=";
1452  event_str += cmask_str;
1453  }
1454  if(atoi(inv_str)>0)
1455  {
1456  event_str += " INV=";
1457  event_str += inv_str;
1458  }
1459  S_events.push_back(event_str);
1460  }// if(res_file != NULL)
1461  else
1462  {
1463  fprintf(stderr, "ERROR: Unable to open input file: %s\naborting...\n", filename);
1464  exit(1);
1465  }
1466  return 0;
1467 }
#define MAX_EVENT_NAME_LENGTH
#define MAX_ARCH_NAME_LENGTH
#define MAX_LINE_LENGTH
#define MAX_SP_STR_LENGTH
#define MAX_CMASK_STR_LENGTH
#define MAX_FILENAME_LENGTH
#define MAX_INV_STR_LENGTH
int line
Definition: ana.py:50
int read_S_file ( const char *  dir,
const char *  filename 
)

Definition at line 1294 of file pfm_gen_analysis.cpp.

1295 {
1296  char line[MAX_LINE_LENGTH];
1297  char event[MAX_EVENT_NAME_LENGTH];
1298  char arch[MAX_ARCH_NAME_LENGTH];
1299  unsigned int cmask;
1300  unsigned int inv;
1301  unsigned int sp;
1302  char cur_module_name[MAX_MODULE_NAME_LENGTH];
1303  bzero(line, MAX_LINE_LENGTH);
1304  bzero(event, MAX_EVENT_NAME_LENGTH);
1305  bzero(cur_module_name, MAX_MODULE_NAME_LENGTH);
1306  bzero(arch, MAX_ARCH_NAME_LENGTH);
1307 
1308  S_module *cur_module = new S_module();
1309  unsigned int module_num = 0;
1310 
1311  char path_name[MAX_FILENAME_LENGTH];
1312  bzero(path_name, MAX_FILENAME_LENGTH);
1313  strcpy(path_name, dir);
1314  strcat(path_name, "/");
1315  strcat(path_name, filename);
1316  gzFile res_file = gzopen(path_name, "rb");
1317 
1318  if(res_file != NULL)
1319  {
1320  bzero(line, MAX_LINE_LENGTH);
1321  gzgets(res_file, line, MAX_LINE_LENGTH);
1322  if(line[strlen(line)-1]=='\n') line[strlen(line)-1]='\0';
1323  bzero(event, MAX_EVENT_NAME_LENGTH);
1324  sscanf(line, "%s %s %u %u %u", arch, event, &cmask, &inv, &sp);
1325  if(!strcmp(arch, "NHM")) nehalem = true; else nehalem = false;
1326  bzero(line, MAX_LINE_LENGTH);
1327  while(gzgets(res_file, line, MAX_LINE_LENGTH)!=Z_NULL)
1328  {
1329  if(line[strlen(line)-1]=='\n') line[strlen(line)-1]='\0';
1330  if(strchr(line, ' ')==NULL) //module
1331  {
1332  if(module_num>0)
1333  {
1334  put_S_module(cur_module, dir);
1335  cur_module->clear();
1336  }
1337  module_num++;
1338  char *end_sym = strchr(line, '%');
1339  if(end_sym == NULL) //error
1340  {
1341  fprintf(stderr, "ERROR: Invalid module name. \nLINE: %s\naborting...\n", line);
1342  exit(1);
1343  }
1344  bzero(cur_module_name, MAX_MODULE_NAME_LENGTH);
1345  strncpy(cur_module_name, line, strlen(line)-strlen(end_sym));
1346  cur_module->init(cur_module_name, arch, event, cmask, inv, sp);
1347  cur_module->set_total(atoi(end_sym+1));
1348  } //module
1349  else //symbol, libName, libOffset, value
1350  {
1351  unsigned int value=0, libOffset=0;
1352  char symbol[MAX_SYM_LENGTH];
1353  char libName[MAX_LIB_LENGTH];
1354  char final_sym[MAX_SYM_MOD_LENGTH];
1355  char final_lib[MAX_LIB_MOD_LENGTH];
1356  bzero(symbol, MAX_SYM_LENGTH);
1357  bzero(libName, MAX_LIB_LENGTH);
1358  bzero(final_sym, MAX_SYM_MOD_LENGTH);
1359  bzero(final_lib, MAX_LIB_MOD_LENGTH);
1360 
1361  sscanf(line, "%s %s %u %u", symbol, libName, &libOffset, &value);
1362  char realPathName_s[FILENAME_MAX];
1363  bzero(realPathName_s, FILENAME_MAX);
1364  char *realPathName = realpath(libName, realPathName_s);
1365  if(realPathName!=NULL && strlen(realPathName)>0)
1366  {
1367  std::map<std::string, FileInfo>::iterator result;
1368  result = libsInfo.find(realPathName);
1369  if(result == libsInfo.end())
1370  {
1371  libsInfo[realPathName] = FileInfo(realPathName, true);
1372  }
1373  const char *temp_sym = libsInfo[realPathName].symbolByOffset(libOffset);
1374  if(temp_sym!=NULL && strlen(temp_sym)>0)
1375  {
1376  int status;
1377  char *demangled_symbol = abi::__cxa_demangle(temp_sym, NULL, NULL, &status);
1378  if(status == 0)
1379  {
1380  strcpy(final_sym, demangled_symbol);
1381  free(demangled_symbol);
1382  }
1383  else
1384  {
1385  strcpy(final_sym, temp_sym);
1386  }
1387  }
1388  else
1389  {
1390  strcpy(final_sym, "???");
1391  }
1392  strcpy(final_lib, realPathName);
1393  }
1394  else
1395  {
1396  strcpy(final_sym, symbol);
1397  strcpy(final_lib, libName);
1398  }
1399  char index[MAX_LINE_LENGTH];
1400  bzero(index, MAX_LINE_LENGTH);
1401  strcpy(index, final_sym);
1402  strcat(index, "%");
1403  strcat(index, final_lib);
1404  cur_module->add_sample(index, value);
1405  }// symbol, libName, libOffset, value
1406  bzero(line, MAX_LINE_LENGTH);
1407  }// while(gzgets(res_file, line, MAX_LINE_LENGTH)!=Z_NULL)
1408  put_S_module(cur_module, dir);//last module!
1409  cur_module->clear();
1410  gzclose(res_file);
1411  }// if(res_file != NULL)
1412  else
1413  {
1414  fprintf(stderr, "ERROR: Unable to open input file: %s\naborting...\n", filename);
1415  exit(1);
1416  }
1417  delete cur_module; //delete it!
1418  return 0;
1419 }
#define MAX_EVENT_NAME_LENGTH
#define MAX_LIB_LENGTH
void put_S_module(S_module *cur_module, const char *dir)
#define MAX_SYM_LENGTH
#define MAX_ARCH_NAME_LENGTH
void add_sample(const char *index, unsigned int value)
#define MAX_LINE_LENGTH
#define MAX_LIB_MOD_LENGTH
void init(const char *name, const char *architecture, const char *event_name, unsigned int c_mask, unsigned int inv_mask, unsigned int smpl_period)
void set_total(unsigned int total)
#define MAX_FILENAME_LENGTH
#define MAX_MODULE_NAME_LENGTH
int line
Definition: ana.py:50
#define MAX_SYM_MOD_LENGTH
bool skipString ( const char *  strptr,
const char *  srcbuffer,
const char **  dstbuffer 
)

Definition at line 153 of file pfm_gen_analysis.cpp.

154 {
155  if(strncmp(srcbuffer, strptr, strlen(strptr)))
156  {
157  return false;
158  }
159  *dstbuffer = srcbuffer + strlen(strptr);
160  return true;
161 }
bool skipWhitespaces ( const char *  srcbuffer,
const char **  destbuffer 
)

Definition at line 132 of file pfm_gen_analysis.cpp.

133 {
134  if(!isspace(*srcbuffer++))
135  {
136  return false;
137  }
138  while(isspace(*srcbuffer))
139  {
140  srcbuffer++;
141  }
142  *destbuffer = srcbuffer;
143  return true;
144 }