60
Software & Services Group, Developer Products Division Copyright © 2009, Intel Corporation. All rights reserved. *Other brands and names are the property of their respective owners. 並列化のロードマップ: 今後のインテルソフトウェア開発製品について 池井 満 ソフトウェア&サービス統括本部部長 インテル株式会社

Parallel Technology

Embed Size (px)

DESCRIPTION

今後ますます必要とされるソフトウェアの並列化について、さまざまなソフトウェア開発製品や技術を提供してきたインテルが、今年リリース予定の新しいテクノロジーについてご紹介します。

Citation preview

Page 1: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

並列化のロードマップ: 今後のインテルソフトウェア開発製品について

池井 満 ソフトウェア&サービス統括本部部長 インテル株式会社

Page 2: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Legal Disclaimer

INFORMATION IN THIS DOCUMENT IS PROVIDED “AS IS”. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO THIS INFORMATION INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. Performance tests and ratings are measured using specific computer systems and/or components and reflect the approximate performance of Intel products as measured by those tests. Any difference in system hardware or software design or configuration may affect actual performance. Buyers should consult other sources of information to evaluate the performance of systems or components they are considering purchasing. For more information on performance tests and on the performance of Intel products, reference www.intel.com/software/products. Intel, Intel Core and the Intel logo are trademarks of Intel Corporation in the U.S. and other countries. *Other names and brands may be claimed as the property of others. Copyright © 2009. Intel Corporation.

http://intel.com/software/products

2

Page 3: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

マルチコアとメニーコア

M i s c I O

M i s c I O

Q P I 1

Q P I 0

Memory Controller

コア コア コア コア Q u e u e

Shared L3 Cache

インテル® Core™ i7 プロセッサー

Larrabee✝

✝開発コード名

Page 4: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

ほとんどのプロセッサーが 並列プロセッサー

Page 5: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners. September 18, 2007 Copyright © 2007, RapidMind, Inc.

ソフトウェア開発部門へのインパクト

マルチコアのプロセッサは膨大な性能向上を提供できる

マルチコアに対応していないアプリケーションは新しいプロセッサが登場しても速くならない。実際は遅くなるかもしれない!

• マルチスレッド化は難しく、時間がかかり、バグを作りやすい

• マルチスレッド化しただけではコア数に応じて性能が向上するアプリケーションは得られない

• マルチスレッド化ではシングルコアで利用可能な並列性を利用できない

• 現在のマルチコア用の方法ではアクセラレータには適用できない

• 各バーティカルのアプリケーションはそれぞれデータマネージメントやプロセッサ特有の開発に固有のチャレンジがある

Page 6: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

スケーラビリティー

パフォーマンス “スケーリング”

1 2 4 8 1X

2X

4X

8X

Page 7: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

主要な 5 つの並列化手法 いずれの手法を導入するか?

•メッセージ・パッシング – MPI、PVM

•明示的なスレディング – Windows スレッド API、Pthreads、Solaris スレッド、

Java スレッド・クラス

•コンパイラーのサポートと言語の拡張 –自動並列化、OpenMP、インテル・スレッディング・ビルディング・ブロック

•並列プログラミング言語 – HPF、CAF、UPC、CxC、Cilk

•並列マス・ライブラリー – ScaLAPACK、PARDISO、PLAPACK、PETsc

2009/12/5

Page 8: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテルの HPC ツール

インテル® コンパイラー 11.1 日本語版をリリースしました

Page 9: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® Parallel Studio

• Windows* クライアント・アプリケーション開発者の 並列化プログラミングをサポート

Page 10: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

細分化: 目的に応じた 2 つの製品ライン

2009 年 5 月

並列による生産性を最大限に引き出す製品 Windows* の Visual Studio* を使用する C++

販売中 継続的に投資...

並列パフォーマンスを最大限に引き出す製品 Windows*/Linux*/Mac OS* X の C++ および Fortran

Page 11: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® スレッディング・ビルディング・ ブロック (インテル® TBB)

•並列化向けに C++ を拡張 • 複数の箇所で C++ の課題を解決

• あらゆる C++ コンパイラー、プロセッサー、OS に移植可能。 すでに幅広い移植実績有り!

•インテルが開始したオープン・ソース・プロジェクト

•インテル® Parallel Studio でフルサポート

Page 12: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

ツールが行うべき 支援

•シリアルプログラムの開発向けに設計された古いツールの 使用では不十分

•新しいツールの利点:

• 並列化における 2 つの主要な課題 を支援: 正当性とスケーラビリティ

• 適切な抽象化を提供: 保守性、“将来への保証”

Page 13: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

並列化を行うための開発ライフサイクル

設計

並列化の恩恵が得られる既存の

ソースコード部分を特定

コーディング & デバッグ

C/C++ コンパイラーと包括的な

スレッド化ライブラリーで効率的な

アプリケーションを開発

検証

並列メモリーエラーとスレッド化

エラーを未然に防ぐ検証機能で

