/* Function : portable_init
	Target specific initialization code 
	Test for some common mistakes.
*/
void portable_init(core_portable *p, int *argc, char *argv[])
{
	if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
		ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
	}
	if (sizeof(ee_u32) != 4) {
		ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
	}
	p->portable_id=1;
}
Beispiel #2
0
void printmatC(MATRES *C, ee_u32 N, char *name) {
	ee_u32 i,j;
	ee_printf("Matrix %s [%dx%d]:\n",name,N,N);
	for (i=0; i<N; i++) {
		for (j=0; j<N; j++) {
			if (j!=0)
				ee_printf(",");
			ee_printf("%d",C[i*N+j]);
		}
		ee_printf("\n");
	}
}
MEMORY_SECTION
void printmat(MATDAT *A, ee_u32 N, char *name) {
	ee_u32 i,j;
	ee_printf("Matrix %s [%dx%d]:\n",name,N,N);
	for (i=0; i<N; i++) {
		for (j=0; j<N; j++) {
			if (j!=0)
				ee_printf(",");
			ee_printf("%d",A[i*N+j]);
		}
		ee_printf("\n");
	}
}
Beispiel #4
0
void portable_init(core_portable *p, int *argc, char *argv[])
{
	//#error "Call board initialization routines in portable init (if needed), in particular initialize UART!\n"
	if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
		ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
	}
	if (sizeof(ee_u32) != 4) {
		ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
	}
	p->portable_id=1;
        
//#warning "At this point is safe to disable all clks except Core, FLASH, RAM and PIT (or LPT if challenge was accepted). Or in other words, disable UART here!"
        
}
Beispiel #5
0
/* Function : portable_fini
	Target specific final code 
*/
void portable_fini(core_portable *p)
{
  
//#warning "Enable UART clk at least"
  
	/*FSL: added message*/
	ee_printf("CoreBenchmark for FSL completed\n");
	p->portable_id=0;
}
Beispiel #6
0
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;
        Rec_Type        sp1, sp2;

  /* Initializations */

  Next_Ptr_Glob = (Rec_Pointer) &sp1;
  Ptr_Glob = (Rec_Pointer) &sp2;

  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.                   */

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


  Number_Of_Runs = *(int *)SM_ITER_PORT;


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

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

  Begin_Time = *(long *)SM_TIME_PORT;

  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 */
  /**************/

  End_Time = *(long *)SM_TIME_PORT;

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

  User_Time = End_Time - Begin_Time;

