Mercurial > hg > Game > Cerium
changeset 1856:429cf7e669a1 draft
some fix (cannot running)
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 22 Dec 2013 23:10:13 +0900 |
parents | 69250f6636e0 |
children | 7122e6edce5e |
files | example/regex_mas/main.cc |
diffstat | 1 files changed, 23 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/main.cc Sun Dec 22 18:53:03 2013 +0900 +++ b/example/regex_mas/main.cc Sun Dec 22 23:10:13 2013 +0900 @@ -112,36 +112,39 @@ } static st_mmap_t -divide_read(TaskManager *manager,char *filename, FilereadPtr fr) +divide_read(TaskManager *manager,HTaskPtr run,char *filename, FilereadPtr fr) { + st_mmap_t st_mmap; long fd = (long)manager->allocate(sizeof(long)); - struct stat *sb = (struct stat*)manager->allocate(sizeof(struct stat)); + struct stat sb; if ((fd=open(filename,O_RDONLY,0666))==0) { fprintf(stderr,"can't open %s\n",filename); } - if (fstat(fd,sb)) { + if (fstat(fd,&sb)) { fprintf(stderr,"can't fstat %s\n",filename); } + st_mmap.size = fix_byte(sb.st_size,division * 1024); + st_mmap.file_mmap = (char*)manager->allocate(st_mmap.size); + fr->fd = fd; fr->cpu = spe_cpu; fr->task_blocks = 16; - fr->filesize = sb->st_size; + fr->filesize = sb.st_size; fr->left_size = fr->filesize; fr->division_size = 1024 * division; - fr->task_num = fr->filesize / 1024 * division; + fr->task_num = fr->filesize / (1024 * division); fr->task_num += ((fr->filesize % 1024 * division) != 0); - printf("filesize : %ld\n",fr->filesize); - printf("one_task_size: %ld\n",fr->division_size); - printf("task_num : %ld\n",fr->task_num); + //HTaskPtr run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); + run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); + //run->spawn(); - HTaskPtr run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); - run->spawn(); + st_mmap.file_mmap = fr->read_text; - return fr->read_text; + return st_mmap; } static st_mmap_t @@ -298,12 +301,13 @@ run_start(TaskManager *manager, char *filename,unsigned char *search_word, int search_word_len) { HTaskPtr t_print; + HTaskPtr run = NULL; WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount)); FilereadPtr fr = (FilereadPtr)manager->allocate(sizeof(FilereadPtr)); st_mmap_t st_mmap; if (div_read != 0) { - st_mmap = divide_read(manager,filename,fr); + st_mmap = divide_read(manager,run,filename,fr); printf("in divide read\n"); }else { st_mmap = my_read(manager,filename); @@ -365,10 +369,13 @@ // for(int i = 0;i<2;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ - HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, - (memaddr)&w->self,sizeof(memaddr),0,0); - t_print->wait_for(t_exec); - t_exec->iterate(2); + HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, + (memaddr)&w->self,sizeof(memaddr),0,0); + //t_print->wait_for(t_exec); + //t_exec->wait_for(run); + //run->spawn(); + + t_exec->iterate(2); // t_exec->spawn(); // }