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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [cuc/] [cuc.c] - Diff between revs 1003 and 1041

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1003 Rev 1041
Line 137... Line 137...
/* Pre/unrolls basic block and optimizes it */
/* Pre/unrolls basic block and optimizes it */
cuc_timings *preunroll_bb (char *bb_filename, cuc_func *f, cuc_timings *timings, int b, int i, int j)
cuc_timings *preunroll_bb (char *bb_filename, cuc_func *f, cuc_timings *timings, int b, int i, int j)
{
{
  cuc_func *func;
  cuc_func *func;
  cucdebug (2, "BB%i unroll %i times preroll %i times\n", b, j, i);
  cucdebug (2, "BB%i unroll %i times preroll %i times\n", b, j, i);
 
  log ("BB%i unroll %i times preroll %i times\n", b, j, i);
  func = preunroll_loop (f, b, i, j, bb_filename);
  func = preunroll_loop (f, b, i, j, bb_filename);
  if (cuc_debug >= 2) print_cuc_bb (func, "AFTER_PREUNROLL");
  if (cuc_debug >= 2) print_cuc_bb (func, "AFTER_PREUNROLL");
  cuc_optimize (func);
  cuc_optimize (func);
 
 
  cucdebug (2, "new_time = %i, old_time = %i, size = %f\n",
  cucdebug (2, "new_time = %i, old_time = %i, size = %f\n",
Line 165... Line 166...
}
}
 
 
/* Analyses function; done when cuc command is entered in (sim) prompt */
/* Analyses function; done when cuc command is entered in (sim) prompt */
cuc_func *analyse_function (char *module_name, long orig_time,
cuc_func *analyse_function (char *module_name, long orig_time,
                unsigned long start_addr, unsigned long end_addr,
                unsigned long start_addr, unsigned long end_addr,
                int memory_order)
                int memory_order, int num_runs)
{
{
  cuc_timings timings;
  cuc_timings timings;
  cuc_func *func = (cuc_func *) malloc (sizeof (cuc_func));
  cuc_func *func = (cuc_func *) malloc (sizeof (cuc_func));
  cuc_func *saved;
  cuc_func *saved;
  int b, i, j;
  int b, i, j;
Line 180... Line 181...
  func->start_addr = start_addr;
  func->start_addr = start_addr;
  func->end_addr = end_addr;
  func->end_addr = end_addr;
  func->memory_order = memory_order;
  func->memory_order = memory_order;
  func->nfdeps = 0;
  func->nfdeps = 0;
  func->fdeps = NULL;
  func->fdeps = NULL;
 
  func->num_runs = num_runs;
 
 
  sprintf (tmp1, "%s.bin", module_name);
  sprintf (tmp1, "%s.bin", module_name);
  cucdebug (2, "Loading %s.bin\n", module_name);
  cucdebug (2, "Loading %s.bin\n", module_name);
  if (cuc_load (tmp1)) {
  if (cuc_load (tmp1)) {
    free (func);
    free (func);
Line 576... Line 578...
    config.cuc.memory_order == MO_NONE ? "no" : config.cuc.memory_order == MO_WEAK ? "weak" :
    config.cuc.memory_order == MO_NONE ? "no" : config.cuc.memory_order == MO_WEAK ? "weak" :
    config.cuc.memory_order == MO_STRONG ? "strong" : "exact");
    config.cuc.memory_order == MO_STRONG ? "strong" : "exact");
 
 
  prof_set (1, 0);
  prof_set (1, 0);
  assert (prof_acquire (config.sim.prof_fn) == 0);
  assert (prof_acquire (config.sim.prof_fn) == 0);
  cuc_debug = 0;
  cuc_debug = 9;
 
 
  if (config.cuc.calling_convention)
  if (config.cuc.calling_convention)
    PRINTF ("Assuming OpenRISC standard calling convention.\n");
    PRINTF ("Assuming OpenRISC standard calling convention.\n");
 
 
  /* Try all functions except "total" */
  /* Try all functions except "total" */
Line 595... Line 597...
    end_addr = extract_function (tmp1, start_addr);
    end_addr = extract_function (tmp1, start_addr);
 
 
    log ("Testing function %s (%08x - %08x)\n", prof_func[i].name, start_addr, end_addr);
    log ("Testing function %s (%08x - %08x)\n", prof_func[i].name, start_addr, end_addr);
    PRINTF ("Testing function %s (%08x - %08x)\n", prof_func[i].name, start_addr, end_addr);
    PRINTF ("Testing function %s (%08x - %08x)\n", prof_func[i].name, start_addr, end_addr);
    func[i] = analyse_function (prof_func[i].name, orig_time, start_addr,
    func[i] = analyse_function (prof_func[i].name, orig_time, start_addr,
                   end_addr, config.cuc.memory_order);
                   end_addr, config.cuc.memory_order, prof_func[i].calls);
    func_v[i] = 0;
    func_v[i] = 0;
  }
  }
  set_func_deps ();
  set_func_deps ();
 
 
  while (1) {
  while (1) {
Line 614... Line 616...
      /* quit command */
      /* quit command */
    if (strcmp (tmp1, "q") == 0 || strcmp (tmp1, "quit") == 0) {
    if (strcmp (tmp1, "q") == 0 || strcmp (tmp1, "quit") == 0) {
      /* Delete temporary files */
      /* Delete temporary files */
      for (i = 0; i < prof_nfuncs - 1; i++) {
      for (i = 0; i < prof_nfuncs - 1; i++) {
        sprintf (tmp1, "%s.bin", prof_func[i].name);
        sprintf (tmp1, "%s.bin", prof_func[i].name);
        log ("Deleting temporary file %s %s\n", tmp1, remove (tmp1) ? "OK" : "FAILED");
        log ("Deleting temporary file %s %s\n", tmp1, remove (tmp1) ? "FAILED" : "OK");
        sprintf (tmp1, "%s.bin.bb", prof_func[i].name);
        sprintf (tmp1, "%s.bin.bb", prof_func[i].name);
        log ("Deleting temporary file %s %s\n", tmp1, remove (tmp1) ? "OK" : "FAILED");
        log ("Deleting temporary file %s %s\n", tmp1, remove (tmp1) ? "FAILED" : "OK");
      }
      }
      break;
      break;
 
 
      /* profile command */
      /* profile command */
    } else if (strcmp (tmp1, "p") == 0 || strcmp (tmp1, "profile") == 0) {
    } else if (strcmp (tmp1, "p") == 0 || strcmp (tmp1, "profile") == 0) {
Line 646... Line 648...
          double f = 1.0;
          double f = 1.0;
          if (func_v[i]) {
          if (func_v[i]) {
            int nt = calc_cycles (func[i]);
            int nt = calc_cycles (func[i]);
            int s = calc_size (func[i]);
            int s = calc_size (func[i]);
            f = 1. * func[i]->orig_time / nt;
            f = 1. * func[i]->orig_time / nt;
            ntime += nt * func[i]->num_runs;
            ntime += nt;
            size += s;
            size += s;
          } else ntime += prof_func[i].cum_cycles;
          } else ntime += prof_func[i].cum_cycles;
          PRINTF ("%8.1f |%8.1f | %-8s|\n", 1.f * prof_func[i].cum_cycles
          PRINTF ("%8.1f |%8.1f | %-8s|\n", 1.f * prof_func[i].cum_cycles
                          / func[i]->timings.new_time, f, format_func_options (tmp, func[i]));
                          / func[i]->timings.new_time, f, format_func_options (tmp, func[i]));
        } else {
        } else {

powered by: WebSVN 2.1.0

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