アプリケーションの信頼性を確保

チューニング

直感的なパフォーマンス・アナライザーとチューナーでアプリケーションを向上

Find where to start parallelizing

Introduce threads, compile, and debug with the Intel® Parallel Composer

Find threading and memory errors with the Intel® Parallel Inspector

Tune with the Intel® Parallel Amplifier

Page 14: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® Parallel Studio は次の 3 製品で構成されています。

• インテル® Parallel Composer

• インテル® Parallel Inspector

• インテル® Parallel Amplifier

インテル® Parallel Studio マルチコア並列化の直感的な開発ツール

Microsoft* Visual Studio* を使用して、Windows* 用の並列アプリケーションを作成する C++ アーキテクト、デベロッパー、ソフトウェア・イノベーター向け

• Microsoft* Visual Studio* プラグイン • 並列化向けエンドツーエンド製品スイート • 将来のメニーコア向けにスケーリング

Page 15: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® Parallel Composer

• コーディング& デバッグフェーズ

• 面倒な作業は尐なく、より良いスケーリングで Windows* アプリケーションへすぐに並列化を実装!

• 高度に最適化され、自動並列化機能を 実装したC/C++ コンパイラー

• OpenMP* サポート • インテル® スレッディング・ビルディング・ブロック (インテル® TBB)

• インテル® インテグレーテッド・ パフォーマンス・プリミティブ (インテル® IPP)

• 並列デバッガーを実装

• 開発時間を短縮し生産性を向上

C/C++ コンパイラーと包括的なスレッド化ライブラリーで効率的な

アプリケーションを開発

Find where to start parallelizing

Introduce threads, compile, and debug with the Intel® Parallel Composer

Find threading and memory errors with the Intel® Parallel Inspector

Tune with the Intel® Parallel Amplifier

Page 16: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® Parallel Composer OpenMPに対するKeyWord の拡張

__taskcomplete {

__task f_sum(500, a, b, c); __task f_sum(500, a+500, b+500, c+500); }

void f_sum ( int length, int *a, int *b, int *c ) {

int i;

__par for (i=0; i<length; i++) {

c[i] = a[i] + b[i]; } }

OpenMP 3.0 のtask 機能を簡易表記で利用することが可能

データ並列

アルゴリズムに利用

2009/12/5

Page 17: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® Parallel Inspector

• 検証フェーズ

• スレッド化特有のエラーを素早く検出

• メモリーエラーを点検

• 標準的なデバッグビルドで動作

• コードを素早く分析

• Windows* アプリケーションの信頼性を確認するのに役立ちます

• アプリケーションを事前にテストし

十分にエラーチェックを行うことで、製品の品質向上に役立ちます

並列メモリーエラーとスレッド化エラーを未然に防止

Find where to start parallelizing

Introduce threads, compile, and debug with the Intel® Parallel Composer

Find threading and memory errors with the Intel® Parallel Inspector

Tune with the Intel® Parallel Amplifier

Page 18: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® Parallel Inspector スレッド化エラーを特定

スレッド化特有のエラーの位置と状態を表示

コード行を素早く参照

Page 19: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

17

インテル® Parallel Inspector メモリーエラーの特定

観測結果を特定の

コードに縮小

メモリーリークの位置や

サイズを特定

観測結果により

問題を特定

Page 20: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® Parallel Amplifier

• チューニング・フェーズ • ボトルネックを素早く検知

• アプリケーションのパフォーマンスをチューニング

• アプリケーションのパフォーマンスを最適化

• スケーリングのためのチューニング • 並列化アプリケーションのための設計

• ホットスポット分析

• コンカレンシー分析

• ロック/待機分析

– フレキシブルに分析 • ソースコードを参照

• 統計コールツリー

• 複数の分析を比較

直感的なパフォーマンス・アナライザーとチューナー

Find where to start parallelizing

Introduce threads, compile, and debug with the Intel® Parallel Composer

Find threading and memory errors with the Intel® Parallel Inspector

Tune with the Intel® Parallel Amplifier

Page 21: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® Parallel Amplifier hotspot 分析によるボトルネックの検出

どうしてそうなっているのか? クリティカル・ファンクションの使用を 削減できそうな場所をコールスタックで

ハイライトします

アプリケーションで時間がかかっている場所は? パフォーマンスに最もインパクトのある

クリティカル・ファンクションを素早く見つけます

Page 22: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

並列化の事前検証機能

Find where to start parallelizing

Introduce threads, compile, and debug with the Intel® Parallel Composer

Find threading and memory errors with the Intel® Parallel Inspector

Tune with the Intel® Parallel Amplifier

• “Think Parallel” をお手伝い

• 並列化には魔法のようなソリューションがあるわけではありません

• しかし、さまざまな役立つ方法があります

• 「役立つ方法」のリストは毎日増え続けていて、お客様からのフィードバックをもとに強化されています

• Parallel Studio リリース時に、 Parallel Studio ユーザー限定で 初回バージョンを公開予定です Parallel Studio を拡張!

