Ejemplo n.º 1
0
/* print all simulator stats */
void
sim_print_stats(FILE *fd)		/* output stream */
{
#if 0 /* not portable... :-( */
  extern char etext, *sbrk(int);
#endif

  if (!running)
    return;

  /* get stats time */
  sim_end_time = time((time_t *)NULL);
  sim_elapsed_time = MAX(sim_end_time - sim_start_time, 1);

#if 0 /* not portable... :-( */
  /* compute simulator memory usage */
  sim_mem_usage = (sbrk(0) - &etext) / 1024;
#endif

  /********** Modification for ACAPP tool **********/
      printCacheStats();

  /* print simulation stats */
	
  fprintf(fd, "\nsim: ** simulation statistics **\n");
  stat_print_stats(sim_sdb, fd);
  sim_aux_stats(fd);
  fprintf(fd, "\n");
}
Ejemplo n.º 2
0
/* print all simulator stats */
void
sim_print_stats(FILE *fd)		/* output stream */
{
#if 0 /* not portable... :-( */
  extern char etext, *sbrk(int);
#endif

  if (!running)
    return;

  /* get stats time */
  sim_end_time = time((time_t *)NULL);
  sim_elapsed_time = MAX(sim_end_time - sim_start_time, 1);

#if 0 /* not portable... :-( */
  /* compute simulator memory usage */
  sim_mem_usage = (sbrk(0) - &etext) / 1024;
#endif

  /********** Modification for ACAPP tool **********/
 //   printf("%d\n", profile_level);
	if(profile_level==2){			 
	//	int h = hitOrMissFunc(dset, dtag);
		int i;
		for(i=0; i<=profile_max-profile_min; i++){	
			printCacheStats(pcache2[i]);
		}
	}
	if(profile_level==1){	 
	//	int h = hitOrMissFunc(dset, dtag);
		int i;
		for(i=0; i<=profile_max-profile_min; i++){	
			printCacheStats(pcache1[i]);
		}
	}
  /* print simulation stats */
	
  fprintf(fd, "\nsim: ** simulation statistics **\n");
  stat_print_stats(sim_sdb, fd);
  sim_aux_stats(fd);
  fprintf(fd, "\n");
}
Ejemplo n.º 3
0
int
main(int argc, char *argv[])
{
  // Set defaults
  set_defaults();

  // Process cmdline Arguments
  for (int i = 1; i < argc; ++i) {
    if (!strcmp(argv[i],"--help")) {
      usage();
      exit(0);
    } else if (!strncmp(argv[i],"--",2)) {
      if (!handle_option(argv[i])) {
        printf("Unrecognized option %s\n", argv[i]);
        usage();
        exit(1);
      }
    } else {
      // Use as input file
      stream = fopen(argv[i], "r");
    }
  }

  // Initialize the cache
  init_cache();

  uint64_t totalRefs = 0;
  uint64_t totalPenalties = 0;
  uint32_t addr = 0;
  char i_or_d = '\0';

  // Read each memory access from the trace
  while (read_mem_access(&addr, &i_or_d)) {
    totalRefs++;
    // Direct the memory access to the appropriate cache
    if (i_or_d == 'I') {
      totalPenalties += icache_access(addr);
    } else if (i_or_d == 'D') {
      totalPenalties += dcache_access(addr);
    } else {
      fprintf(stderr,"Input Error '%c' must be either 'I' or 'D'\n", i_or_d);
      exit(1);
    }
  }

  // Print out the statistics
  printStudentInfo();
  printCacheConfig();
  printCacheStats();
  printf("Total Memory accesses:  %16llu\n", totalRefs);
  printf("Total Memory penalties: %16llu\n", totalPenalties);
  if (totalRefs > 0) {
    printf("avg Memory access time: %16.2f cycles\n",
        (double)totalPenalties / totalRefs);
  } else {
    printf("avg Memory access time:                -\n");
  }

  // Cleanup
  fclose(stream);
  free(buf);

  return 0;
}