annotate paper/chapter2.tex @ 4:af22b3d1e5c3

about Cerium
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Tue, 13 Jan 2015 17:46:50 +0900
parents aae08d907517
children 786db8c94c6e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
aae08d907517 first commit
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 \chapter{Cerium}
4
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2 Cerium は、当初 Cell 用の Fine-Grain TaskManager として当研究室で開発された。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
3 本章では Cerium の実装について説明する。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
4
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
5 \section{Cerium の概要}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
6 Cerium は当初 Cell 用であったが、現在では Linux、 MaxOS X上で動作する。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
7 GPGPU の Data Parallel を含めて同じ形式で記述できる。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
8
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
9 CeriumはTaskManager、 SceneGraph、Rendering Engine の3つの要素から構成される。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
10 本研究では Cerium の TaskManager を汎用計算フレームワークとして改良を行う。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
11 これによりヘテロジニアス環境に対応したシステムやフレームワークに必要な API や機構について考察していく。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
12 \section{Cerium TaskManager}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
13 Cerium TaskManager では、処理の単位を Task としてプログラムを記述していく。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
14 関数やサブルーチンを Task として扱い、 Task 間の依存関係を考慮しながら実行される。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
15 Task を生成する際に、以下のような要素を設定することができる。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
16
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
17 \begin{itemize}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
18 \item input data
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
19 \item output data
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
20 \item parameter
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
21 \item cpu type
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
22 \item dependency
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
23 \end{itemize}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
24
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
25 input/output data, parameter は関数で言うところの引数に相当する。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
26 cpu type は Task が動作する Device を示し、 dependency は他の Task との依存関係を表す。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
27
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
28 \section{Cerium における Task}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
29 図:\ref{fig:taskmanager}は Cerium が Task を生成/実行する場合のクラスの構成図である。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
30 TaskManager で依存関係が解消され、実行可能になった Task は ActiveTaskList に移される。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
31 ActiveTaskList に移された Task は依存関係が存在しないのでどのような順番で実行されても良い。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
32 Task は転送を行いやすい TaskList に変換され、cpu type に対応した Scheduler に転送される。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
33 なお、転送はSynchronozed Queue である mail を通して行われる。
0
aae08d907517 first commit
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
aae08d907517 first commit
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
4
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
36 \begin{figure}[htpb]
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
37 \begin{center}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
38 \includegraphics[scale=0.7]{./images/createTask.pdf}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
39 \end{center}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
40 \caption{Task Manager}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
41 \label{fig:taskmanager}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
42 \end{figure}
0
aae08d907517 first commit
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
4
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
44 \section{Task の Scheduling}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
45 Scheduler に転送された Task はパイプラインで処理される(図:\ref{fig:scheduler})。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
46 Task が全て終了すると Scheduler から TaskManager に mail を通して通知される。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
47 通知に従い依存関係を解決した Task が再び TaskManager から Scheduler に転送される。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
48
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
49 \begin{figure}[htpb]
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
50 \begin{center}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
51 \includegraphics[scale=0.7]{./images/scheduler.pdf}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
52 \end{center}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
53 \caption{Scheduler}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
54 \label{fig:scheduler}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
55 \end{figure}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
56 \newpage
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
57 \section{Task 生成の例}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
58 ソースコード:\ref{src:createTask}に Task を生成する例題を示す。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
59 input data を2つ用意し、 input data の各要素同士を乗算し、
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
60 output に格納する multiply という例題である。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
61
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
62 \begin{lstlisting}[frame=lrbt,label=src:createTask,caption=Task の生成,numbers=left]
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
63 void
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
64 multiply_init(TaskManager *manager, float *i_data1, float *i_data2, float *o_data) {
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
65
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
66 // create task
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
67 HTask* multiply = manager->create_task(MULTIPLY_TASK);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
68 multiply->set_cpu(spe_cpu);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
69
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
70 // set indata
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
71 multiply->set_inData(0, i_data1, sizeof(float) * length);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
72 multiply->set_inData(1, i_data2, sizeof(float) * length);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
73
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
74 // set outdata
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
75 multiply->set_outData(0, o_data, sizeof(float) * length);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
76
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
77 // set parameter
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
78 multiply−>set_param(0,(long)length);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
79
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
80 // set device
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
81 multiply->set_cpu(SPE_ANY);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
82
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
83 // spawn task
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
84 multiply−>spawn();
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
85 }
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
86 \end{lstlisting}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
87
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
88 表:\ref{table:task_create_api}は Task 生成時に用いる API の一覧である。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
89 create された Task は各種パラメタを設定し、spawn/iterate することで TaskManager に登録される。
0
aae08d907517 first commit
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
4
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
91 \begin{tiny}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
92 \begin{table}[htpb]
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
93 \begin{center}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
94 \small
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
95 \begin{tabular}[htpb]{c|l}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
96 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
97 create\_task & Task を生成する \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
98 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
99 set\_inData & Task への入力データのアドレスを追加 \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
100 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
101 set\_outData & Task からの出力データのアドレスを追加 \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
102 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
103 set\_param & Task へ値を一つ渡す。ここではlengthを渡している \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
104 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
105 set\_cpu & Task を実行する Device の設定 \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
106 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
107 spawn & 生成した Task を ActiveTaskList に登録する \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
108 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
109 \end{tabular}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
110 \caption{Task 生成おける API}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
111 \label{table:task_create_api}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
112 \end{center}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
113 \end{table}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
114 \end{tiny}
0
aae08d907517 first commit
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
4
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
116 ソースコード:\ref{src:createTask}は Host 側で Task を生成しているプログラムである。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
117 Device 側で実行される Task (OpenCL、CUDA でいう kernel) の記述はソースコード:\ref{src:task}のようになる。
0
aae08d907517 first commit
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
4
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
119 \begin{lstlisting}[frame=lrbt,label=src:task,caption=Task,numbers=left]
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
120 static int
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
121 run(SchedTask *s) {
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
122 // get input
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
123 float *i_data1 = (float*)s->get_input(0);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
124 float *i_data2 = (float*)s->get_input(1);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
125 // get output
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
126 float *o_data = (float*)s->get_output(0);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
127 // get parameter
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
128 long length = (long)s->get_param(0);
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
129
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
130 // calculate
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
131 for (int i=0; i<length; i++) {
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
132 o_data[i] = i_data1[i] * i_data2[i];
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
133 }
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
134 return 0;
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
135 }
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
136 \end{lstlisting}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
137
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
138 表:\ref{table:task_api}は Task 側で使用する API である。
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
139
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
140 \begin{tiny}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
141 \begin{table}[htpb]
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
142 \begin{center}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
143 \small
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
144 \begin{tabular}[htpb]{c|l}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
145 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
146 get\_input & 入力データのアドレスを取得 \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
147 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
148 set\_inData & 出力先データのアドレスを取得 \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
149 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
150 set\_outData & パラメータを取得 \\
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
151 \hline
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
152 \end{tabular}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
153 \caption{Task 側で使用する API}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
154 \label{table:task_api}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
155 \end{center}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
156 \end{table}
af22b3d1e5c3 about Cerium
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
157 \end{tiny}