svn commit: r292043 - head/usr.sbin/pmcstudy

Randall Stewart rrs at FreeBSD.org
Thu Dec 10 01:52:30 UTC 2015


Author: rrs
Date: Thu Dec 10 01:52:29 2015
New Revision: 292043
URL: https://svnweb.freebsd.org/changeset/base/292043

Log:
  Fix several typos and bugs within pmcstudy. Also highlight the one SB test
  that is failing (and is likely a problem in the actual PMC defintions). Add
  to this also the -A option to run all canned tests.
  
  Sponsored by:	Netflix Inc.

Modified:
  head/usr.sbin/pmcstudy/pmcstudy.8
  head/usr.sbin/pmcstudy/pmcstudy.c

Modified: head/usr.sbin/pmcstudy/pmcstudy.8
==============================================================================
--- head/usr.sbin/pmcstudy/pmcstudy.8	Thu Dec 10 01:41:05 2015	(r292042)
+++ head/usr.sbin/pmcstudy/pmcstudy.8	Thu Dec 10 01:52:29 2015	(r292043)
@@ -32,7 +32,7 @@
 .Nd Perform various studies on a system's overall PMCs.
 .Sh SYNOPSIS
 .Nm
-.Oo Fl i Ar inputfile | Fl T | Fl v | Fl m Ar max | Fl e exp | Fl Ar E | Fl h | fl H Oc
+.Oo Fl i Ar inputfile | Fl A |  Fl T | Fl v | Fl m Ar max | Fl e exp | Fl Ar E | Fl h | fl H Oc
 .Nm
 .Fl i Ar inputfile
 .Nm
@@ -128,6 +128,8 @@ test like
 "UOPS_RETIRED.RETIRE_SLOTS / (4 * CPU_CLK_UNHALTED.THREAD_P)".
 .It Fl L
 This option will list all known PMCs and their abbreviation (%NNN).
+.It Fl A
+Run all canned tests.
 .El
 .Sh SEE ALSO
 .Xr pmc 3 ,

Modified: head/usr.sbin/pmcstudy/pmcstudy.c
==============================================================================
--- head/usr.sbin/pmcstudy/pmcstudy.c	Thu Dec 10 01:41:05 2015	(r292042)
+++ head/usr.sbin/pmcstudy/pmcstudy.c	Thu Dec 10 01:52:29 2015	(r292043)
@@ -38,6 +38,9 @@
 #include "eval_expr.h"
 __FBSDID("$FreeBSD$");
 
+static int max_pmc_counters = 1;
+static int run_all = 0;
+
 #define MAX_COUNTER_SLOTS 1024
 #define MAX_NLEN 64
 #define MAX_CPU 64
@@ -45,20 +48,20 @@ static int verbose = 0;
 
 extern char **environ;
 extern struct expression *master_exp;
-struct expression *master_exp = NULL;
+struct expression *master_exp=NULL;
 
 #define PMC_INITIAL_ALLOC 512
 extern char **valid_pmcs;
 char **valid_pmcs = NULL;
 extern int valid_pmc_cnt;
-int valid_pmc_cnt = 0;
+int valid_pmc_cnt=0;
 extern int pmc_allocated_cnt;
-int pmc_allocated_cnt = 0;
+int pmc_allocated_cnt=0;
 
 /*
  * The following two varients on popen and pclose with
  * the cavet that they get you the PID so that you
- * can supply it to pclose so it can send a SIGTERM
+ * can supply it to pclose so it can send a SIGTERM 
  *  to the process.
  */
 static FILE *
