/** * Do all necessary initializations * @param settings Pointer to the global settings */ void TaskCoreCell::prepare(swspect_settings_t* settings) { /* setup */ this->cfg = settings; this->total_time = 0; this->total_spectra_count = 0; this->total_ffts_count = 0; /* prepare SPE task context constants */ cb.rank = this->rank; cb.fft_points = cfg->fft_points; cb.fft_points_log2 = (int)log2(cfg->fft_points); cb.overlap_factor = cfg->fft_overlap_factor; cb.integrate_ffts = cfg->integrated_ffts; cb.samples_per_rawbyte = cfg->samples_per_rawbyte; /* load and start the SPE program pointing it to the control block */ this->gid = spe_create_group (SCHED_OTHER, 0, 1); if ((this->gid == NULL) || (spe_group_max (this->gid) < 1)) { cerr << "TaskCoreCell prepare : spe_create_group() failed!" << endl; exit(1); } this->speid = spe_create_thread(this->gid, &spectrometer_spu, (unsigned long long *)&(this->cb), NULL, -1, 0); if (this->speid == NULL) { cerr << "TaskCoreCell prepare : spe_create_thread() failed!" << endl; } cerr << "SPE thread created, rank " << this->rank << " ID " << speid << endl; return; }
void TxStartSPE(extern spe_program_handle_t spuCode) { /* we allocate one control block, to correspond to one SPE */ //control_block cb[1] __attribute__ ((aligned (128))); /* this is the pointer to the SPE code, to be used at thread creation time */ //extern spe_program_handle_t spuCode; /* before the thread is created, we create a group environment to contain it. */ /* this "gid" is the handle for that group. */ spe_gid_t gid; /* this is the handle which will be returned by "spe_create_thread." */ speid_t speids[1]; /* this variable is used to return data regarding an abnormal return from the SPE*/ int status[1]; /* here is the variable to hold the address returned by the malloc() call. */ int *data; data = (int *) malloc(128); /* Create an SPE group */ gid = spe_create_group(SCHED_OTHER, 0, 1); if (gid == NULL) { fprintf(stderr, "Failed spe_create_group(errno=%d)\n", errno); return -1; } if (spe_group_max(gid) < 1) { fprintf(stderr, "System doesn't have a working SPE. I'm leaving.\n"); return -1; } /* load the address into the control block */ //cb[0].addr = (unsigned int) data; /* allocate the SPE task */ speids[0] = spe_create_thread(gid, &spuCode, (unsigned long long *) &cb[0], NULL, -1, 0); if (speids[0] == NULL) { fprintf(stderr, "FAILED: spe_create_thread(num=%d, errno=%d)\n", 0, errno); exit(3); } }