• 並列化の概念は、実行前に、安全に モデル化し、測定し、テストします

次にプレビューをご紹介…

Page 23: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Visual Studio* 2010 による並列化 コミュニティー・テクノロジー・プレビュー

インテル® Parallel

Studio

インテル® TBB

OpenMP*

Parallel

Inspector、

Amplifier

インテルは

Microsoft* Concurrency

Runtime をサポート

インテル®

Parallel

Studio は

VS2005、VS2008、

将来の VS2010

をサポート

Page 24: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インテル® スレッディング・ ビルディング・ブロック マルチコア時代の C++ 並列 プログラミング 著者: James Reinders

インテル® Parallel Studio プログラミングガイド Windows* C++ での並列プログラミングにおける最適な最初のステップ

著者: 池井 満、林 浩史 、田中 智子

インテル® ソフトウェア開発製品 関連書籍

C/C++ プログラマーの ための OpenMP* 並列 プログラミング OpenMP* を詳説 著者: 菅原 清文

Page 25: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct テクノロジー:マルチコアおよびメニーコアプロセッサーのための 高生産性 スループット・コンピューティング

池井 満 ソフトウェア&サービス統括本部部長 インテル株式会社

Page 26: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

目次

概要

‐ Ctテクノロジーとは何?

‐ Ctテクノロジーがもたらす価値とは?

‐ Ctテクノロジーの主要な機能とは?またその利点とは?

‐ どのようなワークロードに向くのか

詳細

‐ Ctテクノロジーはどのようなもの?

‐ Ctテクノロジーはどうやって動く?

‐ どのようなツールをサポートするのか?

26

Page 27: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ctテクノロジーとは何か? • アプリケーション開発者を特定のハードウェア・アーキテクチャーに依存させない汎用のデータ・パラレル・プログラミングの方法

• 既存の開発環境に統合することができ、それによってハイレベルで並列化アルゴリズムの仕様を定めさせることができるシステム

• ハイレベルに記述した計算を効率的に並列化して実装できる動的コンパイラーとランタイムで、SIMDとスレッドレベルの並列化、およびアクセラレーターの両者の恩恵を受けることができます。

• アプリケーション開発者が「パフォーマンス(性能)」、「ポータビリティー(移植性)」および「プロダクティビティー(生産性)」を両立させることができるシステムです。

27

Page 28: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

CPU Future

SSE 4

AVX

Single source プロダクティビティー(生産性) ・既存のツールと統合 ・多くの問題領域に適用可能 ・基本的に安全:メンテナンス可能

パフォーマンス(性能) ・効率的でスケーラブル ・ベクターとスレッドの両方を利用する ・C++モジュール化のオーバーヘッドをなくす

ポータビリティー(移植性) ・ハイレベルな抽象化 ・ハードウェアに依存しない ・フォワード・スケーリング

Ctテクノロジーがもたらす価値とは?

28

Page 29: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

プロダクティビティー(生産性)

• 統合:既存のIDE、ツールやコンパイラーと統合:新しいコンパイラーは不要です

• 相互運用:他のインテル並列化ツールやライブラリーと相互に運用可能

• インクリメンタル:既存コードを基に選択的または目標を絞って修正が可能

• 豊かな表現:シンタックス(構文)はアプリケーションのエキスパートに配慮してある

• 基本的に安全:決定論的なセマンティックスにより、レース状態やデッドロックは発生しない

• 簡単に学べる:逐次的で一貫性のあるセマンティックスとシンプルなインターフェースにより既存のスキルを活用できる

• 幅広く適用可能:汎用的なデータ並列化のモデルは、多くの種類の計算に適用可能

29

Page 30: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

パフォーマンス(性能)

• より大きな問題へとスケール可能:データを管理して、メモリーのボトルネックに直接対処する

• スレッドとベクトル化による協調した並列化:一つの記述により、複数のメカニズムを対象にできる

• モジュール化にともなうオーバーヘッドをなくす:自動的に複数のオペレーションを融合させる

• 幅広く、なおかつ深く:開発者は抽象化のレベルを選ぶことができ、必要があれば詳細にまで掘り下げることができる

30

Page 31: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

ポータビリティー(移植性)

• ハイレベル:特定のハードウェアのメカニズムやアーキテクチャーに依存することがない

• ISA拡張からの独立:共通バイナリーは異なるISA拡張を透過的に利用可能である

• 今あるハードウェア上での使用が可能:多数のコアまでスケールして利用可能である

• 将来のハードウェアへの移行とフォワード・スケーリングが可能:AVX、Larrabee、とさらにその先の物もサポート予定

31

Page 32: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

数学的構造

データ編成

数学的構造

データ編成

データレースはどこに?

デッドロックの原因は何?

なぜこの計算を走らせる度に違う結果になるのか?

いくつスレッドを使えばいい?

キャッシュの大きさはどれくらい?

