並列計算 並列実行による高速化ソリューション MathWorks Japan アプリケーションエンジニアリング部アプリケーションエンジニア吉田剛士 2012 The MathWorks, Inc. 1
アジェンダ MATLAB R2012b ハイライト PCT / MDCS 新機能ハイライト Simulink プロダクトの並列化 まとめ 2
MATLAB R2012b のハイライト 1 新しいデスクトップ 使用頻度の高い機能を整理 見つけやすく データのインポート テキストファイルの対話的入力 数値 テキスト 日付処理強化 3
MATLAB R2012b のハイライト 2 アプリケーション 各 Toolbox が提供する様々な GUI アプリを一覧 ( ギャラリー ) ユーザ作成 GUI アプリのパッケージ化 配布 インストールの簡単化 ヘルプの再設計 閲覧機能 検索機能 フィルター処理機能が向上 4
アジェンダ MATLAB R2012b ハイライト PCT / MDCS 新機能ハイライト Simulink プロダクトの並列化 まとめ Desktop Computer Parallel Computing Toolbox Computer Cluster MATLAB Distributed Computing Server Scheduler 5
Parallel Computing Toolbox & MATLAB Distributed Computing Server デスクトップ Parallel Computing Toolbox コンピュータクラスタ MATLAB Distributed Computing Server スケジューラ 6
R2012x の新機能 R2012a Parallel Configuration から Cluster Profile へ変更 GPU サポート関数の拡大 beta / bsxfun / det / inv / fftn / ifftn / R2012b GPU サポート関数の拡大 mpower / convn / var / cov / サポート製品の拡大 7
並列化対応製品一覧 Bioinformatics Toolbox Communication System Toolbox Embedded Coder Global Optimization Toolbox Image Processing Toolbox Model-Based Calibration Toolbox Neural Network Toolbox Optimization Toolbox Robust Control Toolbox Signal Processing Toolbox Simulink Coder Simulink Control Design Simulink Design Optimization Statistics Toolbox SystemTest 8
Web: 並列化対応製品 9
Neural Network Toolbox GPU computing support for training and simulations 学習プロセスの並列化 (CPU) の例 >> % 並列計算用プロセスの起動 >> matlabpool open >> >> % 学習の並列化 >> net2 = train(net1, x, t, 'useparallel', 'yes'); 学習プロセスの並列化 (GPU) の例 >> net2 = train(net1, x, t, 'usegpu', 'yes'); 10
Demo: 加速度データからの動作予測 Input (24 変数 ) - 左手 : 12 変数 x,y,z 方向の各加速度に対する 平均 分散 最大値 最小値 - 右手 : 12 変数 x,y,z 方向の各加速度に対する 平均 分散 最大値 最小値 秒 5 4 3 2 1 0 y f ( x, x2,, x 1 n 1 core 4 cores GPU Tesla C2050 ) Output - 読書 - キータイプ - マウス操作 - 文字筆記 - 静止 11
MATLAB における機械学習 Neural Network Support Vector Machine Input y f ( x, x2,, x 1 n ) Output Decision Tree 12
Statistics Toolbox : Computation of decision trees on multiple bootstrap replicates uses multi-processors TreeBagger class バギング (Bootstrap Aggregating) 法やランダム フォレスト法を扱うためのクラス ツリーの並列生成 >> % 並列計算用プロセスの起動 >> matlabpool open >> % 並列オプションの設定 >> opt = statset('useparallel', 'always'); >> % 決定木の並列化 >> b = TreeBagger(nTrees, X, Y, OOBVarImp, on, categorical, 6, 'minleaf', leaf, 'Options', opt); 13
Demo: アンケートからの性格分類 H A B G C F E D Input - 40 の設問からなるアンケート y f ( x, x2,, x 1 n ) Output - 8 つのグループ 学習時間の比較 秒 40 30 20 10 0 1 core 2 cores 4 cores 6 cores 14
アジェンダ MATLAB R2012b ハイライト PCT / MDCS 新機能ハイライト Simulink プロダクトの並列化 まとめ 15
Simulink Coder Parallel building for large model reference hierarchies パラレルビルドの準備 ビルドに対する MATLAB ワーカー初期化 - なし : ワーカー ( 計算プロセス ) に対して何もしない - ベースワークスペースへコピー : ベースワークスペースにある変数をワーカーに送信する - 最上位モデルの読み込み : モデル起動時に読み込まれる変数をワーカーに送信する 16
パラレルビルドのベンチマーク 環境 CPU: Intel Xeon W3690 @ 3.47GHz (6-cores) Memory: 24GB OS: Win7 SP1 Compiler: Microsoft Visual Studio 64-bit Edition MATLAB: R2012a ベンチマーク 総ブロック数 323,976 を有するモデルで計測 450 400 350 300 250 200 150 100 50 0 17
SLDV: Simulink Design Verifier テストケース自動生成 解析 プロパティ検証 要求仕様 設計エラー検出 検証仕様 入力と出力との間に矛盾が無いことを形式的手法に証明 ゼロ割やオーバーフローなどの検出 オーバーフロー可能性あり 反例となる入力ベクタを作成 18
例 : テストケース生成の並列実行 Parallel For-Loop による検証の並列化 >> ModelList = { sldvdemo_cruise_control ; 'sldvdemo_design_error_detection'}; >> opts = sldvoptions; >> opts.mode = TestGeneration ; % テストケース生成を選択 >> % 並列計算用プロセスの起動 >> matlabpool open 2 >> >> parfor n = 1:length(ModelList) end load_system(modellist{n}); sldvrun(bdroot, opts); % 検証の実行 TIPS sldvrun 実行の際は MATLAB プロセスと検証用プロセス dvoanalyzer.exe が起動するので matlabpool open 時にコア数の半分の値を指定するのが効果的 19
SLVV: Simulink Verification and Validation モデルカバレッジ測定 仕様とモデル間のトレーサビリティ設定 モデルアドバイザ ( モデルのスタイルチェック ) GUI からのモデルチェックの実行 指摘に従い修正 ( 自動修正も有 ) レポート生成 カスタムチェックの追加 TT,TF,FT 制御モデル モデルから仕様書へ 仕様書からモデルへ Word Excel DOORS MKS Integrity 任意 モデルカバレッジレポート Decision Condition MC/DC Word Excel DOORS MKS Integrity 任意 20
例 : モデルアドバイザの並列実行 >> matlabpool open % 並列計算用プロセスの起動 >> >> SysList = {'sldemo_auto_climatecontrol/heater Control',... >> 'sldemo_auto_climatecontrol/ac Control'}; >> [fail, warn] = run_configuration(syslist); function [fail, warn] = run_configuration(syslist) filename = 'slvnvdemo_mdladv_config.mat'; fail = 0; warn = 0; SysResultObjArray = ModelAdvisor.run(SysList, 'Configuration', filename); for n = 1:length(SysResultObjArray) fail = fail + SysResultObjArray{n}.numFail; warn = warn + SysResultObjArray{n}.numWarn; end 21
アジェンダ MATLAB R2012b ハイライト PCT / MDCS 新機能ハイライト Simulink プロダクトの並列化 まとめ 22
まとめ 新しいリリースとともに Parallel Computing Toolbox および MATLAB Distributed Computing Server との連携製品が拡大 Simulink 関連製品 特にコード生成や検証系の製品との親和性が高い Desktop Computer Parallel Computing Toolbox Computer Cluster MATLAB Distributed Computing Server Scheduler 23
MATLAB Production Server Computer Cluster Web Browser MATLAB Production Server End User License Manager MATLAB Toolboxes MATLAB Compiler Shared Directory 特徴 MCR ( ランタイム ) をサーバで一元管理 クラスタ環境をサポート 24
アプリケーション配布のフロー 1 Toolboxes MATLAB デスクトップ 3 End User 2 MATLAB Compiler 4.exe MATLAB Compiler 25