예제 #1
0
int main (int argc, char** argv)
/*****/
  /* main program, corresponds to procedures        */
  /* Main and Proc_0 in the Ada version             */
{
        One_Fifty       Int_1_Loc;
  REG   One_Fifty       Int_2_Loc;
        One_Fifty       Int_3_Loc;
  REG   char            Ch_Index;
        Enumeration     Enum_Loc;
        Str_30          Str_1_Loc;
        Str_30          Str_2_Loc;
  REG   int             Run_Index;
  REG   int             Number_Of_Runs;

  /* Arguments */
#if HOST_DEBUG
  if (argc > 2)
  {
     do_fprintf (stdout, "Usage: %s [number of loops]\n", argv[0]);
     exit (1);
  }
  if (argc == 2)
  {
     Number_Of_Runs = atoi (argv[1]);
  } else
#endif
  {
     Number_Of_Runs = NUMBER_OF_RUNS;
  }
  if (Number_Of_Runs <= 0)
  {
     Number_Of_Runs = NUMBER_OF_RUNS;
  }

  /* Initializations */

  Next_Ptr_Glob = (Rec_Pointer) alloca (sizeof (Rec_Type));
  Ptr_Glob = (Rec_Pointer) alloca (sizeof (Rec_Type));

  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
  Ptr_Glob->Discr                       = Ident_1;
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
  strcpy (Ptr_Glob->variant.var_1.Str_Comp, 
          "DHRYSTONE PROGRAM, SOME STRING");
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

  Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */

#if HOST_DEBUG
  do_fprintf (stdout, "\n");
  do_fprintf (stdout, "Dhrystone Benchmark, Version %s\n", Version);
  if (Reg)
  {
    do_fprintf (stdout, "Program compiled with 'register' attribute\n");
  }
  else
  {
    do_fprintf (stdout, "Program compiled without 'register' attribute\n");
  }
  do_fprintf (stdout, "Using %s, HZ=%d\n", CLOCK_TYPE, HZ);
  do_fprintf (stdout, "\n");
#endif

  Done = false;
  while (!Done) {
#if HOST_DEBUG
    do_fprintf (stdout, "Trying %d runs through Dhrystone:\n", Number_Of_Runs);
#endif

    /***************/
    /* Start timer */
    /***************/

    Start_Timer();
    setStats(1);

    for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
    {

      Proc_5();
      Proc_4();
	/* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
      Int_1_Loc = 2;
      Int_2_Loc = 3;
      strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
      Enum_Loc = Ident_2;
      Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
	/* Bool_Glob == 1 */
      while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
      {
	Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
	  /* Int_3_Loc == 7 */
	Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
	  /* Int_3_Loc == 7 */
	Int_1_Loc += 1;
      } /* while */
	/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
      Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
	/* Int_Glob == 5 */
      Proc_1 (Ptr_Glob);
      for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
			       /* loop body executed twice */
      {
	if (Enum_Loc == Func_1 (Ch_Index, 'C'))
	    /* then, not executed */
	  {
	  Proc_6 (Ident_1, &Enum_Loc);
	  strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
	  Int_2_Loc = Run_Index;
	  Int_Glob = Run_Index;
	  }
      }
	/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
      Int_2_Loc = Int_2_Loc * Int_1_Loc;
      Int_1_Loc = Int_2_Loc / Int_3_Loc;
      Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
	/* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
      Proc_2 (&Int_1_Loc);
	/* Int_1_Loc == 5 */

    } /* loop "for Run_Index" */

    /**************/
    /* Stop timer */
    /**************/

    setStats(0);
    Stop_Timer();

    User_Time = End_Time - Begin_Time;

    if (User_Time < Too_Small_Time)
    {
      do_fprintf (stdout, "Measured time too small to obtain meaningful results\n");
      Number_Of_Runs = Number_Of_Runs * 10;
      do_fprintf (stdout, "\n");
    } else Done = true;
  }

  do_fprintf (stderr, "Final values of the variables used in the benchmark:\n");
  do_fprintf (stderr, "\n");
  do_fprintf (stderr, "Int_Glob:            %d\n", Int_Glob);
  do_fprintf (stderr, "        should be:   %d\n", 5);
  do_fprintf (stderr, "Bool_Glob:           %d\n", Bool_Glob);
  do_fprintf (stderr, "        should be:   %d\n", 1);
  do_fprintf (stderr, "Ch_1_Glob:           %c\n", Ch_1_Glob);
  do_fprintf (stderr, "        should be:   %c\n", 'A');
  do_fprintf (stderr, "Ch_2_Glob:           %c\n", Ch_2_Glob);
  do_fprintf (stderr, "        should be:   %c\n", 'B');
  do_fprintf (stderr, "Arr_1_Glob[8]:       %d\n", Arr_1_Glob[8]);
  do_fprintf (stderr, "        should be:   %d\n", 7);
  do_fprintf (stderr, "Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
  do_fprintf (stderr, "        should be:   Number_Of_Runs + 10\n");
  do_fprintf (stderr, "Ptr_Glob->\n");
  do_fprintf (stderr, "  Ptr_Comp:          %d\n", (int) Ptr_Glob->Ptr_Comp);
  do_fprintf (stderr, "        should be:   (implementation-dependent)\n");
  do_fprintf (stderr, "  Discr:             %d\n", Ptr_Glob->Discr);
  do_fprintf (stderr, "        should be:   %d\n", 0);
  do_fprintf (stderr, "  Enum_Comp:         %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
  do_fprintf (stderr, "        should be:   %d\n", 2);
  do_fprintf (stderr, "  Int_Comp:          %d\n", Ptr_Glob->variant.var_1.Int_Comp);
  do_fprintf (stderr, "        should be:   %d\n", 17);
  do_fprintf (stderr, "  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
  do_fprintf (stderr, "        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  do_fprintf (stderr, "Next_Ptr_Glob->\n");
  do_fprintf (stderr, "  Ptr_Comp:          %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
  do_fprintf (stderr, "        should be:   (implementation-dependent), same as above\n");
  do_fprintf (stderr, "  Discr:             %d\n", Next_Ptr_Glob->Discr);
  do_fprintf (stderr, "        should be:   %d\n", 0);
  do_fprintf (stderr, "  Enum_Comp:         %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
  do_fprintf (stderr, "        should be:   %d\n", 1);
  do_fprintf (stderr, "  Int_Comp:          %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
  do_fprintf (stderr, "        should be:   %d\n", 18);
  do_fprintf (stderr, "  Str_Comp:          %s\n",
                                Next_Ptr_Glob->variant.var_1.Str_Comp);
  do_fprintf (stderr, "        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  do_fprintf (stderr, "Int_1_Loc:           %d\n", Int_1_Loc);
  do_fprintf (stderr, "        should be:   %d\n", 5);
  do_fprintf (stderr, "Int_2_Loc:           %d\n", Int_2_Loc);
  do_fprintf (stderr, "        should be:   %d\n", 13);
  do_fprintf (stderr, "Int_3_Loc:           %d\n", Int_3_Loc);
  do_fprintf (stderr, "        should be:   %d\n", 7);
  do_fprintf (stderr, "Enum_Loc:            %d\n", Enum_Loc);
  do_fprintf (stderr, "        should be:   %d\n", 1);
  do_fprintf (stderr, "Str_1_Loc:           %s\n", Str_1_Loc);
  do_fprintf (stderr, "        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
  do_fprintf (stderr, "Str_2_Loc:           %s\n", Str_2_Loc);
  do_fprintf (stderr, "        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
  do_fprintf (stderr, "\n");


#if HOST_DEBUG
    Microseconds = (float) User_Time * Mic_secs_Per_Second 
                        / ((float) HZ * ((float) Number_Of_Runs));
    Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
                        / (float) User_Time;

    do_fprintf (stdout, "Microseconds for one run through Dhrystone: ");
    do_fprintf (stdout, "%10.1f \n", Microseconds);
    do_fprintf (stdout, "Dhrystones per Second:                      ");
    do_fprintf (stdout, "%10.0f \n", Dhrystones_Per_Second);
    do_fprintf (stdout, "\n");
#endif

  finishTest(1);
}
예제 #2
0
파일: dhry_1.c 프로젝트: 32bitmicro/xvisor
void dhry_main (int iterations)
/*****/

  /* main program, corresponds to procedures        */
  /* Main and Proc_0 in the Ada version             */
{
        One_Fifty       Int_1_Loc;
  REG   One_Fifty       Int_2_Loc;
        One_Fifty       Int_3_Loc;
  REG   char            Ch_Index;
        Enumeration     Enum_Loc;
        Str_30          Str_1_Loc;
        Str_30          Str_2_Loc;
  REG   int             Run_Index;
  REG   int             Number_Of_Runs;

  /* Initializations */
  Number_Of_Runs = iterations;
  Next_Ptr_Glob = (Rec_Pointer) dhry_malloc (sizeof (Rec_Type));
  Ptr_Glob = (Rec_Pointer) dhry_malloc (sizeof (Rec_Type));

  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
  Ptr_Glob->Discr                       = Ident_1;
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
  dhry_strcpy (Ptr_Glob->variant.var_1.Str_Comp, 
          "DHRYSTONE PROGRAM, SOME STRING");
  dhry_strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

  Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */

  dhry_prints ("\n");
  dhry_prints ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
  dhry_prints ("\n");
  if (Reg)
  {
    dhry_prints ("Program compiled with 'register' attribute\n");
    dhry_prints ("\n");
  }
  else
  {
    dhry_prints ("Program compiled without 'register' attribute\n");
    dhry_prints ("\n");
  }

  dhry_prints ("Execution starts, ");
  dhry_printi (Number_Of_Runs);
  dhry_prints (" runs through Dhrystone\n");

  /***************/
  /* Start timer */
  /***************/
 
  Begin_Time = dhry_timestamp();

  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
  {

    Proc_5();
    Proc_4();
      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
    Int_1_Loc = 2;
    Int_2_Loc = 3;
    dhry_strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
    Enum_Loc = Ident_2;
    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
      /* Bool_Glob == 1 */
    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
    {
      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
        /* Int_3_Loc == 7 */
      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
        /* Int_3_Loc == 7 */
      Int_1_Loc += 1;
    } /* while */
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
      /* Int_Glob == 5 */
    Proc_1 (Ptr_Glob);
    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
                             /* loop body executed twice */
    {
      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
          /* then, not executed */
        {
        Proc_6 (Ident_1, &Enum_Loc);
        dhry_strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
        Int_2_Loc = Run_Index;
        Int_Glob = Run_Index;
        }
    }
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Int_2_Loc = Int_2_Loc * Int_1_Loc;
    Int_1_Loc = dhry_sdiv32(Int_2_Loc, Int_3_Loc);
    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
    Proc_2 (&Int_1_Loc);
      /* Int_1_Loc == 5 */

  } /* loop "for Run_Index" */

  /**************/
  /* Stop timer */
  /**************/
  
  End_Time = dhry_timestamp();

  dhry_prints ("Execution ends\n");
  dhry_prints ("\n");
  dhry_prints ("Final values of the variables used in the benchmark:\n");
  dhry_prints ("\n");
  dhry_prints ("Int_Glob:            ");
  dhry_printi (Int_Glob);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (5);
  dhry_prints ("\n");
  dhry_prints ("Bool_Glob:           ");
  dhry_printi (Bool_Glob);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (1);
  dhry_prints ("\n");
  dhry_prints ("Ch_1_Glob:           ");
  dhry_printc (Ch_1_Glob);
  dhry_prints ("\n");
  dhry_prints ("        should be:   A\n");
  dhry_prints ("Ch_2_Glob:           ");
  dhry_printc (Ch_2_Glob);
  dhry_prints ("\n");
  dhry_prints ("        should be:   B\n");
  dhry_prints ("Arr_1_Glob[8]:       ");
  dhry_printi (Arr_1_Glob[8]);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (7);
  dhry_prints ("\n");
  dhry_prints ("Arr_2_Glob[8][7]:    ");
  dhry_printi (Arr_2_Glob[8][7]);
  dhry_prints ("\n");
  dhry_prints ("        should be:   Number_Of_Runs + 10\n");
  dhry_prints ("Ptr_Glob->\n");
  dhry_prints ("  Ptr_Comp:          ");
  dhry_printi ((int) Ptr_Glob->Ptr_Comp);
  dhry_prints ("\n");
  dhry_prints ("        should be:   (implementation-dependent)\n");
  dhry_prints ("  Discr:             ");
  dhry_printi (Ptr_Glob->Discr);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (0);
  dhry_prints ("\n");
  dhry_prints ("  Enum_Comp:         ");
  dhry_printi (Ptr_Glob->variant.var_1.Enum_Comp);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (2);
  dhry_prints ("\n");
  dhry_prints ("  Int_Comp:          ");
  dhry_printi (Ptr_Glob->variant.var_1.Int_Comp);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (17);
  dhry_prints ("\n");
  dhry_prints ("  Str_Comp:          ");
  dhry_prints (Ptr_Glob->variant.var_1.Str_Comp);
  dhry_prints ("\n");
  dhry_prints ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  dhry_prints ("Next_Ptr_Glob->\n");
  dhry_prints ("  Ptr_Comp:          ");
  dhry_printi ((int) Next_Ptr_Glob->Ptr_Comp);
  dhry_prints ("\n");
  dhry_prints ("        should be:   (implementation-dependent), same as above\n");
  dhry_prints ("  Discr:             ");
  dhry_printi (Next_Ptr_Glob->Discr);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (0);
  dhry_prints ("\n");
  dhry_prints ("  Enum_Comp:         ");
  dhry_printi (Next_Ptr_Glob->variant.var_1.Enum_Comp);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (1);
  dhry_prints ("\n");
  dhry_prints ("  Int_Comp:          ");
  dhry_printi (Next_Ptr_Glob->variant.var_1.Int_Comp);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (18);
  dhry_prints ("\n");
  dhry_prints ("  Str_Comp:          ");
  dhry_prints (Next_Ptr_Glob->variant.var_1.Str_Comp);
  dhry_prints ("\n");
  dhry_prints ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  dhry_prints ("Int_1_Loc:           ");
  dhry_printi (Int_1_Loc);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (5);
  dhry_prints ("\n");
  dhry_prints ("Int_2_Loc:           ");
  dhry_printi (Int_2_Loc);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (13);
  dhry_prints ("\n");
  dhry_prints ("Int_3_Loc:           ");
  dhry_printi (Int_3_Loc);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (7);
  dhry_prints ("\n");
  dhry_prints ("Enum_Loc:            ");
  dhry_printi (Enum_Loc);
  dhry_prints ("\n");
  dhry_prints ("        should be:   ");
  dhry_printi (1);
  dhry_prints ("\n");
  dhry_prints ("Str_1_Loc:           ");
  dhry_prints (Str_1_Loc);
  dhry_prints ("\n");
  dhry_prints ("        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
  dhry_prints ("Str_2_Loc:           ");
  dhry_prints (Str_2_Loc);
  dhry_prints ("\n");
  dhry_prints ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
  dhry_prints ("\n");

  User_Time = End_Time - Begin_Time;

  if (User_Time < Too_Small_Time)
  {
    dhry_prints ("Measured time too small to obtain meaningful results\n");
    dhry_prints ("Please increase number of runs\n");
    dhry_prints ("\n");
  }
  else
  {
    Microseconds = dhry_to_microsecs(User_Time);
    Dhrystones_Per_Second = dhry_iter_per_sec(User_Time, Number_Of_Runs);
    dhry_prints ("Microseconds for one run through Dhrystone: ");
    dhry_printi (Microseconds);
    dhry_prints (" \n");
    dhry_prints ("Dhrystones per Second:                      ");
    dhry_printi (Dhrystones_Per_Second);
    dhry_prints (" \n");
    dhry_prints ("Dhrystones MIPS:                            ");
    dhry_printi (arm_sdiv32(Dhrystones_Per_Second, 1757));
    dhry_prints (" \n");
    dhry_prints ("\n");
  }
  
}
예제 #3
0
파일: dhry.c 프로젝트: 0day-ci/gcc
main ()
/*****/

  /* main program, corresponds to procedures        */
  /* Main and Proc_0 in the Ada version             */
{
        One_Fifty       Int_1_Loc;
  REG   One_Fifty       Int_2_Loc;
        One_Fifty       Int_3_Loc;
  REG   char            Ch_Index;
        Enumeration     Enum_Loc;
        Str_30          Str_1_Loc;
        Str_30          Str_2_Loc;
  REG   int             Run_Index;
  REG   int             Number_Of_Runs;

  /* Initializations */

  Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
  Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));

  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
  Ptr_Glob->Discr                       = Ident_1;
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
  strcpy (Ptr_Glob->variant.var_1.Str_Comp, 
          "DHRYSTONE PROGRAM, SOME STRING");
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

  Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */

/*
  printf ("\n");
  printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
  printf ("\n");
*/
  if (Reg)
  {
/*
    printf ("Program compiled with 'register' attribute\n");
    printf ("\n");
*/
  }
  else
  {
/*
    printf ("Program compiled without 'register' attribute\n");
    printf ("\n");
*/
  }
/*
  printf ("Please give the number of runs through the benchmark: ");
*/
  {
    int n;
/*
    scanf ("%d", &n);
*/
    Number_Of_Runs = n=1000;
  }
/*
  printf ("\n");

  printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
*/

  /***************/
  /* Start timer */
  /***************/

/* 
#ifdef TIMES
  times (&time_info);
  Begin_Time = (long) time_info.tms_utime;
#endif
#ifdef TIME
  Begin_Time = time ( (long *) 0);
#endif
*/

  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
  {

    Proc_5();
    Proc_4();
      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
    Int_1_Loc = 2;
    Int_2_Loc = 3;
    strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
    Enum_Loc = Ident_2;
    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
      /* Bool_Glob == 1 */
    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
    {
      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
        /* Int_3_Loc == 7 */
      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
        /* Int_3_Loc == 7 */
      Int_1_Loc += 1;
    } /* while */
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
      /* Int_Glob == 5 */
    Proc_1 (Ptr_Glob);
    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
                             /* loop body executed twice */
    {
      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
          /* then, not executed */
        {
        Proc_6 (Ident_1, &Enum_Loc);
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
        Int_2_Loc = Run_Index;
        Int_Glob = Run_Index;
        }
    }
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Int_2_Loc = Int_2_Loc * Int_1_Loc;
    Int_1_Loc = Int_2_Loc / Int_3_Loc;
    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
    Proc_2 (&Int_1_Loc);
      /* Int_1_Loc == 5 */

  } /* loop "for Run_Index" */

  /**************/
  /* Stop timer */
  /**************/
 
/* 
#ifdef TIMES
  times (&time_info);
  End_Time = (long) time_info.tms_utime;
#endif
#ifdef TIME
  End_Time = time ( (long *) 0);
#endif
*/

/*
  printf ("Execution ends\n");
  printf ("\n");
  printf ("Final values of the variables used in the benchmark:\n");
  printf ("\n");
  printf ("Int_Glob:            %d\n", Int_Glob);
  printf ("        should be:   %d\n", 5);
  printf ("Bool_Glob:           %d\n", Bool_Glob);
  printf ("        should be:   %d\n", 1);
  printf ("Ch_1_Glob:           %c\n", Ch_1_Glob);
  printf ("        should be:   %c\n", 'A');
  printf ("Ch_2_Glob:           %c\n", Ch_2_Glob);
  printf ("        should be:   %c\n", 'B');
  printf ("Arr_1_Glob[8]:       %d\n", Arr_1_Glob[8]);
  printf ("        should be:   %d\n", 7);
  printf ("Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
  printf ("        should be:   Number_Of_Runs + 10\n");
  printf ("Ptr_Glob->\n");
  printf ("  Ptr_Comp:          %d\n", (int) Ptr_Glob->Ptr_Comp);
  printf ("        should be:   (implementation-dependent)\n");
  printf ("  Discr:             %d\n", Ptr_Glob->Discr);
  printf ("        should be:   %d\n", 0);
  printf ("  Enum_Comp:         %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
  printf ("        should be:   %d\n", 2);
  printf ("  Int_Comp:          %d\n", Ptr_Glob->variant.var_1.Int_Comp);
  printf ("        should be:   %d\n", 17);
  printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  printf ("Next_Ptr_Glob->\n");
  printf ("  Ptr_Comp:          %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
  printf ("        should be:   (implementation-dependent), same as above\n");
  printf ("  Discr:             %d\n", Next_Ptr_Glob->Discr);
  printf ("        should be:   %d\n", 0);
  printf ("  Enum_Comp:         %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
  printf ("        should be:   %d\n", 1);
  printf ("  Int_Comp:          %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
  printf ("        should be:   %d\n", 18);
  printf ("  Str_Comp:          %s\n",
                                Next_Ptr_Glob->variant.var_1.Str_Comp);
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  printf ("Int_1_Loc:           %d\n", Int_1_Loc);
  printf ("        should be:   %d\n", 5);
  printf ("Int_2_Loc:           %d\n", Int_2_Loc);
  printf ("        should be:   %d\n", 13);
  printf ("Int_3_Loc:           %d\n", Int_3_Loc);
  printf ("        should be:   %d\n", 7);
  printf ("Enum_Loc:            %d\n", Enum_Loc);
  printf ("        should be:   %d\n", 1);
  printf ("Str_1_Loc:           %s\n", Str_1_Loc);
  printf ("        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
  printf ("Str_2_Loc:           %s\n", Str_2_Loc);
  printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
  printf ("\n");
*/

  User_Time = End_Time - Begin_Time;

  if (User_Time < Too_Small_Time)
  {
/*
    printf ("Measured time too small to obtain meaningful results\n");
    printf ("Please increase number of runs\n");
    printf ("\n");
*/
  }
  else
  {
#ifdef TIME
/*
    Microseconds = (float) User_Time * Mic_secs_Per_Second 
                        / (float) Number_Of_Runs;
    Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time;
*/
#else
/*
    Microseconds = (float) User_Time * Mic_secs_Per_Second 
                        / ((float) HZ * ((float) Number_Of_Runs));
    Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
                        / (float) User_Time;
*/
#endif
/*
    printf ("Microseconds for one run through Dhrystone: ");
    printf ("%6.1f \n", Microseconds);
    printf ("Dhrystones per Second:                      ");
    printf ("%6.1f \n", Dhrystones_Per_Second);
    printf ("\n");
*/
  }

  exit (0);
}
예제 #4
0
파일: dhry_1.c 프로젝트: gatieme/Benchmark
int main (int argc, char *argv[])
/*****/

  /* main program, corresponds to procedures        */
  /* Main and Proc_0 in the Ada version             */
{
  double   dtime();

        One_Fifty       Int_1_Loc;
  REG   One_Fifty       Int_2_Loc;
        One_Fifty       Int_3_Loc;
  REG   char            Ch_Index;
        Enumeration     Enum_Loc;
        Str_30          Str_1_Loc;
        Str_30          Str_2_Loc;
  REG   int             Run_Index;
  REG   int             Number_Of_Runs;

        FILE            *Ap;

  /* Initializations */

  if ((Ap = fopen("result","a+")) == NULL)
    {
       printf("Can not open dhry.res\n\n");
       exit(1);
    }

  Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
  Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));

  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
  Ptr_Glob->Discr                       = Ident_1;
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
  strcpy (Ptr_Glob->variant.var_1.Str_Comp, 
          "DHRYSTONE PROGRAM, SOME STRING");
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

  Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */

  printf ("\n");
  printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
  printf ("\n");
/*  
  if (Reg)
  {
    printf ("Program compiled with 'register' attribute\n");
    printf ("\n");
  }
  else
  {
    printf ("Program compiled without 'register' attribute\n");
    printf ("\n");
  }
*/
  printf ("Please give the number of runs through the benchmark: ");
  {
    int n;
    scanf ("%d", &n);
    Number_Of_Runs = n;
  }
  printf ("\n");

  printf ("Execution starts, %d runs through Dhrystone\n",Number_Of_Runs);

  /***************/
  /* Start timer */
  /***************/
 
  Begin_Time = dtime();
  
  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
  {

    Proc_5();
    Proc_4();
      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
    Int_1_Loc = 2;
    Int_2_Loc = 3;
    strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
    Enum_Loc = Ident_2;
    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
      /* Bool_Glob == 1 */
    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
    {
      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
        /* Int_3_Loc == 7 */
      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
        /* Int_3_Loc == 7 */
      Int_1_Loc += 1;
    } /* while */
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
      /* Int_Glob == 5 */
    Proc_1 (Ptr_Glob);
    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)//Ch_2_Glob == 'B'
                             /* loop body executed twice */
    {//Enum_Loc==Ident_2==1
      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
          /* then, not executed ,*/
        {
        Proc_6 (Ident_1, &Enum_Loc);  //Proc_6(0,1),执行后,Enum_Loc==0
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
        Int_2_Loc = Run_Index;
        Int_Glob = Run_Index;
        }
    }
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Int_2_Loc = Int_2_Loc * Int_1_Loc;
    Int_1_Loc = Int_2_Loc / Int_3_Loc;
    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
    Proc_2 (&Int_1_Loc);
      /* Int_1_Loc == 5 */

  } /* loop "for Run_Index" */

  /**************/
  /* Stop timer */
  /**************/

  End_Time = dtime();
   printf ("Execution ends\n");
  printf ("\n");
  printf ("Final values of the variables used in the benchmark:\n");
  printf ("\n");
  printf ("Int_Glob:            %d\n", Int_Glob);
  printf ("        should be:   %d\n", 5);
  printf ("Bool_Glob:           %d\n", Bool_Glob);
  printf ("        should be:   %d\n", 1);
  printf ("Ch_1_Glob:           %c\n", Ch_1_Glob);
  printf ("        should be:   %c\n", 'A');
  printf ("Ch_2_Glob:           %c\n", Ch_2_Glob);
  printf ("        should be:   %c\n", 'B');
  printf ("Arr_1_Glob[8]:       %d\n", Arr_1_Glob[8]);
  printf ("        should be:   %d\n", 7);
  printf ("Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
  printf ("        should be:   Number_Of_Runs + 10\n");
  printf ("Ptr_Glob->\n");
  printf ("  Ptr_Comp:          %d\n", (int) Ptr_Glob->Ptr_Comp);
  printf ("        should be:   (implementation-dependent)\n");
  printf ("  Discr:             %d\n", Ptr_Glob->Discr);
  printf ("        should be:   %d\n", 0);
  printf ("  Enum_Comp:         %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
  printf ("        should be:   %d\n", 2);
  printf ("  Int_Comp:          %d\n", Ptr_Glob->variant.var_1.Int_Comp);
  printf ("        should be:   %d\n", 17);
  printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  printf ("Next_Ptr_Glob->\n");
  printf ("  Ptr_Comp:          %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
  printf ("        should be:   (implementation-dependent), same as above\n");
  printf ("  Discr:             %d\n", Next_Ptr_Glob->Discr);
  printf ("        should be:   %d\n", 0);
  printf ("  Enum_Comp:         %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
  printf ("        should be:   %d\n", 1);
  printf ("  Int_Comp:          %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
  printf ("        should be:   %d\n", 18);
  printf ("  Str_Comp:          %s\n", Next_Ptr_Glob->variant.var_1.Str_Comp);
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  printf ("Int_1_Loc:           %d\n", Int_1_Loc);
  printf ("        should be:   %d\n", 5);
  printf ("Int_2_Loc:           %d\n", Int_2_Loc);
  printf ("        should be:   %d\n", 13);
  printf ("Int_3_Loc:           %d\n", Int_3_Loc);
  printf ("        should be:   %d\n", 7);
  printf ("Enum_Loc:            %d\n", Enum_Loc);
  printf ("        should be:   %d\n", 1);
  printf ("Str_1_Loc:           %s\n", Str_1_Loc);
  printf ("        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
  printf ("Str_2_Loc:           %s\n", Str_2_Loc);
  printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
  printf ("\n");

  //User_Time = End_Time - Begin_Time;
  User_Time=End_Time;
  
  if (User_Time < Too_Small_Time)
  {
    printf ("Measured time too small to obtain meaningful results\n");
    printf ("Please increase number of runs\n");
    printf ("\n");
  }
  else
  {
    Microseconds = User_Time * Mic_secs_Per_Second  / (double) Number_Of_Runs;
    Dhrystones_Per_Second = (double) Number_Of_Runs / User_Time;
    Vax_Mips = Dhrystones_Per_Second / 1757.0;

#ifdef ROPT
    printf ("Register option selected?  YES\n");
#else
    printf ("Register option selected?  NO\n");
    strcpy(Reg_Define, "Register option not selected.");
#endif
    printf ("Microseconds for one run through Dhrystone: ");
    printf ("%7.1lf \n", Microseconds);
    printf ("Dhrystones per Second:                      ");
    printf ("%10.1lf \n", Dhrystones_Per_Second);
    printf ("VAX MIPS rating = %10.3lf \n",Vax_Mips);
    printf ("\n");
  
  fprintf(Ap,"\n");
  fprintf(Ap,"Dhrystone Benchmark, Version 2.1 (Language: C)\n");
  fprintf(Ap,"%s\n",Reg_Define);
  fprintf(Ap,"Microseconds for one loop: %7.1lf\n",Microseconds);
  fprintf(Ap,"Dhrystones per second: %10.1lf\n",Dhrystones_Per_Second);
  fprintf(Ap,"VAX MIPS rating: %10.3lf\n",Vax_Mips);
  fclose(Ap);
  
  }

  return 0;  
}
예제 #5
0
int main ()
/*****/

  /* main program, corresponds to procedures        */
  /* Main and Proc_0 in the Ada version             */
{
        One_Fifty       Int_1_Loc;
  REG   One_Fifty       Int_2_Loc=0;
        One_Fifty       Int_3_Loc;
  REG   char            Ch_Index;
        Enumeration     Enum_Loc;
        Str_30          Str_1_Loc;
        Str_30          Str_2_Loc;
  REG   int             Run_Index;
  REG   int             Number_Of_Runs;
  Rec_Type		x, y;

  /* Initializations */

  Next_Ptr_Glob = (Rec_Pointer) &x;
  Ptr_Glob = (Rec_Pointer) &y;

  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
  Ptr_Glob->Discr                       = Ident_1;
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
  strcpy (Ptr_Glob->variant.var_1.Str_Comp, 
          "DHRYSTONE PROGRAM, SOME STRING");
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

  Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */

/* Initalize Data and Instruction Cache */


  printf (" %c", '\n');
  printf ("Dhrystone Benchmark, Version 2.1 (Language: C)%c", '\n');
  printf (" %c", '\n');
  if (Reg)
  {
    printf ("Program compiled with 'register' attribute%c", '\n');
    printf (" %c", '\n');
  }
  else
  {
    printf ("Program compiled without 'register' attribute%c", '\n');
    printf (" %c", '\n');
  }
  printf ("Please give the number of runs through the benchmark:%c", ' ');

  {
    int n;
    /* scanf ("%d", &n);
 */
    n = NUM_RUNS;
    Number_Of_Runs = n;
  }
  printf (" %c", '\n');

  printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
 


  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
  {

	Ireport(1);
	Ireport(Run_Index);
    Proc_5();
	Ireport(2);
    Proc_4();
	Ireport(3);
      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
    Int_1_Loc = 2;
    Int_2_Loc = 3;
    strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
    Enum_Loc = Ident_2;
	Ireport(0x31);
	Ireport((unsigned long)Str_1_Loc);
	Ireport((unsigned long)Str_2_Loc);
    
    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
      /* Bool_Glob == 1 */
	Ireport(4);
    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
    {
      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
        /* Int_3_Loc == 7 */
      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
        /* Int_3_Loc == 7 */
      Int_1_Loc += 1;
    } /* while */
	Ireport(5);
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
#if DBG
      printf("a) Int_1_Loc: %x\n", Int_1_Loc);
      printf("a) Int_2_Loc: %x\n", Int_2_Loc);
      printf("a) Int_3_Loc: %x\n\n", Int_3_Loc);
#endif
    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
      /* Int_Glob == 5 */
#if DBG
      printf("b) Int_1_Loc: %x\n", Int_1_Loc);
      printf("b) Int_2_Loc: %x\n", Int_2_Loc);
      printf("b) Int_3_Loc: %x\n\n", Int_3_Loc);
#endif
	Ireport(6);

    Proc_1 (Ptr_Glob);
#if DBG
      printf("c) Int_1_Loc: %x\n", Int_1_Loc);
      printf("c) Int_2_Loc: %x\n", Int_2_Loc);
      printf("c) Int_3_Loc: %x\n\n", Int_3_Loc);
#endif
	Ireport(7);

    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
                             /* loop body executed twice */
    {
      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
          /* then, not executed */
        {
        Proc_6 (Ident_1, &Enum_Loc);
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
        Int_2_Loc = Run_Index;
        Int_Glob = Run_Index;
#if DBG
      printf("d) Int_1_Loc: %x\n", Int_1_Loc);
      printf("d) Int_2_Loc: %x\n", Int_2_Loc);
      printf("d) Int_3_Loc: %x\n\n", Int_3_Loc);
#endif
        }
    }
    	Ireport(8);

      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
#if DBG
      printf("e) Int_1_Loc: %x\n", Int_1_Loc);
      printf("e) Int_2_Loc: %x\n", Int_2_Loc);
      printf("e) Int_3_Loc: %x\n", Int_3_Loc);
      printf("e) Ch_1_Glob: %c\n\n", Ch_1_Glob);
#endif
    Int_2_Loc = Int_2_Loc * Int_1_Loc;
    Int_1_Loc = Int_2_Loc / Int_3_Loc;
    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
    Proc_2 (&Int_1_Loc);
	Ireport(9);

      /* Int_1_Loc == 5 */
#if DBG
      printf("f) Int_1_Loc: %x\n", Int_1_Loc);
      printf("f) Int_2_Loc: %x\n", Int_2_Loc);
      printf("f) Int_3_Loc: %x\n\n", Int_3_Loc);
#endif

  } /* loop "for Run_Index" */


  printf ("Execution ends%c", '\n');
  printf (" %c", '\n');
  printf ("Final values of the variables used in the benchmark:%c", '\n');
  printf (" %c", '\n');
  printf ("Int_Glob:            %d\n", Int_Glob);
  printf ("        should be:   %d\n", 5);
  printf ("Bool_Glob:           %d\n", Bool_Glob);
  printf ("        should be:   %d\n", 1);
  printf ("Ch_1_Glob:           %c\n", Ch_1_Glob);
  printf ("        should be:   %c\n", 'A');
  printf ("Ch_2_Glob:           %c\n", Ch_2_Glob);
  printf ("        should be:   %c\n", 'B');
  printf ("Arr_1_Glob[8]:       %d\n", Arr_1_Glob[8]);
  printf ("        should be:   %d\n", 7);
  printf ("Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
  printf ("        should be:   Number_Of_Runs + 10%c", '\n');
  printf ("Ptr_Glob->%c", '\n');
//  printf ("  Ptr_Comp:          %d\n", (int) Ptr_Glob->Ptr_Comp);
  printf ("        should be:   (implementation-dependent)%c", '\n');
  printf ("  Discr:             %d\n", Ptr_Glob->Discr);
  printf ("        should be:   %d\n", 0);
  printf ("  Enum_Comp:         %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
  printf ("        should be:   %d\n", 2);
  printf ("  Int_Comp:          %d\n", Ptr_Glob->variant.var_1.Int_Comp);
  printf ("        should be:   %d\n", 17);
  printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING%c", '\n');
  printf ("Next_Ptr_Glob->%c", '\n');
//  printf ("  Ptr_Comp:          %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
  printf ("        should be:   (implementation-dependent), same as above%c", '\n');
  printf ("  Discr:             %d\n", Next_Ptr_Glob->Discr);
  printf ("        should be:   %d\n", 0);
  printf ("  Enum_Comp:         %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
  printf ("        should be:   %d\n", 1);
  printf ("  Int_Comp:          %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
  printf ("        should be:   %d\n", 18);
  printf ("  Str_Comp:          %s\n",
                                Next_Ptr_Glob->variant.var_1.Str_Comp);
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING%c", '\n');
  printf ("Int_1_Loc:           %d\n", Int_1_Loc);
  printf ("        should be:   %d\n", 5);
  printf ("Int_2_Loc:           %d\n", Int_2_Loc);
  printf ("        should be:   %d\n", 13);
  printf ("Int_3_Loc:           %d\n", Int_3_Loc);
  printf ("        should be:   %d\n", 7);
  printf ("Enum_Loc:            %d\n", Enum_Loc);
  printf ("        should be:   %d\n", 1);
  printf ("Str_1_Loc:           %s\n", Str_1_Loc);
  printf ("        should be:   DHRYSTONE PROGRAM, 1'ST STRING%c", '\n');
  printf ("Str_2_Loc:           %s\n", Str_2_Loc);
  printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING%c", '\n');




  User_Time = End_Time - Begin_Time;
 /* microseconds */

  printf("Begin Time = %d\n",Begin_Time);
  printf("End Time   = %d\n",End_Time);
 

  if (User_Time < Too_Small_Time)
  {
    printf ("Measured time too small to obtain meaningful results%c", '\n');
    printf ("Please increase number of runs%c", '\n');
    printf (" %c", '\n');
  }
  else
  {
#if DLX || OR1K
    User_Time /= DLX_FREQ;
#if DLX
    printf("DLX%c", ' ');
#else
#if OR1K
    printf("OR1K%c", ' ');
#else
    printf("Unknown CPU%c", '\n');
#endif
#endif
    printf("at %u MHz  ", DLX_FREQ);
    if (PROC_6)
	    printf("(+PROC_6) ");
    printf(" %c", '\n');
#endif
    Microseconds = User_Time / Number_Of_Runs;
    Dhrystones_Per_Second = Number_Of_Runs * 1000 / User_Time;
    printf ("Microseconds for one run through Dhrystone:%c", ' ');
    printf ("%d us / %d runs\n", User_Time,Number_Of_Runs);
    printf ("Dhrystones per Second:                     %c", ' ');
    printf ("%d \n", Dhrystones_Per_Second);
  }
  //report (0xdeaddead);
  return 0;
}
예제 #6
0
파일: dhry_1.c 프로젝트: Flyagin/BS-MRZV
//int main ( void )
void testloop ( int Number_Of_Runs )
/*****/

/* main program, corresponds to procedures        */
/* Main and Proc_0 in the Ada version             */
{
    One_Fifty       Int_1_Loc;
    REG One_Fifty   Int_2_Loc;
    One_Fifty       Int_3_Loc;
    REG char        Ch_Index;
    Enumeration     Enum_Loc;
    Str_30          Str_1_Loc;
    Str_30          Str_2_Loc;
    REG int         Run_Index;


    /* Initializations */
    Rec_Type alloc_NextGlob;
    Rec_Type alloc_Glob;
    Next_Ptr_Glob = (Rec_Pointer) &alloc_NextGlob;
    Ptr_Glob      = (Rec_Pointer) &alloc_Glob;

    //Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
    //Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));

    Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
    Ptr_Glob->Discr                       = Ident_1;
    Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
    Ptr_Glob->variant.var_1.Int_Comp      = 40;
    strcpy (Ptr_Glob->variant.var_1.Str_Comp,
            "DHRYSTONE PROGRAM, SOME STRING");
    strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

    Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */


    /***************/
    /* Start loop */
    /***************/

    for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
    {
        Proc_5();
        Proc_4();
        /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
        Int_1_Loc = 2;
        Int_2_Loc = 3;
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
        Enum_Loc = Ident_2;
        Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
        /* Bool_Glob == 1 */
        while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
        {
            Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
            /* Int_3_Loc == 7 */
            Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
            /* Int_3_Loc == 7 */
            Int_1_Loc += 1;
        } /* while */
        /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
        Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
        /* Int_Glob == 5 */
        Proc_1 (Ptr_Glob);
        for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
                             /* loop body executed twice */
        {
            if (Enum_Loc == Func_1 (Ch_Index, 'C'))
            /* then, not executed */
            {
                Proc_6 (Ident_1, &Enum_Loc);
                strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
                Int_2_Loc = Run_Index;
                Int_Glob = Run_Index;
            }
        }
        /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
        Int_2_Loc = Int_2_Loc * Int_1_Loc;
        Int_1_Loc = Int_2_Loc / Int_3_Loc;
        Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
        /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
        Proc_2 (&Int_1_Loc);
        /* Int_1_Loc == 5 */

    } /* loop "for Run_Index" */

}
예제 #7
0
int dhry ( int Number_Of_Runs )
/*****/

  /* main program, corresponds to procedures        */
  /* Main and Proc_0 in the Ada version             */
{
        One_Fifty       Int_1_Loc;
  REG   One_Fifty       Int_2_Loc;
        One_Fifty       Int_3_Loc;
  REG   char            Ch_Index;
        Enumeration     Enum_Loc;
        Str_30          Str_1_Loc;
        Str_30          Str_2_Loc;
  REG   int             Run_Index;

  /* Initializations */

  Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
  Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));

  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
  Ptr_Glob->Discr                       = Ident_1;
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
  strcpy (Ptr_Glob->variant.var_1.Str_Comp, 
          "DHRYSTONE PROGRAM, SOME STRING");
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

  Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */

  printf ("\n");
  printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
  printf ("\n");
  if (Reg)
  {
    printf ("Program compiled with 'register' attribute\n");
    printf ("\n");
  }
  else
  {
    printf ("Program compiled without 'register' attribute\n");
    printf ("\n");
  }
  printf ("\n");

  printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);

  /***************/
  /* Start timer */
  /***************/
 
#ifdef TIMES
  times (&time_info);
  Begin_Time = (long) time_info.tms_utime;
#endif
#ifdef TIME
  Begin_Time = time ( (long *) 0);
#endif

  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
  {

    Proc_5();
    Proc_4();
      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
    Int_1_Loc = 2;
    Int_2_Loc = 3;
    strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
    Enum_Loc = Ident_2;
    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
      /* Bool_Glob == 1 */
    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
    {
      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
        /* Int_3_Loc == 7 */
      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
        /* Int_3_Loc == 7 */
      Int_1_Loc += 1;
    } /* while */
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
      /* Int_Glob == 5 */
    Proc_1 (Ptr_Glob);
    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
                             /* loop body executed twice */
    {
      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
          /* then, not executed */
        {
        Proc_6 (Ident_1, &Enum_Loc);
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
        Int_2_Loc = Run_Index;
        Int_Glob = Run_Index;
        }
    }
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Int_2_Loc = Int_2_Loc * Int_1_Loc;
    Int_1_Loc = Int_2_Loc / Int_3_Loc;
    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
    Proc_2 (&Int_1_Loc);
      /* Int_1_Loc == 5 */

  } /* loop "for Run_Index" */

  /**************/
  /* Stop timer */
  /**************/
  
#ifdef TIMES
  times (&time_info);
  End_Time = (long) time_info.tms_utime;
#endif
#ifdef TIME
  End_Time = time ( (long *) 0);
#endif

  assert(Int_Glob == 5);
  assert(Bool_Glob);
  assert(Ch_1_Glob ==  'A');
  assert(Ch_2_Glob ==  'B');
  assert(Arr_1_Glob[8] ==  7);
  assert(Arr_2_Glob[8][7] == Number_Of_Runs + 10);
  assert(Ptr_Glob->Discr ==  0);
  assert(Ptr_Glob->variant.var_1.Enum_Comp ==  2);
  assert(Ptr_Glob->variant.var_1.Int_Comp ==  17);
  assert(!strcmp(Ptr_Glob->variant.var_1.Str_Comp,
				 "DHRYSTONE PROGRAM, SOME STRING"));
  assert((int) Ptr_Glob->Ptr_Comp == (int) Next_Ptr_Glob->Ptr_Comp);
  assert(Next_Ptr_Glob->Discr ==  0);
  assert(Next_Ptr_Glob->variant.var_1.Enum_Comp ==  1);
  assert(Next_Ptr_Glob->variant.var_1.Int_Comp == 18);
  assert(!strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp,
				 "DHRYSTONE PROGRAM, SOME STRING"));
  assert(Int_1_Loc ==  5);
  assert(Int_2_Loc ==  13);
  assert(Int_3_Loc ==  7);
  assert(Enum_Loc ==  1);
  assert(!strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING"));
  assert(!strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING"));

  User_Time = End_Time - Begin_Time;
  return User_Time;
}