いろんなISAやベクター幅にどうやって対応すればいい?

もともとこのコードを書いた人はどこ?コードが何の計算をやっているのかわからない!

ハイレベルな抽象化によるプロダクティビティー “何をするかを指定、どのように行うかではなく”

注力:エキスパート・アプリケーション開発者効率性を向上させる

32

Page 33: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

チャレンジ: 複数の並列化のメカニズム

マルチコアのシステムには、並列化の方法が何種類もあります:

• パイプライン

• SIMDレジスター(SWAR)によるベクトル化

• スーパースカラー命令またはVLIW

• メモリーアクセスと計算をオーバーラップさせる(プリフェッチ)

• 1つのコア上でのマルチスレッディング(ハイパースレッディング)

• 複数のコア

• 複数のプロセッサー

• 非同期にホストとアクセラレーターで実行

33

Page 34: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

利用可能 複数の並列化のメカニズム

実装の例:

• 2コア

• 4-way ベクトル化

• ストリーミングによりメモリー待ち時間が隠ぺいされる

実際の分配はハードウェアに依存する

プラットフォームの実装:

ユーザーの定義:

解法: 潜在的な並列性とデータの局所性を指定する抽象的な記述を行い、それを自動的に複数の実装方法に適用してこれらの性質を全て活かす

34

Page 35: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct vs. SSE 組み込み関数 #define NCO 4

#if (NCO==2)

#define fptype double

#define SIMD_WIDTH 2

#define _MMR __m128d

#define _MM_LOAD _mm_load_pd

#define _MM_STORE _mm_store_pd

#define _MM_MUL _mm_mul_pd

#define _MM_ADD _mm_add_pd

#define _MM_SUB _mm_sub_pd

#define _MM_DIV _mm_div_pd

#define _MM_SQRT _mm_sqrt_pd

#define _MM_SET(A) _mm_set_pd(A,A)

#define _MM_SETR _mm_set_pd

#endif

#if (NCO==4)

#define fptype float

#define SIMD_WIDTH 4

#define _MMR __m128

#define _MM_LOAD _mm_load_ps

#define _MM_STORE _mm_store_ps

#define _MM_MUL _mm_mul_ps

#define _MM_ADD _mm_add_ps

#define _MM_SUB _mm_sub_ps

#define _MM_DIV _mm_div_ps

#define _MM_SQRT _mm_sqrt_ps

#define _MM_SET(A) _mm_set_ps(A,A,A,A)

#define _MM_SETR _mm_set_ps

#endif

__forceinline void CNDF ( fptype * OutputX, fptype * InputX )

{

_MM_ALIGN16 int sign[SIMD_WIDTH];

int i;

_MMR xInput;

_MMR xNPrimeofX;

_MM_ALIGN16 fptype expValues[SIMD_WIDTH];

_MMR xK2;

_MMR xK2_2, xK2_3, xK2_4, xK2_5;

_MMR xLocal, xLocal_1, xLocal_2, xLocal_3;

for (i=0; i<SIMD_WIDTH; i++) {

// Check for negative value of InputX

if (InputX[i] < 0.0) {

InputX[i] = -InputX[i];

sign[i] = 1;

} else

sign[i] = 0;

}

xInput = _MM_LOAD(InputX);

// Compute NPrimeX term common to both four & six decimal

accuracy calcs

for (i=0; i<SIMD_WIDTH; i++) {

expValues[i] = exp(-0.5f * InputX[i] * InputX[i]);

// printf("exp[%d]: %f¥n", i, expValues[i]);

}

xNPrimeofX = _MM_LOAD(expValues);

xNPrimeofX = _MM_MUL(xNPrimeofX,

_MM_SET(inv_sqrt_2xPI));

xK2 = _MM_MUL(_MM_SET((fptype)0.2316419), xInput);

xK2 = _MM_ADD(xK2, _MM_SET((fptype)1.0));

xK2 = _MM_DIV(_MM_SET((fptype)1.0), xK2);

// xK2 = _mm_rcp_pd(xK2); // No rcp function for double-

precision

xK2_2 = _MM_MUL(xK2, xK2);

xK2_3 = _MM_MUL(xK2_2, xK2);

xK2_4 = _MM_MUL(xK2_3, xK2);

xK2_5 = _MM_MUL(xK2_4, xK2);

xLocal_1 = _MM_MUL(xK2, _MM_SET((fptype)0.319381530));

xLocal_2 = _MM_MUL(xK2_2, _MM_SET((fptype)-

0.356563782));

xLocal_3 = _MM_MUL(xK2_3,

_MM_SET((fptype)1.781477937));

xLocal_2 = _MM_ADD(xLocal_2, xLocal_3);

xLocal_3 = _MM_MUL(xK2_4, _MM_SET((fptype)-

1.821255978));

xLocal_2 = _MM_ADD(xLocal_2, xLocal_3);

xLocal_3 = _MM_MUL(xK2_5,

_MM_SET((fptype)1.330274429));

xLocal_2 = _MM_ADD(xLocal_2, xLocal_3);

xLocal_1 = _MM_ADD(xLocal_2, xLocal_1);

xLocal = _MM_MUL(xLocal_1, xNPrimeofX);

xLocal = _MM_SUB(_MM_SET((fptype)1.0), xLocal);

_MM_STORE(OutputX, xLocal);

// _mm_storel_pd(&OutputX[0], xLocal);

// _mm_storeh_pd(&OutputX[1], xLocal);

for (i=0; i<SIMD_WIDTH; i++) {

if (sign[i]) {

OutputX[i] = ((fptype)1.0 - OutputX[i]);

}

}

}

