Mercurial > hg > Game > Cerium
changeset 1984:7bea670cdba0 draft
divide read flag change enum type
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 17 Apr 2014 23:43:09 +0900 |
parents | c3b4083c4467 |
children | d703157bb280 |
files | example/fileread/Func.h example/fileread/main.cc example/word_count/main.cc |
diffstat | 3 files changed, 15 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/example/fileread/Func.h Sat Mar 15 17:46:13 2014 +0900 +++ b/example/fileread/Func.h Thu Apr 17 23:43:09 2014 +0900 @@ -6,3 +6,8 @@ MMAP, }; +enum { + MY_MMAP, + MY_READ, + BLOCKED_READ, +};
--- a/example/fileread/main.cc Sat Mar 15 17:46:13 2014 +0900 +++ b/example/fileread/main.cc Thu Apr 17 23:43:09 2014 +0900 @@ -15,8 +15,8 @@ static double st_time; static double ed_time; static int spe_num = 1; -int divide_read_flag = 0; static CPU_TYPE spe_cpu = IO_0; +static int READ_TYPE = MY_MMAP; static int DIVISION_SIZE = 1024*256*256; extern TaskManager *manager; @@ -99,8 +99,8 @@ spe_num = atoi(argv[i+1]); } else if (strcmp(argv[i], "-file") == 0) { filename = argv[i+1]; - } else if (strcmp(argv[i], "-dr") == 0) { - divide_read_flag = 1; + } else if (strcmp(argv[i], "-br") == 0) { + READ_TYPE = BLOCKED_READ; } } @@ -135,7 +135,6 @@ exit(0); } - printf("in mmap mode\n"); return 0; } @@ -174,13 +173,15 @@ HTaskPtr t_print = manager->create_task(Print_task, (memaddr)&fr->self, sizeof(memaddr),0,0); fr->t_print = t_print; - if (divide_read_flag != 0) { + if (READ_TYPE == MY_MMAP) { + run = manager->create_task(MMAP , (memaddr)&fr->self, sizeof(memaddr),0,0); + printf("+ in mmap mode +\n"); + }else { + //my_mmap(filename, fd, fr); + printf("+ in Blocked Read mode +\n"); char *read_text = (char*)manager->allocate(fr->filesize); run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),read_text,fr->filesize); fr->read_text = read_text; - }else { - //my_mmap(filename, fd, fr); - run = manager->create_task(MMAP , (memaddr)&fr->self, sizeof(memaddr),0,0); } t_print->wait_for(run);
--- a/example/word_count/main.cc Sat Mar 15 17:46:13 2014 +0900 +++ b/example/word_count/main.cc Thu Apr 17 23:43:09 2014 +0900 @@ -47,15 +47,6 @@ off_t size; } st_mmap_t; -/*与えられたsizeをfix_byte_sizeの倍数にする(丸め込むっていうのかな?)*/ -static int -fix_byte(int size,int fix_byte_size) -{ - size = (size/fix_byte_size)*fix_byte_size + ((size%fix_byte_size)!= 0)*fix_byte_size; - - return size; -} - static void my_mmap(char *filename, WordCount *w) { @@ -86,7 +77,7 @@ } static void -run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_read, HTaskPtr t_next, int size) +run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_read, HTaskPtr t_next, int size) { if (task_count < array_task_num) {