annotate Slide/prosym.md @ 9:5790bdc1d515

add gears_structure
author tobaru
date Mon, 21 May 2018 17:18:19 +0900
parents f275411f458d
children d4e58a38aae7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
tobaru
parents:
diff changeset
1 title: Gears OS のモジュール化と並列 API
tobaru
parents:
diff changeset
2 author: Mitsuki Miyagi, Yu Tobaru, Shinji Kono
tobaru
parents:
diff changeset
3 profile: 琉球大学
tobaru
parents:
diff changeset
4 lang: Japanese
tobaru
parents:
diff changeset
5 code-engine: coderay
tobaru
parents:
diff changeset
6
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
7 % ## OS の信頼性
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
8 % - コンピュータの信頼性の基本はメモリなどの資源管理を行う OS である。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
9 % - OS は非決定的な実行を持つため、OS の信頼性を保証するには、証明を用いる方法とプログラムの可能な実行を全て数え上げるモデル検査を用いる必要がある。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
10 % - 従来のテストとデバッグではテスト仕切れない部分が残ってしまい、不十分。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
11 % - モデル検査は無限の状態でなくても巨大な状態を調べる事になり、状態を有限に制限したり、状態を抽象化したりする方法が用いられる。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
12 %
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
13 % ## OS の拡張性
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
14 % - 時代とともに進歩するハードウェア、サービスに対応するために OS 自体が拡張される必要がある。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
15 % - OS を検証する際にも、1度ではなくアプリケーションやサービス、デバイスが新しくなる毎に検証をやり直す必要がある。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
16 %
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
17 % ## OS の拡張性と信頼性の両立
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
18 % - OSの拡張性と信頼性の観点から、OS は信頼性と拡張性を両立させることが重要であるといえる。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
19 % - 本研究室では、OS の信頼性の保証と拡張性を実現することを目標に Gears OS を設計中である。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
20
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
21 ## Gears OS
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
22 - 現代のOS では拡張性と信頼性を両立させることが要求されている。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
23 - 時代と共にハードウェア、サービスが進歩していき、その度に OS を検証できる必要があるため、拡張性が必要。
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
24 - OS は非決定的な実行を持ち、従来の OS ではテストしきれない部分が残ってしまうため、信頼性が欠けてしまうので信頼性のある OS が必要。
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
25 - 本研究室では、拡張性と信頼性を実現することを目標に Gears OS の開発を行なっている。
0
tobaru
parents:
diff changeset
26
5
tobaru
parents: 4
diff changeset
27 % 欠けてしまうで終わってるので "それら"は 分かりづらい
tobaru
parents: 4
diff changeset
28 % 並列API 研究目的とAPIとの繋がりがない
tobaru
parents: 4
diff changeset
29 % モジュールとAPIの説明分ける
tobaru
parents: 4
diff changeset
30 % 拡張性と信頼性を実現する時に Interfaceと par goto 構文がなぜ必要なのかに繋げる話が必要
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
31 % APIと実装の分離が望ましい理由は?
5
tobaru
parents: 4
diff changeset
32
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
33 ## API と実装の分離
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
34 - Gears OS は Continuation based C(以下、CbC)によって記述されている。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
35 - CbC は Code Gear と Data Gear の単位でプログラムを記述していて、システムやアプリケーションを作る際に、この2つは柔軟に再利用する必要がある。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
36 - この時に、機能を接続する API と実装の分離が可能であることが望ましい。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
37
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
38 % 上と繋がってない
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
39 % なんでモジュールシステムが必要?
5
tobaru
parents: 4
diff changeset
40 % 形式化と言わない
tobaru
parents: 4
diff changeset
41 % 形式化 formalization
tobaru
parents: 4
diff changeset
42 % ここでいう形式化はInterfaceとは関係ない
tobaru
parents: 4
diff changeset
43 % interface は仕様とAPIの分離
tobaru
parents: 4
diff changeset
44 % 実装の分割 がInterface
tobaru
parents: 4
diff changeset
45 % まず、形式化が重要(仕様、実装、実行をlogicで記述)
tobaru
parents: 4
diff changeset
46 % その記述にAgdaを使う
tobaru
parents: 4
diff changeset
47
tobaru
parents: 4
diff changeset
48 % Interfaceはほとんどかかない
6
tobaru
parents: 5
diff changeset
49 % TaskScheduler の図も入れる Gears の構成のやつ
5
tobaru
parents: 4
diff changeset
50
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
51 ## Gears OS での形式化とInterfaceの導入
5
tobaru
parents: 4
diff changeset
52 - 形式化とは仕様、実装、実行を Logic で記述する事である。
tobaru
parents: 4
diff changeset
53 - Gears OS では、継続を使った関数型プログラムとして実装を記述する
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
54 - Logic としては、依存型関数言語である Agda を使う(外間の発表)
5
tobaru
parents: 4
diff changeset
55 - 証明とモデル検査を使って、信頼性を確保する
tobaru
parents: 4
diff changeset
56
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
57 ## Gears OS の Interface
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
58 - Code Gear と Deta Gear は Interface と呼ばれるまとまり(モジュール)で記述される。
5
tobaru
parents: 4
diff changeset
59 - Interface 作成時に Code Gear の集合を指定することにより複数の実装を持つことができる。
tobaru
parents: 4
diff changeset
60 - Interface は Data Gear で記述されて、Meta Deta Gear と呼ばれる。
tobaru
parents: 4
diff changeset
61 - Java などの Class に相当する。
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
62 % - Interface を外から呼び出すための Code Gear 群の型
5
tobaru
parents: 4
diff changeset
63 - Interface を呼び出す時に必要となる引数を全て格納する Data Gear
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
64 % - 実装に使う Code Gear の番号が含まれている。
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
65 % - Code Gear の番号を変更することによって異なる実装を実現できる
5
tobaru
parents: 4
diff changeset
66
tobaru
parents: 4
diff changeset
67 % Interface は実行時に実装を入れ替える事ができる
tobaru
parents: 4
diff changeset
68 % 呼び出すものはStack 上に積めない
tobaru
parents: 4
diff changeset
69 % Contextも集合
tobaru
parents: 4
diff changeset
70
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
71 ## 並列API
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
72 - Geas OS 信頼性を保証するために、モジュールシステムが必要である。
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
73 - 本研究では、モジュールシステムとその応用である並列APIについて考察する。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
74 - 並列APIは継続を基本とした関数型プログラミングと両立する必要があり、ここでは CbC の goto 文を拡張した par goto を導入する。
0
tobaru
parents:
diff changeset
75
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
76 ## スライドの流れ
5
tobaru
parents: 4
diff changeset
77 - Interface
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
78 - <font color="red">CbC</font>
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
79 - Gears OS における並列実行
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
80 - 比較
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
81 - 今後の課題
0
tobaru
parents:
diff changeset
82
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
83
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
84
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
85
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
86
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
87 ## CbC
5
tobaru
parents: 4
diff changeset
88 - ノーマルレベルとメタレベルの計算を1つの言語で表現できる言語として、本研究室で設計した CbC を用いる。
2
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
89 - ノーマルレベルの計算
5
tobaru
parents: 4
diff changeset
90 - コンピュータの計算はプログラミング言語で行われる。
2
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
91 - その部分をノーマルレベルの計算と呼ぶ。
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
92 - メタレベルの計算
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
93 - コードが実行される際の以下の部分が、メタレベルの計算という。
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
94 - 処理系の詳細や使用する資源
5
tobaru
parents: 4
diff changeset
95 - コードの仕様や型などの部分
tobaru
parents: 4
diff changeset
96
tobaru
parents: 4
diff changeset
97 % ノーマルレベルとメタレベルの違い
tobaru
parents: 4
diff changeset
98 % 以外 = メモリ
tobaru
parents: 4
diff changeset
99 % 定義されたものに従って形式的にプログラムが記述されるが、その実行の資源や環境がメタレベル
tobaru
parents: 4
diff changeset
100 % 実行するのはOSや資源
tobaru
parents: 4
diff changeset
101 % 実際にはプログラムで記述されていない部分(CPU,メモリの資源、並列処理、外界の影響) この4つ書く
tobaru
parents: 4
diff changeset
102 % CbC の特徴はメタもかける
tobaru
parents: 4
diff changeset
103 % OS での資源はCbCでかける
tobaru
parents: 4
diff changeset
104 % シミュレーションされた外界
tobaru
parents: 4
diff changeset
105 % シミュレーションされてない外界はOSとは違うのでCbCで書けない
tobaru
parents: 4
diff changeset
106 % ぱるすさんの図入れるMeta data Gear
tobaru
parents: 4
diff changeset
107
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
108 ## CbC
2
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
109 - CbC を用いることで、ノーマルレベルの計算の信頼性をメタレベルから保証できるようになる。
5
tobaru
parents: 4
diff changeset
110 - CbC を用いてCode Gear と Data Gear を導入する。
tobaru
parents: 4
diff changeset
111
2
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
112
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
113 % - 検証には 定理証明支援系である Agda を用いる。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
114 % - Gears の記述をモジュール化するために Interface を導入した。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
115 % - さらに並列処理の記述用に par goto 構文を導入する。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
116
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
117 % ## par goto の実行
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
118 % - 本論文では Interface と par goto の実装を記述し、評価を行なった。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
119 % - また、マルチ CPU と GPU 上での par goto 文の実行を確認した。
2
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
120
5
tobaru
parents: 4
diff changeset
121 % par goto には構文と実行の話がある
tobaru
parents: 4
diff changeset
122 % ストーリー的に早いのでここでは入れない
tobaru
parents: 4
diff changeset
123
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
124 ## CbC の構文
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
125 - CbC の Code Gear は __code という型を持つ関数として記述する。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
126 - 継続で次の Code Gear に遷移するので、戻り値は持たない。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
127 - 遷移は goto 文による継続で処理を行い、引数として入出力を行う。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
128 ```c
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
129 __code cg0(int a, int b) {
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
130 goto cg1(a+b);
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
131 }
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
132 __code cg1(int c) {
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
133 goto cg2(c);
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
134 }
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
135 ```
5
tobaru
parents: 4
diff changeset
136 - CbC の記述だけでは並列実行にならない
tobaru
parents: 4
diff changeset
137
tobaru
parents: 4
diff changeset
138 % 関数呼び出しで実装したい なのでpar つける
tobaru
parents: 4
diff changeset
139 % 意味: 戻り値がなく exitで呼び出す
tobaru
parents: 4
diff changeset
140 % par goto (並列実行を実装したい、形式化したい=Agdaの記述をしたい) 並列実行を形式化する
tobaru
parents: 4
diff changeset
141 % 本文のpar goto を削って載せる
tobaru
parents: 4
diff changeset
142 % なぜ par goto が必要か
tobaru
parents: 4
diff changeset
143 % context がこれの先に出てないとだめ
tobaru
parents: 4
diff changeset
144 % 形式化はどうするの?-> par goto を使う。
tobaru
parents: 4
diff changeset
145 % par goto を使えば並列実行されたGears の形式化ができる
tobaru
parents: 4
diff changeset
146
tobaru
parents: 4
diff changeset
147
tobaru
parents: 4
diff changeset
148
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
149 ## スライドの流れ
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
150 - CbC
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
151 - <font color="red">Gears OS における並列実行</font>
0
tobaru
parents:
diff changeset
152 - 比較
tobaru
parents:
diff changeset
153 - 今後の課題
tobaru
parents:
diff changeset
154
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
155
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
156 ## Gears における並列実行
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
157 - Gears OS ではメタ計算を柔軟に記述するためのプログラミングの単位として Code Gear と Data Gear を用いる。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
158 - それぞれにメタレベルの単位が存在し、Meta Data Gear と Meta Code Gear と呼ぶ。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
159 - メタレベルの計算は Perl スクリプトによって生成され、Code Gear で記述される。
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
160 <div style="text-align: center;">
8
f275411f458d fix size
tobaru
parents: 7
diff changeset
161 <img src="./image/meta_cg_dg.svg" alt="Meta Data Gear と Meta Code Gear" width="600">
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
162 </div>
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
163
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
164
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
165
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
166 % ## Interface
5
tobaru
parents: 4
diff changeset
167 % - この時、Code Gear と Deta Gear は Interface と呼ばれるまとまり(モジュール)で記述される。
tobaru
parents: 4
diff changeset
168 % - Interface 作成時に Code Gear の集合を指定することにより複数の実装を持つことができる。
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
169
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
170 ## Gears OS の構造
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
171 - Gears OS は以下の要素で構成されている
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
172 - Context
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
173 - TaskQueue
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
174 - TaskManager
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
175 - Worker
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
176
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
177 <div style="text-align: center;">
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
178 <img src="./image/gears_structure.png" alt="Gears OS の構造" width="400">
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
179 </div>
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
180
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
181
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
182 ## Context
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
183 - 1つのスレッド内で使われる Interface の Code Gear と Data Gear は Meta Data Gear に格納される。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
184 - この Meta Data Gear を Context と呼ぶ。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
185 - Context を複製して複数の CPU に割り当てることにより並列実行が可能になる。
5
tobaru
parents: 4
diff changeset
186 - Context は Task でもある。
tobaru
parents: 4
diff changeset
187 - Task は実行する Code Gear と Data Gear を全て持っている。
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
188
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
189 ## par goto
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
190 - Context の複製には par goto を用いる。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
191 - 他に、入力の同期、タスクスケジューラへの Context の登録が行われる。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
192
5
tobaru
parents: 4
diff changeset
193 % exit が説明不足
tobaru
parents: 4
diff changeset
194 % code gear の実行は他のシープに邪魔されない。
tobaru
parents: 4
diff changeset
195 % 並列実行時の書き換えは許してない
tobaru
parents: 4
diff changeset
196
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
197 ## 1つの Code Gear の実行は他の Code Gear に割り込まれない
5
tobaru
parents: 4
diff changeset
198 - 共有された Data Gear があった時に、それに対する変更はただ1つの Code Gear だけが許される
tobaru
parents: 4
diff changeset
199 - 読み込みは複数であってもいい
tobaru
parents: 4
diff changeset
200 - Agda 側で、並列実行を Code Gear の順次実行としてシミュレーションするため
tobaru
parents: 4
diff changeset
201 - このような実行になるように Gears OS の実装を行う
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
202
5
tobaru
parents: 4
diff changeset
203 % 複数走ったなかの成功したものをコミットするのがexit
tobaru
parents: 4
diff changeset
204
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
205 <div style="text-align: center;">
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
206 <img src="./image/gears_structure.png" alt="Gears OS の構造" width="400">
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
207 </div>
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
208
5
tobaru
parents: 4
diff changeset
209
tobaru
parents: 4
diff changeset
210
tobaru
parents: 4
diff changeset
211
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
212 ## __exit
5
tobaru
parents: 4
diff changeset
213 - 複数実行した時に、共有 Data Gear に書き込みを成功したかを確認する(commit)
tobaru
parents: 4
diff changeset
214 - par goto で生成された Task は __exit に継続することで終了する
tobaru
parents: 4
diff changeset
215 - GearsOS の Task は Output Data Gear を生成した時点で終了する
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
216 - そのため、par goto では直接 __exit に継続せず、Output Data Gear への書き出し処理に継続される。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
217 - Code Gear と Data Gear の依存関係をノーマルレベルで記述できるようになる。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
218 ```c
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
219 __code code1(Integer *integer1, Integer * integer2, Integer *output) {
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
220 par goto add(integer1, integer2, output, __exit);
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
221 goto code2();
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
222 }
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
223 ```
0
tobaru
parents:
diff changeset
224
9
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
225 ## Perl スクリプトによる Meta Data Gear の生成
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
226
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
227
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
228 % Task Manager
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
229 %
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
230
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
231 ```c
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
232 __code code1(struct Context *context, Integer *integer1, Integer *integer2, Integer *output) {
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
233 // create context
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
234 context->task = NEW(struct Context);
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
235 initContext(context->task);
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
236
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
237 // set task parameter
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
238 context->task->next = C_add;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
239 context->task->idgCount = 2;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
240 context->task->idg = context->task->dataNum;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
241 context->task->maxIdg = context->task->idg + 2;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
242 context->task->odg = context->task->maxIdg;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
243 context->task->maxOdg = context->task->odg + 1;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
244
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
245 // create Data Gear Queue
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
246 GET_META(integer1)->wait = createSynchronizedQueue(context);
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
247 GET_META(integer2)->wait = createSynchronizedQueue(context);
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
248 GET_META(integer3)->wait = createSynchronizedQueue(context);
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
249
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
250 // set Input Data Gear
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
251 context->task->data[context->task->idg+0] = (union Data*)integer1;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
252 context->task->data[context->task->idg+1] = (union Data*)integer2;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
253
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
254 // set Output Data Gear
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
255 context->task->data[context->task->odg+0] = (union Data*)integer3;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
256
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
257
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
258 // set TaskManager->spawns parameter
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
259 Gearef(context, TaskManager)->taskList = context->taskList;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
260 Gearef(context, TaskManager)->next1 = C_code2;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
261 goto parGotoMeta(context, C_code2);
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
262 }
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
263 ```
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
264 % // add taskList Element
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
265 % struct Element* element;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
266 % element = &ALLOCATE(context, Element)->Element;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
267 % element->data = (union Data*)context->task;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
268 % element->next = context->taskList;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
269 % context->taskList = element;
5790bdc1d515 add gears_structure
tobaru
parents: 8
diff changeset
270
5
tobaru
parents: 4
diff changeset
271 % 失敗した時はmeta compitation で処理する
tobaru
parents: 4
diff changeset
272
2
60405cc47b3a chapter1
tobaru
parents: 0
diff changeset
273
0
tobaru
parents:
diff changeset
274
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
275 % ## Interface
0
tobaru
parents:
diff changeset
276
tobaru
parents:
diff changeset
277
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
278 % ## Context
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
279
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
280 % ## 並列構文
0
tobaru
parents:
diff changeset
281
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
282 ## スライドの流れ
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
283 - CbC
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
284 - Gears OS における並列実行
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
285 - <font color="red">比較</font>
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
286 - 今後の課題
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
287
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
288 ## Gears OS の評価(目的)
5
tobaru
parents: 4
diff changeset
289 - 並列構文とそれを実現する Meta Compitation が十分に揃っているかを確認したい
tobaru
parents: 4
diff changeset
290 - 並列処理の台数効果を確認する
tobaru
parents: 4
diff changeset
291 - 既存の並列言語と比較して不要なオーバーヘッドがあるか調べたい
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
292
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
293 ## Gears OS の評価(環境)
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
294 - CPU、GPU環境で Gears OS の測定を行う。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
295 - 使用した環境は次のようになる。
4
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
296 - CPU 環境
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
297 - Model : Dell PowerEdgeR630
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
298 - Memory : 768GB
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
299 - CPU : 2 × 18-Core Intel Xeon 2.30GHz
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
300 - CPU 環境
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
301 - GPU : GeForce GTX 1070
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
302 - Cores : 1920
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
303 - ClockSpeed : 1683MHZ
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
304 - Memory Size : 8GB GDDR5
0
tobaru
parents:
diff changeset
305
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
306 ## Twice
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
307 - 評価には与えられた整数配列の全ての要素を2倍にする例題である Twice を使う。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
308 - Twice では 通信時間を考慮しなければ、CPU より コア数の多い GPU が有利となる。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
309 - 要素数2^27のデータに対する Twice の実行結果を示す。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
310 - CPU では2^27のデータを64個のデータに分割した。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
311 - kernel only は 通信速度を除いた速度である。
4
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
312
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
313 <table border="1" align='center' width='50%'>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
314 <tbody>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
315 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
316 <td style="text-align: center;">Processor</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
317 <td style="text-align: center;">Time(ms)</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
318 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
319 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
320 <td style="text-align: center;">1 CPU</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
321 <td style="text-align: right;">1181.215</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
322 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
323 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
324 <td style="text-align: center;">2 CPUs</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
325 <td style="text-align: right;">627.914</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
326 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
327 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
328 <td style="text-align: center;">4 CPUs</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
329 <td style="text-align: right;">324.059</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
330 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
331 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
332 <td style="text-align: center;">8 CPUs</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
333 <td style="text-align: right;">159.932</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
334 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
335 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
336 <td style="text-align: center;">16 CPUs</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
337 <td style="text-align: right;">85.518</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
338 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
339 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
340 <td style="text-align: center;">32 CPUs</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
341 <td style="text-align: right;">43.496</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
342 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
343 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
344 <td style="text-align: center;">GPU</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
345 <td style="text-align: right;">127.018</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
346 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
347 <tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
348 <td style="text-align: center;">GPU(kernel only)</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
349 <td style="text-align: right;">6.018</td>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
350 </tr>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
351 </tbody>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
352 </table>
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
353
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
354 ## 評価の考察
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
355 - コア数が上がるごとに、処理速度が上がっている。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
356 - GPUでの実行は 32CPU に比べて約7.2倍の速度向上が見られた。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
357 - 通信速度を含めると 16CPU より遅い。
0
tobaru
parents:
diff changeset
358
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
359 % なんでGo言語?
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
360 ## Go 言語との比較
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
361 - Go 言語でも Twice を用いた検証を行い、Gears OS との速度比較を行なった。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
362 - 1CPU と 32CPU では約4.33倍の速度向上が見られた。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
363 - CPU数による速度向上は、Gears OS の方が上だが、処理速度では Go言語の方が速い結果となった。
4
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
364 <div style="text-align: center;">
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
365 <img src="./image/vsgo.svg" alt="Goとの比較" width="500">
4
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
366 </div>
c456e4d68e1a add image file
tobaru
parents: 3
diff changeset
367
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
368
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
369 ## スライドの流れ
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
370 - CbC
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
371 - Gears OS における並列実行
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
372 - 比較
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
373 - <font color="red">今後の課題</font>
0
tobaru
parents:
diff changeset
374
7
dfa8973bfe10 add images
tobaru
parents: 6
diff changeset
375 ## 今後の課題
3
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
376 - Go 言語との比較から 1CPU での動作が遅いことがわかった。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
377 - par goto 文を使用することで、Contextを生成し、並列処理を行う。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
378 - しかし、Context はメモリ空間の確保や使用する全ての Code Gear Data Gear の設定をする必要があり、生成に時間がかかってしまう事が原因。
7f5c0330e711 add module API
tobaru
parents: 2
diff changeset
379 - 処理が軽い場合は Context を生成しないようなチューニングが必要である。