void BlkSchlsEqEuroNoDiv (fptype * OptionPrice, int numOptions,

fptype * sptprice,

fptype * strike, fptype * rate, fptype * volatility,

fptype * time, int * otype, float timet)

{

int i;

// local private working variables for the calculation

_MMR xStockPrice;

_MMR xStrikePrice;

_MMR xRiskFreeRate;

_MMR xVolatility;

_MMR xTime;

_MMR xSqrtTime;

_MM_ALIGN16 fptype logValues[NCO];

_MMR xLogTerm;

_MMR xD1, xD2;

_MMR xPowerTerm;

_MMR xDen;

_MM_ALIGN16 fptype d1[SIMD_WIDTH];

_MM_ALIGN16 fptype d2[SIMD_WIDTH];

_MM_ALIGN16 fptype FutureValueX[SIMD_WIDTH];

_MM_ALIGN16 fptype NofXd1[SIMD_WIDTH];

_MM_ALIGN16 fptype NofXd2[SIMD_WIDTH];

_MM_ALIGN16 fptype NegNofXd1[SIMD_WIDTH];

_MM_ALIGN16 fptype NegNofXd2[SIMD_WIDTH];

xStockPrice = _MM_LOAD(sptprice);

xStrikePrice = _MM_LOAD(strike);

xRiskFreeRate = _MM_LOAD(rate);

xVolatility = _MM_LOAD(volatility);

xTime = _MM_LOAD(time);

xSqrtTime = _MM_SQRT(xTime);

for(i=0; i<SIMD_WIDTH;i ++) {

logValues[i] = log(sptprice[i] / strike[i]);

}

xLogTerm = _MM_LOAD(&(logValues[0]));

xPowerTerm = _MM_MUL(xVolatility, xVolatility);

xPowerTerm = _MM_MUL(xPowerTerm, _MM_SET(0.5));

// xPowerTerm = _mm_div_pd(xPowerTerm, _MM_SET(2.0,

2.0));

xD1 = _MM_ADD(xRiskFreeRate, xPowerTerm);

xD2 = _MM_SUB(xRiskFreeRate, xPowerTerm);

xD1 = _MM_MUL(xD1, xTime);

xD2 = _MM_MUL(xD2, xTime);

xD1 = _MM_ADD(xD1, xLogTerm);

xD2 = _MM_ADD(xD2, xLogTerm);

xDen = _MM_MUL(xVolatility, xSqrtTime);

xD1 = _MM_DIV(xD1, xDen);

// VL: 10/15/06. An optimization is not to recompute xD2, but to

derive it from xD1

// xD2 = _MM_DIV(xD2, xDen);

xD2 = _MM_SUB(xD1, xDen);

_MM_STORE(d1, xD1);

_MM_STORE(d2, xD2);

CNDF( NofXd1, d1 );

CNDF( NofXd2, d2 );

for (i=0; i<SIMD_WIDTH; i++) {

FutureValueX[i] = strike[i] * (exp(-(rate[i])*(time[i])));

NegNofXd1[i] = ((fptype)1.0 - (NofXd1[i]));

NegNofXd2[i] = ((fptype)1.0 - (NofXd2[i]));

OptionPrice[i] = (FutureValueX[i] * NegNofXd2[i]) -

(sptprice[i] * NegNofXd1[i]);

}

}

void sseBlackScholes(fptype *option_price,

int num_options,

fptype *stkprice,

fptype *strike,

fptype *rate,

fptype *volatility,

fptype *time)

{

for (int i = 0; i < num_options; i += NCO) {

// Calling main function to calculate option value based on

Black & Sholes's

// equation.

BlkSchlsEqEuroNoDiv(&(option_price[i]), NCO, &(stkprice[i]),

&(strike[i]),

&(rate[i]), &(volatility[i]), &(time[i]),

NULL/*&(otype[i])*/, 0);

}

}

186 lines

• ベクトル化

• 非 スレッド化

• マシン依存

42 lines

• ベクトル化

• スレッド化

• マシン非依存

template <typename T>

Vec<T> CND(Vec<T> x)

