annotate example/word_count/main.cc @ 1130:5addc6c1d5c4 draft

fix.
author root@dolphins.cr.ie.u-ryukyu.ac.jp
date Sun, 13 Feb 2011 22:34:44 +0900
parents 2a63ba2c9506
children f0808a329663
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 if (use_task_creater) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
187 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
188 w->file_mmap, w->o_data, manager, w->t_print, 0);
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
189 }
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
190
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
191 if (use_task_array) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
192
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
193 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
194 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
195
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
196 for (int i = 0; i < loop; i += 1) {
972
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
197
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
198 if (spl > w->task_num) {
972
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
199 if (w->task_num >= spe_num) {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
200 array_task_num = w->task_num / spe_num;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
201 } else {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
202
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
203 int task_num = w->task_num;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
204
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
205 for (int j = 0; j < task_num; j++) {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
206 HTask *h_exec = 0;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
207 int i = w->task_spwaned++;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
208
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
209 if (w->size < size) size = w->size;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
210
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
211 h_exec = manager->create_task(TASK_EXEC,
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
212 (memaddr)(w->file_mmap + i*w->division_size), size,
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
213 (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
214
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
215 if (all) {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
216 w->t_print->wait_for(h_exec);
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
217 } else {
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
218 t_next->wait_for(h_exec);
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
219 }
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
220
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
221 h_exec->set_cpu(SPE_ANY);
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
222 h_exec->spawn();
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
223
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
224 w->size -= size;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
225 w->task_num--;
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
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
229 return;
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 970
diff changeset
230 }
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
231 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
232
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
233
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
234 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
235 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
236
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
237 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
238 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
239 t_exec[k] = 0;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
240 if (all) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
241 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
242 } else {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
243 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
244 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
245 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
246
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
247
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
248 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
249 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
250
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
251 int a = w->task_spwaned++;
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 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
254
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
255 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
256 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
257 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
258
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
259 w->size -= size;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
260 w->task_num--;
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 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
263
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
264 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
265 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
266 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
267 task_array[k]->spawn();
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
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
272 return;
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
273
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
274 }
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
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
277 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
278
1021
47ca99c5cf84 use MailManager
yutaka@localhost.localdomain
parents: 1007
diff changeset
279 HTask *h_exec = 0;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
280 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
281 int i = w->task_spwaned++;
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
282 if (w->size < size) size = w->size;
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
283 if (size==0) break;
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
284
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
285 if (use_compat) {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
286 h_exec = manager->create_task(TASK_EXEC);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
287 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
288 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
289
1021
47ca99c5cf84 use MailManager
yutaka@localhost.localdomain
parents: 1007
diff changeset
290
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
291 if (all) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
292 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
293 } else {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
294 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
295 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
296
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
297 h_exec->set_cpu(SPE_ANY);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
298 h_exec->spawn();
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
299
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
300 } else {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
301 h_exec = manager->create_task(TASK_EXEC,
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
302 (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
303 (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
304
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
305 if (all) {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
306 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
307 } else {
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
308 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
309 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
310
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
311 h_exec->set_cpu(SPE_ANY);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
312 h_exec->spawn();
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
313 }
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
314 w->size -= size;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
315 w->task_num--;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
316 }
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
317
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
318 }
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 968
diff changeset
319
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
320 }
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
321
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
322 /**
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
323 * このTaskは、PPE上で実行されるので、並列に実行されることはない
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
324 * 二つ実行されていて、Task が足りなくなることがないようにしている。
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
325 */
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
326
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
327 SchedDefineTask1(RUN_TASK_BLOCKS,run16);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
328
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
329 static int
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
330 run16(SchedTask *manager, void *in, void *out)
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
331 {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
332 WordCount *w = *(WordCount **)in;
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 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
335 // last case
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
336 if (w->size >= w->division_size)
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
337 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
338 // remaining data
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
339 while (w->size>0)
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
340 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
341 // 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
342 } else {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
343 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
344 (memaddr)&w->self,sizeof(memaddr),0,0);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
345 w->t_print->wait_for(t_next);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
346
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
347 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
348
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
349 t_next->spawn();
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
350 // 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
351 }
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
352 return 0;
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
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 static int blocks = 48;
1123
2a63ba2c9506 bug fix.
yutaka@localhost.localdomain
parents: 1083
diff changeset
357 //static int blocks = 31 * 6 * 24;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
358 static int division = 16; // in Kbyte
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
359
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
360 static void
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
361 run_start(TaskManager *manager, char *filename)
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
362 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
363 HTaskPtr t_print;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
364
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
365 st_mmap_t st_mmap;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
366 st_mmap = my_mmap(filename);
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
367 WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount));
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
368 // bzero(w,sizeof(WordCount));
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
369
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
370 w->self = w;
968
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
371 //w->task_blocks = blocks;
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
372 w->task_spwaned = 0;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
373
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
374 /*sizeはdivision_sizeの倍数にしている。*/
949
5f0135ca75ee word count size fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 948
diff changeset
375 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
376 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
377 printf("w %lx\n",(long)w);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
378
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
379 /* 1task分のデータサイズ(byte) */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
380 if (w->size >= 1024*division) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
381 w->division_size = 1024 * division;/*16kbyte*/
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
382 } else {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
383 w->division_size = w->size;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
384 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
385
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
386 printf("dvision_size %d\n",w->division_size);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
387
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
388 /* "word num" and "line num" */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
389 w->status_num = 2;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
390 /* taskの数 */
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
391 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
392 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
393 int out_task_num = w->task_num;
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
394
968
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
395 if(!all) {
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
396 w->task_blocks = blocks;
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
397 } else {
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
398 w->task_blocks = w->task_num;
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
399 }
122b1fddfa94 fix wordcount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 967
diff changeset
400
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
401 w->out_task_num = out_task_num;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
402 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
403 printf("out_task_num %d\n",w->out_task_num);
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
404
1007
00c01f416e3a add mail_queue
yutaka@localhost.localdomain
parents: 972
diff changeset
405 /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
406
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
407 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
408 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
409 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
410 w->out_size = 4;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
411 printf("out size %d\n",out_size);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
412
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
413 /*各SPEの結果を合計して出力するタスク*/
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
414
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
415 t_print = manager->create_task(TASK_PRINT,
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
416 (memaddr)&w->self,sizeof(memaddr),0,0);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
417
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
418 w->t_print = t_print;
783
76781837ff3a wordcount fix?
yutaka@localhost.localdomain
parents: 743
diff changeset
419
1123
2a63ba2c9506 bug fix.
yutaka@localhost.localdomain
parents: 1083
diff changeset
420 for(int i = 0;i<20;i++) {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
421 /* Task を task_blocks ずつ起動する Task */
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
422 /* serialize されていると仮定する... */
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
423 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
424 (memaddr)&w->self,sizeof(memaddr),0,0);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
425 t_print->wait_for(t_exec);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
426 t_exec->spawn();
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
427 }
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
428
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
429 t_print->spawn();
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
430 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
431
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
432 static char*
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
433 init(int argc, char **argv)
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
434 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
435
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
436 char *filename = 0;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
437
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
438 for (int i = 1; argv[i]; ++i) {
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
439 if (strcmp(argv[i], "-file") == 0) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
440 filename = argv[i+1];
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
441 } else if (strcmp(argv[i], "-division") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
442 division = atoi(argv[i+1]);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
443 } else if (strcmp(argv[i], "-block") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
444 blocks = atoi(argv[i+1]);
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
445 } else if (strcmp(argv[i], "-a") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
446 // create task all at once
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
447 all = 1;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
448 } else if (strcmp(argv[i], "-c") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
449 use_task_array = 0;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
450 use_compat = 1;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
451 } else if (strcmp(argv[i], "-s") == 0) {
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
452 use_task_array = 0;
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
453 use_compat = 0;
1039
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
454 } else if (strcmp(argv[i], "-t") == 0) {
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
455 use_task_creater = 1;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
456 use_task_array = 0;
e8ef7f5f22f6 add TaskCreater test funciton..
yutaka@localhost.localdomain
parents: 1021
diff changeset
457 use_compat = 0;
967
daab1b74b32d add anum option in WordCount
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 950
diff changeset
458 } 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
459 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
460 } 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
461 spe_num = atoi(argv[i+1]);
1083
54cf940e124a minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1039
diff changeset
462 if (spe_num==0) spe_num = 1;
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
463 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
464 }
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
465 if (filename==0) {
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
466 puts(usr_help_str);
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
467 exit(1);
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
468 }
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
469
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
470 return filename;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
471 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
472
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
473
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
474 int
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
475 TMmain(TaskManager *manager, int argc, char *argv[])
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
476 {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
477
394
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
478 char *filename = 0;
bc2012726a51 debug word_count
e065725@localhost.localdomain
parents: 393
diff changeset
479 filename = init(argc, argv);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
480
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
481 if (filename < 0) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
482 return -1;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
483 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
484
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
485 task_init();
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 394
diff changeset
486 run_start(manager, filename);
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
487
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
488 return 0;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
489 }
946
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
490
852ed17d8af1 unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 797
diff changeset
491 /* end */