Mercurial > hg > Members > kono > Cerium
diff example/Bulk/main.cc @ 787:5df90e02e34f
fix Bulk
author | yutaka@localhost.localdomain |
---|---|
date | Sat, 24 Apr 2010 17:25:46 +0900 |
parents | 226d95fa2691 |
children |
line wrap: on
line diff
--- a/example/Bulk/main.cc Sat Apr 24 15:24:33 2010 +0900 +++ b/example/Bulk/main.cc Sat Apr 24 17:25:46 2010 +0900 @@ -10,12 +10,14 @@ static int length = DATA_NUM; static int task = 3; -static int count = 3; -static int data_count = 3; +static int task_array_num = 3; +static int block_num = 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\ - -count Number of task (default 1)\n"; +const char *usr_help_str = "Usage: ./twice [-length data_length] [-task_array_num task_num]\n\ + -task_array_num Number of data in a block (default 16)\n\ + -block_num Number of block\n\ + -task Number of task\n\ + -block_size Size of a block\n"; static void @@ -36,7 +38,7 @@ { int* data = (int*)a; int* task_buf = (int*)b; - print_data(data, length*count, "after"); + print_data(data, length*task_array_num, "after"); free(data); free(task_buf); } @@ -44,17 +46,19 @@ static int init(int argc, char **argv) { + int block_size = 16; for (int i = 1; argv[i]; ++i) { - if (strcmp(argv[i], "-length") == 0) { - length = atoi(argv[++i]); - } else if (strcmp(argv[i], "-task") == 0) { + if (strcmp(argv[i], "-task") == 0) { task = atoi(argv[++i]); - } else if (strcmp(argv[i], "-count") == 0) { - count = atoi(argv[++i]); - } else if (strcmp(argv[i], "-data_count") == 0) { - data_count = atoi(argv[++i]); + } else if (strcmp(argv[i], "-task_array_num") == 0) { + task_array_num = atoi(argv[++i]); + } else if (strcmp(argv[i], "-block_num") == 0) { + block_num = atoi(argv[++i]); + } else if (strcmp(argv[i], "-block_size") == 0) { + block_size = atoi(argv[++i]); } } + length = task_array_num * block_num * block_size; return 0; } @@ -73,54 +77,54 @@ { - for (int i = 0; i < length*count; i++) { + for (int i = 0; i < length*task_array_num; i++) { data[i] = i; } - print_data(data, length*count, "before"); + print_data(data, length*task_array_num, "before"); /** * Create Task * create_task(Task ID); */ - HTask *twice_main = manager->create_task_array(Twice,count,data_count+1,data_count,data_count); + HTask *twice_main = manager->create_task_array(Twice,task_array_num,block_num+1,block_num,block_num); 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); + t->size(), task_array_num); #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++) { + for(int i = 0;i<task_array_num;i++) { t = twice_main->next_task_array(Twice, t); - int length2 = length/data_count; - t->set_param(0, (memaddr)data_count); + int block_size = length/block_num; + t->set_param(0, (memaddr)block_num); - for(int j = 0;j<data_count;j++) { + for(int j = 0;j<block_num;j++) { /** * Set 32bits parameter * add_param(32bit parameter); */ - t->set_param(j+1, (memaddr)length2); + t->set_param(j+1, (memaddr)block_size); /** * Set of Input Data * add_inData(address of input data, size of input data); */ - t->set_inData(j,data, sizeof(int)*length2); + t->set_inData(j,data, sizeof(int)*block_size); /** * Set of Output area * add_outData(address of output area, size of output area); */ - t->set_outData(j,data, sizeof(int)*length2); - data += length2; + t->set_outData(j,data, sizeof(int)*block_size); + data += block_size; } #if 0 - print_ListData(data_count,t->inData(0)); - print_ListData(data_count,t->outData(0)); + print_ListData(block_num,t->inData(0)); + print_ListData(block_num,t->outData(0)); printf("pos 0x%0lx size 0x%0x\n",(unsigned long)t, t->size()); #endif } @@ -146,7 +150,7 @@ task_init(); for (int i = 0; i < task; ++i) { - int *data = (int*)manager->allocate(sizeof(int)*length*count); + int *data = (int*)manager->allocate(sizeof(int)*length*task_array_num); twice_init(manager, data, length); }