annotate paper/cerium.tex @ 15:5bdd06f52b61

add expriment Data
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Mon, 21 Apr 2014 21:15:36 +0900
parents 6f6f482b9f12
children d354ebd64148
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 \section{Cerium TaskManager}\label{section:cerium}
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
3 Cerium Task Manager は並列プログラミングフレームワークであり、内部では C や C++ で実装されている。
15
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
4 Cerium Task Manager は、User が並列処理を Task 単位で記述し、関数やサブルーチンを Task として扱い、その Task に対して Input Data、Output Data を設定する。
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
5 Input Data、Output Data とは関数でいう引数に相当する。そして Task が複数存在する場合、それらに依存関係を設定することができる。
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
6 そして、それに基づいた設定の元で Task Manager にて管理し実行される。
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
7 Cerium Task Manager は PlayStation 3/Cell、Mac OS X 及び Linux 上で利用することが可能である。
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
8
24384cb335cf add PDF file
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
9 図\ref{fig:cerium} は Cerium が Task を作成・実行する場合のクラスの構成となる。User が createtask を行い、input data や Task の依存関係の設定を行うと、TaskManager で Task が生成される。
24384cb335cf add PDF file
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
10 Task 毎に依存関係を表す wait\_i と wait\_me というリストがあり、依存関係が解消されて実行可能になった Task は ActiveTaskList に移される。さらに、Scheduler に転送する際には TaskList に変換を行ってから各 Scheduler に転送される。
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
11
3
05a0e70f5823 add some image files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
12 \begin{figure}[htbp]
05a0e70f5823 add some image files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
13 \begin{center}
8
24384cb335cf add PDF file
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
14 \includegraphics[scale=0.3]{images/ceriumtaskmanager.pdf}
3
05a0e70f5823 add some image files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
15 \end{center}
8
24384cb335cf add PDF file
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
16 \caption{Cerium Task Manager}
3
05a0e70f5823 add some image files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
17 \label{fig:cerium}
05a0e70f5823 add some image files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
18 \end{figure}
05a0e70f5823 add some image files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
19
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
20 \newpage
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
21
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
22 \subsection{Cerium Task Manager を使った例題}
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
23 今回計測に使用した例題 WordCount を例にとり、以下に Task の生成部分を以下に示す。
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
24 このプログラムは、WordCount Task と Print Task の2種類の Task から構成される。
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
25
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
26 input data とは、mmap や read で読み込んだファイルであり、このファイルを $ n $ KByte の大きさに分割して、WordCount Task にそれぞれ割り当てる。
9
91662ffcaf0b finish??
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
27
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
28 WordCount Task は、input された data の単語数と行数をカウントし、それらを output に指定された data 領域に書きこむ。
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
29
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
30 以下に WordCount の Task 生成部分を示す。
9
91662ffcaf0b finish??
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
31
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 \begin{verbatim}
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
33 exec = manager->create_task(TASK_EXEC);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
34 exec->set_inData(0,
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
35 file_mmap + i*division_size,
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
36 size);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
37 exec->set_outData(0,o_data + i*out_size,
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
38 division_out_size);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
39
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
40 exec->set_cpu(spe_cpu);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
41 exec->spawn();
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
42 i++;
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 \end{verbatim}
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 \begin{tiny}
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 \begin{table}[ht]
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 \begin{center}
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 \label{table:create_taskAPI}
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 \small
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 \begin{tabular}[t]{c|l}
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 \hline
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
52 create\_task& Task を生成する \\
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
53 \hline
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
54 set\_inData & Task に入力データのアドレスを追加 \\
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
55 \hline
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
56 set\_outData & Task に出力データのアドレスを追加 \\
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 \hline
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
58 set\_cpu & Task を実行するデバイスの設定 \\
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
59 \hline
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
60 spawn & 生成した Task を TaskList に set \\
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 \hline
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
62 \end{tabular}
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
63 \caption{Task 生成における API}
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
64 \end{center}
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
65 \end{table}
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
66 \end{tiny}
15
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
67 set\_inData には、WordCount Task が担当するテキストの範囲を設定し、set\_outData にはその範囲の単語数や行数、範囲の先頭と末尾の状態を表すフラグを配列として格納してる。
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
68 input data は分割されたデータが送られてくるため、分割された前後のテキストがどうなっているかはわからない。
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
69 そのため、担当範囲であるデータの先頭と末尾のパラメータを単語数と行数の他に付け加える。後にそのデータを他の WordCount の結果と照らし合わせ、分割されたテキストを正しく整合する。
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
70
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
71 Task の記述は以下のようになる。
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
72 \\
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
73
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
74 \begin{verbatim}
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
75 wordcount(SchedTask *s, void *rbuf, void *wbuf)
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
76 {
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
77 char *i_data = (char *)s->get_input(0);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
78 unsigned long long *o_data =
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
79 (unsigned long long *)s->get_output(0);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
80 unsigned long long *head_tail_flag =
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
81 o_data + 2;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
82 int length = (int)s->get_inputSize(0);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
83
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
84 head_tail_flag[0] =
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
85 (i_data[0] != 0x20) &&
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
86 (i_data[0] != 0x0A);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
87
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
88 word_num -= 1-head_tail_flag[0];
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
89
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
90 for (; i < length; i++) {
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
91 if (i_data[i] == 0x20) {
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
92 word_flag = 1;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
93 } else if (i_data[i] == 0x0A) {
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
94 line_num += 1;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
95 word_flag = 1;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
96 } else {
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
97 word_num += word_flag;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
98 word_flag = 0;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
99 }
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
100 }
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
101
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
102 word_num += word_flag;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
103 head_tail_flag[1] =
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
104 (i_data[i-1] != 0x20) &&
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
105 (i_data[i-1] != 0x0A);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
106
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
107 o_data[0] = (unsigned long long)word_num;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
108 o_data[1] = (unsigned long long)line_num;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
109
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
110 return 0;
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
111 }
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
112 \end{verbatim}
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
113
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
114 \begin{tiny}
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
115 \begin{table}[ht]
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
116 \begin{center}
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
117 \label{table:taskAPI}
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
118 \small
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
119 \begin{tabular}[t]{c|l}
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 \hline
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
121 get\_input & Scheduler から input data を取得 \\
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 \hline
1
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
123 get\_output & Scheduler から output data を取得 \\
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
124 \hline
7264fa1d8f69 write chapter2
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
125 get\_param & set\_param した値を取得 \\
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 \hline
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 \end{tabular}
9
91662ffcaf0b finish??
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
128 \caption{Task 側で使用する API}
0
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 \end{center}
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 \end{table}
2408ae0327d5 add paper's base
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 \end{tiny}
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
132
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
133 Print Task は WordCount Task によって書き出された単語数と行数を集計し、結果を出力する Task である。
15
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
134 WordCount Task が全て走り終わったあとに、Print Task が走るように依存関係を設定している。(図\ref{fig:wordcount})
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
135
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
136
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
137 \begin{figure}[htbp]
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
138 \begin{center}
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
139 \includegraphics[scale=0.4]{images/wordcount.pdf}
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
140 \end{center}
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
141 \caption{WordCount Model}
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
142 \label{fig:wordcount}
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
143 \end{figure}
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
144
15
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
145 \if0
12
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
146 単語数や行数、そして担当範囲の先頭と末尾の文字列の状態を配列としてデータを保持している。
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
147 その配列を Print Task にて処理を行い単語数、行数を集計する。
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
148
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
149 しかし、分割のされ方によっては、単語数がカウントされない場合がある。(((図が必要!!!)))
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
150
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
151
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
152 Print Task の記述は以下のようになる。
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
153
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
154 \begin{verbatim}
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
155 static int
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
156 run_print(SchedTask *s, void *rbuf, void *wbuf)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
157 {
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
158 WordCount *w = (WordCount*)s->get_input(0);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
159 unsigned long long *idata = w->o_data;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
160 long status_num = w->status_num;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
161 int out_task_num = w->out_task_num;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
162
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
163 unsigned long long word_data[2];
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
164
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
165 int flag_cal_sum = 0;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
166
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
167 for (int i = 0; i < out_task_num ; i++) {
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
168 word_data[0] += idata[i*w->out_size+0];
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
169 word_data[1] += idata[i*w->out_size+1];
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
170 unsigned long long *head_tail_flag =
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
171 &idata[i*w->out_size+2];
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
172 if((i!=out_task_num-1)&&
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
173 (head_tail_flag[1] == 1) &&
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
174 (head_tail_flag[4] == 0)) {
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
175 flag_cal_sum++;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
176 }
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
177 }
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
178
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
179 word_data[0] += flag_cal_sum;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
180
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
181 for (int i = status_num-1; i >=0; i--) {
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
182 s->printf("%llu ",word_data[i]);
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
183 }
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
184 return 0;
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
185 }
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
186 \end{verbatim}
15
5bdd06f52b61 add expriment Data
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents: 12
diff changeset
187 \fi