Mercurial > hg > Game > Cerium
annotate example/word_count_test/main.cc @ 839:1001c4bea1a0 draft
if unnecessary
author | Yutaka_Kinjyo |
---|---|
date | Fri, 28 May 2010 03:24:52 +0900 |
parents | 4cdf9df6a92f |
children |
rev | line source |
---|---|
658 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <sys/mman.h> | |
5 #include <sys/types.h> | |
6 #include <sys/stat.h> | |
7 #include <fcntl.h> | |
8 #include <unistd.h> | |
9 #include "TaskManager.h" | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
10 #include "SchedTask.h" |
658 | 11 #include "Func.h" |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
12 #include "WordCount.h" |
658 | 13 |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
14 #define TASKARRAY |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
15 |
658 | 16 extern void task_init(); |
17 | |
18 const char *usr_help_str = "Usage: ./word_count [-cpu spe_num] [-file filename]\n"; | |
19 | |
20 typedef struct { | |
21 caddr_t file_mmap; | |
22 off_t size; | |
23 } st_mmap_t; | |
24 | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
25 |
658 | 26 |
27 /*与えられたsizeをfix_byte_sizeの倍数にする(丸め込むっていうのかな?)*/ | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
28 static int |
658 | 29 fix_byte(int size,int fix_byte_size) |
30 { | |
31 size = (size/fix_byte_size)*fix_byte_size + ((size%fix_byte_size)!= 0)*fix_byte_size; | |
32 | |
33 return size; | |
34 } | |
35 | |
36 | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
37 static st_mmap_t |
658 | 38 my_mmap(char *filename) |
39 { | |
40 | |
41 /*マッピングだよ!*/ | |
42 int fd = -1; | |
43 int map = MAP_PRIVATE; | |
44 st_mmap_t st_mmap; | |
45 struct stat sb; | |
46 | |
47 if ((fd=open(filename,O_RDONLY,0666))==0) { | |
48 fprintf(stderr,"can't open %s\n",filename); | |
49 } | |
50 | |
51 if (fstat(fd,&sb)) { | |
52 fprintf(stderr,"can't fstat %s\n",filename); | |
53 } | |
54 | |
55 printf("file size %d\n",(int)sb.st_size); | |
56 | |
57 /*sizeをページングサイズの倍数にあわせる*/ | |
58 st_mmap.size = fix_byte(sb.st_size,4096); | |
59 | |
60 printf("fix 4096byte file size %d\n",(int)st_mmap.size); | |
61 | |
62 st_mmap.file_mmap = (char*)mmap(NULL,st_mmap.size,PROT_READ,map,fd,(off_t)0); | |
63 if (st_mmap.file_mmap == (caddr_t)-1) { | |
64 fprintf(stderr,"Can't mmap file\n"); | |
65 perror(NULL); | |
66 exit(0); | |
67 } | |
68 | |
69 return st_mmap; | |
70 | |
71 } | |
72 | |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
73 #ifdef TASKARRAY |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
74 static HTask * |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
75 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
76 { |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
77 HTask *t_exec = manager->create_task_array(TASK_EXEC,task_count,0,1,1); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
78 Task *t = 0; |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
79 for (int j = 0; j < task_count && w->size>0; j++) { |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
80 int i = w->task_spwaned++; |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
81 // printf("div %0x\n", (w->file_mmap + i*w->division_size)); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
82 t = t_exec->next_task_array(TASK_EXEC, t); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
83 t->set_inData(0, (memaddr)(w->file_mmap + i*w->division_size), size); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
84 t->set_outData(0, (memaddr)(w->o_data + i*w->out_size), w->division_out_size); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
85 w->size -= size; |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
86 w->task_num--; |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
87 } |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
88 if (w->size!=0) { |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
89 printf("bad align %d\n",w->size); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
90 } |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
91 t_exec->spawn_task_array(t->next()); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
92 t_exec->set_cpu(SPE_ANY); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
93 t_next->wait_for(t_exec); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
94 t_exec->spawn(); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
95 return t_exec; |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
96 } |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
97 #else |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
98 static void |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
99 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
100 { |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
101 HTaskPtr t_exec = 0; |
664 | 102 for (int j = 0; j < task_count && w->size>0; j++) { |
103 int i = w->task_spwaned++; | |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
104 // printf("div %0x\n", (w->file_mmap + i*w->division_size)); |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
105 t_exec = manager->create_task(TASK_EXEC, |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
106 (memaddr)(w->file_mmap + i*w->division_size), size, |
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
107 (memaddr)(w->o_data + i*w->out_size), w->division_out_size); |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
108 t_exec->set_cpu(SPE_ANY); |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
109 t_next->wait_for(t_exec); |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
110 t_exec->spawn(); |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
111 w->size -= size; |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
112 w->task_num--; |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
113 } |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
114 return t_exec; |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
115 } |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
116 #endif |
658 | 117 |
664 | 118 SchedDefineTask1(RUN_TASK_BLOCKS,run16); |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
119 |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
120 static int |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
121 run16(SchedTask *manager, void *in, void *out) |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
122 { |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
123 WordCount *w = *(WordCount **)in; |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
124 |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
125 if (w->task_num < w->task_blocks) { |
664 | 126 if (w->size >= w->division_size) |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
127 run_tasks(manager,w,w->task_blocks, w->t_print, w->division_size); |
664 | 128 while (w->size>0) |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
129 run_tasks(manager,w,1, w->t_print, w->size); |
664 | 130 // printf("run16 last %d\n",w->task_num); |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
131 } else { |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
132 HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS, |
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
133 (memaddr)&w->self,sizeof(memaddr),0,0); |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
134 w->t_print->wait_for(t_next); |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
135 HTask *wait = next_wait_task(w, t_next); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
136 HTask *exec = run_tasks(manager,w, w->task_blocks, w->t_print, w->division_size); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
137 if (wait) { |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
138 wait->wait_for(t_next); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
139 wait->wait_for(exec); |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
140 } |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
141 t_next->spawn(); |
664 | 142 // printf("run16 next %d\n",w->task_num); |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
143 } |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
144 return 0; |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
145 } |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
146 |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
147 static int blocks = 48; |
666 | 148 static int division = 16; // in Kbyte |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
149 static int pipeline = 16; // Pipelined Tasks Blocks |
672 | 150 static int profile = 0; |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
151 |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
152 static void |
658 | 153 run_start(TaskManager *manager, char *filename) |
154 { | |
155 HTaskPtr t_print; | |
156 | |
157 st_mmap_t st_mmap; | |
158 st_mmap = my_mmap(filename); | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
159 WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount)); |
664 | 160 // bzero(w,sizeof(WordCount)); |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
713
diff
changeset
|
161 set_pipeline_count(w,manager,pipeline); |
658 | 162 |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
163 w->self = w; |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
164 w->task_blocks = blocks; |
664 | 165 w->task_spwaned = 0; |
810 | 166 //w->waiting = 0; |
658 | 167 |
168 /*sizeはdivision_sizeの倍数にしている。*/ | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
169 w->size = st_mmap.size; |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
170 w->file_mmap = st_mmap.file_mmap; |
658 | 171 |
172 /* 1task分のデータサイズ(byte) */ | |
666 | 173 if (w->size >= 1024*division) { |
174 w->division_size = 1024 * division;/*16kbyte*/ | |
175 } else { | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
176 w->division_size = w->size; |
658 | 177 } |
178 | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
179 printf("dvision_size %d\n",w->division_size); |
658 | 180 |
181 /* "word num" and "line num" */ | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
182 w-> status_num = 2; |
658 | 183 /* taskの数 */ |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
184 w-> task_num = w->size / w->division_size; |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
185 int out_task_num = w->task_num + (w->division_size*w->task_num < w->size); |
658 | 186 |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
187 w->out_task_num = out_task_num; |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
188 printf("task_num %d\n",w->task_num); |
658 | 189 |
190 /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(8byte)を使用 */ | |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
191 |
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
192 w-> division_out_size = sizeof(unsigned long long)*4; |
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
193 int out_size = w->division_out_size*out_task_num; |
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
194 w->o_data = (unsigned long long *)manager->allocate(out_size); |
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
195 w-> out_size = 4; |
658 | 196 printf("out size %d\n",out_size); |
197 | |
198 /*各SPEの結果を合計して出力するタスク*/ | |
199 | |
667
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
200 t_print = manager->create_task(TASK_PRINT, |
ae1d1eebf9ff
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
666
diff
changeset
|
201 (memaddr)&w->self,sizeof(memaddr),0,0); |
658 | 202 |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
203 w->t_print = t_print; |
658 | 204 |
670 | 205 for(int i = 0;i<1;i++) { |
206 /* Task を task_blocks ずつ起動する Task */ | |
207 /* serialize されていると仮定する... */ | |
208 HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, | |
209 (memaddr)&w->self,sizeof(memaddr),0,0); | |
210 t_exec->spawn(); | |
211 t_print->wait_for(t_exec); | |
212 } | |
658 | 213 |
214 t_print->spawn(); | |
215 } | |
216 | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
217 static char* |
658 | 218 init(int argc, char **argv) |
219 { | |
220 | |
221 char *filename = 0; | |
222 | |
223 for (int i = 1; argv[i]; ++i) { | |
224 if (strcmp(argv[i], "-file") == 0) { | |
225 filename = argv[i+1]; | |
666 | 226 } else if (strcmp(argv[i], "-division") == 0) { |
227 division = atoi(argv[i+1]); | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
228 } else if (strcmp(argv[i], "-block") == 0) { |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
229 blocks = atoi(argv[i+1]); |
672 | 230 } else if (strcmp(argv[i], "-p") == 0) { |
231 profile = 1; | |
658 | 232 } |
233 } | |
234 if (filename==0) { | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
235 printf("usage: %s [-block 10] -file filename\n",argv[0]); |
658 | 236 exit(1); |
237 } | |
238 | |
239 return filename; | |
240 } | |
241 | |
672 | 242 |
658 | 243 int |
244 TMmain(TaskManager *manager, int argc, char *argv[]) | |
245 { | |
246 | |
247 char *filename = 0; | |
248 filename = init(argc, argv); | |
249 | |
250 if (filename < 0) { | |
251 return -1; | |
252 } | |
253 | |
254 task_init(); | |
255 run_start(manager, filename); | |
256 | |
257 return 0; | |
258 } | |
663
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
259 |
ad4b6b556483
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
658
diff
changeset
|
260 /* end */ |