Download - Matlab distributed computing serverの使い方
![Page 1: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/1.jpg)
Matlab Distributed Computing Server(MDCS)の使い方
SIGPP #3
2015.3.10
増谷
![Page 2: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/2.jpg)
MATLAB Distributed Computing Server とは?
• MATLABのコンピュータクラスタ環境• http://jp.mathworks.com/products/distriben/• 以下の並列環境をサポート
• バッチジョブ• 並行処理• 大規模分散データ
•機能• ほごすべてのツールボックス、ブロックセットにアクセス可能• GPU対応機能を実行可能• MATLAB Compiler のアプリから並列実行可能(コンパイル可)• MATLABをサポートする、全てのHW、OSをサポート• 組み込みスケジューラの他にサードパーティスケジューラをサポート
![Page 3: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/3.jpg)
MDCSのメリット
• Matlabでの重いバッチ処理を素早く終わらせる• Matlabスクリプト(.mファイルのまま)をそのまま並列実行
• 並列化を意識したコンパイル済み実行コードを高速に実行
• GPU対応
• 複数ユーザ同時アクセス可能
• 既存のクラスタを利用できる• Windows HPC Serverなど• MDCS以外の追加コストは不要• ノードはクラウド上にあっても構わない
![Page 4: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/4.jpg)
MDCSの利用条件
• MDCSに処理を投げるクライアント• MATLAB/Simulinkから Parallel Computing
Toolbosを介してDCSを操作
• Matlab Compilerを利用した実行ファイルからDCSを操作
• MDCSクラスタ (Matlabワーカー)• ライセンスはサーバーライセンスのみ
• ノード側に別途ライセンスは必要ない
• ノード側にツールボックスやブロックセットのライセンスは必要ない(ジョブを投げるユーザ側のライセンスに依存)
MATLAB Distributed Computing Server ではすべてのMathWorksツール
ボックスやブロックセットのライセンスが提供されるため、クラスター内の各コンピューターに対して特定の製品のためのライセンスを追加購入しなくても、MATLAB プラグラムをクラスターで実行できます。
特殊なツールボックスはサポートしないhttp://jp.mathworks.com/products/ineligible_programs/
![Page 5: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/5.jpg)
実際の構成
• ヘッドノード• MDCSとライセンスサーバー、HPC Pack(ヘッドノード)をインストール
• ワーカー• MDCSとHPC Pack(ワーカー)をインストール
• クライアント• MatlabとPCTをインストール
• 参考• http://jp.mathworks.com/support/product/DM/installation/v
er_current/• http://jp.mathworks.com/help/mdce/install-product-and-
choose-cluster-configuration.html• http://jp.mathworks.com/help/mdce/configure-parallel-
computing-products-for-hpc-server.html
![Page 6: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/6.jpg)
導入時期
•試用版入手、試用 ~2月上旬
•購入決定 ~2月下旬
•購入 ~3月
•運用開始 3月~
![Page 7: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/7.jpg)
利用手順
•複数の利用法がある• Parallel for-loops
• Distributed Arrays
• Message-Passing Functions
![Page 8: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/8.jpg)
Parallel for-loops
•みんな大好きパラレルフォー(parfor)• パラメータスイープで簡単に並列化• 自動的に必要なデータとコードを識別• 自動的にワーカーの識別
•要件• ループ内は独立な処理でなければならない。• 通信はワーカー同士では行われない。• 右記ではAのみが結果として得られる。(他は完全独立)
• おまじない(matlabpool)• インタラクティブに利用する場合• バッチとして投げる場合はcreateMatlabPoolJob
初級編
![Page 9: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/9.jpg)
parfor
• Parforはforと全く同じではない• http://jp.mathworks.com/help/distcomp/parfor.html
• 外部から参照できる変数• スイープパラメータ (i)に影響を受ける変数
• コード1では Cだけが結果に影響
• 適切に選択された演算子で計算された変数• コード2ではsが正しく計算される
• 順番に依存しない演算
コード1parfor i = 1:n
t = f(A(i));u = g(B(i));C(i) = h(t, u);
end
コード2s = 0;parfor i = 1:n
if p(i) % assume p is a functions = s + 1;
endend
初級編
![Page 10: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/10.jpg)
Distributed Arrays と並列関数を使った大規模データの扱い
•複数のワーカーに分散したデータに対して分散して関数を実行できる
•分散配列(Distributed Arrays)• 以下のいずれかで生成可能
• Rands,onesなどのコンストラクタ• 各ワーカーの同じ名前の配列を結合• 大規模行列を分散
• 150の関数が分散配列をサポート• http://jp.mathworks.com/help/distcomp/
using-matlab-functions-on-codistributed-arrays.html
• ScaLAPACKを利用している
中級編
![Page 11: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/11.jpg)
自分で分散したい場合
• spmd (single program multiple data)• 明示的にデータの分割や処理を書ける
• 自分のアルゴリズムを適切に分割するために必要
• 分割方法• Codistribution1d : 1次元の分割
• 指定の次元で分割
• 指定の分割数で分割
中級編
![Page 12: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/12.jpg)
Message-Passing Functions
• もっと最適化したい場合• MPI-2準拠のワーカー間通信が可能
• 要件• 並列アルゴリズムのファインチューニングが可能
• 各並列セクションの同期を手動で実現する必要がある
• send, receive, broadcast, barrier, probe が可能
• 激しく難しい並列デバッグを簡単に• セットアップ不要(spmdだけ)• すべてのMATLABデータタイプが利用可能
• デッドロック検出
上級編
![Page 13: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/13.jpg)
ベンチマーク
• Parforならほぼリニア
• オーバーヘッドをなくすには大きなジョブを
![Page 14: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/14.jpg)
MDCS環境
• MDCSの利用環境
•混合プラットフォーム• 混合プラットフォームがサポートされているため、クライアント、MJS およびワーカーが同じプラットフォームにある必要はありません。
• Heterogeneous cluster• 異なるOSで構成されるクラスタ
• Parfor, spmd, 分散配列, mpiは使えない(!)
• 一部の関数のみ利用可能
![Page 15: Matlab distributed computing serverの使い方](https://reader034.vdocuments.pub/reader034/viewer/2022052602/55af03281a28ab0f468b4821/html5/thumbnails/15.jpg)
クラスタの他の利用方法
•様々な環境、言語から利用可能です
コード パラメータスイープ
データ分散 ワーカー間通信 GPGPU グループ化 スケジューラGUI クラウドノード
MDCS with スクリプト(.m) on MJS
Matlabスクリプト ○ (parfor) ○ ○(MPI) NVIDIA × × ―
MDCS with コンパイラ on MJS
mex ○ (parfor) ○ ○(MPI) NVIDIA × × ―
MDCS with スクリプト(.m) on HPC Server
Matlabスクリプト ○ (parfor) ○ ○(MPI) NVIDIA ○ ○ ○ (Azure)
MDCS with コンパイラ on HPC Server
mex ○ (parfor) ○ ○(MPI) NVIDIA ○ ○ ○ (Azure)
バッチ on HPC Server
exe, batなど ○ HPC Manager ― ― 個別 ○ ○ ○ (Azure)
MPI on HPC Server
C,C++, etc… ○ ― ○(MPI) 個別 ○ ○ ○ (Azure)
HPC SOA on HPC Server
C#, .NET ○ ― ○(SOA) 個別 ○ ○ ○ (Azure)