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; }
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); } } }
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; }