{

Vec<T> l = abs(x);

Vec<T> k = 1.0f / ( 1.0f + 0.2316419f * l);

Vec<T> w =

0.31938153f * k -

0.356563782f * k * k +

1.781477937f * k * k * k -

1.821255978f * k * k * k * k +

1.330274429f * k * k * k * k * k;

w = w * inv_sqrt_2xPI * exp(l * l * -0.5f);

w = select(x > 0, 1.0f - w, w);

return w;

}

template <typename T>

void ctBlackScholesKern(Vec<T> s,

Vec<T> x,

Vec<T> r,

Vec<T> v,

Vec<T> t,

Vec<T>& result)

{

Vec<T> sqrt_value = v * sqrt(t);

Vec<T> d1 = ln(s / x) + (r + v * v * 0.5f ) * t) / sqrt_value;

Vec<T> d2 = d1 - sqrt_value;

result = x * exp(0f - r * t) * (1.0f - CND(d2)) + (-s) * (1.0 - CND(d1));

}

template <typename T>

void ctBlackScholes(T *option_price, int num_options,

T *stkprice, T *strike, T *rate, T *volatility,

T *time)

{

Vec<T> s(stkprice, num_options);

Vec<T> x(strike, num_options);

Vec<T> r(rate, num_options);

Vec<T> v(volatility, num_options);

Vec<T> t(time, num_options);

Vec<T> result(option_price, num_options);

rcall( ctBlackScholesKern<T> )( s,x,r,v,t,result );

}

Ct SSE

35

Page 36: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ctによるフォワード・スケーリング

Ct Binary

Ct はムーアの法則と共に、スループットとビジュアル・コンピューティングのためにソフトウェアをフォワード・スケールさせる

•ソースファイルを一度だけコンパイルする

•動的に再最適化される: – より多くのコア

– より大きいキャッシュ

– より広いバンド幅

– より多くの命令セット拡張

Ct Source

36

Page 37: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

両方の良いところをとりましょう

属性 生産性

(数学/スクリプト言語)

性能

(スレッドとイントリンシック)

可読性

明確で理解できる表記法

決定性

入力に対する出力結果が 常に一致

正確さ

誤りをもたらす主要因を取り除けるか

性能

最高の絶対性能

スケーラビリティ

増加するコア数を

活用する能力がある

保守性

メンテし易い

Provides excellent support Provides something in-between Provides little or no support

属性 生産性

(数学/スクリプト言語)

性能

(スレッドとイントリンシック)

生産性と性能

(Ctテクノロジー)

可読性

明確で理解できる表記法

決定性

入力に対する出力結果が 常に一致

正確さ

誤りをもたらす主要因を取り除けるか

性能

最高の絶対性能

スケーラビリティ

増加するコア数を

活用する能力がある

保守性

メンテし易い

37

Page 38: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

何に活用できるのか?

ビジュアル・コンピューティング

・デジタル・コンテンツ・クリエイション(DCC)

・物理エンジンと高度なレンダリング

・可視化

・圧縮/解凍

信号処理画像処理

・コンピューター・ビジョン

・レーダーとソナー処理

・顕微鏡画像や衛星画像処理

科学研究

・学習機械と人工知能

・気候と天候シミュレーション

・惑星探査と天体物理学

企業

・データベース検索

・企業情報

生物情報学

・ゲノミクスと遺伝子配列分析

・分子力学

工学設計

・有限要素と有限差分シミュレーション

・モンテカルロ・シミュレーション

財務分析

・オプションと証券の値付け

・リスク分析

石油とガス

・地震時の状況再現

・貯留層シミュレーション

医療画像

・画像と体積の再現

・分析とコンピューター支援検出(CAD)

38

Page 39: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

スループットとビジュアル・コンピューティング・アプリケーション

Terabytes

TIPS

Gigabytes

MIPS

Megabytes

GIPS

計算

性能

データの大きさ

Kilobytes

KIPS

Mult- Media

3D & Video

Text

RMS パーソナルメディア作成と管理

エンターテイメント

学習と旅行

医療 Single Core

Multi-core

Tera-scale

IPS =

Instr

uction p

er

second

“RMS” アプリケーション Recognition(認識)

Mining(検索) Synthesis(合成)

39

Page 40: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

パフォーマンスによって広がる新しい可能性

新しい並列演算とデータ構造

不規則な/疎データの 並列データ

(例:顔面認識)

JITにより並列化を補強

コア数の増加に伴ってスケールする

40

Page 41: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

医療用画像処理 財務分析

アプリケーションの例

*Sentinelle Medicalのご厚意によりデータを提供いただきました

41

Page 42: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ctテクノロジーは

コードを自動並列化するものではありません

– Ctは効果的な並列化コードを効率よく書くためのサポートを提供します

タスク並列化によるものではありません

– タスク並列化では、大量のプロセッサー上で性能をスケールさせることは難しい

– デッドロックやデータレースなどはデバッグが難しい

– Ct “デフォルトで安全な”データ並列化に重点を置いています

新しい言語ではありません

– 既存の標準C++コンパイラー環境内で動作します

– CtはC++に新しいタイプとオペレーションを追加します

42

