Line 29... |
Line 29... |
struct memory_hash *next;
|
struct memory_hash *next;
|
unsigned long addr;
|
unsigned long addr;
|
unsigned long cnt[3]; /* Various counters */
|
unsigned long cnt[3]; /* Various counters */
|
} *hash[HASH_SIZE];
|
} *hash[HASH_SIZE];
|
|
|
int cnt[64] = {0};
|
|
|
|
/* Groups size -- how much addresses should be joined together */
|
/* Groups size -- how much addresses should be joined together */
|
int group_bits = 2;
|
int group_bits = 2;
|
|
|
/* Start address */
|
/* Start address */
|
int start_addr = 0;
|
int start_addr = 0;
|
Line 45... |
Line 43... |
/* File to read from */
|
/* File to read from */
|
static FILE *fprof = 0;
|
static FILE *fprof = 0;
|
|
|
void mp_help ()
|
void mp_help ()
|
{
|
{
|
printf ("USAGE: mprofiler <-d|-p|-a|-w> [-f filename] [-g group] from to\n");
|
printf ("mprofiler <-d|-p|-a|-w> [-f filename] [-g group] from to\n");
|
printf ("\t-d\t--detail\t\tdetailed output\n");
|
printf ("\t-d\t--detail\t\tdetailed output\n");
|
printf ("\t-p\t--pretty\t\tpretty output\n");
|
printf ("\t-p\t--pretty\t\tpretty output\n");
|
printf ("\t-a\t--access\t\toutput accesses only\n");
|
printf ("\t-a\t--access\t\toutput accesses only\n");
|
printf ("\t-w\t--width\t\t\toutput by width\n");
|
printf ("\t-w\t--width\t\t\toutput by width\n");
|
printf ("\t-f\t--filename filename\tspecify mprofile file [sim.mprofile]\n");
|
printf ("\t-f\t--filename filename\tspecify mprofile file [sim.mprofile]\n");
|
Line 101... |
Line 99... |
unsigned t = buf[i].type;
|
unsigned t = buf[i].type;
|
if (t > 64) {
|
if (t > 64) {
|
printf ("!");
|
printf ("!");
|
t = 0;
|
t = 0;
|
}
|
}
|
cnt[t]++;
|
|
if (mode == MODE_WIDTH) t >>= 3;
|
if (mode == MODE_WIDTH) t >>= 3;
|
else t &= 0x7;
|
else t &= 0x7;
|
|
|
switch (t) {
|
switch (t) {
|
case 1: index = 0; break;
|
case 1: index = 0; break;
|
Line 117... |
Line 114... |
break;
|
break;
|
}
|
}
|
hash_add (buf[i].addr >> group_bits, index);
|
hash_add (buf[i].addr >> group_bits, index);
|
}
|
}
|
} while (num_read > 0);
|
} while (num_read > 0);
|
{int i;
|
|
for (i = 0; i < 64; i++)
|
|
printf ("%i:%i\t", i, cnt[i]);
|
|
printf ("\n");
|
|
}
|
|
}
|
}
|
|
|
static inline int nbits (unsigned long a)
|
static inline int nbits (unsigned long a)
|
{
|
{
|
int cnt = 0;
|
int cnt = 0;
|
Line 142... |
Line 134... |
}
|
}
|
|
|
void printout (int mode)
|
void printout (int mode)
|
{
|
{
|
unsigned long addr = start_addr & ~((1 << group_bits) - 1);
|
unsigned long addr = start_addr & ~((1 << group_bits) - 1);
|
printf ("%08x %08x %08x %08x %i\n", start_addr, end_addr, addr, group_bits, mode);
|
printf ("start = %08x; end = %08x; addr = %08x; group_bits = %08x\n", start_addr, end_addr, addr, group_bits);
|
for (; addr <= end_addr; addr += (1 << group_bits)) {
|
for (; addr <= end_addr; addr += (1 << group_bits)) {
|
int i;
|
int i;
|
unsigned long a = hash_get (addr >> group_bits, 0);
|
unsigned long a = hash_get (addr >> group_bits, 0);
|
unsigned long b = hash_get (addr >> group_bits, 1);
|
unsigned long b = hash_get (addr >> group_bits, 1);
|
unsigned long c = hash_get (addr >> group_bits, 2);
|
unsigned long c = hash_get (addr >> group_bits, 2);
|
Line 183... |
Line 175... |
}
|
}
|
printf ("\n");
|
printf ("\n");
|
}
|
}
|
}
|
}
|
|
|
int main_mprofiler (int mode, int group, char *fname)
|
int main_mprofiler (int argc, char *argv[])
|
{
|
{
|
char fmprofname[50] = "sim.mprofile";
|
char fmprofname[50] = "sim.mprofile";
|
int param = 0;
|
int param = 0;
|
/*int mode = MODE_DETAIL;*/
|
int mode = MODE_DETAIL;
|
|
|
if (!fname) fname = fmprofname;
|
argv++; argc--;
|
group_bits = group;
|
while (argc > 0) {
|
|
if (!strcmp(argv[0], "-d") || !strcmp(argv[0], "--detail")) {
|
/*
|
mode = MODE_DETAIL;
|
argv++; argc--;
|
argv++; argc--;
|
while (argc > 0) {
|
} else if (!strcmp(argv[0], "-p") || !strcmp(argv[0], "--pretty")) {
|
if (!strcmp(argv[0], "-d") || !strcmp(argv[0], "--detail")) {
|
mode = MODE_PRETTY;
|
mode = MODE_DETAIL;
|
argv++; argc--;
|
argv++; argc--;
|
} else if (!strcmp(argv[0], "-a") || !strcmp(argv[0], "--access")) {
|
} else if (!strcmp(argv[0], "-p") || !strcmp(argv[0], "--pretty")) {
|
mode = MODE_ACCESS;
|
mode = MODE_PRETTY;
|
argv++; argc--;
|
argv++; argc--;
|
} else if (!strcmp(argv[0], "-w") || !strcmp(argv[0], "--width")) {
|
} else if (!strcmp(argv[0], "-a") || !strcmp(argv[0], "--access")) {
|
mode = MODE_WIDTH;
|
mode = MODE_ACCESS;
|
argv++; argc--;
|
argv++; argc--;
|
} else if (!strcmp(argv[0], "-g") || !strcmp(argv[0], "--group")) {
|
} else if (!strcmp(argv[0], "-w") || !strcmp(argv[0], "--width")) {
|
argv++; argc--;
|
mode = MODE_WIDTH;
|
group_bits = strtoul (argv[0], NULL, 0);
|
argv++; argc--;
|
argv++; argc--;
|
} else if (!strcmp(argv[0], "-g") || !strcmp(argv[0], "--group")) {
|
} else if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) {
|
argv++; argc--;
|
mp_help ();
|
group_bits = strtoul (argv[0], NULL, 0);
|
return 0;
|
argv++; argc--;
|
} else if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--filename")) {
|
} else if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) {
|
argv++; argc--;
|
mp_help ();
|
strcpy (&fmprofname[0], argv[0]);
|
exit (0);
|
argv++; argc--;
|
} else if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--filename")) {
|
} else {
|
argv++; argc--;
|
switch (param) {
|
strcpy (&fmprofname[0], argv[0]);
|
case 0:
|
argv++; argc--;
|
start_addr = strtoul (argv[0], NULL, 0);
|
} else {
|
break;
|
switch (param) {
|
case 1:
|
case 0:
|
end_addr = strtoul (argv[0], NULL, 0);
|
start_addr = strtoul (argv[0], NULL, 0);
|
break;
|
break;
|
default:
|
case 1:
|
fprintf (stderr, "Invalid number of parameters.\n");
|
end_addr = strtoul (argv[0], NULL, 0);
|
return -1;
|
break;
|
}
|
default:
|
argv++; argc--; param++;
|
fprintf (stderr, "Invalid number of parameters.\n");
|
}
|
exit (-1);
|
}
|
}
|
|
argv++; argc--; param++;
|
|
}
|
|
}
|
|
*/
|
|
|
|
fprof = fopen (fname, "rm");
|
fprof = fopen (fmprofname, "rm");
|
|
|
if (!fprof) {
|
if (!fprof) {
|
fprintf (stderr, "Cannot open profile file: %s\n", fname);
|
fprintf (stderr, "Cannot open profile file: %s\n", fmprofname);
|
exit(1);
|
return 1;
|
}
|
}
|
|
|
init ();
|
init ();
|
read_file (fprof, mode);
|
read_file (fprof, mode);
|
fclose (fprof);
|
fclose (fprof);
|