Mercurial > hg > Game > Cerium
changeset 701:44095db8cb61 draft TaskArray
Bulk task worked on Mac OS X
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2009 12:46:48 +0900 |
parents | ef08dd70eafb |
children | 6c4a81dc22c9 |
files | TaskManager/kernel/schedule/SchedTaskArray.cc example/Bulk/main.cc example/Bulk/ppe/Twice.cc |
diffstat | 3 files changed, 51 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/schedule/SchedTaskArray.cc Mon Dec 14 12:16:52 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskArray.cc Mon Dec 14 12:46:48 2009 +0900 @@ -56,7 +56,7 @@ // load Input Data readbuf = scheduler->allocate(inListData.size); - inListData.print(); + // inListData.print(); scheduler->dma_loadList(&inListData, readbuf, DMA_READ); bound(&inListData); @@ -87,7 +87,7 @@ // User 側で作る方法が必要... if (task->outData_count > 0) { - outListData.print(); + // outListData.print(); scheduler->dma_storeList(&outListData, writebuf, DMA_WRITE); } }
--- a/example/Bulk/main.cc Mon Dec 14 12:16:52 2009 +0900 +++ b/example/Bulk/main.cc Mon Dec 14 12:46:48 2009 +0900 @@ -11,6 +11,7 @@ static int length = DATA_NUM; static int task = 3; static int count = 3; +static int data_count = 3; const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ -length Number of data (default DATA_NUM (Func.h))\n\ @@ -35,7 +36,7 @@ { int* data = (int*)a; int* task_buf = (int*)b; - print_data(data, length, "after"); + print_data(data, length*count, "after"); free(data); free(task_buf); } @@ -46,75 +47,82 @@ for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-length") == 0) { length = atoi(argv[++i]); - } else if (strcmp(argv[i], "-count") == 0) { + } else if (strcmp(argv[i], "-task") == 0) { task = atoi(argv[++i]); - } else if (strcmp(argv[i], "-bluk") == 0) { + } else if (strcmp(argv[i], "-count") == 0) { count = atoi(argv[++i]); + } else if (strcmp(argv[i], "-data_count") == 0) { + data_count = atoi(argv[++i]); } } return 0; } -static void print_ListData(int count, ListElement *t) +#if 0 +static void print_ListData(int size, ListElement *t) { - for(int i = 0;i<count;i++) { + for(int i = 0;i<size;i++) { printf("ListData %d %d %lx\n",i,t[i].size,(unsigned long)t[i].addr); } } +#endif void twice_init(TaskManager *manager,int *data, int length) { - for (int i = 0; i < length; i++) { + for (int i = 0; i < length*count; i++) { data[i] = i; } - print_data(data, length, "before"); + print_data(data, length*count, "before"); /** * Create Task * create_task(Task ID); */ - HTask *twice_main = manager->create_task_array(Twice,count,2,2,2); + HTask *twice_main = manager->create_task_array(Twice,count,data_count+1,data_count,data_count); Task *t = twice_main->next_task_array(Twice, 0); +#if 0 printf("allocate task size 0x%0x\n",t->size()); printf("allocate task total size 0x%0x = 0x%0x * %d\n",twice_main->r_size, t->size(), count); +#endif void *task_buf = twice_main->rbuf; twice_main->set_post(twice_result, (void*)data, task_buf); t = 0; for(int i = 0;i<count;i++) { t = twice_main->next_task_array(Twice, t); - int length2 = length/2; - // 以下の順序でデータを追加する必要がある。 - // length を先に指定すればsetは後からでも良い。 - /** - * Set 32bits parameter - * add_param(32bit parameter); - */ - t->set_param(0, (memaddr)length2); - t->set_param(1, (memaddr)length2); - /** - * Set of Input Data - * add_inData(address of input data, size of input data); - */ - t->set_inData(0,data, sizeof(int)*length2); - t->set_inData(1,data+length2, sizeof(int)*length2); - print_ListData(2,t->inData(0)); - /** - * Set of Output area - * add_outData(address of output area, size of output area); - */ - t->set_outData(0,data, sizeof(int)*length2); - t->set_outData(1,data+length2, sizeof(int)*length2); - print_ListData(2,t->outData(0)); - data += length; + int length2 = length/data_count; + t->set_param(0, (memaddr)data_count); + + for(int j = 0;j<data_count;j++) { + /** + * Set 32bits parameter + * add_param(32bit parameter); + */ + t->set_param(j+1, (memaddr)length2); + /** + * Set of Input Data + * add_inData(address of input data, size of input data); + */ + t->set_inData(j,data, sizeof(int)*length2); + /** + * Set of Output area + * add_outData(address of output area, size of output area); + */ + t->set_outData(j,data, sizeof(int)*length2); + data += length2; + } +#if 0 + print_ListData(data_count,t->inData(0)); + print_ListData(data_count,t->outData(0)); printf("pos 0x%0lx size 0x%0x\n",(unsigned long)t, t->size()); +#endif } twice_main->spawn_task_array(t->next());
--- a/example/Bulk/ppe/Twice.cc Mon Dec 14 12:16:52 2009 +0900 +++ b/example/Bulk/ppe/Twice.cc Mon Dec 14 12:46:48 2009 +0900 @@ -14,13 +14,16 @@ int *i_data; int *o_data; long length; + int count = (int)s->get_param(0); - i_data = (int*)s->get_input(rbuf, 0); - o_data = (int*)s->get_output(wbuf, 0); - length = (long)s->get_param(0); - - for (int i = 0; i < length; i++) { - o_data[i] = i_data[i] * 2; + for(int j = 0; j<count; j++) { + i_data = (int*)s->get_input(rbuf, j); + o_data = (int*)s->get_output(wbuf, j); + length = (long)s->get_param(j+1); + + for (int i = 0; i < length; i++) { + o_data[i] = i_data[i] * 2; + } } return 0;