Mercurial > hg > Members > yutaka > manager
view ppe/Manager.cc @ 0:68a98d68d62a
commit
author | yutaka@localhost.localdomain |
---|---|
date | Sun, 28 Mar 2010 19:47:00 +0900 |
parents | |
children | dcd83cefb980 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <libspe2.h> #include <pthread.h> #include <time.h> #include "Manager.h" #include "MailCommand.h" #include "SIZE.h" #include "Sys.h" #include "Spe.h" #include "Menu.h" #include "params.h" void send_task_params(int &head_num, int &index, send_params_head_t *head, spe_context_ptr_t spe, int &flag) { unsigned int data = 0; if ( head_num ) { data = (unsigned int) &head[index]; //send task param mail spe_in_mbox_write(spe,&data,1,SPE_MBOX_ALL_BLOCKING); head_num--; index++; } else { //task nothing, spe run end data = SPE_RUN_END; flag += 1; //send run end mail spe_in_mbox_write(spe,&data,1,SPE_MBOX_ALL_BLOCKING); //printf("send run end mail\n"); } } int main(int argc, char *argv[]) { spe_program_handle_t *prog; //スタック上にとるのはだめだめ。malloc spe_context_ptr_t spe[SPE_NUM]; pthread_t thread[SPE_NUM]; prog = spe_image_open("spe-main"); //thread run. spe run. spe_run_start(spe,prog,thread,SPE_NUM); int all_spe_run_end = SPE_NUM; int flag = 0; clock_t start = 0,end = 0; //start = clock(); int head_num = 0; send_params_head_t *head = menu(head_num); //end = clock(); //printf("task create %f\n",(double)(end-start)/CLOCKS_PER_SEC); int index = 0; unsigned int data = 0; //mail check while(flag != all_spe_run_end) { for (int i = 0; i < SPE_NUM; i++) { if (spe_out_mbox_status(spe[i])) { spe_out_mbox_read(spe[i],&data,1); //spe wait come task //ppe send task or run end request mail for spe if (data == WANT_DATA) { send_task_params(head_num, index, head, spe[i], flag); } } }// end for }//end while mail check spe_run_endwait(spe,thread,SPE_NUM); spe_image_close(prog); return 0; } /*end*/