示例#1
0
/////////////////////////////////////////////////////////
// main testing function 
/////////////////////////////////////////////////////////
int main(int argc, const char * const argv[])
{
  (void)argc;
  (void)argv;

  boolean_T pass;
  int coreid, k;
  float filt[200];
  float tmp[2];



  /////////////////////////////////////////////////////////
  // main test loop 
  // each core loops over a kernel instance
  /////////////////////////////////////////////////////////
  
  coreid = get_core_id();

  printf("starting %d kernel iterations... (coreid = %d)\n",KERNEL_ITS,coreid);

  if (coreid>3)
    coreid=coreid-4;

  synch_barrier();

  perf_begin();
  
  for(k = 0; k < getKernelIts(); k++)
  {
    // matlab kernel
    mlButter(fv1, *(float (*)[200])&fv0[200 * coreid], filt);
  }

  synch_barrier();

  perf_end();

  /////////////////////////////////////////////////////////
  // check results
  /////////////////////////////////////////////////////////

  synch_barrier();


  tmp[0] = sum(filt);
  tmp[1] = var(filt);
  pass   = checkRes(tmp, *(float (*)[4])&fv2[coreid << 2]);
  
  flagPassFail(pass, get_core_id());

/////////////////////////////////////////////////////////
// synchronize and exit
/////////////////////////////////////////////////////////

  return !pass;
}
示例#2
0
文件: aesxam.c 项目: 8l/pulpino
int main()
{

  int coreid, i, error = 0;
  coreid = get_core_id();

  // set start value of jrand function
  next = 1;

  if (coreid == 0)
    {
      int f=0;
      initialize_aes();

      // 1 iterations of enc+dec
      for (f=0;f<1;f++){
	compute_aes();
	//check output
	for (i = 0; i < 16; i++){
	  if (encoutbuf[i] != check_encoutbuf[i]) {
	    error+=1;
	    /* 	  printf("Error occured in encryption\n",0,0,0,0); */
	    //printf("encrypted: %d, expected: %d\n",encoutbuf[i],check_encoutbuf[i],0,0);
	  }
	  if (decoutbuf[i] != check_decoutbuf[i]) {
	    error+=1;
	    /* 	  printf("Error occured in decryption\n",0,0,0,0); */
	    //printf("decrypted: %d, expected: %d\n",decoutbuf[i],check_decoutbuf[i],0,0);
	  } 
	}
      } 
      int *DEFAULT_RESULT;
      if (error == 0) {
	//printf ("OOOOOOK!!!!!!\n",0,0,0,0);
	DEFAULT_RESULT = (int*)0x10003ffc;
	*(DEFAULT_RESULT) = 1;
      }
      else {
	//printf ("Not OK!! %d\n",error,0,0,0);
  
	DEFAULT_RESULT = (int*)0x10003ffc;
	*(DEFAULT_RESULT) = error;
      }
           
    }
  synch_barrier();
  eoc(0);
  
}
示例#3
0
/////////////////////////////////////////////////////////
// main testing function 
/////////////////////////////////////////////////////////
int main(int argc, const char * const argv[])
{
  (void)argc;
  (void)argv;

  boolean_T pass, flag;
  int coreid;
  
  float omega, ampl, runningPhase;
  float sig[200];
  int k;
  int i;
  float y;
  int ix;
  float xbar;
  float r;
  float b_y;
  float tmp[2];

  float golden[4];
  boolean_T c_y;
  boolean_T exitg1;
  
  /////////////////////////////////////////////////////////
  // main test loop 
  // each core loops over a kernel instance
  /////////////////////////////////////////////////////////
  
  coreid = get_core_id();

  printf("starting %d kernel iterations... (coreid = %d)\n",KERNEL_ITS,coreid);
  
  if (coreid>3)
    coreid=coreid-4;

  synch_barrier();
  
  perf_begin();

  omega =  fv1[coreid];
  ampl  =  fv2[coreid];
  
  for(k = 0; k < getKernelIts(); k++)
  {
    runningPhase = omega;
  
    // matlab kernel
    for (i = 0; i < 200; i++) {
      sig[i] = ampl * fSin(runningPhase);
      runningPhase += omega;

      if(runningPhase > pi2[0])
      {
	runningPhase -= pi2[0];
      }    
    }
  }

  synch_barrier();

  perf_end();

  /////////////////////////////////////////////////////////
  // check results
  /////////////////////////////////////////////////////////

  synch_barrier();


  y = sig[0];
  ix = 0;
  xbar = sig[0];
  for (k = 0; k < 199; k++) {
    y += sig[k + 1];
    ix++;
    xbar += sig[ix];
  }

  xbar = fDiv(xbar,200.0F);
  ix = 0;
  r = sig[0] - xbar;
  b_y = r * r;
  for (k = 0; k < 199; k++) {
    ix++;
    r = sig[ix] - xbar;
    b_y += r * r;
  }

  b_y = fDiv(b_y,199.0F);
  tmp[0] = y;
  tmp[1] = b_y;

  pass = true;
  for (k = 0; k < 2; k++) {
    for (ix = 0; ix < 2; ix++) {
      golden[ix + (k << 1)] = fv0[(ix + (k << 1)) + (coreid << 2)];
    }
    flag = true;
    flag = flag && (tmp[k] <= golden[k << 1]);
    flag = flag && (tmp[k] >= golden[1 + (k << 1)]);
    printErrors(!flag, k, tmp[k] ,golden[k << 1], golden[1 + (k << 1)]);
    pass = pass && flag;
  }

  flagPassFail(pass, get_core_id());

/////////////////////////////////////////////////////////
// synchronize and exit
/////////////////////////////////////////////////////////

  return !pass;
}
示例#4
0
/////////////////////////////////////////////////////////
// main testing function 
/////////////////////////////////////////////////////////
int main(int argc, const char * const argv[])
{
  (void)argc;
  (void)argv;

  int coreid, k;
  boolean_T pass;

  float V[25];
  float s[5];
  float U[25];
  
  int b_k;
  float y[25];
  float b_y;
  float c_y;
  float d_y;
  float tmp[3];
  
  init_fp_regs();

  /////////////////////////////////////////////////////////
  // main test loop 
  // each core loops over a kernel instance
  /////////////////////////////////////////////////////////
  
  coreid = get_core_id();

  printf("starting %d kernel iterations... (coreid = %d)\n",KERNEL_ITS,coreid);
  
  if (coreid>3)
    coreid=coreid-4;

  synch_barrier();
  
  perf_begin();

  for(k = 0; k < getKernelIts(); k++)
  {

    // call matlab kernel
    eml_xgesvd(*(float (*)[25])&fv0[25 * coreid], U, s, V);
    
  }

  synch_barrier();

  perf_end();

  /////////////////////////////////////////////////////////
  // check results
  /////////////////////////////////////////////////////////
  
  synch_barrier();

  for (b_k = 0; b_k < 25; b_k++) {
    y[b_k] = fAbs(U[b_k]);
  }

  b_y = y[0];
  c_y = s[0];
  
  for (b_k = 0; b_k < 4; b_k++) {
    c_y += s[b_k + 1];
  }

  for (b_k = 0; b_k < 24; b_k++) {
    b_y += y[b_k + 1];
  }

  for (b_k = 0; b_k < 25; b_k++) {
    y[b_k] = fAbs(V[b_k]);
  }

  d_y = y[0];
  for (b_k = 0; b_k < 24; b_k++) {
    d_y += y[b_k + 1];
  }

  tmp[0] = b_y;
  tmp[1] = c_y;
  tmp[2] = d_y;
  
  pass = true;
  for (b_k = 0; b_k < 3; b_k++) {
    pass = pass && (tmp[b_k] <= fv1[(0 + (b_k << 1)) + 6 * coreid]);
    pass = pass && (tmp[b_k] >= fv1[(1 + (b_k << 1)) + 6 * coreid]);
  }

  flagPassFail(pass, get_core_id());
  
  synch_barrier();

/////////////////////////////////////////////////////////
// synchronize and exit
/////////////////////////////////////////////////////////

  return !pass;
}
示例#5
0
/////////////////////////////////////////////////////////
// main testing function 
/////////////////////////////////////////////////////////
int main(int argc, const char * const argv[])
{
  (void)argc;
  (void)argv;

  int coreid;
  int it;

  int k;
  boolean_T pass, flag;
  float y[100];
  int ix;
  float b_y;
  float xbar;
  float r;
  float c_y;
  float tmp[2];
  float golden[4];


  /////////////////////////////////////////////////////////
  // main test loop 
  // each core loops over a kernel instance
  /////////////////////////////////////////////////////////

  coreid = get_core_id();

  printf("starting %d kernel iterations... (coreid = %d)\n",KERNEL_ITS,coreid);

  if (coreid>3)
    coreid=coreid-4;

  synch_barrier();

  perf_begin();

  for(it = 0; it < KERNEL_ITS; it++)
  {
    // matlab kernel
    for (ix = 0; ix < 100; ix++) {
      y[ix] = (real32_T)fLog(fv0[ix + 100 * coreid]);
    }
  }

  synch_barrier();

  perf_end();

  synch_barrier();

  /////////////////////////////////////////////////////////
  // check results
  /////////////////////////////////////////////////////////

  pass = true;
  b_y = y[0];
  ix = 0;
  xbar = y[0];
  for (k = 0; k < 99; k++) {
    b_y += y[k + 1];
    ix++;
    xbar += y[ix];
  }

  xbar *= 1.0F/100.0F;
  ix = 0;
  r = y[0] - xbar;
  c_y = r * r;
  for (k = 0; k < 99; k++) {
    ix++;
    r = y[ix] - xbar;
    c_y += r * r;
  }

  c_y *= 1.0F/99.0F;
  tmp[0] = b_y;
  tmp[1] = c_y;
  pass  = true;

  for (ix = 0; ix < 2; ix++) {
    for (k = 0; k < 2; k++) {
      golden[k + (ix << 1)] = fv1[(k + (ix << 1)) + (coreid << 2)];
    }
    flag = true;
    flag = flag && (tmp[ix] <= golden[ix << 1]);
    flag = flag && (tmp[ix] >= golden[1 + (ix << 1)]);
    printErrors(!flag, ix, tmp[ix] ,golden[(ix << 1)] ,golden[1 + (ix << 1)]);
    pass = pass && flag;
  }

  flagPassFail(pass, get_core_id());
  
  synch_barrier();

/////////////////////////////////////////////////////////
// synchronize and exit
/////////////////////////////////////////////////////////

  return !pass;
}
示例#6
0
/////////////////////////////////////////////////////////
// main testing function 
/////////////////////////////////////////////////////////
int main(int argc, const char * const argv[])
{
  (void)argc;
  (void)argv;

  int coreid;
  int it;

  boolean_T pass;
  boolean_T flag;
  float y[10];
  int ix;
  float b_y;
  int b_k;
  float xbar;
  float r;
  float c_y;
  float check[2];
  float golden[4];



  /////////////////////////////////////////////////////////
  // main test loop 
  // each core loops over a kernel instance
  /////////////////////////////////////////////////////////
  coreid = get_core_id();

  printf("starting %d kernel iterations... (coreid = %d)\n",KERNEL_ITS,coreid);

  if (coreid>3)
    coreid=coreid-4;

  synch_barrier();

  perf_begin();

  for(it = 0; it < getKernelIts(); it++)
  {
    // matlab kernel
    for (ix = 0; ix < 10; ix++) {
      b_y = 0.0F;
      for (b_k = 0; b_k < 10; b_k++) {
        b_y += fv1[(ix + 10 * b_k) + 100 * coreid] * fv0[b_k + 10 * coreid];
      }
      y[ix] = b_y + fv3[coreid] * fv2[ix + 10 * coreid];
    }
  }

  synch_barrier();

  perf_end();

  synch_barrier();

  /////////////////////////////////////////////////////////
  // check results
  /////////////////////////////////////////////////////////

  b_y = y[0];
  ix = 0;
  xbar = y[0];
  for (b_k = 0; b_k < 9; b_k++) {
    b_y += y[b_k + 1];
    ix++;
    xbar += y[ix];
  }

  xbar *= 1.0F/10.0F;
  ix = 0;
  r = y[0] - xbar;
  c_y = r * r;
  for (b_k = 0; b_k < 9; b_k++) {
    ix++;
    r = y[ix] - xbar;
    c_y += r * r;
  }

  c_y *= 1.0F/9.0F;
  check[0] = b_y;
  check[1] = c_y;
  pass = true;
  for (ix = 0; ix < 2; ix++) {
    for (b_k = 0; b_k < 2; b_k++) {
      golden[b_k + (ix << 1)] = fv4[(b_k + (ix << 1)) + (coreid << 2)];
    }
    flag = true;
    flag = pass && (check[ix] <= golden[ix << 1]);
    flag = pass && (check[ix] >= golden[1 + (ix << 1)]);
    printErrors(!flag, ix, check[ix], golden[ix<<1], golden[1+(ix<<1)]);
    pass = pass && flag;
  }
  flagPassFail(pass, get_core_id());


/////////////////////////////////////////////////////////
// synchronize and exit
/////////////////////////////////////////////////////////

  return !pass;
}