# HG changeset patch # User Tatsuki IHA # Date 1515478920 -32400 # Node ID 791013bd44294252751bf16985555111ad6540a1 # Parent 382cd93f2a60f03165b4106b2f588eaf494b36ca Update diff -r 382cd93f2a60 -r 791013bd4429 2017/2017_11_07/slide.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2017/2017_11_07/slide.md Tue Jan 09 15:22:00 2018 +0900 @@ -0,0 +1,98 @@ +title: Gears OS による並列処理 +author: Tatsuki IHA +profile: +lang: Japanese +code-engine: coderay + +## 研究目的 +- 当研究室では 処理の単位を Code Gear、 データの単位を Data Gear を用いて 信頼性が高い並列処理を行う Gears OS を開発している +- Gears OS では Task を Code Gear と実行するときに必要な Input Data Gear と出力するための Output Data Gear の組で表現される。 Input Data Gear/Output Data Gear によって依存関係が決定し、それにそって並列実行を行う. +- 信頼性の確保はモデルチェック、検証等を使用して行う。この信頼性のための計算は通常の計算とは別の階層のメタ計算として記述する。 +- また、 メタ計算は信頼性の他に CPU, GPU などの実行環境の切り替え, データ拡張等の柔軟性を提供する。 +- 本研究では、 Gears OS の並列処理機構の実装を行う。また、並列処理の検証をメタ計算として記述することで、 並列処理の信頼性を保証する。 + +## 今週 +- 前回の Executor interface の呼び出し側 +- primitive な型 を union Data に入れられるようにする + +## Executor interface の呼び出し +- 例: twice_stub +- buffer に gpu に送りたい Data を指定 + +``` c +__code twice_stub(struct Context* context) { +#ifdef USE_CUDAWorker + if (context->gpu) { + Array* inputArray = &context->data[context->idg]->Array; + Array* outputArray = &context->data[context->odg]->Array; + outputArray->array = inputArray->array; + + // setting buffer + CUDABuffer* buffer = &ALLOCATE(context, CUDABuffer)->CUDABuffer; + buffer->inputData = (union Data**)ALLOCATE_PTR_ARRAY(context, Array, 2); + buffer->inputData[0] = (union Data*)inputArray->array; + buffer->inputData[1] = (union Data*)inputArray; + buffer->outputData = NULL; + buffer->inputLen = 2; + buffer->outputLen = 0; + + Executor* executor = context->worker->worker->CUDAWorker.executor; + executor->executor->CUDAExecutor.buffer = buffer; + cudaLoadFunction(context, "c/examples/twice/CUDAtwice.ptx", "twice"); + Gearef(context, Executor)->executor = (union Data*)executor; + Gearef(context, Executor)->task = context; + Gearef(context, Executor)->next = context->next; + goto meta(context, executor->read); + } +#endif +``` + +## Cuda Executor の実装 +- いまは read->exec->write の順番で continuation する(パイプラインを実装するともちろん変わる) + +``` +__code readCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) { + struct CUDABuffer* buffer = executor->buffer; + ... + // TODO: Implements pipeline + // goto next(...); + goto meta(context, C_execCUDAExecutor); +} + +__code execCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) { + // Asynchronous launch kernel + task->num_exec = 1; + ...... + // TODO: Implements pipeline + // goto next(...); + goto meta(context, C_writeCUDAExecutor); +} + +__code writeCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) { + struct CUDABuffer* buffer = executor->buffer; + ... + goto next(...); +} +``` + +## primitive な型 を union Data のメンバーにする +- 今までは union Data の中には struct のみしか書けなかった +- なのでint 等をを使うときはわざわざ struct を定義してその中に int を メンバーを定義していた +- ちょっと不便なので, union Data の中に定義出来るようにしてみました + - int int だと error 吐くので, 一度 typedef を挟む必要がある +- perl script も変更 + - struct 前提だったので,,,, + +``` c +typedef int Int; +union Data { + struct Meta { + enum DataType type; + long size; + long len; + struct Queue* wait; // tasks waiting this dataGear + } Meta; + ... + Int Int; +}; // union Data end this is necessary for context generator +``` diff -r 382cd93f2a60 -r 791013bd4429 2017/2017_11_21/slide.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2017/2017_11_21/slide.md Tue Jan 09 15:22:00 2018 +0900 @@ -0,0 +1,151 @@ +title: Gears OS による並列処理 +author: Tatsuki IHA +profile: +lang: Japanese +code-engine: coderay + +## 河野研究室について +- 並列, 分散フレームワーク + - Cerium + - Alice +- OS + - Gears OS +- コンパイラ + - Continueation based C + - LLVM + - GCC +- TreeVNC +- 分散データベース + - ゲーム +- 検証、証明 +- カレー + - 配属後にカレーパーティー(B3が作る) + +## 河野研究室について(注意点) +- コードは書く +- ハリーズのカレーは激辛 + +## 研究目的 +- 当研究室では 処理の単位を Code Gear、 データの単位を Data Gear を用いて 信頼性が高い並列処理を行う Gears OS を開発している +- Gears OS では Task を Code Gear と実行するときに必要な Input Data Gear と出力するための Output Data Gear の組で表現される。 Input Data Gear/Output Data Gear によって依存関係が決定し、それにそって並列実行を行う. +- 信頼性の確保はモデルチェック、検証等を使用して行う。この信頼性のための計算は通常の計算とは別の階層のメタ計算として記述する。 +- また、 メタ計算は信頼性の他に CPU, GPU などの実行環境の切り替え, データ拡張等の柔軟性を提供する。 +- 本研究では、 Gears OS の並列処理機構の実装を行う。また、並列処理の検証をメタ計算として記述することで、 並列処理の信頼性を保証する。 + +## 今週 +- CAS のコードのインターフェース化 +- perl script の修正 + +## Atomic Interface +- oldData, new Data は引数 +- method は checkAndSet を持っている + +``` c +typedef struct Atomic{ + union Data* atomic; + union Data* oldData; + union Data* newData; + __code checkAndSet(Impl* atomic, Type* oldData, Type* newData, __code next(...), __code fail(...)); + __code next(...); + __code fail(...); +} Atomic; +``` + +## AtomicReference +- Atomic Interface の実装として AtomicReference を作った +- data は現在の状態 + +``` c +struct AtomicReference { + union Data* data; +} AtomicReference; +``` + +``` c +Atomic* createAtomicReference(struct Context* context, union Data* data) { + struct Atomic* atomic = new Atomic(); + struct AtomicReference* atomicReference = new AtomicReference(); + atomicReference->data = data; + atomic->atomic = AtomicReference; + atomic->checkAndSet = C_checkAndSetAtomicReference; + return atomic; +} + +__code checkAndSetAtomicReference(struct AtomicReference* atomic, union Data* oldData, union Data* newData, __code next(...), __code fail(...)) { + if (__sync_bool_compare_and_swap(&atomic->data, oldData, newData)) { + goto next(...); + } + goto fail(...); +} +``` + +## Synchronized Queue の修正 +- まだ途中 +- ↓ になれば嬉しい? + +``` c + __code clearSynchronizedQueue(struct SynchronizedQueue* queue, __code next(...)) { + struct Element* top = queue->top; + if (__sync_bool_compare_and_swap(&queue->top, top, NULL)) { + goto next(...); + } else { + goto meta(context, C_clearSynchronizedQueue); + } +} + +↓ + +__code clearSynchronizedQueue(struct SynchronizedQueue* queue, __code next(...)) { + struct Atomic* atomic = queue->top; + union Data* oldData = queue->top->data; + goto atomic->checkAndSet(oldData, NULL, next, clearSynchronizedQueue); +} +``` + +## perl script 修正 +- interface での goto がちょっとおかしかったので修正 + +## perl script 修正 +- 今までの変換 +- 引数の queue に queue->queue を入れてておかしい + +``` c +__code queueTest2(struct Queue* queue) { + Node* node = new Node(); + node->color = Black; + goto queue->put(node, queueTest3); +} + +↓ + +__code queueTest2(struct Queue* queue) { + Node* node = new Node(); + node->color = Black; + Gearef(context, Queue)->queue = queue->queue; + Gearef(context, Queue)->data = (union Data*)node; + Gearef(context, Queue)->next = C_queueTest3; + goto meta(context, queue->queue->Queue.put); +} +``` + +## perl script 修正 +- ちゃんと元の queue を受け取るように修正 + +``` c +__code queueTest2(struct Queue* queue) { + Node* node = new Node(); + node->color = Black; + goto queue->put(node, queueTest3); +} + +↓ + +__code queueTest2(struct Queue* queue) { + Node* node = new Node(); + node->color = Black; + Gearef(context, Queue)->queue = queue; + Gearef(context, Queue)->data = (union Data*)node; + Gearef(context, Queue)->next = C_queueTest3; + goto meta(context, queue->put); +} +``` diff -r 382cd93f2a60 -r 791013bd4429 2017/2017_11_28/slide.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2017/2017_11_28/slide.md Tue Jan 09 15:22:00 2018 +0900 @@ -0,0 +1,61 @@ +title: Gears OS による並列処理 +author: Tatsuki IHA +profile: +lang: Japanese +code-engine: coderay + +## 研究目的 +- 当研究室では 処理の単位を Code Gear、 データの単位を Data Gear を用いて 信頼性が高い並列処理を行う Gears OS を開発している +- Gears OS では Task を Code Gear と実行するときに必要な Input Data Gear と出力するための Output Data Gear の組で表現される。 Input Data Gear/Output Data Gear によって依存関係が決定し、それにそって並列実行を行う. +- 信頼性の確保はモデルチェック、検証等を使用して行う。この信頼性のための計算は通常の計算とは別の階層のメタ計算として記述する。 +- また、 メタ計算は信頼性の他に CPU, GPU などの実行環境の切り替え, データ拡張等の柔軟性を提供する。 +- 本研究では、 Gears OS の並列処理機構の実装を行う。また、並列処理の検証をメタ計算として記述することで、 並列処理の信頼性を保証する。 + +## 今週 +- SynchronizedQueue を cas inteface を使うように変更 +- 「線形時相論理を用いた Continuation based C プログラムの検証」論文よみ +- DPP のコード読み(memory, state_db) +- dalmoreの件 + +## SynchronizedQueue の書き換え +- CAS は atomic->checkAndSet を使うように変更 +- perl script を書き換えて,元々引数でしか goto interface->method が出来ない所を, local 変数にも出来るように対応しました + +``` cbc +__code putSynchronizedQueue(struct SynchronizedQueue* queue, union Data* data, __code next(...)) { + Element* element = new Element(); + element->data = data; + element->next = NULL; + Element* last = queue->last; + Element* nextElement = last->next; + if (last != queue->last) { + goto meta(context, C_putSynchronizedQueue); + } + if (nextElement == NULL) { + struct Atomic* atomic = queue->atomic; + goto atomic->checkAndSet(&last->next, nextElement, element, next(...), putSynchronizedQueue); + } else { + struct Atomic* atomic = queue->atomic; + goto atomic->checkAndSet(&queue->last, last, nextElement, putSynchronizedQueue, putSynchronizedQueue); + } +} + +__code takeSynchronizedQueue(struct SynchronizedQueue* queue, __code next(union Data* data, ...)) { + struct Element* top = queue->top; + struct Element* last = queue->last; + struct Element* nextElement = top->next; + if (top != queue->top) { + goto meta(context, C_takeSynchronizedQueue); + } + if (top == last) { + if (nextElement != NULL) { + struct Atomic* atomic = queue->atomic; + goto atomic->checkAndSet(&queue->last, last, nextElement, takeSynchronizedQueue, takeSynchronizedQueue); + } + } else { + struct Atomic* atomic = queue->atomic; + goto atomic->checkAndSet(&queue->top, top, nextElement, takeSynchronizedQueue1, takeSynchronizedQueue); + } + goto meta(context, C_takeSynchronizedQueue); +} +``` diff -r 382cd93f2a60 -r 791013bd4429 2017/2017_12_05/slide.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2017/2017_12_05/slide.md Tue Jan 09 15:22:00 2018 +0900 @@ -0,0 +1,17 @@ +title: Gears OS による並列処理 +author: Tatsuki IHA +profile: +lang: Japanese +code-engine: coderay + +## 研究目的 +- 当研究室では 処理の単位を Code Gear、 データの単位を Data Gear を用いて 信頼性が高い並列処理を行う Gears OS を開発している +- Gears OS では Task を Code Gear と実行するときに必要な Input Data Gear と出力するための Output Data Gear の組で表現される。 Input Data Gear/Output Data Gear によって依存関係が決定し、それにそって並列実行を行う. +- 信頼性の確保はモデルチェック、検証等を使用して行う。この信頼性のための計算は通常の計算とは別の階層のメタ計算として記述する。 +- また、 メタ計算は信頼性の他に CPU, GPU などの実行環境の切り替え, データ拡張等の柔軟性を提供する。 +- 本研究では、 Gears OS の並列処理機構の実装を行う。また、並列処理の検証をメタ計算として記述することで、 並列処理の信頼性を保証する。 + +## 今週 +- 修論のマインドマップ +- 細々としたGearsの修正 +- ie-docker のバグとり diff -r 382cd93f2a60 -r 791013bd4429 2017/2017_12_12/slide.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2017/2017_12_12/slide.md Tue Jan 09 15:22:00 2018 +0900 @@ -0,0 +1,26 @@ +title: Gears OS による並列処理 +author: Tatsuki IHA +profile: +lang: Japanese +code-engine: coderay + +## 研究目的 +- 当研究室では 処理の単位を Code Gear、 データの単位を Data Gear を用いて 信頼性が高い並列処理を行う Gears OS を開発している +- Gears OS では Task を Code Gear と実行するときに必要な Input Data Gear と出力するための Output Data Gear の組で表現される。 Input Data Gear/Output Data Gear によって依存関係が決定し、それにそって並列実行を行う. +- 信頼性の確保はモデルチェック、検証等を使用して行う。この信頼性のための計算は通常の計算とは別の階層のメタ計算として記述する。 +- また、 メタ計算は信頼性の他に CPU, GPU などの実行環境の切り替え, データ拡張等の柔軟性を提供する。 +- 本研究では、 Gears OS の並列処理機構の実装を行う。また、並列処理の検証をメタ計算として記述することで、 並列処理の信頼性を保証する。 + +## 今週 +- 12月8-11 東京行ってました(部屋探しとか) +- B3引き継ぎネタ考えてました + - Gears での WordCount + - 並列IO とか + - Gears でのモデルチェッカー + +## Gears でのモデルチェッカー +- 今のところはシングルスレッドで実行されるTask(Code Gear)の全組み合わせを実行できるようにする + - java path finder みたいな + +## WordCount +- 並列IOが必要 diff -r 382cd93f2a60 -r 791013bd4429 2017/2017_12_19/slide.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2017/2017_12_19/slide.md Tue Jan 09 15:22:00 2018 +0900 @@ -0,0 +1,51 @@ +title: Gears OS による並列処理 +author: Tatsuki IHA +profile: +lang: Japanese +code-engine: coderay + +## 研究目的 +- 当研究室では 処理の単位を Code Gear、 データの単位を Data Gear を用いて 信頼性が高い並列処理を行う Gears OS を開発している +- Gears OS では Task を Code Gear と実行するときに必要な Input Data Gear と出力するための Output Data Gear の組で表現される。 Input Data Gear/Output Data Gear によって依存関係が決定し、それにそって並列実行を行う. +- 信頼性の確保はモデルチェック、検証等を使用して行う。この信頼性のための計算は通常の計算とは別の階層のメタ計算として記述する。 +- また、 メタ計算は信頼性の他に CPU, GPU などの実行環境の切り替え, データ拡張等の柔軟性を提供する。 +- 本研究では、 Gears OS の並列処理機構の実装を行う。また、並列処理の検証をメタ計算として記述することで、 並列処理の信頼性を保証する。 + +## 今週 +- Gears のリファクタ + +## 基本的には +- interface を使用している所を書き換え + +``` c +taskManager->taskManager = (union Data*)task->taskManager; +taskManager->task = task; +taskManager->next = next; +goto meta(context, task->taskManager->spawn); + +↓ + +struct TaskManager* taskManager = task->taskManager; +goto taskManager->spawn(task, next(...)); +``` + +## だが +- 引っかからないパターンがある +- perl script では, ``create(\w+)\((.*)\)`` みたいに実装の create が何かしらの行にないと, interface の変換がうまくいかない +- なので, ちゃんと Interface file から引数情報を取る必要あり + +``` c +typedef struct TaskManager{ + union Data* taskManager; + struct Context* task; + struct Context** tasks; + __code spawn(Impl* taskManager, struct Context* task, __code next(...)); + __code spawnTasks(Impl* taskManagerImpl, struct Context** tasks, __code next1(...), struct TaskManager* taskManager); + __code setWaitTask(Impl* taskManagerImpl, struct Context* task, __code next(...)); + __code shutdown(Impl* taskManagerImpl, __code next(...), struct TaskManager* taskManager, struct Queue* queue); + __code incrementTaskCount(Impl* taskManagerImpl, __code next(...)); + __code decrementTaskCount(Impl* taskManagerImpl, __code next(...)); + __code next(...); + __code next1(...); +} TaskManager; +``` diff -r 382cd93f2a60 -r 791013bd4429 2017/2017_12_26/slide.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2017/2017_12_26/slide.md Tue Jan 09 15:22:00 2018 +0900 @@ -0,0 +1,42 @@ +title: Gears OS による並列処理 +author: Tatsuki IHA +profile: +lang: Japanese +code-engine: coderay + +## 研究目的 +- 当研究室では 処理の単位を Code Gear、 データの単位を Data Gear を用いて 信頼性が高い並列処理を行う Gears OS を開発している +- Gears OS では Task を Code Gear と実行するときに必要な Input Data Gear と出力するための Output Data Gear の組で表現される。 Input Data Gear/Output Data Gear によって依存関係が決定し、それにそって並列実行を行う. +- 信頼性の確保はモデルチェック、検証等を使用して行う。この信頼性のための計算は通常の計算とは別の階層のメタ計算として記述する。 +- また、 メタ計算は信頼性の他に CPU, GPU などの実行環境の切り替え, データ拡張等の柔軟性を提供する。 +- 本研究では、 Gears OS の並列処理機構の実装を行う。また、並列処理の検証をメタ計算として記述することで、 並列処理の信頼性を保証する。 + +## 今週 +- Gears のリファクタ +- interface file から引数の情報を取得する + +## CbC 側の修正 +- interface.cbc -> interface.h に rename +- Impl 側には使用している interface を記述する + - \#interface + +``` +#include "../context.h" +#include +#interface "Queue.h" + +Queue* createSingleLinkedQueue(struct Context* context) { + struct Queue* queue = new Queue(); + struct SingleLinkedQueue* singleLinkedQueue = new SingleLinkedQueue(); + queue->queue = (union Data*)singleLinkedQueue; + .... +``` + +## perl script の修正 +- 今まで createImpl から引数情報を取っていたところを #interface に変更 +- \#interface は compileには通らないので、 cのファイルとして書き出す際に削除する +- これでほとんどの goto meta を消せそう + - TaskManagerImpl からは消した + +## next +- そろそろ論文