Mercurial > hg > Game > Cerium
annotate example/regex_mas/main.cc @ 1746:f2f69b73afe9 draft
remove global variable in regex_mas
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 18 Nov 2013 18:15:04 +0900 |
parents | ef246e421c8c |
children | efbb42f8077a |
rev | line source |
---|---|
1598 | 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 <sys/time.h> | |
1690 | 10 #include <iostream> |
11 #include <vector> | |
1598 | 12 #include "TaskManager.h" |
13 #include "SchedTask.h" | |
14 #include "Func.h" | |
15 #include "WordCount.h" | |
1680
e44e5a18392c
fix regex_mas.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1676
diff
changeset
|
16 #define EXTRA_LENGTH 4 //多く取ってくる文字数(search word length - 1) |
1630 | 17 |
1598 | 18 /* ;TODO |
19 * PS3でCPU数が2以上の時に、あまりが計算されてない | |
20 */ | |
21 | |
22 extern void task_init(); | |
23 void TMend(TaskManager *); | |
1645
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
24 static double st_time; |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
25 static double ed_time; |
1598 | 26 int all = 0; |
27 int use_task_array = 1; | |
28 int use_task_creater = 0; | |
29 int use_compat = 0; | |
30 int array_task_num = 8; | |
31 int spe_num = 1; | |
32 CPU_TYPE spe_cpu = SPE_ANY; | |
33 const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-file filename]\n"; | |
34 | |
1645
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
35 static double |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
36 getTime() { |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
37 struct timeval tv; |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
38 gettimeofday(&tv, NULL); |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
39 return tv.tv_sec + (double)tv.tv_usec*1e-6; |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
40 } |
1598 | 41 |
42 typedef struct { | |
43 caddr_t file_mmap; | |
44 off_t size; | |
45 } st_mmap_t; | |
46 | |
47 /*与えられたsizeをfix_byte_sizeの倍数にする(丸め込むっていうのかな?)*/ | |
48 static int | |
49 fix_byte(int size,int fix_byte_size) | |
50 { | |
51 size = (size/fix_byte_size)*fix_byte_size + ((size%fix_byte_size)!= 0)*fix_byte_size; | |
52 | |
53 return size; | |
54 } | |
55 | |
56 | |
57 static st_mmap_t | |
1707
64bb17ddc3e6
change "fread" to "read" in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1692
diff
changeset
|
58 my_read(TaskManager *manager,char *filename) |
1598 | 59 { |
60 /*マッピングだよ!*/ | |
61 int fd = -1; | |
62 st_mmap_t st_mmap; | |
63 struct stat sb; | |
64 | |
65 if ((fd=open(filename,O_RDONLY,0666))==0) { | |
66 fprintf(stderr,"can't open %s\n",filename); | |
67 } | |
68 | |
69 if (fstat(fd,&sb)) { | |
70 fprintf(stderr,"can't fstat %s\n",filename); | |
71 } | |
72 | |
73 /*sizeをページングサイズの倍数にあわせる*/ | |
1647 | 74 st_mmap.size = fix_byte(sb.st_size,4096); |
1707
64bb17ddc3e6
change "fread" to "read" in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1692
diff
changeset
|
75 st_mmap.file_mmap = (char*)manager->allocate(st_mmap.size); |
1598 | 76 |
1707
64bb17ddc3e6
change "fread" to "read" in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1692
diff
changeset
|
77 read(fd,st_mmap.file_mmap,st_mmap.size); |
1691
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
78 |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
79 if (st_mmap.file_mmap == (caddr_t)-1) { |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
80 fprintf(stderr,"Can't mmap file\n"); |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
81 perror(NULL); |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
82 exit(0); |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
83 } |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
84 |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
85 return st_mmap; |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
86 |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
87 } |
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
88 |
1598 | 89 static void |
90 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) | |
91 { | |
92 | |
93 if (task_count < array_task_num) { | |
94 array_task_num = task_count; | |
95 if (task_count<=0) return; | |
96 } | |
97 | |
98 if (use_task_array) { | |
99 | |
100 int spl = spe_num * array_task_num; | |
101 int loop = (task_count + spl - 1) / spl; | |
102 | |
103 for (int i = 0; i < loop; i += 1) { | |
104 | |
1676 | 105 if (w->task_num < spe_num) spe_num = w->task_num; |
1598 | 106 |
107 // ここから | |
108 HTask **task_array = (HTask**)manager->allocate(sizeof(HTask*)*spe_num); | |
109 Task **t_exec = (Task**)manager->allocate(sizeof(Task*)*spe_num); | |
110 | |
1690 | 111 for (int k = 0; k < spe_num; k++) { |
1598 | 112 task_array[k] = manager->create_task_array(TASK_EXEC,array_task_num,1,1,1); |
113 t_exec[k] = 0; | |
114 if (all) { | |
115 w->t_print->wait_for(task_array[k]); | |
116 } else { | |
117 t_next->wait_for(task_array[k]); | |
118 } | |
119 } | |
120 | |
121 for (int j = 0; j < array_task_num; j++) { | |
122 for (int k = 0; k < spe_num; k++) { | |
123 | |
124 int a = w->task_spwaned++; | |
1740 | 125 |
1598 | 126 if (w->size < size) size = w->size; |
1740 | 127 |
1680
e44e5a18392c
fix regex_mas.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1676
diff
changeset
|
128 int set_one_task_length = size/sizeof(char); |
1740 | 129 //const int ONE_TASK_LENGTH = w->division_size; |
130 //const int ONE_LOOP_LENGTH = array_task_num*spe_num*ONE_TASK_LENGTH; | |
131 //const int ARRAY_LENGTH_SIZE = spe_num * ONE_TASK_LENGTH; | |
132 //int offset = ONE_LOOP_LENGTH * i + ARRAY_LENGTH_SIZE*j + ONE_TASK_LENGTH*k; | |
1680
e44e5a18392c
fix regex_mas.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1676
diff
changeset
|
133 t_exec[k] = task_array[k]->next_task_array(TASK_EXEC,t_exec[k]); |
e44e5a18392c
fix regex_mas.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1676
diff
changeset
|
134 |
e44e5a18392c
fix regex_mas.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1676
diff
changeset
|
135 if(size != w->size){ //最後のタスクかどうかの判定 |
1743
36eb8c21281a
remove warning in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1740
diff
changeset
|
136 t_exec[k]->set_param(0,&set_one_task_length + EXTRA_LENGTH); |
1662 | 137 t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size+EXTRA_LENGTH); |
1744
68e5872085ff
set_inData(rbuf,1) bugs? same address get_input Data in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1743
diff
changeset
|
138 t_exec[k]->set_inData(1,w->search_word, w->search_word_len); |
1647 | 139 }else{ |
1743
36eb8c21281a
remove warning in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1740
diff
changeset
|
140 t_exec[k]->set_param(0,&set_one_task_length); |
1662 | 141 t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size); |
1744
68e5872085ff
set_inData(rbuf,1) bugs? same address get_input Data in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1743
diff
changeset
|
142 t_exec[k]->set_inData(1,w->search_word, w->search_word_len); |
1647 | 143 } |
1740 | 144 |
1662 | 145 t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); |
146 | |
1598 | 147 w->size -= size; |
148 w->task_num--; | |
149 } | |
150 } | |
151 for (int k = 0; k < spe_num; k++) { | |
152 task_array[k]->spawn_task_array(t_exec[k]->next()); | |
153 task_array[k]->set_cpu(spe_cpu); | |
154 task_array[k]->spawn(); | |
155 } | |
156 | |
157 } | |
158 | |
159 return; | |
160 | |
161 } | |
162 | |
163 for (int i = 0; i < task_count; i += array_task_num) { | |
164 | |
165 HTask *h_exec = 0; | |
166 for (int j = 0; j < array_task_num; j++) { | |
167 int i = w->task_spwaned++; | |
168 if (w->size < size) size = w->size; | |
169 int length = size/sizeof(char); | |
170 if (size==0) break; | |
171 | |
172 if (use_compat) { | |
173 h_exec = manager->create_task(TASK_EXEC); | |
1743
36eb8c21281a
remove warning in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1740
diff
changeset
|
174 h_exec->set_param(0,&length); |
1598 | 175 h_exec->set_inData(0,w->file_mmap + i*w->division_size, size); |
176 h_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size); | |
177 | |
178 | |
179 if (all) { | |
180 w->t_print->wait_for(h_exec); | |
181 } else { | |
182 t_next->wait_for(h_exec); | |
183 } | |
184 | |
185 h_exec->set_cpu(spe_cpu); | |
186 h_exec->spawn(); | |
187 | |
188 } else { | |
189 h_exec = manager->create_task(TASK_EXEC, | |
190 (memaddr)(w->file_mmap + i*w->division_size), size, | |
191 (memaddr)(w->o_data + i*w->out_size), w->division_out_size); | |
192 | |
193 if (all) { | |
194 w->t_print->wait_for(h_exec); | |
195 } else { | |
196 t_next->wait_for(h_exec); | |
197 } | |
198 | |
199 h_exec->set_cpu(spe_cpu); | |
200 h_exec->spawn(); | |
201 } | |
202 w->size -= size; | |
203 w->task_num--; | |
204 } | |
205 | |
206 } | |
207 | |
208 } | |
209 | |
210 /** | |
211 * このTaskは、PPE上で実行されるので、並列に実行されることはない | |
212 * 二つ実行されていて、Task が足りなくなることがないようにしている。 | |
213 */ | |
214 | |
215 SchedDefineTask1(RUN_TASK_BLOCKS,run16); | |
216 | |
217 static int | |
218 run16(SchedTask *manager, void *in, void *out) | |
219 { | |
220 WordCount *w = *(WordCount **)in; | |
221 | |
222 if (w->task_num < w->task_blocks) { | |
223 // last case | |
224 while (w->size >= w->division_size) | |
225 run_tasks(manager,w,w->task_num, w->t_print, w->division_size); | |
226 // remaining data | |
227 while (w->size>0) | |
228 run_tasks(manager,w,1, w->t_print, w->size); | |
229 // printf("run16 last %d\n",w->task_num); | |
230 } else { | |
231 HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS, | |
232 (memaddr)&w->self,sizeof(memaddr),0,0); | |
233 w->t_print->wait_for(t_next); | |
234 | |
235 run_tasks(manager,w, w->task_blocks, t_next, w->division_size); | |
236 | |
237 t_next->spawn(); | |
238 // printf("run16 next %d\n",w->task_num); | |
239 } | |
240 return 0; | |
241 } | |
242 | |
243 | |
244 static int blocks = 48; | |
245 //static int blocks = 31 * 6 * 24; | |
246 static int division = 16; // in Kbyte | |
247 | |
248 static void | |
1746
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
249 run_start(TaskManager *manager, char *filename,unsigned char *search_word) |
1598 | 250 { |
251 HTaskPtr t_print; | |
252 | |
253 st_mmap_t st_mmap; | |
1691
6b3991ac3f07
changed mmap to fread.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1690
diff
changeset
|
254 //st_mmap = my_mmap(filename); |
1707
64bb17ddc3e6
change "fread" to "read" in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1692
diff
changeset
|
255 st_mmap = my_read(manager,filename); |
1598 | 256 WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount)); |
257 // bzero(w,sizeof(WordCount)); | |
258 | |
1745
ef246e421c8c
refactoring in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1744
diff
changeset
|
259 /* prepare BMSearch*/ |
ef246e421c8c
refactoring in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1744
diff
changeset
|
260 w->search_word = search_word; |
ef246e421c8c
refactoring in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1744
diff
changeset
|
261 w->search_word_len = strlen((const char*)w->search_word); |
ef246e421c8c
refactoring in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1744
diff
changeset
|
262 |
1598 | 263 //w->task_blocks = blocks; |
264 w->self = w; | |
265 w->task_spwaned = 0; | |
266 | |
267 /*sizeはdivision_sizeの倍数にしている。*/ | |
268 w->size = w->file_size = st_mmap.size; | |
269 w->file_mmap = st_mmap.file_mmap; | |
270 /* 1task分のデータサイズ(byte) */ | |
271 if (w->size >= 1024*division) { | |
272 w->division_size = 1024 * division;/*16kbyte*/ | |
273 } else { | |
274 w->division_size = w->size; | |
275 } | |
276 | |
1680
e44e5a18392c
fix regex_mas.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1676
diff
changeset
|
277 /* exec output only "match_num" */ |
e44e5a18392c
fix regex_mas.
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1676
diff
changeset
|
278 w->status_num = 1; |
1598 | 279 /* taskの数 */ |
280 w->task_num = w->size / w->division_size; | |
281 w->task_num = w->task_num + (w->division_size*w->task_num < w->size); | |
282 int out_task_num = w->task_num; | |
283 | |
284 if(!all) { | |
285 w->task_blocks = blocks; | |
286 } else { | |
287 w->task_blocks = w->task_num; | |
288 } | |
289 | |
290 w->out_task_num = out_task_num; | |
291 | |
292 /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */ | |
293 | |
1660
8b50b1ee068e
change result position to match_num.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1655
diff
changeset
|
294 w->division_out_size = sizeof(unsigned long long)*1; |
1598 | 295 int out_size = w->division_out_size*out_task_num; |
296 w->o_data = (unsigned long long *)manager->allocate(out_size); | |
1660
8b50b1ee068e
change result position to match_num.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1655
diff
changeset
|
297 w->out_size = 1; |
1598 | 298 |
299 /*各SPEの結果を合計して出力するタスク*/ | |
300 | |
301 t_print = manager->create_task(TASK_PRINT, | |
302 (memaddr)&w->self,sizeof(memaddr),0,0); | |
303 w->t_print = t_print; | |
304 | |
1690 | 305 for(int i = 0;i<2;i++) { |
1598 | 306 /* Task を task_blocks ずつ起動する Task */ |
307 /* serialize されていると仮定する... */ | |
308 HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, | |
309 (memaddr)&w->self,sizeof(memaddr),0,0); | |
310 t_print->wait_for(t_exec); | |
311 t_exec->spawn(); | |
312 } | |
313 | |
314 t_print->spawn(); | |
315 } | |
316 | |
317 static char* | |
318 init(int argc, char **argv) | |
319 { | |
320 | |
321 char *filename = 0; | |
1746
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
322 unsigned char *search_word = 0; |
1598 | 323 |
324 for (int i = 1; argv[i]; ++i) { | |
325 if (strcmp(argv[i], "-file") == 0) { | |
326 filename = argv[i+1]; | |
327 } else if (strcmp(argv[i], "-division") == 0) { | |
328 division = atoi(argv[i+1]); | |
329 } else if (strcmp(argv[i], "-block") == 0) { | |
330 blocks = atoi(argv[i+1]); | |
331 } else if (strcmp(argv[i], "-a") == 0) { | |
332 // create task all at once | |
333 all = 1; | |
334 } else if (strcmp(argv[i], "-c") == 0) { | |
335 use_task_array = 0; | |
336 use_compat = 1; | |
337 } else if (strcmp(argv[i], "-s") == 0) { | |
338 use_task_array = 0; | |
339 use_compat = 0; | |
340 } else if (strcmp(argv[i], "-t") == 0) { | |
341 use_task_creater = 1; | |
342 use_task_array = 0; | |
343 use_compat = 0; | |
344 } else if (strcmp(argv[i], "-anum") == 0) { | |
345 array_task_num = atoi(argv[i+1]); | |
346 } else if (strcmp(argv[i], "-g") == 0 ) { | |
347 spe_cpu = GPU_0; | |
348 } else if (strcmp(argv[i], "-cpu") == 0) { | |
349 spe_num = atoi(argv[i+1]); | |
350 if (spe_num==0) spe_num = 1; | |
1645
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
351 } else if (strcmp(argv[i], "-sw") == 0) { |
1651 | 352 search_word = (unsigned char*)argv[i+1]; |
1598 | 353 } |
354 } | |
355 if (filename==0) { | |
356 puts(usr_help_str); | |
357 exit(1); | |
358 } | |
359 | |
360 return filename; | |
361 } | |
362 | |
363 | |
364 int | |
365 TMmain(TaskManager *manager, int argc, char *argv[]) | |
366 { | |
367 | |
368 char *filename = 0; | |
1746
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
369 unsigned char *search_word = 0; |
1598 | 370 filename = init(argc, argv); |
371 | |
1746
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
372 for (int i = 1; argv[i]; ++i) { |
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
373 if (strcmp(argv[i], "-sw") == 0) { |
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
374 search_word = (unsigned char*)argv[i+1]; |
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
375 } |
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
376 } |
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
377 |
1598 | 378 if (filename < 0) { |
379 return -1; | |
380 } | |
381 | |
1746
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
382 if (search_word < 0) { |
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
383 return -1; |
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
384 } |
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
385 |
1598 | 386 task_init(); |
1723
d54e287eeef3
change time measurement point in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1707
diff
changeset
|
387 st_time = getTime(); |
1746
f2f69b73afe9
remove global variable in regex_mas
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1745
diff
changeset
|
388 run_start(manager, filename,search_word); |
1645
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
389 manager->set_TMend(TMend); |
1598 | 390 return 0; |
391 } | |
392 | |
1645
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
393 void |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
394 TMend(TaskManager *manager) |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
395 { |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
396 ed_time = getTime(); |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
397 printf("Time: %0.6f\n",ed_time-st_time); |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
398 } |
4698c92bf2ca
Regex_mas implement time measurement.
Masa <e085726@ie.u-ryukyu.ac.jp>
parents:
1642
diff
changeset
|
399 |
1662 | 400 /* end */ |