📄 cmdmain.c
字号:
} }}/* * Produce a summary line for parameters with typical unsigned integer value. */voidsummary_uint (const struct arglist *adesc, FILE *f){ fprintf (f, "%s %u\n", adesc->optstring, *(unsigned int *)adesc->var);}/* * Produce a summary line for parameters with typical unsigned integer value, * handled as a double for extended range. */voidsummary_uintd (const struct arglist *adesc, FILE *f){ fprintf (f, "%s %.0f\n", adesc->optstring, *(double *)adesc->var);}/* * Produce a summary line for parameters with level/idu prefix and typical * unsigned integer value. */voidpsummary_uint (const struct arglist *adesc, FILE *f){ int idu, lev; unsigned int (*var)[3][MAX_LEV] = adesc->var; for (idu = 0; idu < 3; idu++) { for (lev = 0; lev <= maxlevel; lev++) { if ((*var)[idu][lev] != 0) { fprintf (f, "-l%d-%c%s %u\n", lev+1, idu==0?'u':(idu==1?'i':'d'), adesc->optstring, (*var)[idu][lev]); } } }}/* * Produce a summary line for parameters with level/idu prefix and typical * unsigned power-of-2 integer value, remembered as its log. */voidpsummary_luint (const struct arglist *adesc, FILE *f){ int idu, lev; unsigned int (*var)[3][MAX_LEV] = adesc->var; for (idu = 0; idu < 3; idu++) { for (lev = 0; lev <= maxlevel; lev++) { if ((*var)[idu][lev] != 0) { fprintf (f, "-l%d-%c%s %u\n", lev+1, idu==0?'u':(idu==1?'i':'d'), adesc->optstring, (*var)[idu][lev]); } } }}/* * Produce a summary line for parameters with typical single char argument. */voidsummary_char (const struct arglist *adesc, FILE *f){ fprintf (f, "%s %c\n", adesc->optstring, *(int *)adesc->var);}/* * Produce a summary line for parameters with level/idu prefix and typical * single char value. */voidpsummary_char (const struct arglist *adesc, FILE *f){ int idu, lev; int (*var)[3][MAX_LEV] = adesc->var; for (idu = 0; idu < 3; idu++) { for (lev = 0; lev <= maxlevel; lev++) { if ((*var)[idu][lev] != 0) { fprintf (f, "-l%d-%c%s %c\n", lev+1, idu==0?'u':(idu==1?'i':'d'), adesc->optstring, (*var)[idu][lev]); } } }}/* * Produce a summary line for parameters with typical hexadecimal address * as argument. */voidsummary_addr (const struct arglist *adesc, FILE *f){ fprintf (f, "%s 0x%lx\n", adesc->optstring, *(long *)adesc->var);}/* * Produce a help line for a possible command line option taking no args. */voidhelp_0arg (const struct arglist *adesc){ printf ("%-*s %s", optstringmax, adesc->optstring, adesc->helpstring);}/* * Produce a help line for a possible command line option with * level/idu prefix and no args. * We don't bother trying to show the default values; there are too many. */voidphelp_0arg (const struct arglist *adesc){ printf ("-lN-T%-*s %s", optstringmax-adesc->pad, adesc->optstring, adesc->helpstring);}/* * Produce a help line for a possible command line option taking * an unsigned int value. */voidhelp_uint (const struct arglist *adesc){ printf ("%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "U", adesc->helpstring);}/* * Produce a help line for a possible command line option taking * a scaled unsigned int value, but using double for extra range. */voidhelp_scale_uintd (const struct arglist *adesc){ printf ("%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "U", adesc->helpstring);}/* * Produce a help line for a possible command line option with * level/idu prefix and unsigned int value. * We don't bother trying to show the default values; there are too many. */voidphelp_uint (const struct arglist *adesc){ printf ("-lN-T%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "U", adesc->helpstring);}/* * Produce a help line for a possible command line option with * level/idu prefix and scaled unsigned int value. * We don't bother trying to show the default values; there are too many. */voidphelp_scale_uint (const struct arglist *adesc){ printf ("-lN-T%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "S", adesc->helpstring);}/* * Produce a help line for a possible command line option with * level/idu prefix and scaled power-of-2 unsigned int value. * We don't bother trying to show the default values; there are too many. */voidphelp_scale_pow2 (const struct arglist *adesc){ printf ("-lN-T%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "P", adesc->helpstring);}/* * Produce a help line for a possible command line option with * a single char value. */voidhelp_char (const struct arglist *adesc){ printf ("%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "C", adesc->helpstring);}/* * Produce a help line for a possible command line option with * level/idu prefix and single char value. * We don't bother trying to show the default values; there are too many. */voidphelp_char (const struct arglist *adesc){ printf ("-lN-T%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "C", adesc->helpstring);}/* * Produce a help line for a possible command line option taking a string. */voidhelp_string (const struct arglist *adesc){ printf ("%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "F", adesc->helpstring); if (*(char **)adesc->var != NULL) printf (" (\"%s\")", *(char **)adesc->var);}/* * Produce a help line for a possible command line option with * a hexidecimal address value. */voidhelp_addr (const struct arglist *adesc){ printf ("%s %-*s %s", adesc->optstring, optstringmax-(int)strlen(adesc->optstring)-adesc->pad+1, "A", adesc->helpstring); if (*(long *)adesc->var != 0) printf (" (0x%lx)", *(long *)adesc->var);}/* * Print info about how the caches are set up */voidsummarize_caches (d4cache *ci, d4cache *cd){ struct arglist *adesc; printf ("\n---Summary of options " "(-help option gives usage information).\n\n"); for (adesc = args; adesc->optstring != NULL; adesc++) if (adesc->sumf != (void (*)())NULL) adesc->sumf (adesc, stdout);}/* * Print out the stuff the user really wants */voiddostats(){ int lev; int i; for (lev = 0; lev < maxlevel; lev++) { if (stat_idcombine && levcache[0][lev] == NULL) { d4cache cc; /* a bogus cache structure */ char ccname[30]; cc.name = ccname; sprintf (cc.name, "l%d-I/Dcaches", lev+1); cc.prefetchf = NULL; if (levcache[1][lev]->prefetchf==d4prefetch_none && levcache[2][lev]->prefetchf==d4prefetch_none) cc.prefetchf = d4prefetch_none; /* controls prefetch printout stats */ /* add the i & d stats into the new bogus structure */ for (i = 0; i < 2 * D4NUMACCESSTYPES; i++) { cc.fetch[i] = levcache[1][lev]->fetch[i] + levcache[2][lev]->fetch[i]; cc.miss[i] = levcache[1][lev]->miss[i] + levcache[2][lev]->miss[i]; cc.blockmiss[i] = levcache[1][lev]->blockmiss[i] + levcache[2][lev]->blockmiss[i]; cc.comp_miss[i] = levcache[1][lev]->comp_miss[i] + levcache[2][lev]->comp_miss[i]; cc.comp_blockmiss[i] = levcache[1][lev]->comp_blockmiss[i] + levcache[2][lev]->comp_blockmiss[i]; cc.cap_miss[i] = levcache[1][lev]->cap_miss[i] + levcache[2][lev]->cap_miss[i]; cc.cap_blockmiss[i] = levcache[1][lev]->cap_blockmiss[i] + levcache[2][lev]->cap_blockmiss[i]; cc.conf_miss[i] = levcache[1][lev]->conf_miss[i] + levcache[2][lev]->conf_miss[i]; cc.conf_blockmiss[i] = levcache[1][lev]->conf_blockmiss[i] + levcache[2][lev]->conf_blockmiss[i]; } cc.multiblock = levcache[1][lev]->multiblock + levcache[2][lev]->multiblock; cc.bytes_read = levcache[1][lev]->bytes_read + levcache[2][lev]->bytes_read; cc.bytes_written = levcache[1][lev]->bytes_written + levcache[2][lev]->bytes_written; cc.flags = levcache[1][lev]->flags | levcache[2][lev]->flags; /* get D4F_CCC */ /* * block and subblock size should match; * should be checked at startup time */ cc.lg2subblocksize = levcache[1][lev]->lg2subblocksize; cc.lg2blocksize = levcache[1][lev]->lg2blocksize; do1stats (&cc); } else { if (levcache[0][lev] != NULL) do1stats (levcache[0][lev]); if (levcache[1][lev] != NULL) do1stats (levcache[1][lev]); if (levcache[2][lev] != NULL) do1stats (levcache[2][lev]); } }}#define NONZERO(i) (((i)==0.0) ? 1.0 : (double)(i)) /* avoid divide-by-zero exception *//* * Print stats for 1 cache */voiddo1stats (d4cache *c){ double demand_fetch_data, demand_fetch_alltype; double prefetch_fetch_data, prefetch_fetch_alltype; double demand_data, demand_alltype; double prefetch_data, prefetch_alltype; double demand_comp_data, demand_comp_alltype; double demand_cap_data, demand_cap_alltype; double demand_conf_data, demand_conf_alltype; double floatnum; /* Used in bus traffic calculations even if no prefetching. */ prefetch_fetch_alltype = 0; /* * Print Header */ printf( "%s\n", c->name); printf( " Metrics Total Instrn Data Read Write Misc\n"); printf( " ----------------- ------ ------ ------ ------ ------ ------\n"); /* * Print Fetch Numbers */ demand_fetch_data = c->fetch[D4XMISC] + c->fetch[D4XREAD] + c->fetch[D4XWRITE]; demand_fetch_alltype = demand_fetch_data + c->fetch[D4XINSTRN]; printf( " Demand Fetches %12.0f %12.0f %12.0f %12.0f %12.0f %12.0f\n", demand_fetch_alltype, c->fetch[D4XINSTRN], demand_fetch_data, c->fetch[D4XREAD], c->fetch[D4XWRITE], c->fetch[D4XMISC]); floatnum = NONZERO(demand_fetch_alltype); printf( " Fraction of total %12.4f %12.4f %12.4f %12.4f %12.4f %12.4f\n", demand_fetch_alltype / floatnum, c->fetch[D4XINSTRN] / floatnum, demand_fetch_data / floatnum, c->fetch[D4XREAD] / floatnum, c->fetch[D4XWRITE] / floatnum, c->fetch[D4XMISC] / floatnum); /* * Prefetching? */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -