# HG changeset patch # User yutaka@localhost.localdomain # Date 1270585132 -32400 # Node ID 1e1b0d280427f77edccd8ba300d4b3cfc7302da3 # Parent dcd83cefb98085f2971ca5b4bbd165ece997cf5a commit diff -r dcd83cefb980 -r 1e1b0d280427 include/Menu.h --- a/include/Menu.h Tue Apr 06 22:52:33 2010 +0900 +++ b/include/Menu.h Wed Apr 07 05:18:52 2010 +0900 @@ -1,3 +1,8 @@ +#ifndef INCLUDED_MENU +#define INCLUDED_MENU + #include "params.h" -send_params_head_t* menu(int &task_num); +task_head_t* menu(int &task_num); + +#endif diff -r dcd83cefb980 -r 1e1b0d280427 include/Sys.h --- a/include/Sys.h Tue Apr 06 22:52:33 2010 +0900 +++ b/include/Sys.h Wed Apr 07 05:18:52 2010 +0900 @@ -1,6 +1,14 @@ +#ifndef INCLUDED_SYS +#define INCLUDED_SYS + #include "params.h" void* allocate(int size); int size_fix(int size, int fix); -void fix_type(send_params_t *send_params_t, void *buff); -send_params_t task_allocate(int size); +void fix_type(task_t *task_t, void *buff); +task_t* task_allocate(int in_size, int out_size); + +task_t* add_list(task_t *tail, task_t *task); +void set_pin(task_t *task, int pin_in, int pin_out); + +#endif diff -r dcd83cefb980 -r 1e1b0d280427 include/params.h --- a/include/params.h Tue Apr 06 22:52:33 2010 +0900 +++ b/include/params.h Wed Apr 07 05:18:52 2010 +0900 @@ -15,13 +15,14 @@ unsigned int pin_in; //4 unsigned int pin_out; //4 -} send_params_head_t; //32 +} task_head_t; //32 typedef struct { - send_params_head_t *head; //next data param - void *buff; + task_head_t *head; //next data param + void *input; + unsigned int task_size; -} send_params_t; +} task_t; #endif diff -r dcd83cefb980 -r 1e1b0d280427 ppe/Manager.cc --- a/ppe/Manager.cc Tue Apr 06 22:52:33 2010 +0900 +++ b/ppe/Manager.cc Wed Apr 07 05:18:52 2010 +0900 @@ -14,28 +14,30 @@ #include "params.h" void -ppe_run(send_params_head_t *head, int tmphead_num) +ppe_run(task_head_t *head, int tmplist_num) { - send_params_head_t *tmphead; - send_params_t *tmp = (send_params_t*)allocate(sizeof(send_params_t)); + task_head_t *tmphead; + task_t *tmp = (task_t*)allocate(sizeof(task_t)); //printf("hoge1\n"); - for (int j = 0; j < tmphead_num; j++) { + for (int j = 0; j < tmplist_num; j++) { - //printf("hoge\n"); + //printf("list_num %d\n",tmplist_num); - for (tmphead = (send_params_head_t*)head[j].next_task; tmphead != 0; tmphead = (send_params_head_t*)tmphead->next_task) { + for (tmphead = (task_head_t*)head[j].next_task; tmphead != 0; tmphead = (task_head_t*)tmphead->next_task) { - fix_type(tmp, (void*)tmphead); + fix_type(tmp, tmphead); int *out = (int*)tmp->head->ea_out; - int *in = (int*)tmp->buff; + int *in = (int*)tmp->input; //printf("in[%d] %f\n",i,in[i]); //printf("out[%d] %f\n",i,out[i]); - + + //printf("size->out %d\n",tmp->head->size_out); + run(in, out, tmp->head->size_out); //printf("out_spe[%d] %f\n",i,out_spe[i]); @@ -49,21 +51,21 @@ } void -check_output(send_params_head_t *head, int tmphead_num) +check_output(task_head_t *head, int tmplist_num) { - send_params_head_t *tmphead; - send_params_t *tmp = (send_params_t*)allocate(sizeof(send_params_t)); + task_head_t *tmphead; + task_t *tmp = (task_t*)allocate(sizeof(task_t)); - for (int j = 0; j < tmphead_num; j++) { + for (int j = 0; j < tmplist_num; j++) { - for (tmphead = (send_params_head_t*)head[j].next_task; tmphead != 0; tmphead = (send_params_head_t*)tmphead->next_task) { + for (tmphead = (task_head_t*)head[j].next_task; tmphead != 0; tmphead = (task_head_t*)tmphead->next_task) { fix_type(tmp, (void*)tmphead); int *out = (int*)tmp->head->ea_out; int *out_spe = (int*)allocate(tmp->head->size_out); - int *in = (int*)tmp->buff; + int *in = (int*)tmp->input; //printf("in[%d] %f\n",i,in[i]); //printf("out[%d] %f\n",i,out[i]); @@ -92,20 +94,20 @@ } void -send_task_params(int &head_num, int &index, send_params_head_t *head, +send_task_params(int &list_num, int &index, task_head_t *head, spe_context_ptr_t spe, int &flag) { unsigned int data = 0; - if ( head_num ) { + if ( list_num ) { data = (unsigned int) &head[index]; //send task param mail spe_in_mbox_write(spe,&data,1,SPE_MBOX_ALL_BLOCKING); - head_num--; + list_num--; index++; } else { //task nothing, spe run end @@ -148,9 +150,9 @@ if (ppe_flag) { - int head_num; - send_params_head_t *head = menu(head_num); - ppe_run(head, head_num); + int list_num; + task_head_t *head = menu(list_num); + ppe_run(head, list_num); prog_e = clock(); @@ -174,11 +176,11 @@ int all_spe_run_end = SPE_NUM; int flag = 0; - int head_num = 0; + int list_num = 0; create_s = clock(); - send_params_head_t *head = menu(head_num); + task_head_t *head = menu(list_num); create_e = clock(); - int tmphead_num = head_num; + int tmplist_num = list_num; int index = 0; unsigned int data = 0; @@ -196,7 +198,7 @@ //ppe send task or run end request mail for spe if (data == WANT_DATA) { //printf("spe %p\n",spe[i]); - send_task_params(head_num, index, head, spe[i], flag); + send_task_params(list_num, index, head, spe[i], flag); } } @@ -212,7 +214,7 @@ if (check_flag) { printf("check now\n"); - check_output(head, tmphead_num); + check_output(head, tmplist_num); } prog_e = clock(); diff -r dcd83cefb980 -r 1e1b0d280427 ppe/Menu.cc --- a/ppe/Menu.cc Tue Apr 06 22:52:33 2010 +0900 +++ b/ppe/Menu.cc Wed Apr 07 05:18:52 2010 +0900 @@ -6,93 +6,56 @@ //headk_num と send_param_head の値を必ず返さないと、動作しない -send_params_head_t* -menu(int &head_num) { +task_head_t* +menu(int &list_num) { - head_num = SPE_NUM; + list_num = SPE_NUM; int all_task_num = SPE_NUM*1000; //int all_task_num = 1; //int task_size = MAX_DMA_SIZE; int task_size = 16*1024; - int in_size = (task_size - sizeof(send_params_head_t)) * all_task_num; - int out_size = (task_size - sizeof(send_params_head_t)) * all_task_num; + //int in_size = (task_size - sizeof(task_head_t)) * all_task_num; + //int out_size = (task_size - sizeof(task_head_t)) * all_task_num; + + int in_size = (task_size - sizeof(task_head_t)); + int out_size = (task_size - sizeof(task_head_t)); + + task_head_t *list_head = (task_head_t*)allocate(sizeof(task_head_t)*list_num); - int *in; - int *out = (int*)allocate(out_size); + int list_length = all_task_num / list_num; + + for (int i = 0; i < list_num; i++) { - int partition_size = task_size - sizeof(send_params_head_t); - send_params_t *send_params = (send_params_t*)allocate(sizeof(send_params_t)*all_task_num); + list_head[i].ea_out = 0; + list_head[i].size_out = 0; + list_head[i].pin_in = 0; + list_head[i].pin_out = 0; - send_params_head_t *head = (send_params_head_t*)allocate(sizeof(send_params_head_t)*head_num); + task_t *tail = (task_t*)allocate(sizeof(task_t)); + tail->head = &list_head[i]; + tail->input = NULL; - for (int i = 0; i < all_task_num; i++) { + for (int j = 0; j < list_length; j++) { + + task_t *task = task_allocate(in_size, out_size); + int *in = (int*)task->input; - send_params[i] = task_allocate(task_size); // header と、in サイズを確保するよ。 - in = (int*)send_params[i].buff; - - for (int j = 0; j < partition_size / sizeof(int); j++) { - in[j] = j; - //printf("%f\n",in[j]); + for (int k = 0; k < in_size / sizeof(int); k++) { + in[k] = k; + } + + int pin_in = 0; + int pin_out = 0; + + set_pin(task, pin_in, pin_out); + tail = add_list(tail, task); + } } - int task_list_length = all_task_num / head_num; - int index = 0; - - for (int i = 0; i < head_num; i++) { - - head[i].next_task = (unsigned long) send_params[index].head; - head[i].next_task_size = task_size; - - head[i].ea_out = (unsigned long) &out[(index * partition_size) / sizeof(int)]; - head[i].size_out = partition_size; - - head[i].pin_in = 0; - head[i].pin_out = 0; - - - for (int j = 0; j < task_list_length - 1; j++) { - - //Cerium を要チェック - - send_params[index].head->next_task = (unsigned long) send_params[index+1].head; - send_params[index].head->next_task_size = task_size; - - send_params[index].head->ea_out = (unsigned long) &out[((index) * partition_size) / sizeof(int)]; - send_params[index].head->size_out = partition_size; - - send_params[index].head->pin_in = 0; - send_params[index].head->pin_out = 0; - - index++; - - - } - - - send_params[index].head->next_task = 0; - send_params[index].head->next_task_size = 0; - - send_params[index].head->ea_out = (unsigned long) &out[(index) * partition_size / sizeof(int)]; - - //printf("[PPE] %p\n",(unsigned long)send_params[index].head->ea_out); - - //send_params[index].head->ea_out = 0; - send_params[index].head->size_out = partition_size; - - send_params[index].head->pin_in = 0; - send_params[index].head->pin_out = 0; - - //send_params[index].head = NULL; - - index++; - - - } - printf("return run\n"); - return head; + return list_head; } diff -r dcd83cefb980 -r 1e1b0d280427 ppe/Sys.cc --- a/ppe/Sys.cc Tue Apr 06 22:52:33 2010 +0900 +++ b/ppe/Sys.cc Wed Apr 07 05:18:52 2010 +0900 @@ -2,6 +2,29 @@ #include #include "Sys.h" +task_t* +add_list(task_t *tail, task_t *task) +{ + + tail->head->next_task = (unsigned long long) (unsigned long) task->head; + tail->head->next_task_size = task->task_size; + + task->head->next_task = 0; + task->head->next_task_size = 0; + + return task; + +} + +void +set_pin(task_t *task, int pin_in, int pin_out) +{ + + task->head->pin_in = pin_in; + task->head->pin_out = pin_out; + +} + int size_fix(int size, int fix) { @@ -27,33 +50,48 @@ } void -fix_type(send_params_t *send_params, void *buff) +fix_type(task_t *task, void *buff) { char *p; p = (char*)buff; - p = p + sizeof(send_params_head_t); + p = p + sizeof(task_head_t); - send_params->head = (send_params_head_t*)buff; - send_params->buff = p; + task->head = (task_head_t*)buff; + task->input = p; } -send_params_t -task_allocate(int size) +task_t* +task_allocate(int in_size, int out_size) { - if (size % 16) { - printf("allocate size is not multiple of 16\n"); + if (in_size % 16) { + printf("allocate in_size is not multiple of 16\n"); + } + + if (out_size % 16) { + printf("allocate out_size is not multiple of 16\n"); } int alignment = 16; - send_params_t send_params; + task_t *task = (task_t*)allocate(sizeof(task_t)); void *buff; - posix_memalign(&buff, alignment, size); - fix_type(&send_params, buff); + void *out; + + int task_size = in_size + sizeof(task_head_t); + + posix_memalign(&buff, alignment, task_size); + fix_type(task, buff); - return send_params; + posix_memalign(&out, alignment, out_size); + task->head->ea_out = (unsigned long long) (unsigned long) out; + task->head->size_out = out_size; + + task->task_size = task_size; + + + return task; } diff -r dcd83cefb980 -r 1e1b0d280427 spe/SpeSentry.cc --- a/spe/SpeSentry.cc Tue Apr 06 22:52:33 2010 +0900 +++ b/spe/SpeSentry.cc Wed Apr 07 05:18:52 2010 +0900 @@ -8,15 +8,15 @@ #include "Run.h" void* -fix_type(send_params_t *send_params, void* buff) +fix_type(task_t *task, void* buff) { char *p; p = (char*)buff; - p = p + sizeof(send_params_head_t); + p = p + sizeof(task_head_t); - send_params->head = (send_params_head_t*)buff; - send_params->buff = p; + task->head = (task_head_t*)buff; + task->input = p; } @@ -29,7 +29,7 @@ } -send_params_t +task_t task_allocate(int size) { @@ -38,18 +38,18 @@ } char *buff; - send_params_t send_params; + task_t task; void *head; head = memalign(16, size); buff = (char*)head; - buff = buff + sizeof(send_params_head_t); + buff = buff + sizeof(task_head_t); - send_params.head = (send_params_head_t*)head; - send_params.buff = buff; + task.head = (task_head_t*)head; + task.input = buff; - return send_params; + return task; } @@ -59,7 +59,7 @@ uint32_t data; int buff_num = 2; - int dma_wait_time = 0; + unsigned int dma_wait_time = 0; int in_tag[buff_num]; int out_tag[buff_num]; @@ -72,8 +72,8 @@ int head_tag = 4; - send_params_head_t *head = (send_params_head_t*)allocate(sizeof(send_params_head_t)); - send_params_t *send_params = (send_params_t*)allocate(sizeof(send_params_t)); + task_head_t *head = (task_head_t*)allocate(sizeof(task_head_t)); + task_t *send_params = (task_t*)allocate(sizeof(task_t)); void *input_buff[buff_num]; void *output_buff[buff_num]; @@ -96,7 +96,7 @@ //printf("[SPE] data %p\n",data); - dma_get(head, data, sizeof(send_params_head_t), head_tag); + dma_get(head, data, sizeof(task_head_t), head_tag); dma_wait_time += dma_wait(head_tag); input_buff[0] = allocate(head->next_task_size); @@ -113,7 +113,7 @@ input_buff[cur^1] = allocate(send_params->head->next_task_size); dma_get(input_buff[cur^1], send_params->head->next_task, send_params->head->next_task_size, in_tag[cur^1]); - void *in = send_params->buff; + void *in = send_params->input; //printf("hoge"); output_buff[cur] = allocate(send_params->head->size_out); @@ -147,7 +147,7 @@ }//while - void *in = send_params->buff; + void *in = send_params->input; //printf("hoge"); output_buff[cur] = allocate(send_params->head->size_out);