コード例 #1
0
ファイル: yuvscaler.c プロジェクト: joshdekock/jim-ps3ware
unsigned int sws_receive_message(yuvscaler_t *arg)
{
	unsigned int message;
	struct yuvscaler_s * arg_ptr;
	arg_ptr=(struct yuvscaler_s *) arg;

	int retries = 3;

	while(retries) {
		if(spe_event_wait(arg->spe_event_yuvscaler, &arg->event, 1, -1) <= 0 ||
			!(arg->event.events & SPE_EVENT_OUT_INTR_MBOX)) {
			retries--;
		} else {
			break;
		}
	}

	if(retries == 0) {
		perror("Failed to recive result from spe");
	}

	spe_out_intr_mbox_read(arg_ptr->ctx,&message,1,SPE_MBOX_ANY_NONBLOCKING);	
	return message;

}
コード例 #2
0
ファイル: quilt.cpp プロジェクト: evelinad/WorkAtUPB
void quilt_orizontal(Picture *pout, int dim_bucata_height,
		int dim_bucata_width, int nbucati_height, int nbucati_width,
		int dim_fasie_height, int dim_fasie_width, int npatches,
		int ncandidati, int in_width)
{
	int height = pout->Height();

	int off_candidat = -1, off_candidat_min = -1;
	int min_dif = -1, curr_dif = -1;

#ifndef CELL
	for (int i = 0; i < npatches; i++)
	{
		min_dif = 1 << 30;
		// Pentru fiecare petic nou adaugat, exista ncandidati petice
		// ce candideaza pentru ocuparea pozitiei
		for (int j = 0; j < ncandidati; j++)
		{
			off_candidat = rand() % (in_width - dim_fasie_width);

			curr_dif = orizontal_dif(pout, off_candidat, in_width + (i - 1)
					* dim_bucata_width, dim_fasie_width, dim_bucata_width,
					height);

			if (min_dif> curr_dif)
			{
				min_dif = curr_dif;
				off_candidat_min = off_candidat;
			}
		}

		orizontal_netezire(pout, i, in_width, height, dim_fasie_width,
				dim_bucata_width, off_candidat_min);
	}
#else
	for (int i = 0; i < npatches; i++)
	{
		min_dif = 1 << 30;
		// Pentru fiecare petic nou adaugat, exista ncandidati petice
		// ce candideaza pentru ocuparea pozitiei
		for (int j = 0; j < ncandidati; j++)
		{
			off_candidat = rand() % (in_width - dim_fasie_width);

			curr_dif = orizontal_dif(pout, off_candidat, in_width + (i - 1)
					* dim_bucata_width, dim_fasie_width, dim_bucata_width,
					height);
		}

		// Astept de la toate raspunsul
		for (int i = 0; i < spu_threads; i++)
		{
			adr_value[0] = (unsigned int) 2;
			if (spe_in_mbox_write(spes[i], adr_value, 1,
					SPE_MBOX_ANY_NONBLOCKING) < 0)
			{
				perror("ERROR, writing messages to spe failed\n");
			}
		}

		unsigned int buffer_candidat_off, buffer_candidat_val,
				off_candidat_min = -1, val_candidat_min = 1 << 30;
		for (i = 0; i < NO_SPU; ++i)
		{
			nevents = spe_event_wait(event_handler, &event_received, 1, -1);
			if (event_received.events & SPE_EVENT_OUT_INTR_MBOX)
			{
				while (spe_out_intr_mbox_status(event_received.spe) < 1)
					;
				spe_out_intr_mbox_read(event_received.spe,
						&buffer_candidat_val, 1, SPE_MBOX_ANY_BLOCKING);

				while (spe_out_intr_mbox_status(event_received.spe) < 1)
					;
				spe_out_intr_mbox_read(event_received.spe,
						&buffer_candidat_off, 1, SPE_MBOX_ANY_BLOCKING);
			}

			if (buffer_candidat_val < val_candidat_min)
			{
				val_candidat_min = buffer_candidat_val;
				off_candidat_min = buffer_candidat_off;
			}

			orizontal_netezire(pout, i, in_width, height, dim_fasie_width,
					dim_bucata_width, off_candidat_min);
		}
	}
#endif
}