Exemplo n.º 1
0
/**
 * Core entry point, sets the stuff up and then runs the interpreter
 */
int main() {
	myId=e_group_config.core_row * e_group_config.group_cols + e_group_config.core_col;
	sharedData=(void*) (e_emem_config.base + EXTERNAL_MEM_ABSOLUTE_START);

	while (sharedData->core_ctrl[myId].core_run == 0) {};
	sharedData->core_ctrl[myId].core_busy=1;
	sharedData->core_ctrl[myId].core_run=1;

	int i;
	lowestCoreId=TOTAL_CORES;
	for (i=0;i<TOTAL_CORES;i++) {
		syncValues[i]=0;
		if (sharedData->core_ctrl[i].active) {
			if (i< lowestCoreId) lowestCoreId=i;
		}
	}

	init_barrier(syncbarriers, sync_tgt_bars);
	init_barrier(collectivebarriers, collective_tgt_bars);

	if (sharedData->codeOnCores) {
		cpy(sharedData->edata, sharedData->esdata, sharedData->length);
	}

	syncCores(0);
	runIntepreter(sharedData->edata, sharedData->length, sharedData->symbol_size, myId, sharedData->num_procs, sharedData->baseHostPid);
	sharedData->core_ctrl[myId].core_busy=0;
	sharedData->core_ctrl[myId].core_run=0;
	return 0;
}
Exemplo n.º 2
0
Arquivo: 3.c Projeto: psie/Linux
int main()
{
	int i;
	pthread_t pt[5];

	init_barrier(&b, 5);
	
	for(i=0; i<5; ++i)
		pthread_create(&pt[i], NULL, *pt_funtion, (void*)i);

	for(i=0; i<5; ++i)
		pthread_join(pt[i], NULL);

	destroy_barrier(&b);

	return 0;
}
static void __config_comm(
    comm_t * const comm,
    size_t const nthreads)
{
  size_t maxthreads;

  comm->in_use = 1;
  comm->nthreads = nthreads;
  comm->larray = NULL;

  /* handle data types up to size 16 and round up to a power of two */
  maxthreads = size_uppow2(nthreads);
  comm->bufsize = size_uppow2((__DEFAULT_BYTES_PER_THREAD*maxthreads) + 4096);
  comm->buffer = malloc(comm->bufsize);

  init_lock(&comm->loc);
  init_barrier(&comm->bar,nthreads);
}