Mercurial > hg > Game > Cerium
changeset 1796:355304646b4b draft
send array to task
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 04 Dec 2013 23:12:29 +0900 |
parents | 0aefbf042eb3 |
children | 964978cf41ae |
files | example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc example/send_args/main.cc example/send_args/ppe/Exec.cc |
diffstat | 4 files changed, 40 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/main.cc Wed Dec 04 19:20:20 2013 +0900 +++ b/example/regex_mas/main.cc Wed Dec 04 23:12:29 2013 +0900 @@ -270,7 +270,7 @@ (memaddr)&w->self,sizeof(memaddr),0,0); w->t_print = t_print; - for(int i = 0;i<1;i++) { + for(int i = 0;i<4;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, @@ -333,9 +333,8 @@ { char *filename = init(argc, argv); + int sw_len = strlen((const char *)sword); - int sw_len = strlen((const char *)sword); - //int sw_len = 5; unsigned char *search_word = (unsigned char*)manager->allocate(sw_len + 1); memcpy(search_word, sword, sw_len);
--- a/example/regex_mas/ppe/Exec.cc Wed Dec 04 19:20:20 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Wed Dec 04 23:12:29 2013 +0900 @@ -32,7 +32,7 @@ static int run(SchedTask *s, void *rbuf, void *wbuf) { - //get_inData + //get_input unsigned char *i_data = (unsigned char *)s->get_input(rbuf,0); unsigned char *search_word = (unsigned char *)s->get_input(rbuf,1); int *skip_table = (int *)s->get_input(rbuf,2); @@ -43,11 +43,12 @@ //get_param long task_count = (long)s->get_param(0); - s->printf("[task count: %lld]\n",task_count); - s->printf("[search word: %s]\n",search_word); - s->printf("[search word len : %d]\n",sw_len); + //s->printf("[task count: %lld]\n",task_count); + //s->printf("[search word: %s]\n",search_word); + //s->printf("[search word len : %d]\n",sw_len); unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf,0); + o_data[0] = 0; o_data[0] = BM_method(i_data,length,search_word,sw_len,skip_table);
--- a/example/send_args/main.cc Wed Dec 04 19:20:20 2013 +0900 +++ b/example/send_args/main.cc Wed Dec 04 23:12:29 2013 +0900 @@ -11,47 +11,55 @@ static int spe_num = 1; static int task_num = 1; static CPU_TYPE spe_cpu = SPE_ANY; -static int one_task_size = 4096 * 4; extern TaskManager *manager; -const char *usr_help_str = "Usage: ./string_args [-cpu cpu_num] [-sw search_word] [-t task_num]\n"; +const char *usr_help_str = "Usage: ./string_args [-cpu cpu_num] [-sw send_word] [-t task_num]\n"; static char* init(int argc, char **argv) { - char *search_word = 0; + char *send_word = 0; for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-cpu") == 0) { spe_num = atoi(argv[i+1]); i++; } else if (strcmp(argv[i], "-sw") == 0) { - search_word = argv[i+1]; i++; + send_word = argv[i+1]; i++; } else if (strcmp(argv[i], "-t") == 0) { task_num = atoi(argv[i+1]); i++; } } - if (search_word==0){ + if (send_word==0){ puts(usr_help_str); exit(1); } - return search_word; + return send_word; } static void -run_start(TaskManager *manager,char *search_word,int search_word_len) +run_start(TaskManager *manager,char *send_word,int send_word_len) { HTask *exec; + int *intTable = (int*)manager->allocate(6); + + for(int a = 0; a < 4; a++){ + intTable[a] = 10 * a; + printf("intTable[%d] : %d ", a, intTable[a]); + } + printf("\n"); + printf("%s\n",send_word); + for(int i = 0; i < task_num; i++){ exec = manager->create_task(TASK_EXEC); exec->set_cpu(spe_cpu); - exec->set_inData(0,search_word,search_word_len); + exec->set_inData(0,send_word,send_word_len + 1); + exec->set_inData(1,intTable,4); - exec->set_param(0,(long)one_task_size); - exec->set_param(1,(long)i); + exec->set_param(0,(long)i); exec->spawn(); } } @@ -60,14 +68,14 @@ int TMmain(TaskManager *manager, int argc, char *argv[]) { - const char *search_word = init(argc,argv); - int search_word_len = strlen(search_word); + const char *send_word = init(argc,argv); + int send_word_len = strlen(send_word); - char *sword = (char*)manager->allocate(search_word_len+1); - memcpy(sword,search_word,search_word_len); // to get correct alignment + char *sword = (char*)manager->allocate(send_word_len + 1); + memcpy(sword,send_word,send_word_len + 1); // to get correct alignment task_init(); - run_start(manager, sword, search_word_len); + run_start(manager, sword, send_word_len); return 0; }
--- a/example/send_args/ppe/Exec.cc Wed Dec 04 19:20:20 2013 +0900 +++ b/example/send_args/ppe/Exec.cc Wed Dec 04 23:12:29 2013 +0900 @@ -18,16 +18,20 @@ static int run(SchedTask *s, void *rbuf, void *wbuf) { - const char *search_word = (char *)s->get_input(rbuf,0); + char *search_word = (char *)s->get_input(rbuf,0); + int *intTable = (int *)s->get_input(rbuf,1); + int intTable_size = (int)s->get_inputSize(1); - long task_size = (long)s->get_param(0); - long task_number = (long)s->get_param(1); + long task_number = (long)s->get_param(0); //s->xはiteraterで繰り返した数 + for(int i = 0; i < intTable_size;i++){ + s->printf("%d ",intTable[i]); + } + s->printf("\n"); - s->printf("[task number: %d]\n",task_number); - s->printf("[args : %s]\n",search_word); - s->printf("[task size : %d]\n",task_number); + s->printf("task number: %d\n",task_number + 1); + s->printf("args : %s\n",search_word); return 0;