@@ -75,7 +78,7 @@ my_popen(const char *command, const char
 	if ((strcmp(dir, "r") != 0) &&
 	    (strcmp(dir, "w") != 0)) {
 		errno = EINVAL;
-		return (NULL);
+		return(NULL);
 	}
 	if (pipe(pdesin) < 0)
 		return (NULL);
@@ -94,14 +97,14 @@ my_popen(const char *command, const char
 	argv[3] = NULL;
 
 	switch (pid = fork()) {
-	case -1:		/* Error. */
+	case -1:			/* Error. */
 		(void)close(pdesin[0]);
 		(void)close(pdesin[1]);
 		(void)close(pdesout[0]);
 		(void)close(pdesout[1]);
 		return (NULL);
 		/* NOTREACHED */
-	case 0:		/* Child. */
+	case 0:				/* Child. */
 		/* Close out un-used sides */
 		(void)close(pdesin[1]);
 		(void)close(pdesout[0]);
@@ -129,8 +132,8 @@ my_popen(const char *command, const char
 		(void)close(pdesin[0]);
 		(void)close(pdesout[0]);
 		(void)close(pdesout[1]);
-		return (io_out);
-	} else {
+		return(io_out);
+ 	} else {
 		/* Prepare the input stream */
 		io_in = fdopen(pdesout[0], "r");
 		(void)close(pdesout[1]);
@@ -146,7 +149,7 @@ my_popen(const char *command, const char
  *	if already `pclosed', or waitpid returns an error.
  */
 static void
-my_pclose(FILE * io, pid_t the_pid)
+my_pclose(FILE *io, pid_t the_pid)
 {
 	int pstat;
 	pid_t pid;
@@ -164,41 +167,41 @@ my_pclose(FILE * io, pid_t the_pid)
 
 struct counters {
 	struct counters *next_cpu;
-	char counter_name[MAX_NLEN];	/* Name of counter */
-	int cpu;		/* CPU we are on */
-	int pos;		/* Index we are filling to. */
+	char counter_name[MAX_NLEN];		/* Name of counter */
+	int cpu;				/* CPU we are on */
+	int pos;				/* Index we are filling to. */
 	uint64_t vals[MAX_COUNTER_SLOTS];	/* Last 64 entries */
-	uint64_t sum;		/* Summary of entries */
+	uint64_t sum;				/* Summary of entries */
 };
 
 extern struct counters *glob_cpu[MAX_CPU];
 struct counters *glob_cpu[MAX_CPU];
 
 extern struct counters *cnts;
-struct counters *cnts = NULL;
+struct counters *cnts=NULL;
 
 extern int ncnts;
-int ncnts = 0;
+int ncnts=0;
 
-extern int (*expression) (struct counters *, int);
-int (*expression) (struct counters *, int);
+extern int (*expression)(struct counters *, int);
+int (*expression)(struct counters *, int);
 
-static const char *threshold = NULL;
+static const char *threshold=NULL;
 static const char *command;
 
 struct cpu_entry {
 	const char *name;
 	const char *thresh;
 	const char *command;
-	int (*func) (struct counters *, int);
+	int (*func)(struct counters *, int);
+	int counters_required;
 };
 
-
 struct cpu_type {
 	char cputype[32];
 	int number;
 	struct cpu_entry *ents;
-	void (*explain) (const char *name);
+	void (*explain)(const char *name);
 };
 extern struct cpu_type the_cpu;
 struct cpu_type the_cpu;
@@ -207,7 +210,6 @@ static void
 explain_name_sb(const char *name)
 {
 	const char *mythresh;
-
 	if (strcmp(name, "allocstall1") == 0) {
 		printf("Examine PARTIAL_RAT_STALLS.SLOW_LEA_WINDOW / CPU_CLK_UNHALTED.THREAD_P\n");
 		mythresh = "thresh > .05";
@@ -218,10 +220,10 @@ explain_name_sb(const char *name)
 		printf("Examine (20 * BR_MISP_RETIRED.ALL_BRANCHES)/CPU_CLK_UNHALTED.THREAD_P\n");
 		mythresh = "thresh >= .2";
 	} else if (strcmp(name, "splitload") == 0) {
-		printf("Examine MEM_UOP_RETIRED.SPLIT_LOADS * 5) / CPU_CLK_UNHALTED.THREAD_P\n");
+		printf("Examine MEM_UOPS_RETIRED.SPLIT_LOADS * 5) / CPU_CLK_UNHALTED.THREAD_P\n");
 		mythresh = "thresh >= .1";
 	} else if (strcmp(name, "splitstore") == 0) {
-		printf("Examine MEM_UOP_RETIRED.SPLIT_STORES / MEM_UOP_RETIRED.ALL_STORES\n");
+		printf("Examine MEM_UOPS_RETIRED.SPLIT_STORES / MEM_UOPS_RETIRED.ALL_STORES\n");
 		mythresh = "thresh >= .01";
 	} else if (strcmp(name, "contested") == 0) {
 		printf("Examine (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 60) / CPU_CLK_UNHALTED.THREAD_P\n");
@@ -279,7 +281,7 @@ explain_name_sb(const char *name)
 	} else {
 		printf("Unknown name:%s\n", name);
 		mythresh = "unknown entry";
-	}
+        }
 	printf("If the value printed is %s we may have the ability to improve performance\n", mythresh);
 }
 
@@ -287,7 +289,6 @@ static void
 explain_name_ib(const char *name)
 {
 	const char *mythresh;
-
 	if (strcmp(name, "br_miss") == 0) {
 		printf("Examine ((BR_MISP_RETIRED.ALL_BRANCHES /(BR_MISP_RETIRED.ALL_BRANCHES +\n");
 		printf("         MACHINE_CLEAR.COUNT) * ((UOPS_ISSUED.ANY - UOPS_RETIRED.RETIRE_SLOTS + 4 * INT_MISC.RECOVERY_CYCLES)\n");
@@ -307,7 +308,7 @@ explain_name_ib(const char *name)
 		mythresh = "thresh >= .2";
 	} else if (strcmp(name, "itlbmiss") == 0) {
 		printf("Examine ITLB_MISSES.WALK_DURATION / CPU_CLK_UNHALTED.THREAD_P\n");
-		mythresh = "thresh > .05";
+		mythresh = "thresh > .05"; 
 	} else if (strcmp(name, "icachemiss") == 0) {
 		printf("Examine (ICACHE.IFETCH_STALL - ITLB_MISSES.WALK_DURATION)/ CPU_CLK_UNHALTED.THREAD_P\n");
 		mythresh = "thresh > .05";
@@ -325,7 +326,7 @@ explain_name_ib(const char *name)
 		printf("         LD_BLOCKS.NO_SR)/CPU_CLK_UNHALTED.THREAD_P\n");
 		mythresh = "thresh >= .1";
 	} else if (strcmp(name, "splitstore") == 0) {
-		printf("Examine MEM_UOP_RETIRED.SPLIT_STORES / MEM_UOP_RETIRED.ALL_STORES\n");
+		printf("Examine MEM_UOPS_RETIRED.SPLIT_STORES / MEM_UOPS_RETIRED.ALL_STORES\n");
 		mythresh = "thresh >= .01";
 	} else if (strcmp(name, "aliasing_4k") == 0) {
 		printf("Examine (LD_BLOCKS_PARTIAL.ADDRESS_ALIAS * 5) / CPU_CLK_UNHALTED.THREAD_P\n");
@@ -362,7 +363,7 @@ explain_name_ib(const char *name)
 	} else {
 		printf("Unknown name:%s\n", name);
 		mythresh = "unknown entry";
-	}
+        }
 	printf("If the value printed is %s we may have the ability to improve performance\n", mythresh);
 }
 
@@ -371,7 +372,6 @@ static void
 explain_name_has(const char *name)
 {
 	const char *mythresh;
-
 	if (strcmp(name, "eff1") == 0) {
 		printf("Examine (UOPS_RETIRED.RETIRE_SLOTS)/(4 *CPU_CLK_UNHALTED.THREAD_P)\n");
 		mythresh = "thresh < .75";
@@ -380,7 +380,7 @@ explain_name_has(const char *name)
 		mythresh = "thresh > 1.0";
 	} else if (strcmp(name, "itlbmiss") == 0) {
 		printf("Examine ITLB_MISSES.WALK_DURATION / CPU_CLK_UNHALTED.THREAD_P\n");
-		mythresh = "thresh > .05";
+		mythresh = "thresh > .05"; 
 	} else if (strcmp(name, "icachemiss") == 0) {
 		printf("Examine (36 * ICACHE.MISSES)/ CPU_CLK_UNHALTED.THREAD_P\n");
 		mythresh = "thresh > .05";
@@ -406,10 +406,10 @@ explain_name_has(const char *name)
 		printf("Examine (LD_BLOCKS_STORE_FORWARD * 13) / CPU_CLK_UNHALTED.THREAD_P\n");
 		mythresh = "thresh >= .05";
 	} else if (strcmp(name, "splitload") == 0) {
-		printf("Examine  (MEM_UOP_RETIRED.SPLIT_LOADS * 5) / CPU_CLK_UNHALTED.THREAD_P\n");
+		printf("Examine  (MEM_UOPS_RETIRED.SPLIT_LOADS * 5) / CPU_CLK_UNHALTED.THREAD_P\n");
 		mythresh = "thresh >= .1";
 	} else if (strcmp(name, "splitstore") == 0) {
-		printf("Examine MEM_UOP_RETIRED.SPLIT_STORES / MEM_UOP_RETIRED.ALL_STORES\n");
+		printf("Examine MEM_UOPS_RETIRED.SPLIT_STORES / MEM_UOPS_RETIRED.ALL_STORES\n");
 		mythresh = "thresh >= .01";
 	} else if (strcmp(name, "aliasing_4k") == 0) {
 		printf("Examine (LD_BLOCKS_PARTIAL.ADDRESS_ALIAS * 5) / CPU_CLK_UNHALTED.THREAD_P\n");
@@ -442,10 +442,12 @@ explain_name_has(const char *name)
 	} else {
 		printf("Unknown name:%s\n", name);
 		mythresh = "unknown entry";
-	}
+        }
 	printf("If the value printed is %s we may have the ability to improve performance\n", mythresh);
 }
 
+
+
 static struct counters *
 find_counter(struct counters *base, const char *name)
 {
@@ -454,16 +456,16 @@ find_counter(struct counters *base, cons
 
 	at = base;
 	len = strlen(name);
-	while (at) {
+	while(at) {
 		if (strncmp(at->counter_name, name, len) == 0) {
-			return (at);
+			return(at);
 		}
 		at = at->next_cpu;
 	}
 	printf("Can't find counter %s\n", name);
 	printf("We have:\n");
 	at = base;
-	while (at) {
+	while(at) {
 		printf("- %s\n", at->counter_name);
 		at = at->next_cpu;
 	}
@@ -478,7 +480,6 @@ allocstall1(struct counters *cpu, int po
 	struct counters *partial;
 	struct counters *unhalt;
 	double un, par, res;
-
 	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
 	partial = find_counter(cpu, "PARTIAL_RAT_STALLS.SLOW_LEA_WINDOW");
 	if (pos != -1) {
@@ -488,9 +489,9 @@ allocstall1(struct counters *cpu, int po
 		par = partial->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = par / un;
+	res = par/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
@@ -501,7 +502,6 @@ allocstall2(struct counters *cpu, int po
 	struct counters *partial;
 	struct counters *unhalt;
 	double un, par, res;
-
 	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
 	partial = find_counter(cpu, "PARTIAL_RAT_STALLS.FLAGS_MERGE_UOP");
 	if (pos != -1) {
@@ -511,9 +511,9 @@ allocstall2(struct counters *cpu, int po
 		par = partial->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = par / un;
+	res = par/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
@@ -522,14 +522,12 @@ br_mispredict(struct counters *cpu, int 
 	struct counters *brctr;
 	struct counters *unhalt;
 	int ret;
-
 /*  3  - (20 * BR_MISP_RETIRED.ALL_BRANCHES)/CPU_CLK_UNHALTED.THREAD_P (thresh >= .2) */
 	double br, un, con, res;
-
 	con = 20.0;
-
+	
 	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
-	brctr = find_counter(cpu, "BR_MISP_RETIRED.ALL_BRANCHES");
+        brctr = find_counter(cpu, "BR_MISP_RETIRED.ALL_BRANCHES");
 	if (pos != -1) {
 		br = brctr->vals[pos] * 1.0;
 		un = unhalt->vals[pos] * 1.0;
@@ -537,9 +535,9 @@ br_mispredict(struct counters *cpu, int 
 		br = brctr->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (con * br) / un;
-	ret = printf("%1.3f", res);
-	return (ret);
+	res = (con * br)/un;
+ 	ret = printf("%1.3f", res);
+	return(ret);
 }
 
 static int
@@ -549,25 +547,22 @@ br_mispredictib(struct counters *cpu, in
 	struct counters *unhalt;
 	struct counters *clear, *clear2, *clear3;
 	struct counters *uops;
-	struct counters *recv;
+	struct counters *recv;	
 	struct counters *iss;
-
 /*	  "pmcstat -s CPU_CLK_UNHALTED.THREAD_P -s BR_MISP_RETIRED.ALL_BRANCHES -s MACHINE_CLEARS.MEMORY_ORDERING -s MACHINE_CLEARS.SMC -s MACHINE_CLEARS.MASKMOV -s UOPS_ISSUED.ANY -s UOPS_RETIRED.RETIRE_SLOTS -s INT_MISC.RECOVERY_CYCLES -w 1",*/
 	int ret;
-
-	/*
-	 * (BR_MISP_RETIRED.ALL_BRANCHES / (BR_MISP_RETIRED.ALL_BRANCHES +
-	 * MACHINE_CLEAR.COUNT) * ((UOPS_ISSUED.ANY -
-	 * UOPS_RETIRED.RETIRE_SLOTS + 4 * INT_MISC.RECOVERY_CYCLES) / (4 *
-	 * CPU_CLK_UNHALTED.THREAD)))
-	 * 
+        /*  
+	 * (BR_MISP_RETIRED.ALL_BRANCHES / 
+	 *         (BR_MISP_RETIRED.ALL_BRANCHES +
+	 *          MACHINE_CLEAR.COUNT) * 
+	 *	   ((UOPS_ISSUED.ANY - UOPS_RETIRED.RETIRE_SLOTS + 4 * INT_MISC.RECOVERY_CYCLES) / (4 * CPU_CLK_UNHALTED.THREAD)))
+	 *
 	 */
 	double br, cl, cl2, cl3, uo, re, un, con, res, is;
-
 	con = 4.0;
-
+	
 	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
-	brctr = find_counter(cpu, "BR_MISP_RETIRED.ALL_BRANCHES");
+        brctr = find_counter(cpu, "BR_MISP_RETIRED.ALL_BRANCHES");
 	clear = find_counter(cpu, "MACHINE_CLEARS.MEMORY_ORDERING");
 	clear2 = find_counter(cpu, "MACHINE_CLEARS.SMC");
 	clear3 = find_counter(cpu, "MACHINE_CLEARS.MASKMOV");
@@ -593,11 +588,12 @@ br_mispredictib(struct counters *cpu, in
 		is = iss->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (br / (br + cl + cl2 + cl3) * ((is - uo + con * re) / (con * un)));
-	ret = printf("%1.3f", res);
-	return (ret);
+	res = (br/(br + cl + cl2 + cl3) * ((is - uo + con * re) / (con * un)));
+ 	ret = printf("%1.3f", res);
+	return(ret);
 }
 
+
 static int
 br_mispredict_broad(struct counters *cpu, int pos)
 {
@@ -611,9 +607,9 @@ br_mispredict_broad(struct counters *cpu
 	double br, cl, uo, uo_r, re, con, un, res;
 
 	con = 4.0;
-
+	
 	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
-	brctr = find_counter(cpu, "BR_MISP_RETIRED.ALL_BRANCHES");
+        brctr = find_counter(cpu, "BR_MISP_RETIRED.ALL_BRANCHES");
 	clear = find_counter(cpu, "MACHINE_CLEARS.CYCLES");
 	uops = find_counter(cpu, "UOPS_ISSUED.ANY");
 	uops_ret = find_counter(cpu, "UOPS_RETIRED.RETIRE_SLOTS");
@@ -635,8 +631,8 @@ br_mispredict_broad(struct counters *cpu
 		re = recv->sum * 1.0;
 	}
 	res = br / (br + cl) * (uo - uo_r + con * re) / (un * con);
-	ret = printf("%1.3f", res);
-	return (ret);
+ 	ret = printf("%1.3f", res);
+	return(ret);
 }
 
 static int
@@ -647,12 +643,9 @@ splitloadib(struct counters *cpu, int po
 	struct counters *l1d, *ldblock;
 	struct counters *unhalt;
 	double un, memd, res, l1, ldb;
-
-	/*
-	 * ((L1D_PEND_MISS.PENDING / MEM_LOAD_UOPS_RETIRED.L1_MISS) *
-	 * LD_BLOCKS.NO_SR) / CPU_CLK_UNHALTED.THREAD_P "pmcstat -s
-	 * CPU_CLK_UNHALTED.THREAD_P -s L1D_PEND_MISS.PENDING -s
-	 * MEM_LOAD_UOPS_RETIRED.L1_MISS -s LD_BLOCKS.NO_SR -w 1",
+        /*  
+	 * ((L1D_PEND_MISS.PENDING / MEM_LOAD_UOPS_RETIRED.L1_MISS) * LD_BLOCKS.NO_SR) / CPU_CLK_UNHALTED.THREAD_P
+	 * "pmcstat -s CPU_CLK_UNHALTED.THREAD_P -s L1D_PEND_MISS.PENDING -s MEM_LOAD_UOPS_RETIRED.L1_MISS -s LD_BLOCKS.NO_SR -w 1",
 	 */
 
 	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
@@ -670,11 +663,12 @@ splitloadib(struct counters *cpu, int po
 		ldb = ldblock->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = ((l1 / memd) * ldb) / un;
+	res = ((l1 / memd) * ldb)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
+
 static int
 splitload(struct counters *cpu, int pos)
 {
@@ -682,7 +676,31 @@ splitload(struct counters *cpu, int pos)
 	struct counters *mem;
 	struct counters *unhalt;
 	double con, un, memd, res;
+/*  4  - (MEM_UOPS_RETIRED.SPLIT_LOADS * 5) / CPU_CLK_UNHALTED.THREAD_P (thresh >= .1)*/
+
+	con = 5.0;
+	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
+	mem = find_counter(cpu, "MEM_UOPS_RETIRED.SPLIT_LOADS");
+	if (pos != -1) {
+		memd = mem->vals[pos] * 1.0;
+		un = unhalt->vals[pos] * 1.0;
+	} else {
+		memd = mem->sum * 1.0;
+		un = unhalt->sum * 1.0;
+	}
+	res = (memd * con)/un;
+	ret = printf("%1.3f", res);
+	return(ret);
+}
 
+
+static int
+splitload_sb(struct counters *cpu, int pos)
+{
+	int ret;
+	struct counters *mem;
+	struct counters *unhalt;
+	double con, un, memd, res;
 /*  4  - (MEM_UOP_RETIRED.SPLIT_LOADS * 5) / CPU_CLK_UNHALTED.THREAD_P (thresh >= .1)*/
 
 	con = 5.0;
@@ -695,23 +713,20 @@ splitload(struct counters *cpu, int pos)
 		memd = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (memd * con) / un;
+	res = (memd * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
+
 static int
-splitstore(struct counters *cpu, int pos)
+splitstore_sb(struct counters *cpu, int pos)
 {
-	/*
-	 * 5  - MEM_UOP_RETIRED.SPLIT_STORES / MEM_UOP_RETIRED.ALL_STORES
-	 * (thresh > 0.01)
-	 */
+        /*  5  - MEM_UOP_RETIRED.SPLIT_STORES / MEM_UOP_RETIRED.ALL_STORES (thresh > 0.01) */
 	int ret;
 	struct counters *mem_split;
 	struct counters *mem_stores;
 	double memsplit, memstore, res;
-
 	mem_split = find_counter(cpu, "MEM_UOP_RETIRED.SPLIT_STORES");
 	mem_stores = find_counter(cpu, "MEM_UOP_RETIRED.ALL_STORES");
 	if (pos != -1) {
@@ -721,19 +736,40 @@ splitstore(struct counters *cpu, int pos
 		memsplit = mem_split->sum * 1.0;
 		memstore = mem_stores->sum * 1.0;
 	}
-	res = memsplit / memstore;
+	res = memsplit/memstore;
+	ret = printf("%1.3f", res);
+	return(ret);
+}
+
+
+
+static int
+splitstore(struct counters *cpu, int pos)
+{
+        /*  5  - MEM_UOPS_RETIRED.SPLIT_STORES / MEM_UOPS_RETIRED.ALL_STORES (thresh > 0.01) */
+	int ret;
+	struct counters *mem_split;
+	struct counters *mem_stores;
+	double memsplit, memstore, res;
+	mem_split = find_counter(cpu, "MEM_UOPS_RETIRED.SPLIT_STORES");
+	mem_stores = find_counter(cpu, "MEM_UOPS_RETIRED.ALL_STORES");
+	if (pos != -1) {
+		memsplit = mem_split->vals[pos] * 1.0;
+		memstore = mem_stores->vals[pos] * 1.0;
+	} else {
+		memsplit = mem_split->sum * 1.0;
+		memstore = mem_stores->sum * 1.0;
+	}
+	res = memsplit/memstore;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 
 static int
 contested(struct counters *cpu, int pos)
 {
-	/*
-	 * 6  - (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 60) /
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >.05)
-	 */
+        /*  6  - (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 60) / CPU_CLK_UNHALTED.THREAD_P (thresh >.05) */
 	int ret;
 	struct counters *mem;
 	struct counters *unhalt;
@@ -749,18 +785,15 @@ contested(struct counters *cpu, int pos)
 		memd = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (memd * con) / un;
+	res = (memd * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
 contested_has(struct counters *cpu, int pos)
 {
-	/*
-	 * 6  - (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 84) /
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >.05)
-	 */
+        /*  6  - (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 84) / CPU_CLK_UNHALTED.THREAD_P (thresh >.05) */
 	int ret;
 	struct counters *mem;
 	struct counters *unhalt;
@@ -776,18 +809,15 @@ contested_has(struct counters *cpu, int 
 		memd = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (memd * con) / un;
+	res = (memd * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
 contestedbroad(struct counters *cpu, int pos)
 {
-	/*
-	 * 6  - (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 84) /
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >.05)
-	 */
+        /*  6  - (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 84) / CPU_CLK_UNHALTED.THREAD_P (thresh >.05) */
 	int ret;
 	struct counters *mem;
 	struct counters *mem2;
@@ -797,7 +827,7 @@ contestedbroad(struct counters *cpu, int
 	con = 84.0;
 	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
 	mem = find_counter(cpu, "MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM");
-	mem2 = find_counter(cpu, "MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_MISS");
+	mem2 = find_counter(cpu,"MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_MISS");
 
 	if (pos != -1) {
 		memd = mem->vals[pos] * 1.0;
@@ -808,19 +838,16 @@ contestedbroad(struct counters *cpu, int
 		memtoo = mem2->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = ((memd * con) + memtoo) / un;
+	res = ((memd * con) + memtoo)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 
 static int
 blockstoreforward(struct counters *cpu, int pos)
 {
-	/*
-	 * 7  - (LD_BLOCKS_STORE_FORWARD * 13) / CPU_CLK_UNHALTED.THREAD_P
-	 * (thresh >= .05)
-	 */
+        /*  7  - (LD_BLOCKS_STORE_FORWARD * 13) / CPU_CLK_UNHALTED.THREAD_P (thresh >= .05)*/
 	int ret;
 	struct counters *ldb;
 	struct counters *unhalt;
@@ -836,19 +863,17 @@ blockstoreforward(struct counters *cpu, 
 		ld = ldb->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (ld * con) / un;
+	res = (ld * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
 cache2(struct counters *cpu, int pos)
 {
-	/*
-	 * ** Suspect *** 8  - ((MEM_LOAD_RETIRED.L3_HIT * 26) +
-	 * (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HIT * 43) +
-	 * (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 60)) /
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >.2)
+	/* ** Suspect ***
+	 *  8  - ((MEM_LOAD_RETIRED.L3_HIT * 26) + (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HIT * 43) +
+	 *        (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 60)) / CPU_CLK_UNHALTED.THREAD_P (thresh >.2)
 	 */
 	int ret;
 	struct counters *mem1, *mem2, *mem3;
@@ -874,17 +899,16 @@ cache2(struct counters *cpu, int pos)
 		me_3 = mem3->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = ((me_1 * con1) + (me_2 * con2) + (me_3 * con3)) / un;
+	res = ((me_1 * con1) + (me_2 * con2) + (me_3 * con3))/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
 datasharing(struct counters *cpu, int pos)
 {
-	/*
-	 * (MEM_LOAD_UOPS_L3_HIT_RETIRED.XSNP_HIT * 43)/
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >.2)
+	/* 
+	 * (MEM_LOAD_UOPS_L3_HIT_RETIRED.XSNP_HIT * 43)/ CPU_CLK_UNHALTED.THREAD_P (thresh >.2)
 	 */
 	int ret;
 	struct counters *mem;
@@ -901,9 +925,9 @@ datasharing(struct counters *cpu, int po
 		me = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (me * con) / un;
+	res = (me * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 
 }
 
@@ -911,9 +935,8 @@ datasharing(struct counters *cpu, int po
 static int
 datasharing_has(struct counters *cpu, int pos)
 {
-	/*
-	 * (MEM_LOAD_UOPS_L3_HIT_RETIRED.XSNP_HIT * 43)/
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >.2)
+	/* 
+	 * (MEM_LOAD_UOPS_L3_HIT_RETIRED.XSNP_HIT * 43)/ CPU_CLK_UNHALTED.THREAD_P (thresh >.2)
 	 */
 	int ret;
 	struct counters *mem;
@@ -930,9 +953,9 @@ datasharing_has(struct counters *cpu, in
 		me = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (me * con) / un;
+	res = (me * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 
 }
 
@@ -940,9 +963,8 @@ datasharing_has(struct counters *cpu, in
 static int
 cache2ib(struct counters *cpu, int pos)
 {
-	/*
-	 * (29 * MEM_LOAD_UOPS_RETIRED.LLC_HIT / CPU_CLK_UNHALTED.THREAD_P
-	 * (thresh >.2)
+        /*
+	 *  (29 * MEM_LOAD_UOPS_RETIRED.LLC_HIT / CPU_CLK_UNHALTED.THREAD_P (thresh >.2)
 	 */
 	int ret;
 	struct counters *mem;
@@ -959,9 +981,9 @@ cache2ib(struct counters *cpu, int pos)
 		me = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (con * me) / un;
+	res = (con * me)/un; 
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
@@ -969,9 +991,9 @@ cache2has(struct counters *cpu, int pos)
 {
 	/*
 	 * Examine ((MEM_LOAD_UOPS_RETIRED.LLC_HIT * 36) + \
-	 * (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HIT * 72) +
-	 * (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 84)) /
-	 * CPU_CLK_UNHALTED.THREAD_P
+	 *          (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HIT * 72) +
+	 *          (MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM * 84))
+	 *           / CPU_CLK_UNHALTED.THREAD_P
 	 */
 	int ret;
 	struct counters *mem1, *mem2, *mem3;
@@ -996,17 +1018,17 @@ cache2has(struct counters *cpu, int pos)
 		me3 = mem3->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = ((me1 * con1) + (me2 * con2) + (me3 * con3)) / un;
+	res = ((me1 * con1) + (me2 * con2) + (me3 * con3))/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
+
 static int
 cache2broad(struct counters *cpu, int pos)
 {
-	/*
-	 * (29 * MEM_LOAD_UOPS_RETIRED.LLC_HIT / CPU_CLK_UNHALTED.THREAD_P
-	 * (thresh >.2)
+        /*
+	 *  (29 * MEM_LOAD_UOPS_RETIRED.LLC_HIT / CPU_CLK_UNHALTED.THREAD_P (thresh >.2)
 	 */
 	int ret;
 	struct counters *mem;
@@ -1023,19 +1045,16 @@ cache2broad(struct counters *cpu, int po
 		me = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (con * me) / un;
+	res = (con * me)/un; 
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 
 static int
 cache1(struct counters *cpu, int pos)
 {
-	/*
-	 * 9  - (MEM_LOAD_UOPS_MISC_RETIRED.LLC_MISS * 180) /
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >= .2)
-	 */
+	/*  9  - (MEM_LOAD_UOPS_MISC_RETIRED.LLC_MISS * 180) / CPU_CLK_UNHALTED.THREAD_P (thresh >= .2) */
 	int ret;
 	struct counters *mem;
 	struct counters *unhalt;
@@ -1051,18 +1070,15 @@ cache1(struct counters *cpu, int pos)
 		me = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (me * con) / un;
+	res = (me * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
 cache1ib(struct counters *cpu, int pos)
 {
-	/*
-	 * 9  - (MEM_LOAD_UOPS_L3_MISS_RETIRED.LCOAL_DRAM * 180) /
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >= .2)
-	 */
+	/*  9  - (MEM_LOAD_UOPS_L3_MISS_RETIRED.LCOAL_DRAM * 180) / CPU_CLK_UNHALTED.THREAD_P (thresh >= .2) */
 	int ret;
 	struct counters *mem;
 	struct counters *unhalt;
@@ -1078,19 +1094,16 @@ cache1ib(struct counters *cpu, int pos)
 		me = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (me * con) / un;
+	res = (me * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 
 static int
 cache1broad(struct counters *cpu, int pos)
 {
-	/*
-	 * 9  - (MEM_LOAD_UOPS_L3_MISS_RETIRED.LCOAL_DRAM * 180) /
-	 * CPU_CLK_UNHALTED.THREAD_P (thresh >= .2)
-	 */
+	/*  9  - (MEM_LOAD_UOPS_L3_MISS_RETIRED.LCOAL_DRAM * 180) / CPU_CLK_UNHALTED.THREAD_P (thresh >= .2) */
 	int ret;
 	struct counters *mem;
 	struct counters *unhalt;
@@ -1106,20 +1119,16 @@ cache1broad(struct counters *cpu, int po
 		me = mem->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (me * con) / un;
+	res = (me * con)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 
 static int
 dtlb_missload(struct counters *cpu, int pos)
 {
-	/*
-	 * 10  - ((DTLB_LOAD_MISSES.STLB_HIT * 7) +
-	 * DTLB_LOAD_MISSES.WALK_DURATION) / CPU_CLK_UNHALTED.THREAD_P (t
-	 * >=.1)
-	 */
+	/* 10  - ((DTLB_LOAD_MISSES.STLB_HIT * 7) + DTLB_LOAD_MISSES.WALK_DURATION) / CPU_CLK_UNHALTED.THREAD_P (t >=.1) */
 	int ret;
 	struct counters *dtlb_m, *dtlb_d;
 	struct counters *unhalt;
@@ -1138,40 +1147,39 @@ dtlb_missload(struct counters *cpu, int 
 		d2 = dtlb_d->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = ((d1 * con) + d2) / un;
+	res = ((d1 * con) + d2)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 static int
 dtlb_missstore(struct counters *cpu, int pos)
 {
-	/*
-	 * ((DTLB_STORE_MISSES.STLB_HIT * 7) +
-	 * DTLB_STORE_MISSES.WALK_DURATION) / CPU_CLK_UNHALTED.THREAD_P (t
-	 * >= .1)
-	 */
-	int ret;
-	struct counters *dtsb_m, *dtsb_d;
-	struct counters *unhalt;
-	double con, un, d1, d2, res;
-
-	con = 7.0;
-	unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
-	dtsb_m = find_counter(cpu, "DTLB_STORE_MISSES.STLB_HIT");
-	dtsb_d = find_counter(cpu, "DTLB_STORE_MISSES.WALK_DURATION");
-	if (pos != -1) {
-		d1 = dtsb_m->vals[pos] * 1.0;
-		d2 = dtsb_d->vals[pos] * 1.0;
-		un = unhalt->vals[pos] * 1.0;
-	} else {
-		d1 = dtsb_m->sum * 1.0;
-		d2 = dtsb_d->sum * 1.0;
-		un = unhalt->sum * 1.0;
-	}
-	res = ((d1 * con) + d2) / un;
-	ret = printf("%1.3f", res);
-	return (ret);
+        /* 
+	 * ((DTLB_STORE_MISSES.STLB_HIT * 7) + DTLB_STORE_MISSES.WALK_DURATION) / 
+	 * CPU_CLK_UNHALTED.THREAD_P (t >= .1) 
+	 */
+        int ret;
+        struct counters *dtsb_m, *dtsb_d;
+        struct counters *unhalt;
+        double con, un, d1, d2, res;
+
+        con = 7.0;
+        unhalt = find_counter(cpu, "CPU_CLK_UNHALTED.THREAD_P");
+        dtsb_m = find_counter(cpu, "DTLB_STORE_MISSES.STLB_HIT");
+        dtsb_d = find_counter(cpu, "DTLB_STORE_MISSES.WALK_DURATION");
+        if (pos != -1) {
+                d1 = dtsb_m->vals[pos] * 1.0;
+                d2 = dtsb_d->vals[pos] * 1.0;
+                un = unhalt->vals[pos] * 1.0;
+        } else {
+                d1 = dtsb_m->sum * 1.0;
+                d2 = dtsb_d->sum * 1.0;
+                un = unhalt->sum * 1.0;
+        }
+        res = ((d1 * con) + d2)/un;
+        ret = printf("%1.3f", res);
+        return(ret);
 }
 
 static int
@@ -1192,19 +1200,16 @@ itlb_miss(struct counters *cpu, int pos)
 		d1 = itlb->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = d1 / un;
+	res = d1/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 
 static int
 itlb_miss_broad(struct counters *cpu, int pos)
 {
-	/*
-	 * (7 * ITLB_MISSES.STLB_HIT_4K + ITLB_MISSES.WALK_DURATION) /
-	 * CPU_CLK_UNTHREAD_P
-	 */
+	/* (7 * ITLB_MISSES.STLB_HIT_4K + ITLB_MISSES.WALK_DURATION) / CPU_CLK_UNTHREAD_P   */
 	int ret;
 	struct counters *itlb;
 	struct counters *unhalt;
@@ -1223,19 +1228,16 @@ itlb_miss_broad(struct counters *cpu, in
 		un = unhalt->sum * 1.0;
 		k = four_k->sum * 1.0;
 	}
-	res = (7.0 * k + d1) / un;
+	res = (7.0 * k + d1)/un;
 	ret = printf("%1.3f", res);
-	return (ret);
+	return(ret);
 }
 
 
 static int
 icache_miss(struct counters *cpu, int pos)
 {
-	/*
-	 * (ICACHE.IFETCH_STALL - ITLB_MISSES.WALK_DURATION) /
-	 * CPU_CLK_UNHALTED.THREAD_P IB
-	 */
+	/* (ICACHE.IFETCH_STALL - ITLB_MISSES.WALK_DURATION) / CPU_CLK_UNHALTED.THREAD_P IB */
 
 	int ret;
 	struct counters *itlb, *icache;
@@ -1254,9 +1256,9 @@ icache_miss(struct counters *cpu, int po
 		ic = icache->sum * 1.0;
 		un = unhalt->sum * 1.0;
 	}
-	res = (ic - d1) / un;
+	res = (ic-d1)/un;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-head mailing list