Mercurial > hg > Game > Cerium
diff example/Bulk/main.cc @ 684:ecf7e09b1fe8 draft
adding Array Task.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 06 Dec 2009 11:33:09 +0900 |
parents | c7199f162b64 |
children | 6e42b20f6198 |
line wrap: on
line diff
--- a/example/Bulk/main.cc Sun Dec 06 10:23:19 2009 +0900 +++ b/example/Bulk/main.cc Sun Dec 06 11:33:09 2009 +0900 @@ -7,8 +7,8 @@ extern void task_init(void); static int length = DATA_NUM; -static int task = 1; -static int count = 1; +static int task = 10; +static int count = 10; const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ -length Number of data (default DATA_NUM (Func.h))\n\ @@ -55,7 +55,6 @@ void twice_init(TaskManager *manager) { - TaskArray *twice; int *data = (int*)manager->allocate(sizeof(int)*length); @@ -69,38 +68,47 @@ * Create Task * create_task(Task ID); */ - twice = manager->create_bulk_task(count); + int size = count*(SizeOfParam(2) + SizeOfData(sizeof(int)*length) + + SizeOfData(sizeof(int)*length)); + HTask *twice_main = manager->create_task_array(size); + int pos = 0; for(int i = 0;i<count;i++) { - Task t = twice_main->create_stask(Twice); + Task t = twice_main->create_task(Twice,pos); int length2 = length/2; + // 以下の順序でデータを追加する必要がある。 + // length を先に指定すればsetは後からでも良い。 /** * Set 32bits parameter * add_param(32bit parameter); */ + t->set_param_length(2); 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->add_inData(data, sizeof(int)*length2); - t->add_inData(data+length2, sizeof(int)*length2); + t->set_inData_length(2); + t->set_inData(0,data, sizeof(int)*length2); + t->set_inData(1,data+length2, sizeof(int)*length2); /** - * Set of OutPut area + * Set of Output area * add_outData(address of output area, size of output area); */ - t->add_outData(data, sizeof(int)*length2); - t->add_outData(data+length2, sizeof(int)*length2); + t->set_outData_length(2); + t->set_outData(0,data, sizeof(int)*length2); + t->set_outData(1,data+length2, sizeof(int)*length2); + pos += t->size(); + + delete t; // Wao! } twice_main->set_cpu(SPE_ANY); - /* * set_post() で ppe task を渡せるようにしたい */ - twice->set_post(twice_result, (void*)data, 0); - + twice_main->set_post(twice_result, (void*)data, 0); // add Active Queue - twice->spawn_bulk(); + twice_main->spawn(); } int