annotate example/word_count/main.cc @ 1083:54cf940e124a draft

minor fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 18 Dec 2010 12:02:19 +0900
parents e8ef7f5f22f6
children 2a63ba2c9506
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
1 #include <stdio.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
2 #include <stdlib.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
3 #include <string.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
4 #include <sys/mman.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
5 #include <sys/types.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
6 #include <sys/stat.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
7 #include <fcntl.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
8 #include <unistd.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
9 #include "TaskManager.h"
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
10 #include "SchedTask.h"
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
11 #include "Func.h"
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
12 #include "WordCount.h"
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
13
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
14 extern void task_init();
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
15
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
16 int all = 0;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
17 int use_task_array = 1;
1039
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
18 int use_task_creater = 0;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
19 int use_compat = 0;
967
daab1b74b32d add anum option in WordCount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 950
diff changeset
20 int array_task_num = 8;
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
21 int spe_num = 1;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
22
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
23 const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-file filename]\n";
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
24
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
25 typedef struct {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
26 caddr_t file_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
27 off_t size;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
28 } st_mmap_t;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
29
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
30
1039
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
31 static void simple_task_creater(int in_total_size, int out_total_size,
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
32 int command, int in_data_size, int out_data_size,
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
33 void *in_data, void *out_data, SchedTask *manager,
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
34 HTask *wait_i, HTask *wait_me) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
35
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
36
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
37 int in_task_size = 0;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
38 int out_task_size = 0;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
39
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
40 if (in_total_size != 0) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
41 in_task_size = in_total_size / in_data_size;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
42 if (in_total_size != in_task_size * in_data_size) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
43 printf("mismatch of in_total_size and in_data_size\n");
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
44 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
45 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
46
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
47 if (out_total_size != 0) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
48 out_task_size = out_total_size / out_data_size;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
49 if (out_total_size != out_task_size * out_data_size) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
50 printf("mismatch of out_total_size and out_data_size\n");
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
51 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
52 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
53
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
54 /*in, out の大きい方に合わせるのがいいかな? Taskの数は1Task分に使うデータの大きいほうを取るような仕様がいいかな*/
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
55 int task_num = (in_task_size > out_task_size) ? in_task_size : out_task_size;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
56
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
57 if (task_num == 0) task_num = 1;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
58
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
59 /*spe分あればいいのかな?*/
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
60
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
61 int array_num = spe_num;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
62 if (task_num < array_num) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
63 array_num = task_num;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
64 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
65
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
66
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
67 HTaskPtr *task_array = (HTask**)manager->allocate(sizeof(HTask*)*array_num);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
68 TaskPtr *t_exec = (Task**)manager->allocate(sizeof(Task*)*array_num);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
69
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
70 int array_length = task_num / array_num;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
71 int rest = task_num % array_num;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
72
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
73 int index = 0;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
74
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
75 for (int k = 0; k < array_num; k++) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
76
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
77 task_array[k] = manager->create_task_array(command,array_length,0,1,1);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
78 t_exec[k] = 0;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
79
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
80 if (wait_me != 0) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
81 wait_me->wait_for(task_array[k]);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
82 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
83 if (wait_i != 0) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
84 task_array[k]->wait_for(wait_i);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
85 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
86
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
87 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
88
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
89 for (int j = 0; j < array_length; j++) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
90 for (int k = 0; k < array_num; k++) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
91
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
92 t_exec[k] = task_array[k]->next_task_array(command,t_exec[k]);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
93 t_exec[k]->set_inData(0,(char*)in_data + index*in_data_size, in_data_size);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
94 t_exec[k]->set_outData(0,(char*)out_data + index*out_data_size, out_data_size);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
95
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
96 index++;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
97
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
98 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
99 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
100
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
101 for (int k = 0; k < array_num; k++) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
102 task_array[k]->spawn_task_array(t_exec[k]->next());
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
103 task_array[k]->set_cpu(SPE_ANY);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
104 task_array[k]->spawn();
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
105 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
106
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
107 for (int k = 0; k < rest; k++) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
108 HTaskPtr t_exec = manager->create_task(command);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
109
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
110 t_exec->set_inData(0,(char*)in_data + index*in_data_size, in_data_size);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
111 t_exec->set_outData(0,(char*)out_data + index*out_data_size, out_data_size);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
112
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
113 index++;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
114
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
115 if (wait_me != 0) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
116 wait_me->wait_for(t_exec);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
117 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
118 if (wait_i != 0) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
119 t_exec->wait_for(wait_i);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
120 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
121
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
122 t_exec->spawn();
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
123 t_exec->set_cpu(SPE_ANY);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
124
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
125 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
126
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
127
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
128 }
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
129
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
130
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
131 /*与えられたsizeをfix_byte_sizeの倍数にする(丸め込むっていうのかな?)*/
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
132 static int
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
133 fix_byte(int size,int fix_byte_size)
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
134 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
135 size = (size/fix_byte_size)*fix_byte_size + ((size%fix_byte_size)!= 0)*fix_byte_size;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
136
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
137 return size;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
138 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
139
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
140
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
141 static st_mmap_t
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
142 my_mmap(char *filename)
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
143 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
144
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
145 /*マッピングだよ!*/
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
146 int fd = -1;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
147 int map = MAP_PRIVATE;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
148 st_mmap_t st_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
149 struct stat sb;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
150
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
151 if ((fd=open(filename,O_RDONLY,0666))==0) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
152 fprintf(stderr,"can't open %s\n",filename);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
153 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
154
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
155 if (fstat(fd,&sb)) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
156 fprintf(stderr,"can't fstat %s\n",filename);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
157 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
158
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
159 printf("file size %d\n",(int)sb.st_size);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
160
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
161 /*sizeをページングサイズの倍数にあわせる*/
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
162 st_mmap.size = fix_byte(sb.st_size,4096);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
163
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
164 printf("fix 4096byte file size %d\n",(int)st_mmap.size);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
165
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
166 st_mmap.file_mmap = (char*)mmap(NULL,st_mmap.size,PROT_READ,map,fd,(off_t)0);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
167 if (st_mmap.file_mmap == (caddr_t)-1) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
168 fprintf(stderr,"Can't mmap file\n");
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
169 perror(NULL);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
170 exit(0);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
171 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
172
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
173 return st_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
174
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
175 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
176
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
177 static void
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
178 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size)
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
179 {
1021
47ca99c5cf84 use MailManager
yutaka@localhost.localdomain
parents: 1007
diff changeset
180
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
181 if (task_count < array_task_num) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
182 array_task_num = task_count;
948
233bb9355fb7 fix word count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 946
diff changeset
183 if (task_count<=0) return;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
184 }
1039
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
185
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
186 //static void simple_task_creater(int in_total_size, int out_total_size,
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
187 // int command, int in_data_size, int out_data_size,
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
188 // void *in_data, void *out_data, TaskManager *manager,
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
189 // HTask *wait_i, HTask *wait_me)
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
190
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
191
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
192
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
193 if (use_task_creater) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
194 simple_task_creater(w->file_size, w->division_out_size * w->task_num, TASK_EXEC, w->division_size, w->division_out_size,
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
195 w->file_mmap, w->o_data, manager, w->t_print, 0);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
196 }
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
197
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
198 if (use_task_array) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
199
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
200 int spl = spe_num * array_task_num;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
201 int loop = (task_count + spl - 1) / spl;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
202
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
203 for (int i = 0; i < loop; i += 1) {
972
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
204
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
205 if (spl > w->task_num) {
972
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
206 if (w->task_num >= spe_num) {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
207 array_task_num = w->task_num / spe_num;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
208 } else {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
209
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
210 int task_num = w->task_num;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
211
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
212 for (int j = 0; j < task_num; j++) {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
213 HTask *h_exec = 0;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
214 int i = w->task_spwaned++;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
215
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
216 if (w->size < size) size = w->size;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
217
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
218 h_exec = manager->create_task(TASK_EXEC,
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
219 (memaddr)(w->file_mmap + i*w->division_size), size,
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
220 (memaddr)(w->o_data + i*w->out_size), w->division_out_size);
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
221
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
222 if (all) {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
223 w->t_print->wait_for(h_exec);
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
224 } else {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
225 t_next->wait_for(h_exec);
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
226 }
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
227
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
228 h_exec->set_cpu(SPE_ANY);
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
229 h_exec->spawn();
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
230
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
231 w->size -= size;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
232 w->task_num--;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
233
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
234 }
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
235
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
236 return;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
237 }
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
238 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
239
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
240
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
241 HTask **task_array = (HTask**)manager->allocate(sizeof(HTask*)*spe_num);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
242 Task **t_exec = (Task**)manager->allocate(sizeof(Task*)*spe_num);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
243
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
244 for (int k = 0; k < spe_num; k++) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
245 task_array[k] = manager->create_task_array(TASK_EXEC,array_task_num,0,1,1);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
246 t_exec[k] = 0;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
247 if (all) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
248 w->t_print->wait_for(task_array[k]);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
249 } else {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
250 t_next->wait_for(task_array[k]);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
251 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
252 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
253
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
254
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
255 for (int j = 0; j < array_task_num; j++) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
256 for (int k = 0; k < spe_num; k++) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
257
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
258 int a = w->task_spwaned++;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
259
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
260 if (w->size < size) size = w->size;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
261
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
262 t_exec[k] = task_array[k]->next_task_array(TASK_EXEC,t_exec[k]);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
263 t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
264 t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
265
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
266 w->size -= size;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
267 w->task_num--;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
268 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
269 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
270
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
271 for (int k = 0; k < spe_num; k++) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
272 task_array[k]->spawn_task_array(t_exec[k]->next());
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
273 task_array[k]->set_cpu(SPE_ANY);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
274 task_array[k]->spawn();
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
275 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
276
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
277 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
278
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
279 return;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
280
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
281 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
282
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
283
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
284 for (int i = 0; i < task_count; i += array_task_num) {
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
285
1021
47ca99c5cf84 use MailManager
yutaka@localhost.localdomain
parents: 1007
diff changeset
286 HTask *h_exec = 0;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
287 for (int j = 0; j < array_task_num; j++) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
288 int i = w->task_spwaned++;
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
289 if (w->size < size) size = w->size;
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
290 if (size==0) break;
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
291
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
292 if (use_compat) {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
293 h_exec = manager->create_task(TASK_EXEC);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
294 h_exec->set_inData(0,w->file_mmap + i*w->division_size, size);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
295 h_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size);
968
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
296
1021
47ca99c5cf84 use MailManager
yutaka@localhost.localdomain
parents: 1007
diff changeset
297
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
298 if (all) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
299 w->t_print->wait_for(h_exec);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
300 } else {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
301 t_next->wait_for(h_exec);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
302 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
303
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
304 h_exec->set_cpu(SPE_ANY);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
305 h_exec->spawn();
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
306
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
307 } else {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
308 h_exec = manager->create_task(TASK_EXEC,
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
309 (memaddr)(w->file_mmap + i*w->division_size), size,
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
310 (memaddr)(w->o_data + i*w->out_size), w->division_out_size);
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
311
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
312 if (all) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
313 w->t_print->wait_for(h_exec);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
314 } else {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
315 t_next->wait_for(h_exec);
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
316 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
317
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
318 h_exec->set_cpu(SPE_ANY);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
319 h_exec->spawn();
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
320 }
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
321 w->size -= size;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
322 w->task_num--;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
323 }
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
324
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
325 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
326
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
327 }
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
328
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
329 /**
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
330 * このTaskは、PPE上で実行されるので、並列に実行されることはない
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
331 * 二つ実行されていて、Task が足りなくなることがないようにしている。
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
332 */
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
333
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
334 SchedDefineTask1(RUN_TASK_BLOCKS,run16);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
335
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
336 static int
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
337 run16(SchedTask *manager, void *in, void *out)
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
338 {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
339 WordCount *w = *(WordCount **)in;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
340
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
341 if (w->task_num < w->task_blocks) {
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
342 // last case
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
343 if (w->size >= w->division_size)
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
344 run_tasks(manager,w,w->task_num, w->t_print, w->division_size);
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
345 // remaining data
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
346 while (w->size>0)
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
347 run_tasks(manager,w,1, w->t_print, w->size);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
348 // printf("run16 last %d\n",w->task_num);
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
349 } else {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
350 HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS,
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
351 (memaddr)&w->self,sizeof(memaddr),0,0);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
352 w->t_print->wait_for(t_next);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
353
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
354 run_tasks(manager,w, w->task_blocks, t_next, w->division_size);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
355
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
356 t_next->spawn();
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
357 // printf("run16 next %d\n",w->task_num);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
358 }
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
359 return 0;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
360 }
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
361
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
362
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
363 static int blocks = 48;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
364 static int division = 16; // in Kbyte
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
365
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
366 static void
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
367 run_start(TaskManager *manager, char *filename)
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
368 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
369 HTaskPtr t_print;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
370
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
371 st_mmap_t st_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
372 st_mmap = my_mmap(filename);
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
373 WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount));
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
374 // bzero(w,sizeof(WordCount));
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
375
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
376 w->self = w;
968
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
377 //w->task_blocks = blocks;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
378 w->task_spwaned = 0;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
379
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
380 /*sizeはdivision_sizeの倍数にしている。*/
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
381 w->size = w->file_size = st_mmap.size;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
382 w->file_mmap = st_mmap.file_mmap;
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
383 printf("w %lx\n",(long)w);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
384
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
385 /* 1task分のデータサイズ(byte) */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
386 if (w->size >= 1024*division) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
387 w->division_size = 1024 * division;/*16kbyte*/
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
388 } else {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
389 w->division_size = w->size;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
390 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
391
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
392 printf("dvision_size %d\n",w->division_size);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
394 /* "word num" and "line num" */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
395 w->status_num = 2;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
396 /* taskの数 */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
397 w->task_num = w->size / w->division_size;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
398 w->task_num = w->task_num + (w->division_size*w->task_num < w->size);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
399 int out_task_num = w->task_num;
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
400
968
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
401 if(!all) {
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
402 w->task_blocks = blocks;
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
403 } else {
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
404 w->task_blocks = w->task_num;
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
405 }
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
406
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
407 w->out_task_num = out_task_num;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
408 printf("task_num %d\n",w->task_num);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
409 printf("out_task_num %d\n",w->out_task_num);
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
410
1007
00c01f416e3a add mail_queue
yutaka@localhost.localdomain
parents: 972
diff changeset
411 /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
412
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
413 w->division_out_size = sizeof(unsigned long long)*4;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
414 int out_size = w->division_out_size*out_task_num;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
415 w->o_data = (unsigned long long *)manager->allocate(out_size);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
416 w->out_size = 4;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
417 printf("out size %d\n",out_size);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
418
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
419 /*各SPEの結果を合計して出力するタスク*/
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
420
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
421 t_print = manager->create_task(TASK_PRINT,
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
422 (memaddr)&w->self,sizeof(memaddr),0,0);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
423
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
424 w->t_print = t_print;
783
76781837ff3a wordcount fix?
yutaka@localhost.localdomain
parents: 743
diff changeset
425
968
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
426 for(int i = 0;i<1;i++) {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
427 /* Task を task_blocks ずつ起動する Task */
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
428 /* serialize されていると仮定する... */
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
429 HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS,
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
430 (memaddr)&w->self,sizeof(memaddr),0,0);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
431 t_print->wait_for(t_exec);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
432 t_exec->spawn();
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
433 }
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
434
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
435 t_print->spawn();
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
436 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
437
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
438 static char*
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
439 init(int argc, char **argv)
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
440 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
441
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
442 char *filename = 0;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
443
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
444 for (int i = 1; argv[i]; ++i) {
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
445 if (strcmp(argv[i], "-file") == 0) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
446 filename = argv[i+1];
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
447 } else if (strcmp(argv[i], "-division") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
448 division = atoi(argv[i+1]);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
449 } else if (strcmp(argv[i], "-block") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
450 blocks = atoi(argv[i+1]);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
451 } else if (strcmp(argv[i], "-a") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
452 // create task all at once
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
453 all = 1;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
454 } else if (strcmp(argv[i], "-c") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
455 use_task_array = 0;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
456 use_compat = 1;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
457 } else if (strcmp(argv[i], "-s") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
458 use_task_array = 0;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
459 use_compat = 0;
1039
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
460 } else if (strcmp(argv[i], "-t") == 0) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
461 use_task_creater = 1;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
462 use_task_array = 0;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
463 use_compat = 0;
967
daab1b74b32d add anum option in WordCount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 950
diff changeset
464 } else if (strcmp(argv[i], "-anum") == 0) {
daab1b74b32d add anum option in WordCount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 950
diff changeset
465 array_task_num = atoi(argv[i+1]);
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
466 } else if (strcmp(argv[i], "-cpu") == 0) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
467 spe_num = atoi(argv[i+1]);
1083
54cf940e124a minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1039
diff changeset
468 if (spe_num==0) spe_num = 1;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
469 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
470 }
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
471 if (filename==0) {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
472 puts(usr_help_str);
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
473 exit(1);
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
474 }
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
475
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
476 return filename;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
477 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
478
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
479
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
480 int
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
481 TMmain(TaskManager *manager, int argc, char *argv[])
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
482 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
483
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
484 char *filename = 0;
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
485 filename = init(argc, argv);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
486
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
487 if (filename < 0) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
488 return -1;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
489 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
490
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
491 task_init();
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
492 run_start(manager, filename);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
493
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
494 return 0;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
495 }
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
496
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
497 /* end */