#define Too_Small_Time 0
  if (User_Time < Too_Small_Time)
  {
    ee_printf ("Measured time too small to obtain meaningful results\n");
    ee_printf ("Please increase number of runs\n");
    ee_printf ("\n");
  }
  else
  {
#if 0
    Microseconds = (float)User_Time/CLOCKS_PER_US;
    Dhrystones_Per_Second = (float) Number_Of_Runs / ((float)Microseconds / 1000000.0);
#endif

    ee_printf ("Number of Runs: %d\n", Number_Of_Runs);
    ee_printf ("User Time: %ld\n", User_Time);

#if 0
    ee_printf ("Microseconds for one run through Dhrystone: ");
    ee_printf ("%6.1f \n", Microseconds);
    ee_printf ("Dhrystones per Second:                      ");
    ee_printf ("%6.1f \n", Dhrystones_Per_Second);
    ee_printf ("\n");
#endif
  }

}
Beispiel #7
0
MAIN_RETURN_TYPE main_app(void) {
    int argc=0;
    char *argv[1];
#else
MAIN_RETURN_TYPE main(int argc, char *argv[]) {
#endif
    ee_u16 i,j=0,num_algorithms=0;
    ee_s16 known_id=-1,total_errors=0;
    ee_u16 seedcrc=0;
    CORE_TICKS total_time;
    core_results results[MULTITHREAD];
#if (MEM_METHOD==MEM_STACK)
    ee_u8 stack_memblock[TOTAL_DATA_SIZE*MULTITHREAD];
#endif
    /* first call any initializations needed */
    portable_init(&(results[0].port), &argc, argv);
    /* First some checks to make sure benchmark will run ok */
    if (sizeof(struct list_head_s)>128) {
        ee_printf("list_head structure too big for comparable data!\n");
        return MAIN_RETURN_VAL;
    }
    results[0].seed1=get_seed(1);
    results[0].seed2=get_seed(2);
    results[0].seed3=get_seed(3);
    results[0].iterations=get_seed_32(4);
#if CORE_DEBUG
    results[0].iterations=1;
#endif
    results[0].execs=get_seed_32(5);
    if (results[0].execs==0) { /* if not supplied, execute all algorithms */
        results[0].execs=ALL_ALGORITHMS_MASK;
    }
    /* put in some default values based on one seed only for easy testing */
    if ((results[0].seed1==0) && (results[0].seed2==0) && (results[0].seed3==0)) { /* validation run */
        results[0].seed1=0;
        results[0].seed2=0;
        results[0].seed3=0x66;
    }
    if ((results[0].seed1==1) && (results[0].seed2==0) && (results[0].seed3==0)) { /* perfromance run */
        results[0].seed1=0x3415;
        results[0].seed2=0x3415;
        results[0].seed3=0x66;
    }
#if (MEM_METHOD==MEM_STATIC)
    results[0].memblock[0]=(void *)static_memblk;
    results[0].size=TOTAL_DATA_SIZE;
    results[0].err=0;
#if (MULTITHREAD>1)
#error "Cannot use a static data area with multiple contexts!"
#endif
#elif (MEM_METHOD==MEM_MALLOC)
    for (i=0 ; i<MULTITHREAD; i++) {
        ee_s32 malloc_override=get_seed(7);
        if (malloc_override != 0)
            results[i].size=malloc_override;
        else
            results[i].size=TOTAL_DATA_SIZE;
        results[i].memblock[0]=portable_malloc(results[i].size);
        results[i].seed1=results[0].seed1;
        results[i].seed2=results[0].seed2;
        results[i].seed3=results[0].seed3;
        results[i].err=0;
        results[i].execs=results[0].execs;
    }
#elif (MEM_METHOD==MEM_STACK)
    for (i=0 ; i<MULTITHREAD; i++) {
        results[i].memblock[0]=stack_memblock+i*TOTAL_DATA_SIZE;
        results[i].size=TOTAL_DATA_SIZE;
        results[i].seed1=results[0].seed1;
        results[i].seed2=results[0].seed2;
        results[i].seed3=results[0].seed3;
        results[i].err=0;
        results[i].execs=results[0].execs;
    }
#else
#error "Please define a way to initialize a memory block."
#endif
    /* Data init */
    /* Find out how space much we have based on number of algorithms */
    for (i=0; i<NUM_ALGORITHMS; i++) {
        if ((1<<(ee_u32)i) & results[0].execs)
            num_algorithms++;
    }
    for (i=0 ; i<MULTITHREAD; i++)
        results[i].size=results[i].size/num_algorithms;
    /* Assign pointers */
    for (i=0; i<NUM_ALGORITHMS; i++) {
        ee_u32 ctx;
        if ((1<<(ee_u32)i) & results[0].execs) {
            for (ctx=0 ; ctx<MULTITHREAD; ctx++)
                results[ctx].memblock[i+1]=(char *)(results[ctx].memblock[0])+results[0].size*j;
            j++;
        }
    }
    /* call inits */
    for (i=0 ; i<MULTITHREAD; i++) {
        if (results[i].execs & ID_LIST) {
            results[i].list=core_list_init(results[0].size,results[i].memblock[1],results[i].seed1);
        }
        if (results[i].execs & ID_MATRIX) {
            core_init_matrix(results[0].size, results[i].memblock[2], (ee_s32)results[i].seed1 | (((ee_s32)results[i].seed2) << 16), &(results[i].mat) );
        }
        if (results[i].execs & ID_STATE) {
            core_init_state(results[0].size,results[i].seed1,results[i].memblock[3]);
        }
    }

    /* automatically determine number of iterations if not set */
    if (results[0].iterations==0) {
        secs_ret secs_passed=0;
        ee_u32 divisor;
        results[0].iterations=1;
        while (secs_passed < (secs_ret)1) {
            results[0].iterations*=10;
            start_time();
            iterate(&results[0]);
            stop_time();
            secs_passed=time_in_secs(get_time());
        }
        /* now we know it executes for at least 1 sec, set actual run time at about 10 secs */
        divisor=(ee_u32)secs_passed;
        if (divisor==0) /* some machines cast float to int as 0 since this conversion is not defined by ANSI, but we know at least one second passed */
            divisor=1;
        results[0].iterations*=1+10/divisor;
    }
    /* perform actual benchmark */
    start_time();
#if (MULTITHREAD>1)
    if (default_num_contexts>MULTITHREAD) {
        default_num_contexts=MULTITHREAD;
    }
    for (i=0 ; i<default_num_contexts; i++) {
        results[i].iterations=results[0].iterations;
        results[i].execs=results[0].execs;
        core_start_parallel(&results[i]);
    }
    for (i=0 ; i<default_num_contexts; i++) {
        core_stop_parallel(&results[i]);
    }
#else
    iterate(&results[0]);
#endif
    stop_time();
    total_time=get_time();
    /* get a function of the input to report */
    seedcrc=crc16(results[0].seed1,seedcrc);
    seedcrc=crc16(results[0].seed2,seedcrc);
    seedcrc=crc16(results[0].seed3,seedcrc);
    seedcrc=crc16(results[0].size,seedcrc);

    switch (seedcrc) { /* test known output for common seeds */
    case 0x8a02: /* seed1=0, seed2=0, seed3=0x66, size 2000 per algorithm */
        known_id=0;
        ee_printf("6k performance run parameters for coremark.\n");
        break;
    case 0x7b05: /*  seed1=0x3415, seed2=0x3415, seed3=0x66, size 2000 per algorithm */
        known_id=1;
        ee_printf("6k validation run parameters for coremark.\n");
        break;
    case 0x4eaf: /* seed1=0x8, seed2=0x8, seed3=0x8, size 400 per algorithm */
        known_id=2;
        ee_printf("Profile generation run parameters for coremark.\n");
        break;
    case 0xe9f5: /* seed1=0, seed2=0, seed3=0x66, size 666 per algorithm */
        known_id=3;
        ee_printf("2K performance run parameters for coremark.\n");
        break;
    case 0x18f2: /*  seed1=0x3415, seed2=0x3415, seed3=0x66, size 666 per algorithm */
        known_id=4;
        ee_printf("2K validation run parameters for coremark.\n");
        break;
    default:
        total_errors=-1;
        break;
    }
    if (known_id>=0) {
        for (i=0 ; i<default_num_contexts; i++) {
            results[i].err=0;
            if ((results[i].execs & ID_LIST) &&
                    (results[i].crclist!=list_known_crc[known_id])) {
                ee_printf("[%u]ERROR! list crc 0x%04x - should be 0x%04x\n",i,results[i].crclist,list_known_crc[known_id]);
                results[i].err++;
            }
            if ((results[i].execs & ID_MATRIX) &&
                    (results[i].crcmatrix!=matrix_known_crc[known_id])) {
                ee_printf("[%u]ERROR! matrix crc 0x%04x - should be 0x%04x\n",i,results[i].crcmatrix,matrix_known_crc[known_id]);
                results[i].err++;
            }
            if ((results[i].execs & ID_STATE) &&
                    (results[i].crcstate!=state_known_crc[known_id])) {
                ee_printf("[%u]ERROR! state crc 0x%04x - should be 0x%04x\n",i,results[i].crcstate,state_known_crc[known_id]);
                results[i].err++;
            }
            total_errors+=results[i].err;
        }
    }
    total_errors+=check_data_types();
    /* and report results */
    ee_printf("CoreMark Size    : %lu\n",(ee_u32)results[0].size);
    ee_printf("Total ticks      : %lu\n",(ee_u32)total_time);
#if HAS_FLOAT
    ee_printf("Total time (secs): %f\n",time_in_secs(total_time));
    if (time_in_secs(total_time) > 0)
        ee_printf("Iterations/Sec   : %f\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
#else
    ee_printf("Total time (secs): %d\n",time_in_secs(total_time));
    if (time_in_secs(total_time) > 0)
        ee_printf("Iterations/Sec   : %d\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
#endif
    if (time_in_secs(total_time) < 10) {
        ee_printf("ERROR! Must execute for at least 10 secs for a valid result!\n");
        total_errors++;
    }

    ee_printf("Iterations       : %lu\n",(ee_u32)default_num_contexts*results[0].iterations);
    ee_printf("Compiler version : %s\n",COMPILER_VERSION);
    ee_printf("Compiler flags   : %s\n",COMPILER_FLAGS);
#if (MULTITHREAD>1)
    ee_printf("Parallel %s : %d\n",PARALLEL_METHOD,default_num_contexts);
#endif
    ee_printf("Memory location  : %s\n",MEM_LOCATION);
    /* output for verification */
    ee_printf("seedcrc          : 0x%04x\n",seedcrc);
    if (results[0].execs & ID_LIST)
        for (i=0 ; i<default_num_contexts; i++)
            ee_printf("[%d]crclist       : 0x%04x\n",i,results[i].crclist);
    if (results[0].execs & ID_MATRIX)
        for (i=0 ; i<default_num_contexts; i++)
            ee_printf("[%d]crcmatrix     : 0x%04x\n",i,results[i].crcmatrix);
    if (results[0].execs & ID_STATE)
        for (i=0 ; i<default_num_contexts; i++)
            ee_printf("[%d]crcstate      : 0x%04x\n",i,results[i].crcstate);
    for (i=0 ; i<default_num_contexts; i++)
        ee_printf("[%d]crcfinal      : 0x%04x\n",i,results[i].crc);
    if (total_errors==0) {
        ee_printf("Correct operation validated. See readme.txt for run and reporting rules.\n");
#if HAS_FLOAT
        if (known_id==3) {
            ee_printf("CoreMark 1.0 : %f / %s %s",default_num_contexts*results[0].iterations/time_in_secs(total_time),COMPILER_VERSION,COMPILER_FLAGS);
#if defined(MEM_LOCATION) && !defined(MEM_LOCATION_UNSPEC)
            ee_printf(" / %s",MEM_LOCATION);
#else
            ee_printf(" / %s",mem_name[MEM_METHOD]);
#endif

#if (MULTITHREAD>1)
            ee_printf(" / %d:%s",default_num_contexts,PARALLEL_METHOD);
#endif
            ee_printf("\n");
        }
#endif
    }
    if (total_errors>0)
        ee_printf("Errors detected\n");
    if (total_errors<0)
        ee_printf("Cannot validate operation for these seed values, please compare with results on a known platform.\n");

#if (MEM_METHOD==MEM_MALLOC)
    for (i=0 ; i<MULTITHREAD; i++)
        portable_free(results[i].memblock[0]);
#endif
    /* And last call any target specific code for finalizing */
    portable_fini(&(results[0].port));

    return MAIN_RETURN_VAL;
}