Page 43: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ctテクノロジー: システム・コンポーネント

•ユーザーは逐次的で一貫性のあるセマンティックスを用いて並列化コードを記述します

•シングル・アサイメントと独立したデータスペースによって安全性を持つ

プログラミング・モデル

•並列収集型と暗示的な並列化オペレーションを持つ

• Cの制御構造そのまま使用します インターフェイス

•ハイレベルでのインターフェース抽象化により下層のハードウェアの詳細から解放

•将来リリースされるプロセッサーやプラットフォーム上でもスケールする(フォワード・スケーリング)

HWの抽象化

•一部のコード・カーネルにのみ適用可能であり、アプリケーション全体に影響しない

•ユーザーは既存のコンパイラーを使用してアプリケーションのビルドが可能 API

43

43

Page 44: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

インターフェイス:言語としてのAPI C++を拡張するシンタックスとセマンティクス

C++に並列集合オブジェクトとメソッドを追加する

– テンプレートと、演算子の多重定義を使用して新しい型と演算を定義

標準C++コンパイラー環境内で動作します – インテル® C++コンパイラー

– Microsoft* Visual* C++ コンパイラー

– Gnu Compiler Collection*

数学的表記を使用してアルゴリズムを表現します – 開発者は、「どうやって行うか」ではなく、「何をするか」に集中できる

シーケンシャルなセマンティックスを使用する

– 開発者はスレッドやロック、または低レベルの機構を使わずにすみ、それらに伴う複雑性を回避することができる

プログラマは並列化ではなく、処理の流れを考えられる

44

Page 45: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

データ

データは隔離された「データスペース」保持され、収集クラスによって管理されます

規則的なデータ:

– Vec: 1Dデータの塊

– Vec2D: 2Dデータの塊

– Vec3D: 3Dデータの塊

– Tuple: 固定長 n組

不規則なデータ:

– VecIndexed, VecNested

演算

演算はCt コレクションと/または

スカラー型を通じたオペレーションにて、C++関数として記述される。

コンポーネントごとと集合オペレーションの両方をサポート

演算が呼び出される要素 – Map: 配列の全ての要素上で関数を並列に実行

– Call: 並列オペレーションを逐次実行

インターフェイス:プログラミング言語としてのAPI C++を拡張するシンタックスとセマンティクス

45

Page 46: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

集合オブジェクト

Vecは基本的な並列集合オブジェクト型

• 値に対する呼び名

• ランタイムによって管理される

• フラット、複数次元、または不規則な入れ子

• API を介して排他的に生成そして操作される

–決定性と分離

–パフォーマンス追及のために上書きや直接操作

#include "ct.h“

using namespace Ct;

int main(int argc, char *argv[])

{

// A Vec declaration must specify a base

// type: Vec<basetype> aTypedVector;

// For example, DoubleVec can refer to any

// vector of doubles.

Vec<F64> DoubleVec;

// A regular 2 dimensional vector:

Vec2D<I8> 2DMatrix (“{{0,1,2}, {3,4,5},

{6,7,8}}”);

//An irregularly nested vector:

VecNested<I32> IrregularVector (“{{0,1,2},

{3,4}, {5,6,7,8}}”);

return 0;

} 「デフォルトで安全」を提供する

46

Page 47: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

並列集合上での演算

規則的な Vecs

Vec3D

不規則 Vecs

VecIndexed

VecNested

Vec

Vec2D

Vec<Tuple<…>>

& 増殖中…

Priorities: VecSparse, Vec2DSparse, VecND

repeatCol, shuffle, transpose, swapRows, shift, rotate, scatter, …

47

Page 48: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ctにおける演算の表現

Vector Processing

Vec<F32> A, B, C, D; A += B/C * D;

Scalar Processing

F32 kernel(F32 a, b, c, d) { return a + (b/c)*d; } … Vec<F32> A, B, C, D; A = map(kernel)(A, B, C, D);

Native/Intrinsic Coding

CMP cviVPREFETCH cviFMADD INC JMP

STRIP<F32>native( STRIP<F32> a, b, c, d) { __asm__ { … }; } … Vec<F32> A, B, C, D; A = nmap(native)(A, B, C, D);

Ct のJIT が変換を自動的に行う

またはプログラマーが適切なレベルの抽象化を行う

48

Page 49: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

どのようにして動作するのか?

シリアルなC++アプリに組み込まれたCtカーネル

標準的な C++ コンパイラ

Ct ランタイム

•テンプレート

•オーバロードされた演算子

•動的にライブラリとリンク

•動的なコンパイラ

•スレッド化と異機種用ランタイム

逐次プログラム CPU

将来製品

将来製品

49

Page 50: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct 動的処理実行

int ar_a[1024], ar_b[1024]

Vec<I32> va(ar_a, …);

Vec<I32> vb(ar_b,…);

rcall( work ) ( va, vb );

Ct 動的処理

エンジン

50

Page 51: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct 動的処理実行

