OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [ppc/] [mon.c] - Diff between revs 227 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 227 Rev 816
/*  This file is part of the program psim.
/*  This file is part of the program psim.
 
 
    Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
    Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
 
 
    This program is free software; you can redistribute it and/or modify
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    (at your option) any later version.
 
 
    This program is distributed in the hope that it will be useful,
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    GNU General Public License for more details.
 
 
    You should have received a copy of the GNU General Public License
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 
    */
    */
 
 
 
 
#ifndef _MON_C_
#ifndef _MON_C_
#define _MON_C_
#define _MON_C_
 
 
#include "basics.h"
#include "basics.h"
#include "cpu.h"
#include "cpu.h"
#include "mon.h"
#include "mon.h"
#include <stdio.h>
#include <stdio.h>
 
 
#ifdef HAVE_STRING_H
#ifdef HAVE_STRING_H
#include <string.h>
#include <string.h>
#else
#else
#ifdef HAVE_STRINGS_H
#ifdef HAVE_STRINGS_H
#include <strings.h>
#include <strings.h>
#endif
#endif
#endif
#endif
 
 
#ifdef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <unistd.h>
#endif
#endif
 
 
#ifdef HAVE_STDLIB_H
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#include <stdlib.h>
#endif
#endif
 
 
#ifdef HAVE_SYS_TYPES_H
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#include <sys/types.h>
#endif
#endif
 
 
#ifdef HAVE_TIME_H
#ifdef HAVE_TIME_H
#include <time.h>
#include <time.h>
#endif
#endif
 
 
#ifdef HAVE_SYS_TIMES_H
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
#include <sys/times.h>
#endif
#endif
 
 
#ifdef HAVE_SYS_TIME_H
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#include <sys/time.h>
#endif
#endif
 
 
#ifdef HAVE_SYS_RESOURCE_H
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#include <sys/resource.h>
int getrusage();
int getrusage();
#endif
#endif
 
 
#define MAX_BYTE_READWRITE 9
#define MAX_BYTE_READWRITE 9
#define MAX_SHIFT_READWRITE 3
#define MAX_SHIFT_READWRITE 3
 
 
struct _cpu_mon {
struct _cpu_mon {
  count_type issue_count[nr_itable_entries];
  count_type issue_count[nr_itable_entries];
  count_type read_count;
  count_type read_count;
  count_type read_byte_count[MAX_BYTE_READWRITE];
  count_type read_byte_count[MAX_BYTE_READWRITE];
  count_type write_count;
  count_type write_count;
  count_type write_byte_count[MAX_BYTE_READWRITE];
  count_type write_byte_count[MAX_BYTE_READWRITE];
  count_type unaligned_read_count;
  count_type unaligned_read_count;
  count_type unaligned_write_count;
  count_type unaligned_write_count;
  count_type event_count[nr_mon_events];
  count_type event_count[nr_mon_events];
};
};
 
 
struct _mon {
struct _mon {
  int nr_cpus;
  int nr_cpus;
  cpu_mon cpu_monitor[MAX_NR_PROCESSORS];
  cpu_mon cpu_monitor[MAX_NR_PROCESSORS];
};
};
 
 
 
 
INLINE_MON\
INLINE_MON\
(mon *)
(mon *)
mon_create(void)
mon_create(void)
{
{
  mon *monitor = ZALLOC(mon);
  mon *monitor = ZALLOC(mon);
  return monitor;
  return monitor;
}
}
 
 
 
 
INLINE_MON\
INLINE_MON\
(cpu_mon *)
(cpu_mon *)
mon_cpu(mon *monitor,
mon_cpu(mon *monitor,
        int cpu_nr)
        int cpu_nr)
{
{
  if (cpu_nr < 0 || cpu_nr >= MAX_NR_PROCESSORS)
  if (cpu_nr < 0 || cpu_nr >= MAX_NR_PROCESSORS)
    error("mon_cpu() - invalid cpu number\n");
    error("mon_cpu() - invalid cpu number\n");
  return &monitor->cpu_monitor[cpu_nr];
  return &monitor->cpu_monitor[cpu_nr];
}
}
 
 
 
 
INLINE_MON\
INLINE_MON\
(void)
(void)
mon_init(mon *monitor,
mon_init(mon *monitor,
         int nr_cpus)
         int nr_cpus)
{
{
  memset(monitor, 0, sizeof(*monitor));
  memset(monitor, 0, sizeof(*monitor));
  monitor->nr_cpus = nr_cpus;
  monitor->nr_cpus = nr_cpus;
}
}
 
 
 
 
INLINE_MON\
INLINE_MON\
(void)
(void)
mon_issue(itable_index index,
mon_issue(itable_index index,
          cpu *processor,
          cpu *processor,
          unsigned_word cia)
          unsigned_word cia)
{
{
  cpu_mon *monitor = cpu_monitor(processor);
  cpu_mon *monitor = cpu_monitor(processor);
  ASSERT(index <= nr_itable_entries);
  ASSERT(index <= nr_itable_entries);
  monitor->issue_count[index] += 1;
  monitor->issue_count[index] += 1;
}
}
 
 
 
 
INLINE_MON\
INLINE_MON\
(void)
(void)
mon_read(unsigned_word ea,
mon_read(unsigned_word ea,
         unsigned_word ra,
         unsigned_word ra,
         unsigned nr_bytes,
         unsigned nr_bytes,
         cpu *processor,
         cpu *processor,
         unsigned_word cia)
         unsigned_word cia)
{
{
  cpu_mon *monitor = cpu_monitor(processor);
  cpu_mon *monitor = cpu_monitor(processor);
  monitor->read_count += 1;
  monitor->read_count += 1;
  monitor->read_byte_count[nr_bytes] += 1;
  monitor->read_byte_count[nr_bytes] += 1;
  if ((nr_bytes - 1) & ea)
  if ((nr_bytes - 1) & ea)
    monitor->unaligned_read_count += 1;
    monitor->unaligned_read_count += 1;
}
}
 
 
 
 
INLINE_MON\
INLINE_MON\
(void)
(void)
mon_write(unsigned_word ea,
mon_write(unsigned_word ea,
          unsigned_word ra,
          unsigned_word ra,
          unsigned nr_bytes,
          unsigned nr_bytes,
          cpu *processor,
          cpu *processor,
          unsigned_word cia)
          unsigned_word cia)
{
{
  cpu_mon *monitor = cpu_monitor(processor);
  cpu_mon *monitor = cpu_monitor(processor);
  monitor->write_count += 1;
  monitor->write_count += 1;
  monitor->write_byte_count[nr_bytes] += 1;
  monitor->write_byte_count[nr_bytes] += 1;
  if ((nr_bytes - 1) & ea)
  if ((nr_bytes - 1) & ea)
    monitor->unaligned_write_count += 1;
    monitor->unaligned_write_count += 1;
}
}
 
 
INLINE_MON\
INLINE_MON\
(void)
(void)
mon_event(mon_events event,
mon_event(mon_events event,
          cpu *processor,
          cpu *processor,
          unsigned_word cia)
          unsigned_word cia)
{
{
  cpu_mon *monitor = cpu_monitor(processor);
  cpu_mon *monitor = cpu_monitor(processor);
  ASSERT(event < nr_mon_events);
  ASSERT(event < nr_mon_events);
  monitor->event_count[event] += 1;
  monitor->event_count[event] += 1;
}
}
 
 
INLINE_MON\
INLINE_MON\
(unsigned)
(unsigned)
mon_get_number_of_insns(mon *monitor,
mon_get_number_of_insns(mon *monitor,
                        int cpu_nr)
                        int cpu_nr)
{
{
  itable_index index;
  itable_index index;
  unsigned total_insns = 0;
  unsigned total_insns = 0;
  ASSERT(cpu_nr >= 0 && cpu_nr < monitor->nr_cpus);
  ASSERT(cpu_nr >= 0 && cpu_nr < monitor->nr_cpus);
  for (index = 0; index < nr_itable_entries; index++)
  for (index = 0; index < nr_itable_entries; index++)
    total_insns += monitor->cpu_monitor[cpu_nr].issue_count[index];
    total_insns += monitor->cpu_monitor[cpu_nr].issue_count[index];
  return total_insns;
  return total_insns;
}
}
 
 
STATIC_INLINE_MON\
STATIC_INLINE_MON\
(int)
(int)
mon_sort_instruction_names(const void *ptr_a, const void *ptr_b)
mon_sort_instruction_names(const void *ptr_a, const void *ptr_b)
{
{
  itable_index a = *(const itable_index *)ptr_a;
  itable_index a = *(const itable_index *)ptr_a;
  itable_index b = *(const itable_index *)ptr_b;
  itable_index b = *(const itable_index *)ptr_b;
 
 
  return strcmp (itable[a].name, itable[b].name);
  return strcmp (itable[a].name, itable[b].name);
}
}
 
 
STATIC_INLINE_MON\
STATIC_INLINE_MON\
(char *)
(char *)
mon_add_commas(char *buf,
mon_add_commas(char *buf,
               int sizeof_buf,
               int sizeof_buf,
               count_type value)
               count_type value)
{
{
  int comma = 3;
  int comma = 3;
  char *endbuf = buf + sizeof_buf - 1;
  char *endbuf = buf + sizeof_buf - 1;
 
 
  *--endbuf = '\0';
  *--endbuf = '\0';
  do {
  do {
    if (comma-- == 0)
    if (comma-- == 0)
      {
      {
        *--endbuf = ',';
        *--endbuf = ',';
        comma = 2;
        comma = 2;
      }
      }
 
 
    *--endbuf = (value % 10) + '0';
    *--endbuf = (value % 10) + '0';
  } while ((value /= 10) != 0);
  } while ((value /= 10) != 0);
 
 
  ASSERT(endbuf >= buf);
  ASSERT(endbuf >= buf);
  return endbuf;
  return endbuf;
}
}
 
 
 
 
INLINE_MON\
INLINE_MON\
(void)
(void)
mon_print_info(psim *system,
mon_print_info(psim *system,
               mon *monitor,
               mon *monitor,
               int verbose)
               int verbose)
{
{
  char buffer[20];
  char buffer[20];
  char buffer1[20];
  char buffer1[20];
  char buffer2[20];
  char buffer2[20];
  char buffer4[20];
  char buffer4[20];
  char buffer8[20];
  char buffer8[20];
  int cpu_nr;
  int cpu_nr;
  int len_cpu;
  int len_cpu;
  int len_num = 0;
  int len_num = 0;
  int len_sub_num[MAX_BYTE_READWRITE];
  int len_sub_num[MAX_BYTE_READWRITE];
  int len;
  int len;
  int i;
  int i;
  long total_insns = 0;
  long total_insns = 0;
  long cpu_insns_second = 0;
  long cpu_insns_second = 0;
  long total_sim_cycles = 0;
  long total_sim_cycles = 0;
  long sim_cycles_second = 0;
  long sim_cycles_second = 0;
  double cpu_time = 0.0;
  double cpu_time = 0.0;
 
 
  for (i = 0; i < MAX_BYTE_READWRITE; i++)
  for (i = 0; i < MAX_BYTE_READWRITE; i++)
    len_sub_num[i] = 0;
    len_sub_num[i] = 0;
 
 
  for (cpu_nr = 0; cpu_nr < monitor->nr_cpus; cpu_nr++) {
  for (cpu_nr = 0; cpu_nr < monitor->nr_cpus; cpu_nr++) {
    count_type num_insns = mon_get_number_of_insns(monitor, cpu_nr);
    count_type num_insns = mon_get_number_of_insns(monitor, cpu_nr);
 
 
    total_insns += num_insns;
    total_insns += num_insns;
    len = strlen (mon_add_commas(buffer, sizeof(buffer), num_insns));
    len = strlen (mon_add_commas(buffer, sizeof(buffer), num_insns));
    if (len_num < len)
    if (len_num < len)
      len_num = len;
      len_num = len;
 
 
    for (i = 0; i <= MAX_SHIFT_READWRITE; i++) {
    for (i = 0; i <= MAX_SHIFT_READWRITE; i++) {
      int size = 1<<i;
      int size = 1<<i;
      len = strlen (mon_add_commas(buffer, sizeof(buffer),
      len = strlen (mon_add_commas(buffer, sizeof(buffer),
                                   monitor->cpu_monitor[cpu_nr].read_byte_count[size]));
                                   monitor->cpu_monitor[cpu_nr].read_byte_count[size]));
      if (len_sub_num[size] < len)
      if (len_sub_num[size] < len)
        len_sub_num[size] = len;
        len_sub_num[size] = len;
 
 
      len = strlen (mon_add_commas(buffer, sizeof(buffer),
      len = strlen (mon_add_commas(buffer, sizeof(buffer),
                                   monitor->cpu_monitor[cpu_nr].write_byte_count[size]));
                                   monitor->cpu_monitor[cpu_nr].write_byte_count[size]));
      if (len_sub_num[size] < len)
      if (len_sub_num[size] < len)
        len_sub_num[size] = len;
        len_sub_num[size] = len;
    }
    }
  }
  }
 
 
  sprintf (buffer, "%d", (int)monitor->nr_cpus + 1);
  sprintf (buffer, "%d", (int)monitor->nr_cpus + 1);
  len_cpu = strlen (buffer);
  len_cpu = strlen (buffer);
 
 
#ifdef HAVE_GETRUSAGE
#ifdef HAVE_GETRUSAGE
  {
  {
    struct rusage mytime;
    struct rusage mytime;
    if (getrusage (RUSAGE_SELF, &mytime) == 0
    if (getrusage (RUSAGE_SELF, &mytime) == 0
        && (mytime.ru_utime.tv_sec > 0 || mytime.ru_utime.tv_usec > 0)) {
        && (mytime.ru_utime.tv_sec > 0 || mytime.ru_utime.tv_usec > 0)) {
 
 
      cpu_time = (double)mytime.ru_utime.tv_sec + (((double)mytime.ru_utime.tv_usec) / 1000000.0);
      cpu_time = (double)mytime.ru_utime.tv_sec + (((double)mytime.ru_utime.tv_usec) / 1000000.0);
    }
    }
  }
  }
  if (WITH_EVENTS)
  if (WITH_EVENTS)
    total_sim_cycles = event_queue_time(psim_event_queue(system)) - 1;
    total_sim_cycles = event_queue_time(psim_event_queue(system)) - 1;
  if (cpu_time > 0) {
  if (cpu_time > 0) {
    if (total_insns > 0)
    if (total_insns > 0)
      cpu_insns_second = (long)(((double)total_insns / cpu_time) + 0.5);
      cpu_insns_second = (long)(((double)total_insns / cpu_time) + 0.5);
    if (total_sim_cycles) {
    if (total_sim_cycles) {
      sim_cycles_second = (long)(((double)total_sim_cycles / cpu_time) + 0.5);
      sim_cycles_second = (long)(((double)total_sim_cycles / cpu_time) + 0.5);
    }
    }
  }
  }
#endif
#endif
 
 
  for (cpu_nr = 0; cpu_nr < monitor->nr_cpus; cpu_nr++) {
  for (cpu_nr = 0; cpu_nr < monitor->nr_cpus; cpu_nr++) {
 
 
    if (verbose > 1) {
    if (verbose > 1) {
      itable_index sort_insns[nr_itable_entries];
      itable_index sort_insns[nr_itable_entries];
      int nr_sort_insns = 0;
      int nr_sort_insns = 0;
      itable_index index;
      itable_index index;
      int index2;
      int index2;
 
 
      if (cpu_nr)
      if (cpu_nr)
        printf_filtered ("\n");
        printf_filtered ("\n");
 
 
      for (index = 0; index < nr_itable_entries; index++) {
      for (index = 0; index < nr_itable_entries; index++) {
        if (monitor->cpu_monitor[cpu_nr].issue_count[index]) {
        if (monitor->cpu_monitor[cpu_nr].issue_count[index]) {
          sort_insns[nr_sort_insns++] = index;
          sort_insns[nr_sort_insns++] = index;
        }
        }
      }
      }
 
 
      qsort((void *)sort_insns, nr_sort_insns, sizeof(sort_insns[0]), mon_sort_instruction_names);
      qsort((void *)sort_insns, nr_sort_insns, sizeof(sort_insns[0]), mon_sort_instruction_names);
 
 
      for (index2 = 0; index2 < nr_sort_insns; index2++) {
      for (index2 = 0; index2 < nr_sort_insns; index2++) {
        index = sort_insns[index2];
        index = sort_insns[index2];
        printf_filtered("CPU #%*d executed %*s %s instruction%s.\n",
        printf_filtered("CPU #%*d executed %*s %s instruction%s.\n",
                        len_cpu, cpu_nr+1,
                        len_cpu, cpu_nr+1,
                        len_num, mon_add_commas(buffer,
                        len_num, mon_add_commas(buffer,
                                                sizeof(buffer),
                                                sizeof(buffer),
                                                monitor->cpu_monitor[cpu_nr].issue_count[index]),
                                                monitor->cpu_monitor[cpu_nr].issue_count[index]),
                          itable[index].name,
                          itable[index].name,
                          (monitor->cpu_monitor[cpu_nr].issue_count[index] == 1) ? "" : "s");
                          (monitor->cpu_monitor[cpu_nr].issue_count[index] == 1) ? "" : "s");
      }
      }
 
 
      printf_filtered ("\n");
      printf_filtered ("\n");
    }
    }
 
 
    if (CURRENT_MODEL_ISSUE > 0)
    if (CURRENT_MODEL_ISSUE > 0)
      {
      {
        model_data *model_ptr = cpu_model(psim_cpu(system, cpu_nr));
        model_data *model_ptr = cpu_model(psim_cpu(system, cpu_nr));
        model_print *ptr = model_mon_info(model_ptr);
        model_print *ptr = model_mon_info(model_ptr);
        model_print *orig_ptr = ptr;
        model_print *orig_ptr = ptr;
 
 
        while (ptr) {
        while (ptr) {
          if (ptr->count)
          if (ptr->count)
            printf_filtered("CPU #%*d executed %*s %s%s.\n",
            printf_filtered("CPU #%*d executed %*s %s%s.\n",
                            len_cpu, cpu_nr+1,
                            len_cpu, cpu_nr+1,
                            len_num, mon_add_commas(buffer,
                            len_num, mon_add_commas(buffer,
                                                    sizeof(buffer),
                                                    sizeof(buffer),
                                                    ptr->count),
                                                    ptr->count),
                            ptr->name,
                            ptr->name,
                            ((ptr->count == 1)
                            ((ptr->count == 1)
                             ? ptr->suffix_singular
                             ? ptr->suffix_singular
                             : ptr->suffix_plural));
                             : ptr->suffix_plural));
 
 
          ptr = ptr->next;
          ptr = ptr->next;
        }
        }
 
 
        model_mon_info_free(model_ptr, orig_ptr);
        model_mon_info_free(model_ptr, orig_ptr);
      }
      }
 
 
    if (monitor->cpu_monitor[cpu_nr].read_count)
    if (monitor->cpu_monitor[cpu_nr].read_count)
      printf_filtered ("CPU #%*d executed %*s read%s  (%*s 1-byte, %*s 2-byte, %*s 4-byte, %*s 8-byte).\n",
      printf_filtered ("CPU #%*d executed %*s read%s  (%*s 1-byte, %*s 2-byte, %*s 4-byte, %*s 8-byte).\n",
                       len_cpu, cpu_nr+1,
                       len_cpu, cpu_nr+1,
                       len_num, mon_add_commas(buffer,
                       len_num, mon_add_commas(buffer,
                                               sizeof(buffer),
                                               sizeof(buffer),
                                               monitor->cpu_monitor[cpu_nr].read_count),
                                               monitor->cpu_monitor[cpu_nr].read_count),
                       (monitor->cpu_monitor[cpu_nr].read_count == 1) ? "" : "s",
                       (monitor->cpu_monitor[cpu_nr].read_count == 1) ? "" : "s",
                       len_sub_num[1], mon_add_commas(buffer1,
                       len_sub_num[1], mon_add_commas(buffer1,
                                                      sizeof(buffer1),
                                                      sizeof(buffer1),
                                                      monitor->cpu_monitor[cpu_nr].read_byte_count[1]),
                                                      monitor->cpu_monitor[cpu_nr].read_byte_count[1]),
                       len_sub_num[2], mon_add_commas(buffer2,
                       len_sub_num[2], mon_add_commas(buffer2,
                                                      sizeof(buffer2),
                                                      sizeof(buffer2),
                                                      monitor->cpu_monitor[cpu_nr].read_byte_count[2]),
                                                      monitor->cpu_monitor[cpu_nr].read_byte_count[2]),
                       len_sub_num[4], mon_add_commas(buffer4,
                       len_sub_num[4], mon_add_commas(buffer4,
                                                      sizeof(buffer4),
                                                      sizeof(buffer4),
                                                      monitor->cpu_monitor[cpu_nr].read_byte_count[4]),
                                                      monitor->cpu_monitor[cpu_nr].read_byte_count[4]),
                       len_sub_num[8], mon_add_commas(buffer8,
                       len_sub_num[8], mon_add_commas(buffer8,
                                                      sizeof(buffer8),
                                                      sizeof(buffer8),
                                                      monitor->cpu_monitor[cpu_nr].read_byte_count[8]));
                                                      monitor->cpu_monitor[cpu_nr].read_byte_count[8]));
 
 
    if (monitor->cpu_monitor[cpu_nr].write_count)
    if (monitor->cpu_monitor[cpu_nr].write_count)
      printf_filtered ("CPU #%*d executed %*s write%s (%*s 1-byte, %*s 2-byte, %*s 4-byte, %*s 8-byte).\n",
      printf_filtered ("CPU #%*d executed %*s write%s (%*s 1-byte, %*s 2-byte, %*s 4-byte, %*s 8-byte).\n",
                       len_cpu, cpu_nr+1,
                       len_cpu, cpu_nr+1,
                       len_num, mon_add_commas(buffer,
                       len_num, mon_add_commas(buffer,
                                               sizeof(buffer),
                                               sizeof(buffer),
                                               monitor->cpu_monitor[cpu_nr].write_count),
                                               monitor->cpu_monitor[cpu_nr].write_count),
                       (monitor->cpu_monitor[cpu_nr].write_count == 1) ? "" : "s",
                       (monitor->cpu_monitor[cpu_nr].write_count == 1) ? "" : "s",
                       len_sub_num[1], mon_add_commas(buffer1,
                       len_sub_num[1], mon_add_commas(buffer1,
                                                      sizeof(buffer1),
                                                      sizeof(buffer1),
                                                      monitor->cpu_monitor[cpu_nr].write_byte_count[1]),
                                                      monitor->cpu_monitor[cpu_nr].write_byte_count[1]),
                       len_sub_num[2], mon_add_commas(buffer2,
                       len_sub_num[2], mon_add_commas(buffer2,
                                                      sizeof(buffer2),
                                                      sizeof(buffer2),
                                                      monitor->cpu_monitor[cpu_nr].write_byte_count[2]),
                                                      monitor->cpu_monitor[cpu_nr].write_byte_count[2]),
                       len_sub_num[4], mon_add_commas(buffer4,
                       len_sub_num[4], mon_add_commas(buffer4,
                                                      sizeof(buffer4),
                                                      sizeof(buffer4),
                                                      monitor->cpu_monitor[cpu_nr].write_byte_count[4]),
                                                      monitor->cpu_monitor[cpu_nr].write_byte_count[4]),
                       len_sub_num[8], mon_add_commas(buffer8,
                       len_sub_num[8], mon_add_commas(buffer8,
                                                      sizeof(buffer8),
                                                      sizeof(buffer8),
                                                      monitor->cpu_monitor[cpu_nr].write_byte_count[8]));
                                                      monitor->cpu_monitor[cpu_nr].write_byte_count[8]));
 
 
    if (monitor->cpu_monitor[cpu_nr].unaligned_read_count)
    if (monitor->cpu_monitor[cpu_nr].unaligned_read_count)
      printf_filtered ("CPU #%*d executed %*s unaligned read%s.\n",
      printf_filtered ("CPU #%*d executed %*s unaligned read%s.\n",
                       len_cpu, cpu_nr+1,
                       len_cpu, cpu_nr+1,
                       len_num, mon_add_commas(buffer,
                       len_num, mon_add_commas(buffer,
                                               sizeof(buffer),
                                               sizeof(buffer),
                                               monitor->cpu_monitor[cpu_nr].unaligned_read_count),
                                               monitor->cpu_monitor[cpu_nr].unaligned_read_count),
                       (monitor->cpu_monitor[cpu_nr].unaligned_read_count == 1) ? "" : "s");
                       (monitor->cpu_monitor[cpu_nr].unaligned_read_count == 1) ? "" : "s");
 
 
    if (monitor->cpu_monitor[cpu_nr].unaligned_write_count)
    if (monitor->cpu_monitor[cpu_nr].unaligned_write_count)
      printf_filtered ("CPU #%*d executed %*s unaligned write%s.\n",
      printf_filtered ("CPU #%*d executed %*s unaligned write%s.\n",
                       len_cpu, cpu_nr+1,
                       len_cpu, cpu_nr+1,
                       len_num, mon_add_commas(buffer,
                       len_num, mon_add_commas(buffer,
                                               sizeof(buffer),
                                               sizeof(buffer),
                                               monitor->cpu_monitor[cpu_nr].unaligned_write_count),
                                               monitor->cpu_monitor[cpu_nr].unaligned_write_count),
                       (monitor->cpu_monitor[cpu_nr].unaligned_write_count == 1) ? "" : "s");
                       (monitor->cpu_monitor[cpu_nr].unaligned_write_count == 1) ? "" : "s");
 
 
    if (monitor->cpu_monitor[cpu_nr].event_count[mon_event_icache_miss])
    if (monitor->cpu_monitor[cpu_nr].event_count[mon_event_icache_miss])
      printf_filtered ("CPU #%*d executed %*s icache miss%s.\n",
      printf_filtered ("CPU #%*d executed %*s icache miss%s.\n",
                       len_cpu, cpu_nr+1,
                       len_cpu, cpu_nr+1,
                       len_num, mon_add_commas(buffer,
                       len_num, mon_add_commas(buffer,
                                               sizeof(buffer),
                                               sizeof(buffer),
                                               monitor->cpu_monitor[cpu_nr].event_count[mon_event_icache_miss]),
                                               monitor->cpu_monitor[cpu_nr].event_count[mon_event_icache_miss]),
                       (monitor->cpu_monitor[cpu_nr].event_count[mon_event_icache_miss] == 1) ? "" : "es");
                       (monitor->cpu_monitor[cpu_nr].event_count[mon_event_icache_miss] == 1) ? "" : "es");
 
 
    {
    {
      long nr_insns = mon_get_number_of_insns(monitor, cpu_nr);
      long nr_insns = mon_get_number_of_insns(monitor, cpu_nr);
      if (nr_insns > 0)
      if (nr_insns > 0)
        printf_filtered("CPU #%*d executed %*s instructions in total.\n",
        printf_filtered("CPU #%*d executed %*s instructions in total.\n",
                        len_cpu, cpu_nr+1,
                        len_cpu, cpu_nr+1,
                        len_num, mon_add_commas(buffer,
                        len_num, mon_add_commas(buffer,
                                                sizeof(buffer),
                                                sizeof(buffer),
                                                nr_insns));
                                                nr_insns));
    }
    }
  }
  }
 
 
  if (total_insns > 0) {
  if (total_insns > 0) {
    if (monitor->nr_cpus > 1)
    if (monitor->nr_cpus > 1)
      printf_filtered("\nAll CPUs executed %s instructions in total.\n",
      printf_filtered("\nAll CPUs executed %s instructions in total.\n",
                      mon_add_commas(buffer, sizeof(buffer), total_insns));
                      mon_add_commas(buffer, sizeof(buffer), total_insns));
  }
  }
  else if (total_sim_cycles > 0) {
  else if (total_sim_cycles > 0) {
    printf_filtered("\nSimulator performed %s simulation cycles.\n",
    printf_filtered("\nSimulator performed %s simulation cycles.\n",
                    mon_add_commas(buffer, sizeof(buffer), total_sim_cycles));
                    mon_add_commas(buffer, sizeof(buffer), total_sim_cycles));
  }
  }
 
 
  if (cpu_insns_second)
  if (cpu_insns_second)
    printf_filtered ("%sSimulator speed was %s instructions/second.\n",
    printf_filtered ("%sSimulator speed was %s instructions/second.\n",
                     (monitor->nr_cpus > 1) ? "" : "\n",
                     (monitor->nr_cpus > 1) ? "" : "\n",
                     mon_add_commas(buffer, sizeof(buffer), cpu_insns_second));
                     mon_add_commas(buffer, sizeof(buffer), cpu_insns_second));
  else if (sim_cycles_second)
  else if (sim_cycles_second)
    printf_filtered ("Simulator speed was %s simulation cycles/second\n",
    printf_filtered ("Simulator speed was %s simulation cycles/second\n",
                     mon_add_commas(buffer, sizeof(buffer), sim_cycles_second));
                     mon_add_commas(buffer, sizeof(buffer), sim_cycles_second));
  else if (cpu_time > 0.0)
  else if (cpu_time > 0.0)
    printf_filtered ("%sSimulator executed for %.2f seconds\n",
    printf_filtered ("%sSimulator executed for %.2f seconds\n",
                     (monitor->nr_cpus > 1) ? "" : "\n", cpu_time);
                     (monitor->nr_cpus > 1) ? "" : "\n", cpu_time);
 
 
}
}
 
 
#endif /* _MON_C_ */
#endif /* _MON_C_ */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.