Exemplo n.º 1
0
int main() {
  SIM_SLEEP_OFF();

  // some variables
  int corenum   = RigelGetCoreNum();
  int threadnum = RigelGetThreadNum();
	int numcores  = RigelGetNumCores();
  int numthreads = RigelGetNumThreads();
  int th_per_core    = RigelGetNumThreadsPerCore();
  int th_per_cluster = RigelGetNumThreadsPerCluster();

  int rows_per_thread = SIZE / numthreads; // statically divide work up
  int start = rows_per_thread * threadnum;
  int end   = start + rows_per_thread;
  int i=0, j=0;

  // setup on thread 0
  if(threadnum == 0) {

    BARRIER_INIT(&bi);

    // init values
    for(i=0;i<SIZE;i++){
      for(j=0;j<SIZE;j++){
        MATRIX[j][i] = j; 
      }
      VECTOR[i] = i;
      RESULT[i] = 0xbeef;
    }

    //printf("rpf:%d numthreads:%d\n", rows_per_thread, numthreads);
    ClearTimer(0);
    // get started
    StartTimer(0);
    atomic_flag_set(&Init_Flag);
  }

  // wait for core 0 to finish setup
  atomic_flag_spin_until_set(&Init_Flag);

  // do the work
  for( i=start; i<end; i++ ) {
    RESULT[i] = MVM(i);  
  }

  BARRIER_ENTER(&bi);

  // cleanup on thread 0
  if(threadnum == 0) {
    StopTimer(0);
    // print results
    for(i=0; i<SIZE; i++) {
      RigelPrint(RESULT[i]);
    }
  }

  return 1;
}
Exemplo n.º 2
0
void charargs(char a, char b, char c, char d, char e)
{
	char array[6];
	RigelPrint(a);
	RigelPrint(b);
	RigelPrint(c);
	RigelPrint(d);
	RigelPrint(e);
	array[0] = a;
	array[1] = b;
	array[2] = c;
	array[3] = d;
	array[4] = e;
	array[5] = '\0';
	RigelPrint(*(int *)array);
	RigelPrint(*(((int *)array)+1));
	printf("%s\n", array);
	printf("%c\n", array[0]);
	fprintf(stderr, "%c%c%c%c%c\n", array[0], array[1], array[2], array[3], array[4]);
  FILE *buf = fopen("buf.txt", "w");
	FILE *nbuf = fopen("nbuf.txt", "w");
	setbuf(nbuf, NULL);
	fprintf(buf, "%c%c%c%c%c\n", array[0], array[1], array[2], array[3], array[4]);
	fprintf(stderr, "%c%c\n", array[0], array[1]);
	fclose(buf);
	fclose(nbuf);
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
  if(RigelGetThreadNum() == 0) {
    SIM_SLEEP_OFF();
  }
  void *mallocs[100];
  for(int i = 0; i < 100; i++) {
    mallocs[i] = malloc(RigelRandUInt(4, 2000)*4);
    RigelPrint(i);
  }
  for(int i = 0; i < 100; i++) {
    free(mallocs[i]);
    RigelPrint(0xFFFF0000 | i);
  }
  //SIM_SLEEP_OFF();
  //}
  return 0;
}
void __rigel_premain(void)
{
  int tid = RigelGetThreadNum();
  if(tid == 0) {
    SIM_SLEEP_ON();
    SIM_SLEEP_OFF();
    _pt[tid].funcptr = (void *)0xFFFFFFFF; //Make sure we don't get a thread spawned on us by accident
  }
  else {
    RigelPrint(0xFEDC);
    while(1) {
      while(_pt[tid].funcptr == NULL);
      void *retval = _pt[tid].funcptr(_pt[tid].funcarg);
      RigelBroadcastUpdate(retval, _pt[tid].retval);
      RigelBroadcastUpdate(NULL, _pt[tid].funcptr);
    }
  }
}
Exemplo n.º 5
0
void consttest()
{
	RigelPrint(0x08800000);
}
Exemplo n.º 6
0
void shorttest()
{
	  RigelPrint(s.a);
		RigelPrint(s.b);
}
Exemplo n.º 7
0
void doubletest(fi x) {
	  RigelPrint((float)x.f);
}