int ar_a[1024], ar_b[1024]

Vec<I32> va(ar_a, …);

Vec<I32> vb(ar_b,…);

rcall( work ) ( va, vb );

Memory Manager

a b

Ct 動的処理 エンジン

51

Page 52: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct 動的処理実行

int ar_a[1024], ar_b[1024]

Vec<I32> va(ar_a, …);

Vec<I32> vb(ar_b,…);

rcall( work ) ( va, vb );

Memory Manager

a b

Ct 動的処理 エンジン

void work( Vec<I32> a,

Vec<I32> & b )

{

b = a + 1;

}

IR Builder

52

Page 53: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct 動的処理実行

int ar_a[1024], ar_b[1024]

Vec<I32> va(ar_a, …);

Vec<I32> vb(ar_b,…);

rcall( work ) ( va, vb );

Memory Manager

a b

Ct 動的処理 エンジン

void work( Vec<I32> a,

Vec<I32> & b )

{

b = a + 1;

}

IR Builder

V1 1

+

V2

53

Page 54: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct 動的処理実行

int ar_a[1024], ar_b[1024]

Vec<I32> va(ar_a, …);

Vec<I32> vb(ar_b,…);

rcall( work ) ( va, vb );

Memory Manager

a b

Ct 動的処理 エンジン

void work( Vec<I32> a,

Vec<I32> & b )

{

b = a + 1;

}

IR Builder

V1 1

+

V2

JIT

Trigger JIT

54

Page 55: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct 動的処理実行

int ar_a[1024], ar_b[1024]

Vec<I32> va(ar_a, …);

Vec<I32> vb(ar_b,…);

rcall( work ) ( va, vb );

Memory Manager

a b

Ct 動的処理 エンジン

void work( Vec<I32> a,

Vec<I32> & b )

{

b = a + 1;

}

IR Builder

V1 1

+

V2

JIT

ハイレベル最適化

ローレベル最適化

CVI コード生成

SSE LNI AVX

JIT が動作

55

Page 56: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct ランタイム

•インテルCtテクノロジーでは、ランタイム付きの標準規格に準拠したC++ライブラリーを提供しています

•ランタイムは以下のようにスレッドやベクターコードを生成し管理します

–ハードウェアに依存しない最適化

–管理の軽減

–特定のハードウェアのためのコード生成と最適化

– (TBBをもとにした!)スケーラブルなスレッド化ランタイム

JIT Compiler

Virtual Machine

Virtual ISA

Debug/ Svcs

Memory Manager

Backend JIT

Compiler

Threading Runtime

CPU アクセラレータ 将来製品

Application calling Ct APIs

C++ APIs 他言語のバインディング

56

Page 57: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

Ct 動的エンジンの意味

実行時に第2ステージのコンパイル

実行時に実装に特化できる

Ct カーネル:C関数として存在するが、

• 1度だけ実行=>動的コンパイルのため

• 演算を記号としてキャプチャーする

• 現行のバインディングと状態のスナップショットを取得する

Ct コール:実行は遠隔関数コール

• データフロー依存関係を察知

• 自動(そして常に安全な)同期

• 遠隔実行とデータ保存を可能に

57

Page 58: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

なぜこれが重要なのか?

広く使われているライブラリーほど、よくデザインされた汎用的なインターフェースやモジュール化と引き換えにパフォーマンスを妥協している

– 仮想関数呼び出し、関数ポインター、そして制御フローはランタイム時にしか分からないパラメーターに依存しており、パフォーマンスを制限しうる

– モジュール性は本来的に様々な処理に分散してしまう

– 極端なケースでは、アプリケーションは実行時に決められる計算を適宜実行しているにすぎない

動的コンパイルは、「遅延結合」のオーバーヘッドを「コンパイル・アウト」できる

この利点によって、並列化を増大化させる作用がある

58

Page 59: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

•Ctデータ構造の表示をユーザーが制御

•表示フォーマットを選択 例:イメージ、スプレッドシート

•Ct演算またはIDEからインタラクティブに起動 例:Microsoft* Visual Studio*

•変換ステップを可視化できます

•これはプログラム開発生産性向上ための重要な機能です

Ctテクノロジーをお気に入りの開発環境で使用可能

IDEサポート

*Other names and brands may be claimed as the property of others.

59

Page 60: Parallel Technology

Software & Services Group, Developer Products Division

Copyright © 2009, Intel Corporation. All rights reserved.

*Other brands and names are the property of their respective owners.

まとめ

• Ct テクノロジーはマルチコアへのアクセスを容易にし、データ並列化のアプリケーションのための異機種環境でのメニーコア並列化を容易にします

• 逐次セマンティックスは並列プログラミングする負担を軽減します

• 「デフォルトで安全」によって、悩ましいデータレースやデッドロックを回避できます

• 今日、Ctテクノロジーで書かれたコードは、新しくリリースされるメニーコア・プロセッサー上でもスケールする(フォワード・スケーリング)

60