Microsoft PowerPoint - GDEP-GPG_softek_May24-2.pptx

Size: px
Start display at page:

Download "Microsoft PowerPoint - GDEP-GPG_softek_May24-2.pptx"

Transcription

1 G-DEP 第 3 回セミナー PGI OpenACC Compiler PGIコンパイラ使用の実際 新しい OpenACC によるプログラミング 2012 年 5 月 加藤努株式会社ソフテック OpenACC によるプログラミング GPU / Accelerator Computing Model のデファクト スタンダードへ OpenACC Standard 概略説明 Accelerator Programming Model OpenMP と OpenACC 何が違うのか? Accelerator 構成のボトルネックは? OpenACC directives 並列領域の定義データ転送の操作ループ分割の指示 Directives 構文の説明 三つの主要 directives を覚える データの移動指示を行うためのテクニック OpenACC 使用の実際例 1

2 アクセラレータと OpenACC Standard 2 アクセラレータとは Many Cores Multi threading ホスト 本日の前提 アクセラレータ NVIDIA GPU Intel MIC Others 3

3 Accelerator Programming Model ホスト ハイブリッド構成 (CPU+GPU) Accelerator CPU 重い計算部分の処理をオフロード GPGPU Main Memory Device Memory 今日の話 Accelerator のためのコード開発を支援するディレクティブ群 OpenACC directives 4 OpenACC Standard とは何か? 2011 年 11 月 NVIDIA, Cray, PGI,CAPS Accelerators 用のプログラミング API の標準仕様 Fortran, C/C++ 言語上で指定するコンパイラ ディレクティブ群 ユーザサイド開発者がアクセラレータで実行するコード部分をディレクティブで指定する ( コンパイラに対して ヒントを与える ) OpenACC コンパイラホスト側の処理をアクセラレータ (GPU) にオフロードするコード生成ホスト -- GPU 間のデータ転送コードの生成 2009 年リリース以来 実績を積んだ PGI Accelerator Compiler(directives) がベースとなっている 5

4 OpenACC の利点 特長 可搬性 ( ポータビリティ ) ホスト OS, ホスト CPUs, アクセラレータ コンパイラ間の portability 異なるプラットフォームに変わっても 性能 の可搬性を提供 ハイレベル / 高級言語 CUDA, OpenCL or 低レベル GPU programming の知識必要なしソースコードの変更が必要ない 高生産性クイックな開発ステップと段階的に行える開発 OpenMP-like ヘテロジニアスなプログラムシングル ソース ベース (CPU 用 GPU 用と分ける必要なし ) Easy, Fast, Portable! 6 OpenACC は どんな機能を提供するのか? プログラム内に ディレクティブ でヒントを与えると コンパイラは 次のような機能を組込んだホスト側コードとアクセラレータ側コードを自動生成する アクセラレータ (GPU) をイニシャライズ ホスト (CPU) とアクセラレータ間の データ と プログラム の転送の管理 ホスト (CPU) とアクセラレータ間の データ を監視 ホスト (CPU) とアクセラレータ間の 仕事 を管理 仕事 を並列に分割して GPU ハードウェアの並列構造にマッピング さらに 性能最適化を試みる ( キャッシュ等 ) 7

5 OpenMP の取組 2012/3/27 アナウンス OpenACC 知見妥当性確認ユーザの声反映 取り込み OpenMP 4.0 新バージョン (2012 年 ) 8 OpenMP と OpenACC プログラミング モデル 9

6 OpenMP Programming Model マルチコア 共有メモリ上のスレッド並列 (CPU) ホスト マルチコア CPU CPU 処理の分割のみ Main Memory Main Memory データは全て共有メモリ内に 処理の分割のみを考えれば良い データは均一のアドレス空間上でアクセス可能 10 Accelerator Programming Model ホスト側 ハイブリッド構成 (CPU+GPU) GPU 側 CPU Main Memory Host_A(100) 重い計算部分の処理をオフロード 使用データを送る 結果データを戻す Overhead GPGPU Device Memory Device_A(100) Host GPU 間のメモリデータの転送が伴う データ転送のオーバーヘッド時間が伴う 11

7 並列化で必要なプログラム記述 共有メモリ構成 (OpenMP on Host) アクセラレータ構成 (Host+GPU) 処理系 処理の並列化 処理の並列化 (Kernel 記述 ) データ系 なし データの移動 12 Accelerator Memory model の重要な視点 アクセラレータ モデルでは 何を考える必要があるか? ホスト側のデータ空間とGPU 側のデータ空間の二つの空間が必要 ホストとGPU 間のデータ転送が必要 新たなoverhead 時間 データ移動に係わる指示 (directive) が必要 データ移動の最小化を行うために最適化するための要素 ホスト側メモリとGPU 側メモリ間の転送帯域 (PCI 帯域 ) に制約がある 性能加速性があるコード領域かどうかの判別が必要 ループ内の 計算密度 のレベルで加速性が変化 GPU 側のメモリ容量に制約がある ( 現在 < 6GB) 非常に大きな配列を伴う コード領域 のオフロード化に制約 必要な場合 複数のGPUデバイス上のMPI 化が必要 13

8 CPU+Accelerator 構成のボトルネックは? ホスト側 ハイブリッド構成 (CPU+GPU) GPU 側 CPU Main Memory 処理の offload 化 GPGPU Device Memory 2 データの再利用 resident 1 データ転送回数を少なくする工夫 Host GPU 間のデータ転送帯域 (PCI バス性能 ) の遅さ 14 $ pgaccelinfo PGI command pgaccelinfo -- CUDA Driver Version: 4010 (CUDA driver version) NVRM version: NVIDIA UNIX x86_64 Kernel Module Device Number: 0 Device Name: Tesla C2075 Device Revision Number: 2.0 Global Memory Size: Number of Multiprocessors: 14 Number of Cores: 448 Concurrent Copy and Execution: Yes Total Constant Memory: Total Shared Memory per Block: Registers per Block: Warp Size: 32 Maximum Threads per Block: 1024 Maximum Block Dimensions: 1024, 1024, 64 Maximum Grid Dimensions: x x Maximum Memory Pitch: Texture Alignment: Clock Rate: Execution Timeout: Integrated Device: Can Map Host Memory: B 512B 1147 MHz Yes No Yes GPU device の特性の出力コマンド CUDA driver のチェック GPU ボードのチェック 性能要素のチェック CUDA 機能チェック PCI バス性能チェック 15

9 PGI command pgaccelinfo ( 続 ) Compute Mode: default Concurrent Kernels: Yes ECC Enabled: No Memory Clock Rate: 1566 MHz Memory Bus Width: 384 bits L2 Cache Size: bytes Max Threads Per SMP: 1536 Async Engines: 2 Unified Addressing: Yes Initialization time: 7325 microseconds Current free memory: Upload time (4MB): 821 microseconds ( 651 ms pinned) Download time: 948 microseconds ( 649 ms pinned) Upload bandwidth: 5108 MB/sec (6442 MB/sec pinned) Download bandwidth: 4424 MB/sec (6462 MB/sec pinned) CPU memory GPU memory 間の転送帯域 = PCI Express x16 高々 5GB/sec しかない! ちなみに 現在の CPU のメモリ帯域は 20~50GB/sec 16 OpenACC ディレクティブ 17

10 program main integer :: n! size of the vector real,dimension(:),allocatable :: a! the vector real,dimension(:),allocatable :: r! the results integer :: i n = allocate(a(n)) allocate(r(n)) do i = 1,n a(i) = i*2.0!$acc kernels do i = 1,n r(i) = sin(a(i)) ** 2 + cos(a(i)) ** 2!$acc end kernels print *, r(1000) end 2 行のディレクティブ挿入でコード生成 $ pgfortran -acc -Minfo test.f90 main: 12, Generating copyout(r(1:100000)) Generating copyin(a(1:100000)) Generating compute capability 1.0 binary Generating compute capability 2.0 binary 13, Loop is parallelizable Accelerator kernel generated 13,!$acc loop gang, vector(256)! blockidx%x threadidx%x オフロードする並列対象領域の指 ( 一般に ループ部分 ) GPU 側へのデータコピー GPU 用の並列化 Host 側へデータバック 自動的 かつ Implicit に行う 18 Kernel と言う言葉!$acc kernels do i = 1,n r(i) = sin(a(i)) ** 2 + cos(a(i)) ** 2!$acc end kernels アクセラレータへオフロードする並列対象 ( 一般に ループ構成部分 ) Accelerator(GPU) 用の実行サブ ルーチンとして切り出す ひとつの kernel ルーチン という 19

11 OpenACC ディレクティブの主な構成 ホスト CPU 3 ( 処理 ) 1 重い計算部分の処理をオフロード Accelerator GPGPU Main Memory 2 ( データ ) Device Memory 1 Accelerate Compute 構文 (offload 領域指示 ) 2 Data 構文 ( データ移動指示 ) 3 Loop 構文 (Mapping for parallel/vector, Tuning) 20 1 Accelerate Compute 構文 program main integer :: n! size of the vector real,dimension(:),allocatable :: a! the vector real,dimension(:),allocatable :: r! the results integer :: i n = allocate(a(n)) allocate(r(n)) do i = 1,n a(i) = i*2.0!$acc data copyin(a(1:n)),copyout(r)!$acc kernels!$acc loop gang(32),vector(64) do i = 1,n r(i) = sin(a(i)) ** 2 + cos(a(i)) ** 2!$acc end kernels!$acc end data -- Fortran -- 主要な三つのディレクティブ 1 並列実行 kernel 部分の指定 オフロードする並列対象領域の指 ( 一般に ループ部分 ) 21

12 2 Data 構文 program main integer :: n! size of the vector real,dimension(:),allocatable :: a! the vector real,dimension(:),allocatable :: r! the results integer :: i n = allocate(a(n)) allocate(r(n)) do i = 1,n a(i) = i*2.0!$acc data copyin(a(1:n)),copyout(r)!$acc kernels!$acc loop gang(32),vector(64) do i = 1,n r(i) = sin(a(i)) ** 2 + cos(a(i)) ** 2!$acc end kernels!$acc end data -- Fortran -- 主要な三つのディレクティブ 2データ移動指示 1 並列実行 kernel 部分の指定 オフロードする並列対象領域の指 ( 一般に ループ部分 ) 22 3 Loop 構文 program main integer :: n! size of the vector real,dimension(:),allocatable :: a! the vector real,dimension(:),allocatable :: r! the results integer :: i n = allocate(a(n)) allocate(r(n)) do i = 1,n a(i) = i*2.0!$acc data copyin(a(1:n)),copyout(r)!$acc kernels!$acc loop gang(32),vector(64) do i = 1,n r(i) = sin(a(i)) ** 2 + cos(a(i)) ** 2!$acc end kernels!$acc end data -- Fortran -- 主要な三つのディレクティブ 2データ移動指示 1 並列実行 kernel 部分の指定 3mapping for para/vector オフロードする並列対象領域の指 ( 一般に ループ部分 ) 23

13 int main( int argc, char* argv[] ) { int n; /* size of the vector */ float *restrict a; /* the vector */ float *restrict r; /* the results */ float s, c; int i; n = ; a = (float*)malloc(n*sizeof(float)); r = (float*)malloc(n*sizeof(float)); for( i = 0; i < n; ++i ) a[i] = (float)(i+1) * 2.0f; #pragma data copy (a[0:n]), copyout(r) #pragma acc kernels { #pragma acc loop gang, vector(128) } for( i = 0; i < n; ++i ){ s = sinf(a[i]); c = cosf(a[i]); r[i] = s*s + c*c; } C プログラムの場合 オフロードする並列対象領域の指 ( 一般に ループ部分 ) -- C-- 主要な三つのディレクティブ 2 データ移動指示 1 並列実行 kernel 部分の指定 3mapping for para/vector 24 三つの構文を覚える!$acc data copyin(a(1:n)),copyout(r)!$acc kernels!$acc loop gang(32),vector(64) do i = 1,n r(i) = sin(a(i)) ** 2 + cos(a(i)) ** 2!$acc end kernels!$acc end data Data 構文 Accelerate Compute 構文 Loop 構文 オフロードする並列対象領域 ( 一般に ループ部分 ) 25

14 OpenACC ディレクティブの表記法 Fortran!$acc directive-name [clause [,] clause] ] ( 構造化コード ブロック )!$acc end directive-name Clause= 節 ] ( 他の表記法 ) c$acc directive-name [clause [,] clause] ] *$acc directive-name [clause [,] clause] ] C #pragma acc directive-name [clause [,] clause] ] { 構造化コード ブロック } PGI Accelerator directive と同じ 26 Accelerate Compute 構文 アクセラレータ上で並列実行を行う領域を指定するための directive その領域内で使用する データ を転送するコードを生成 (Implicit xfer) 2 種類のディレクティブ Parallel 構文 ( 指定領域を並列に実行する ) C #pragma acc parallel { 並列実行領域 } Fortran!$acc parallel { 並列実行領域 }!$acc end parallel Kernels 構文 ( 複数の並列カーネルループを実行 ) C #pragma acc kernels { 並列ループ領域 } Fortran!$acc kernels { 並列ループ領域 }!$acc end kernels 開発初期の段階は まず kernels を使用する 27

15 Parallel 構文 OpenMP の!$omp parallel と同じコンセプト CPU スレッド 数を生成する 個々のworkerが冗長に実行 Any work-sharing loop gangs of workers 数を解放!$acc parallel Gang!$acc end parallel Gang Gang Multithreaded Workers gangs of workers 並列領域指定された!$acc parallel [clause ] if( condition ) private( list ) async( expression ) firstprivate( list ) num_gangs( expression ) reduction( operator:list ) num_workers( expression ) Any data clause vector_length( expression ) CPU スレッド 28 Parallel 構文の clauses( 節 ) num_gangs ( expression ) num_workers ( expression ) 生成する gang の数 (CUDA griddim) 各 gang 内で生成する worker の数 (CUDA blockdim) vector_length ( expression ) 各 worker 内の vector 長 (SIMD 実行 ) private ( list ) firstprivate ( list ) reduction ( operator:list ) 各 gang 上でプライベート変数の生成 ホスト側からの初期値をプライベート変数にセットする gang 間でプライベート コピーを使ってリダクション処理を行う 29

16 順番に実行Kernels 構文 CUDAの kernelの単位 と同じコンセプト (nested) ループを対象各ループをkernel 化する CPU スレッド コンパイラは 指定領域内のループ構造を独立のカーネルコードとして生成する!$acc kernels do k=1,n do j=1,n do i=1,n a(i,j.k)=b(i,j,k)*c(i,j,k) Kernel 1 Gangs do i=1,n s=s+ a(i,j.k) Kernel 2!$acc kernels [clause ] If( condition ) async( expression ) Any data clause!$acc end kernels CPU スレッド Workers 30 OpenACC Parallelism 3 階層 Gang Worker Vector PEs : プロセッサ要素の基本集合体 each PE : マルチスレッディング処理 Each thread of the PE : ベクトル命令処理 あまり深刻に考えなくてよい = H/W とのマッピングが難しい worker thread PE Multithreaded Vector 命令可能 Gang Worker NVIDIA case PEs => Streaming Multiprocessors thread Multithreading => warps within SM (PE 内の Max. Threads per Thread Block) Vector_length => warp 内スレッド数 32 31

17 Gang 分割 + Worker or Vector 例えば 2 次元配列空間 ( 計算空間 )A(n,n) J 列で Gang 分割 j アクセラレータ H/W の並列実行体にマッピング i SM Worker の形 ( 分割法で異なる ) Vector length NVIDIA の場合は gang/vector の 2 階層でよい 同一 gang 内で worker or vector 特性によりマルチスレッディング処理 32 Loop 構文 役目 直下の ループ の並列の分割方法 (gang, worker, vector) 指示 Acceleratorハードウェアの並列構造にマッピングを行うためのclause ループ内プライベートとなる変数の宣言 リダクション処理の指定 Fortran C!$acc loop [clause ] #pragma acc loop [clause ] Clause( 節 ) collapse (n) gang [ ( expression ) ] worker [ ( expression ) ] vector [ ( expression ) ] seq independent private( list ) reduction ( operator : list) 33

18 parallel 構文内の Loop clauses( 節 ) collapse ( n ) gang worker vector seq Independent private ( list ) reduction ( operator:list ) 次の n の段数の nested ループに collapse を適用 並列領域の gangs 数によって イテレーションを分割引数はなし Parallel 構文の節で指定する gang 内の workers 数によって イテレーションを分割引数はなし Parallel 構文の節で指定する SIMD モードでイテレーションを実行 gang or worker のどちらかと共に使用する ( 但し 実装依存あり ) GPU 内でループをシーケンシャルに実行 次のループは依存性がないことを指示する ループの各イテレーションに対して list の変数のコピーを生成し プライベート変数を生成 イテレーション間でプライベート コピーを使ってリダクション処理を行う PGI の場合は 多くのリダクション演算を 動認識可能 34 kernels 構文内の Loop clauses( 節 ) collapse ( n ) gang ( expression ) worker ( expression ) vector ( length ) seq Independent private ( list ) reduction ( operator:list ) 次の n の段数の nested ループに collapse を適用 並列領域の gangs によって イテレーションを分割 gang 内の workers によって イテレーションを分割 SIMD モードでイテレーションを実行 length で strip-mining( 分割 ) する GPU 内で対象ループをシーケンシャルに実行 次のループは依存性がないことを指示する ループの各イテレーションに対して list の変数のコピーを生成し プライベート変数を生成 イテレーション間でプライベート コピーを使ってリダクション処理を行う PGI の場合は 多くのリダクション演算を 動認識可能 35

19 Combined Directives (parallel + loop) の複合ディレクティブ ( 指定した直下のループを対象とする ) parallel loop C #pragma acc parallel loop Fortran!$acc parallel loop do loop [!$acc end parallel loop ] kernels loop C #pragma acc kernels loop Fortran!$acc kernels loop do loop [!$acc end kernels loop ] 36 役目 Data 構文 Acceleratorのデバイスメモリ上に必要な配列 スカラ変数エリアを割付 Region 入口で ホストからデバイスへデータをコピー Region 出口で デバイスからホストへデータをコピーバック 明示的な指示のために使用 データのコピー動作発生 end data 文指定の場所で Host 側へのコピーバック発生 region entry data 文指定の場所で!$acc data デ!$acc kernels ータ領!$acc kernels 域region exit CPU スレッド!$acc end kernels!$acc end kernels!$acc end data CPU スレッド A(10) A(10) A(10) CPU 側 Memory Device 側 Memory CPU 側 Memory 37

20 Data 構文の clause ( 節 ) コピーの動作方法 データの存置状況を指示するための clause の意味 Host Memory 空間 Accelerator Device memory Memory 空間!$acc data ータ領域!$acc end data Host CPUスレッドデCPU スレッド present create A(10) A(10) A(10) copyin copyout copy 38 Data 構文の clause ( 節 ) Fortran C!$acc data [clause ]...!$acc end data #pragma acc data [clause ] Clause( 節 ) copy(list) copyin(list) copyout(list) create (list) present (list) present_or_copy(list) present_or_copyin(list) present_or_copyout(list) present_or_create(list) deviceptr(list) copyin + copyout 入口で hostからaccelerator 側にコピーするだけ出口で acceleratorからhostにデータをコピーバック accelerator 側のみで使用するローカル変数の割付指示既にaccelerator 側に存在していることを指示 accelerator 側にデータの存在のテストを行う (pcopy) accelerator 側にデータの存在のテストを行う (pcopyin) accelerator 側にデータの存在のテストを行う (pcopyout) accelerator 側にデータの存在のテストを行う (pcreate) list がデバイス側のポインタであることを宣言 39

21 データ転送を行う場所を意識する データ転送の最小化 ループの繰り返し毎に 以下の 1 と 2 のデータ転送が繰り返される 1Host > GPUへデータを転送するポイント Implicit Data xfer Accelerator(GPU) 上で Kernel code 実 2GPU -> Host へデータを転送するポイント 転送時間が大きくなり 性能が出ない! 40 Data 構文を使用する意味とは? データ転送 と 並列処理 を分ける Explicit Data xfer 1Host > GPUへデータを転送するポイント loop の繰り返し中 A,B,C 配列 ( 変数 ) は GPU 上のメモリに常駐する このタイミングではデータ転送は行わないコードが作成される loop の繰り返し終了後 A,B,C 配列 ( 変数 ) をホスト側へ戻す 2GPU -> Host へデータを転送するポイント 例えば A, B, C 配列の場合 41

22 プロシジャー間 Accelerator 側データ常駐化 時間積分ループの前で GPU 側へデータを転送する ( 配列を割付する ) データ転送が 1 回のみ (x, y, z 配列 )= データを常駐化させる Call されたルーチン側で アクセラレータ処理 x,y,z 配列データは GPU 上のデータを使用する ホスト側へデータ バック転送 Data 構文 present 節の利用 42 Data 構文 present 節の意味 Host 側メモリ GPU 側メモリ A(100) copyin copyout resident A(100) present と言う状態 Sub routine (GPU 上で計算 ) Main routine (host 側 ) A!$acc data copy (a(100))!$acc data present(a(100)) A A A call call call プログラムの流れ time A!$acc end data デバイス側のメモリ内の既存データを使用する 43

23 データの同期 update directive( 実行文 ) Host 側メモリ GPU 側メモリ A(100) copyin copyout resident A(100) present と言う状態 Sub routine (GPU 上で計算 )!$acc data present(a(100)) A A A Main routine (host 側 ) A call call call A A!$acc data copy (a(100)) Device to host!$acc update host (a(10:20)) Host to device!$acc update device (a(10:20)) Subarray 指定も可!$acc end data 44 Data 構文の活用 (C プロシジャー間 ) present 節の活用この時点で a をGPU 側で割付 かつ データコピー #pragma acc data copy(a[0:n]) { init( a, n );... 1 Main process( a, n ); のルーチンでも a を使用 } 既に a はGPU 上に存在して void init( float* a, int n ) いることをcompilerに伝える Subroutine { データ転送は行わない #pragma acc kernels loop present(a[0:n]) for( int i = 0; i < n; ++i ) a[i] = sinf((float)i); } Accelerator(GPU) 上のメモリにデータを常駐化させる 45

24 Data 構文 Present 節 (C 言語 ) typedef float *restrict *restrict MAT; typedef float *restrict VEC; main() { MAT aa; VEC bb[100]; ( 略 ) ( 109) ( 110) { ( 111) smooth( aa, bb, w0, w1, w2, n, m, 100 ); ( 112) } ( 略 ) Callee 側 Caller 側 引数 プロシジャー間のデータの引き渡し方法 Caller 側で Accelerator 側の Memory 割付を行い 必要なデータをコピーしておく ( 15) void smooth( MAT a, VEC b[100], float w0, float w1, float w2, int n, int m, int niters ) ( 16) { ( 21) for( iter = 1; iter < niters; ++iter ) { ( 22)... ( 並列化対象ループ )a[i][j], b[i][j] を使用 } ( 39) } 46 Data 構文 Present 節 (C 言語 ) 続き typedef float *restrict *restrict MAT; typedef float *restrict VEC; main() { MAT aa; VEC bb[100]; ( 略 ) ( 109) #pragma acc data copyout (aa[1:n-2][0:m]), copy(bb[0:n][0:n]) ( 110) { ( 111) smooth( aa, bb, w0, w1, w2, n, m, 100 ); ( 112) } ( 略 ) Callee 側 引数 Compiler message main: 109. Generating copyout(aa[1:n-2][0:m]) Generating copy(bb[0:n][0:n]) Visible device copy smooth: 20. Generating present(b[0:n][0:n]) Generating present(a[1:n-2][0:m]) ( 15) void smooth( MAT a, VEC b[100], float w0, float w1, float w2, int n, int m, int niters ) ( 16) { ( 20) #pragma acc data present ( a[1:n-2][0:m], b[0:n][0:n] ) ( 21) #pragma acc kernels { ( 22) for( iter = 1; iter < niters; ++iter ) { 既にGPU 上に割付られたa[],b[] を使用する... } } ( 39) } 47

25 Data 構文 Present 節 (C 言語 ) 続き void smooth( MAT a, VEC b[100], float w0, float w1, float w2, int n, int m, int niters ) { int i, j, iter; } #pragma acc data present ( a[1:n-2][0:m], b[0:n][0:n] ) #pragma acc kernels { for( iter = 1; iter < niters; ++iter ) { #pragma acc loop gang(8) vector(8) for( i = 1; i < n-1; ++i ) { for( j = 1; j < m-1; ++j ) { a[i][j] = w0 * b[i][j] + w1*(b[i-1][j] + b[i+1][j] + b[i][j-1] + b[i][j+1]) + w2*(b[i-1][j-1] + b[i-1][j+1] + b[i+1][j-1] + b[i+1][j+1]); } } for( i = 1; i < n-1; ++i ) { for( j = 1; j < m-1; ++j ) { b[i][j] = a[i][j]; } } } } smooth: 20, Generating present (b[0:n][0:n]) Generating present (a[1:n-2][0:m]) 25, Loop is parallelizable 26, Loop is parallelizable Accelerator kernel generated 25, #pragma acc loop gang(8), vector(8) /* blockidx.y threadidx.y */ 26, #pragma acc loop gang, vector(8) /* blockidx.x threadidx.x */ 32, Loop is parallelizable 33, Loop is parallelizable Accelerator kernel generated 32, #pragma acc loop gang, vector(8) /* blockidx.y threadidx.y */ 33, #pragma acc loop gang, vector(8) /* blockidx.x threadidx.x */ 48 Data 構文 Present 節 (C 言語 ) 続き 実行プロファイル結果 Accelerator Kernel Timing data smooth 21: region entered 1 time time(us): total=3559 kernels=1700 data=0 26: kernel launched 99 times grid: [13x8] block: [8x8] time(us): total=898 max=11 min=9 avg=9 33: kernel launched 99 times grid: [13x13] block: [8x8] time(us): total=802 max=14 min=8 avg=8 main 109: region entered 1 time Kernel 実 時間 データ転送時間を意味する time(us): total= init= region=5151 data=1149 w/o init: total=5151 max=5151 min=5151 avg=5151 Smooth 側では データ転送は行われていない Host-GPU 間のデータ転送は main 側で行っている 49

26 C/C++ Extensions for Array Notation OpenACC プラグマ上での部分配列の指定方法 (C の subarrays) Array [ 開始 index : 長さ ( 個数 ) ] PGI Accelerator notation ( 開始点 0からn 個の表記方法 ) x[0:n-1] OpenACC notation x[0:n] ( 開始点 21から100 個の表記方法 ) x[21:120] x[21:100] OpenACC は Intel s Array Notation for C を採用 データの並びが 連続 であることを保証すること Fortran の場合は Fortran 準拠 notation 例 (A (1:n,1:m)) をそのまま使う 50 部分配列の転送指定は 連続 であること OpenACC の data 構文の約束事 部分配列の転送指定では メモリのアドレスが連続並びになるように指定する Fortran 配列 a(100,100) として配列宣言 内部の98x98を転送したい copyin(a(2:99,2:99)) : PGI Accelerator ModelではOK copyin(a(1:100,2:99)): OpenACC 仕様での指定方法 (100x98) full index 指定 Fortran:Column-major Format ( 列方向に並ぶ順序 ) C : Row-major Format ( 方向並び ) C 配列 a[0:99][0:99] として配列宣言 内部の 98x98 を転送したい copyin(a[1:98][1:98]) : PGI Accelerator ModelではOK copyin(a[1:98][0:100]) : OpenACC 仕様での指定方法 (98x100) OpenACC notation 51

27 Parallel construct の非同期 (async) 実行 use openacc integer,parameter :: n=512 real(4) :: A(n,n), B(n,n), C(n,n), D(n,n), E(n,n) integer(4) :: handle handle = 2!$acc data copyin(a,b), copyout(e), create(c,d)! Task1 : C = A + B!$acc kernels async(handle) do i=1, n do j=1, n C(i,j) = A(i,j) + B(i,j) Task1!$acc end kernels!! Task 2 : D = D + A * B multiply!$acc kernels async(handle) do i = 1, n do j = 1, n D(i,j) = 0.0 do i = 1, n Task2 do j = 1, n do k = 1, n D(i,j) = D(i,j) + A(i,k)*B(k,j)!$acc end kernels! つのカーネル実 ブロックの同期を取る!$acc wait(handle)!!!!call acc_async_wait (handle) あるいは API 使用! Final Task : E = C + D!$acc kernels!$acc loop independent do i=1, n!$acc loop independent do j=1, n E(i,j) = C(i,j) + D(i,j)!$acc end kernels!$acc end data (E の処理 ) end 整数値!$acc parallel async(handle) or!$acc kernels async(handle)...!$acc wait(handle) 同期後 52 その他の OpenACC 構文 API 等 Data Declare Directives (data 構文を宣言文形式 ) device_resident clause Cache directives ( 最内側ループの変数をキャッシュ化 ) Executable Directives update directives ( 任意に Host GPU 間のデータの同期 ) wait directive Runtime Library Routine Environment Variables export ACC_DEVICE_TYPE=NVIDIA ( 使用デバイス名指定 ) export ACC_DEVICE_NUM=0 ( 使用デバイス番号指定 ) 53

28 OpenACC プログラミング例 54 三つの構文を使って並列化して見る!$acc data!$acc kernels!$acc loop do i = 1, n { 並列化可能なループ } end do!$acc end kernels!$acc end data Data 構文 Accelerate Compute 構文 Loop 構文 55

29 PGI コンパイラ OpenACC 用オプション OpenACC directive を認識 Fortran $ pgfortran acc Minfo fast {source}.f90 あるいは $ pgfortran ta=nvidia Minfo fast {source}.f90 (PGI Accelerator directives あるいは OpenACC directives を認識 ) C (C99) 現在 C++ には 実装していない $ pgcc acc Minfo fast {source}.c あるいは $ pgcc ta=nvidia Minfo fast {source}.c (PGI Accelerator directives あるいは OpenACC directives 認識 ) 56 PGI コンパイラ オプション -Minfo=accel Compiler Feedback jacobi: 215, Generating present_or_copyin(f(:,:)) Generating present_or_copy(u(:,:)) Generating local(resid) Generating local(uold(1:n,1:m)) 223, Generating compute capability 1.3 binary Generating compute capability 2.0 binary 225, Loop is parallelizable 227, Loop is parallelizable Accelerator kernel generated 225,!$acc loop gang! blockidx%x 227,!$acc loop vector(256)! threadidx%x データの転送に関して CC 1.3 : 14 registers; 76 shared, 12 constant, 0 local memory bytes; 100% occupancy CC 2.0 : 18 registers; 4 shared, 92 constant, 0 local memory bytes; 100% occupancy 233, Loop is parallelizable 235, Loop is parallelizable Accelerator kernel generated 233,!$acc loop gang(16), vector(16)! blockidx%y threadidx%y 235,!$acc loop gang, vector(16)! blockidx%x threadidx%x 並列化 block 分割に関して NVIDIA H/W 特性 CC 1.3 : 26 registers; 2176 shared, 36 constant, 0 local memory bytes; 50% occupancy CC 2.0 : 26 registers; 2056 shared, 144 constant, 0 local memory bytes; 66% occupancy 57

30 PGI 環境変数 PGI_ACC_TIME $export PGI_ACC_TIME=1 実行時に OpenACC 領域の実行プロファイル情報を出力する jacobi 223: region entered 100 times 単位 :μ 秒 time(us): total= init=10 region= kernels= data=0 w/o init: total= max=10787 min=10544 avg= : kernel launched 100 times grid: [5000] block: [256] time(us): total= max=2515 min=2508 avg= : kernel launched 100 times grid: [320x16] block: [16x16] time(us): total= max=7665 min=7628 avg= : kernel launched 100 times grid: [1] block: [256] time(us): total=1447 max=24 min=13 avg=14 driver 108: region entered 1 time time(us): total= init=94492 region= data= w/o init: total= max= min= avg= PGI 環境変数 ACC_NOTIFY $export ACC_NOTIFY=1 実行中 アクセラレータ上のkernel 動作実行履歴を出力する launch kernel file=/home/kato/jacobi4.f function=initialize line=154 device=0 grid=20 block=256 launch kernel file=/home/kato/jacobi4.f function=jacobi line=227 device=0 grid=5000 block=256 launch kernel file=/home/kato/jacobi4.f function=jacobi line=235 device=0 grid=320x16 block=16x16 launch kernel file=/home/kato/jacobi4.f function=jacobi line=240 device=0 grid=1 block=256 Kernel 実行が行われているか Kernel はどのような並列分割 (grid, thread block) で実行されているか 確認できる 59

31 ヤコビ反復プログラム例 error = 10.0 * tol k = 1 do while (k.le.maxit.and. error.gt. tol) error = 0.0!$omp parallel default(shared)!$omp do do j=1,m do i=1,n uold(i,j) = u(i,j)!$omp do private(resid) reduction(+:error) do j = 2,m-1 do i = 2,n-1 resid = (ax*(uold(i-1,j) + uold(i+1,j)) & & + ay*(uold(i,j-1) + uold(i,j+1)) + b * uold(i,j) - f(i,j))/b u(i,j) = uold(i,j) - omega * resid error = error + resid*resid end do!$omp nowait!$omp end parallel * Error check k = k + 1 error = sqrt(error)/dble(n*m)! End iteration loop 60 ヤコビ反復 (OpenMP) プログラム例 error = 10.0 * tol k = 1 do while (k.le.maxit.and. error.gt. tol) error = 0.0!$omp parallel default(shared)!$omp do do j=1,m do i=1,n uold(i,j) = u(i,j)!$omp do private(resid) reduction(+:error) do j = 2,m-1 do i = 2,n-1 resid = (ax*(uold(i-1,j) + uold(i+1,j)) & & + ay*(uold(i,j-1) + uold(i,j+1)) + b * uold(i,j) - f(i,j))/b u(i,j) = uold(i,j) - omega * resid error = error + resid*resid end do!$omp nowait!$omp end parallel * Error check k = k + 1 error = sqrt(error)/dble(n*m)! End iteration loop Work-sharing Work-sharing 61

32 まず Kernels directive を挿入してみる error = 10.0 * tol k = 1 収束判定ループ do while (k.le.maxit.and. error.gt. tol) error = 0.0!$acc kernels do j=1,m do i=1,n uold(i,j) = u(i,j) & & do j = 2,m-1 do i = 2,n-1 resid = (ax*(uold(i-1,j) + uold(i+1,j)) + ay*(uold(i,j-1) + uold(i,j+1)) + b * uold(i,j) - f(i,j))/b u(i,j) = uold(i,j) - omega * resid error = error + resid*resid end do!$acc end kernels 1 2 Accelerator 領域の開始 3 3 Accelerator 領域の終了 * Error check k = k + 1 error = sqrt(error)/dble(n*m)! End iteration loop コンパイラは 以下のコードを 動生成 GPU 上のメモリに配列データエリアをアロケートホスト側のデータをGPU 側へコピーするホスト側から kernel プログラムを起動する GPU 上で計算した結果をホスト側に戻す GPU 上のデータをデアロケート 問題は? データ転送回数 62 Data Directive を使用する error = 10.0 * tol k = 1!$acc data copy(u)!$acc+ copyin(f) create(uold) do while (k.le.maxit.and. error.gt. tol) error = 0.0 * Copy new solution into old!$acc kernels kernels 並列領域の開始 do j=1,m do i=1,n uold(i,j) = u(i,j) & & do j = 2,m-1 do i = 2,n-1 resid = (ax*(uold(i-1,j) + uold(i+1,j)) + ay*(uold(i,j-1) + uold(i,j+1)) + b * uold(i,j) - f(i,j))/b u(i,j) = uold(i,j) - omega * resid error = error + resid*resid end do!$acc end kernels 1 2 kernels 並列領域の終了 3 3 * Error check k = k + 1 error = sqrt(error)/dble(n*m)! End iteration loop!$acc end data region Accelerator データ領域 4 5 収束判定ループの外側で データ領域 を指定 GPU 上に使用データを 常駐 させる 収束ループが終了時に データをホストに戻す Host-GPU 間のデータ転送の削減 63

33 Loop Directives で並列動作を調整 error = 10.0 * tol k = 1!$acc data copy(u(1:n,1:m))!$acc+ copyin(f(1:n,1:m)) create(uold(1:n,1:m)) do while (k.le.maxit.and. error.gt. tol) error = 0.0 * Copy new solution into old!$acc kernels Accelerator 並列領域の開始 do j=1,m do i=1,n uold(i,j) = u(i,j)!$acc loop gang, vector(8) do j = 2,m-1!$acc loop gang, vector(8) do i = 2,n-1 resid = (ax*(uold(i-1,j) + uold(i+1,j)) & & + ay*(uold(i,j-1) + uold(i,j+1)) + b * uold(i,j) - f(i,j))/b u(i,j) = uold(i,j) - omega * resid error = error + resid*resid end do!$acc end kernels Accelerator 並列領域の終了 * Error check k = k + 1 error = sqrt(error)/dble(n*m)! End iteration loop!$acc end data region コンパイラは 動的に対象並列ループを CUDA の Thread-block/Grid に分割マッピングする ブロック分割等の mapping を変更することが可能 より良い性能を出すには gang, vector の並列スケジューリングを変えて試行錯誤が必要 64 コンパイラによるアクセラレータ翻訳情報 $ pgfortran -fast -Minfo=accel -acc jacobi.f -Minfo=accel : アクセラレータ翻訳情報 -acc : OpenACC 用コンパイル jacobi: 217, Generating local(uold(:,:)) Generating local(resid) Generating copyin(f(:,:)) Generating copy(u(:,:)) 235, Loop is parallelizable 237, Loop is parallelizable Accelerator kernel generated 235,!$acc loop gang vector(8)! blockidx%y threadidx%y 237,!$acc loop gang vector(8)! blockidx%x threadidx%x!$acc loop ( 235) do j = 2,m-1!$acc loop ( 237) do i= 2,n-1 ( 238) resid = (ax*(uold(i-1,j) + uold(i+1,j)) ( 239) & + ay*(uold(i,j-1) + uold(i,j+1)) ( 240) & + b * uold(i,j) - f(i,j))*b1b ( 241) u(i,j) = uold(i,j) - omega * resid ( 242) error = error + resid*resid ( 243) end do ( 244)!$acc end region CC 1.3 : 26 registers; 640 shared, 32 constant, 0 local memory bytes; 50% occupancy CC 2.0 : 26 registers; 520 shared, 144 constant, 0 local memory bytes; 33% occupancy 242, Sum reduction generated for error 65

34 Accelerator ループ マッピングを変更する 例えば Grid size (16 x16) Block size (16 x16) jacobi: 217, Generating local(uold(:,:)) Generating local(resid) Generating copyin(f(:n,:m)) Generating copy(u(:n,:m)) 235, Loop is parallelizable 237, Loop is parallelizable Accelerator kernel generated 235,!$acc loop gang(16), vector(16)! blockidx%y threadidx%y 237,!$acc loop gang(16), vector(16)! blockidx%y threadidx%y loop scheduling 節を変更!$acc loop gang(16) vector(16) ( 235) do j = 2,m-1!$acc loop gang(16) vector(16) ( 237) do i= 2,n-1 ( 238) resid = (ax*(uold(i-1,j) + uold(i+1,j)) ( 239) & + ay*(uold(i,j-1) + uold(i,j+1)) ( 240) & + b * uold(i,j) - f(i,j))*b1b ( 241) u(i,j) = uold(i,j) - omega * resid ( 242) error = error + resid*resid ( 243) end do ( 244)!$acc end region CC 1.3 : 26 registers; 2176 shared, 36 constant, 0 local memory bytes; 50% occupancy CC 2.0 : 26 registers; 2056 shared, 144 constant, 0 local memory bytes; 66% occupancy 242, Sum reduction generated for error 66 実行プロファイル情報で性能評価 loop scheduling(grid/block size) の変更で性能が変わる 235,!$acc loop gang, vector(8)! blockidx%y threadidx%y 237,!$acc loop gang, vector(8)! blockidx%x threadidx%x 237: kernel launched 100 times grid: [640x625] block: [8x8] time(us): total= max=12910 min=12872 avg= ,!$acc loop gang(16), vector(16)! blockidx%y threadidx%y 237,!$acc loop gang(16), vector(16)! blockidx%x threadidx%x 237: kernel launched 100 times grid: [16x16] block: [16x16] time(us): total= max=7501 min=7362 avg=7427 Device Name: GeForce GTX 580 ( 上記は倍精度計算 ) 全体の実行時間 :1.95 秒 全体の実行時間 :1.32 秒 67

35 OpenACC 実行性能サマリー ( 倍精度演算 ) OpenMP と OpenACC 時間 ( 秒 ) 倍率 OpenMP 1 core スレッド (without SSE vector) -O OpenMP 1 core スレッド (with SSE vector) -fastsse 8.18 OpenMP 4 core スレッド並列性能 7.75 x 1.0 OpenACC ( 対象ループに kernels 構文のみ挿入 ) OpenACC ( 繰返ループの外側に data 構文を挿入 ) 2.38 x 3.3 OpenACC ( 対象ループを loop 節で並列 mapping 調整 ) 1.46 OpenACC (mainプログラム上にdata 構文 & present 節使用 ) 1.32 x 5.9 OpenMP 性能 OpenACC 性能 : Intel(R) Core(TM) i GHz (Sandy-bridge) 4core : (Host) Intel(R) Core(TM) i7 CPU 2.67GHz (Nehalem) : (GPU) NVIDIA GeForce GTX 580 PGI 12.3 を使用 68 PGI OpenACC コンパイラのリリース PGI Accelerator Compiler 製品 (x64+gpu) 内に実装 現在 PGI 12.3/12.4/12.5 for Linux/Windows ベータ バージョン使用可能 PGI 12.6 にて 正式製品版リリース (Fortran/C99)(6 月下旬 ) PGI アクセラレータコンパイラ製品 (PGI Accelerator Fortran/C/C++) 1. OpenACC コンパイラ (Fortran, C99) 2. PGI Accelerator Programming Model (directiveベース) 3. PGI CUDA Fortran 4. PGI CUDA-x86 for C/C++ compatible& superset PGI アクセラレータ コンパイラソフテック情報サイト 69

36 終わり 70 付録 71

37 OpenACC directives TIPS for Maximum Performance 72 並列化を う対象は ループ (Nestedループ) である ループの iteration 計算において データ依存性が存在しないこと ループ カウントは GPU-CPU 間のデータ転送オーバーヘッドを無視できる程 十分な大きさが必要である ループ内の Compute Intensity(F.P. 演算数 / メモリアクセス数 ) が大きい程 性能加速性が高い 多次元配列を使用する場合は 素直な添字形式が良い 昔のベクトル機用最適化手法である 添字の1 次元化表現は 災い多し 多次元配列内の要素並びは 連続 であること Stride-1のアクセスができる演算形式は高いベクトル性能を得ることが可能 ループ内のポインタ演算は避けること ループ構造は rectangular 構成が望ましい Triangular Loop の場合は Host<->GPU 間のデータ転送に注意する While loop より for /do loop( 構造化ループ ) へ ループ内のローカル配列により依存性がある場合は 配列のプライベート化を図る Accelerator 領域では サブルーチン コールがある場合 並列化できない この場合は 当該ルーチン 関数のインライン展開を うこと NVIDIA GPUの場合 CUDA cores を常にビジーにするようなマルチスレッディングの状態を作り出せるような並列性を確保すること ( スレッド ブロックのサイズ グリッドの構成を調整 ) 73

38 配列インデックスの一次元化の使用 (1) ( 1) module arrays ( 2) implicit none ( 3) parameter M=2048, N=1024 ( 4) real(8),dimension(m*n):: a ( 5) real(8),dimension(m,n):: b ( 6) end module arrays ( 7) ( 8) program obstacle ( 9) use arrays ( 10) integer(4) :: i,j,idx ( 11) ( 12)!$acc kernels ( 13) do i = 1, M ( 14) do j = 1, N ( 15) idx = ((i-1)*m)+j ( 16) a(idx) = b(i,j) ( 17) ( 18) ( 19)!$acc end kernels ( 20) end program $ pgf90 -acc -Minfo obstacles.f90 obstacle: 12, Generating copyout(a(:)) Generating copyin(b(:,:)) 13, Parallelization would require privatization of array 'a(:)' 14, Parallelization would require privatization of array 'a(:)' Accelerator kernel generated 13,!$acc loop seq 14,!$acc loop seq シーケンシャル実行 too slow! ソースの引用は OpenAcc-standard.org から許可取得済 74 配列インデックスの一次元化の使用 (2) ( 1) module arrays ( 2) implicit none ( 3) parameter M=2048, N=1024 ( 4) real(8),dimension(m*n):: a ( 5) real(8),dimension(m,n):: b ( 6) end module arrays ( 7) ( 8) program obstacle ( 9) use arrays ( 10) integer(4) :: i,j,idx ( 20)!$acc kernels ( 21)!$acc loop independent ( 22) do i = 1, M ( 23) do j = 1, N ( 24) idx = ((i-1)*m)+j ( 25) a(idx) = b(i,j) ( 26) ( 27) ( 28)!$acc end kernels ( 29) end program $ pgf90 -acc -Minfo obstacles.f90 obstacle: 20, Generating copyout(a(:)) Generating copyin(b(:,:)) 強制的に並列化 22, Loop is parallelizable 23, Loop carried reuse of 'a' prevents parallelization Inner sequential loop scheduled on accelerator Accelerator kernel generated 22,!$acc loop gang, vector(256)! blockidx%x threadidx%x 23,!$acc loop seq ソースの引用は OpenAcc-standard.org から許可取得済 外側で並列化 しかし 効率が悪い! 75

39 配列インデックスの一次元化の使用 (3) ( 1) module arrays ( 2) implicit none ( 3) parameter M=2048, N=1024 ( 4) real(8),dimension(m*n):: a ( 5) real(8),dimension(m,n):: b ( 6) end module arrays ( 7) ( 8) program obstacle ( 9) use arrays ( 10) integer(4) :: i,j,idx ( 20)!$acc kernels ( 21) do i = 1, M ( 22)!$acc loop independent ( 23) do j = 1, N ( 24) idx = ((i-1)*m)+j ( 25) a(idx) = b(i,j) ( 26) ( 27) ( 28)!$acc end kernels ( 29) end program $ pgf90 -acc -Minfo obstacles.f90 obstacle: 20, Generating copyout(a(:)) Generating copyin(b(:,:)) 強制的に並列化 21, Parallelization would require privatization of array 'a(:)' 23, Loop is parallelizable Accelerator kernel generated 21,!$acc loop seq 23,!$acc loop gang, vector(256)! blockidx%x threadidx%x 内側で並列化 しかし 効率が悪い! ソースの引用は OpenAcc-standard.org から許可取得済 76 配列インデックスの一次元化の使用 (4) ( 1) module arrays ( 2) implicit none ( 3) parameter M=2048, N=1024 ( 4) real(8),dimension(m,n):: a ( 5) real(8),dimension(m,n):: b ( 6) end module arrays ( 7) ( 8) program obstacle ( 9) use arrays ( 10) integer(4) :: i,j,idx ( 11) ( 12)!$acc kernels ( 13) do j = 1, N ( 14) do i = 1, M ( 15) a(i,j) = b(i,j) ( 16) ( 17) ( 18)!$acc end kernels ( 19) end program 素直な添字に $ pgf90 -acc -Minfo obstacles2.f90 obstacle: 12, Generating copyout(a(:,:)) Generating copyin(b(:,:)) 13, Loop is parallelizable 14, Loop is parallelizable Accelerator kernel generated 13,!$acc loop gang, vector(16)! blockidx%y threadidx%y 14,!$acc loop gang, vector(16)! blockidx%x threadidx%x 外側 内側で並列化多数のスレッドを起動可能となる ソースの引用は OpenAcc-standard.org から許可取得済 77

40 ( 12)!$acc kernels ( 13) i = 0 ( 14) do, while (.not.found) ( 15) i = i + 1 ( 16) if (A(i).eq. 102) then ( 17) found = i ( 18) endif ( 19) ( 20)!$acc end kernels While Loops の使用 $ pgf90 -acc -Minfo while.f90 while: 12, Generating copyin(a(:)) 14, Loop carried scalar dependence for 'found' at line 19 Accelerator kernel generated 14,!$acc loop seq シーケンシャル実 too slow! Rectangular loop 形態に書き換える ( 12)!$acc kernels $ pgf90 -acc -Minfo while2.f90 ( 13) do i = 1, N while: ( 14) if (A(i).eq. 102) then 12, Generating copyin(a(:)) ( 15) found(i) = i Generating copyout(found(:)) ( 16) else 13, Loop is parallelizable ( 17) found(i) = 0 Accelerator kernel generated ( 18) endif 13,!$acc loop gang, vector(256) ( 19)! blockidx%x threadidx%x ( 20)!$acc end kernels 21, maxval reduction inlined ( 21) print *, 'Found at ', maxval(found) ソースの引用は OpenAcc-standard.org から許可取得済 78 Triangular Loops ( 11)!$acc kernels loop ( 12) do I = 1, M ( 13) do J = I, N Triangular loop ( 14) a(i,j) = i + j ( 15) ( 16) ( 17)!$acc end kernels ( 18) ( 19)!$acc kernels loop copy(a) ( 20) do I = 1, M ( 21) do J = I, N ( 22) a(i,j) = i + j ( 23) ( 24) ( 25)!$acc end kernels ( 26) end program $ pgf90 -acc -Minfo triangular.f90 tri: a 配列 :device ->host 転送 11, Generating copyout(a(:,:)) 12, Loop is parallelizable Accelerator kernel generated 12,!$acc loop gang, vector(36)! blockidx%x threadidx%x 13, Loop is parallelizable a 配列 : host-> device ->host 転送 19, Generating copy(a(:,:)) 20, Loop is parallelizable Accelerator kernel generated 20,!$acc loop gang, vector(36)! blockidx%x threadidx%x 21, Loop is parallelizable Triangular loop コンパイラは必要とするデータの転送しか わないホスト側のA 配列のLower triangle 明 的なデータ転送を指 する必要あり部分に ごみデータ が転送される (Visible device copy) ソースの引用は OpenAcc-standard.org から許可取得済 79

41 ( 11)!$acc kernels ( 12) do i = 1, M ( 13) do j = 1, N ( 14) idx = i+j ( 15) A(i,j) = idx ( 16) ( 17) ( 18)!$acc end kernels ( 19) print *, idx, A(1,1), A(M,N) スカラ idx をプライベート化内部的にローカル配列にプロモートする ( 11)!$acc kernels ( 12) do i = 1, M ( 13)!$acc loop private(idx) ( 14) do j = 1, N ( 15) idx = i+j ( 16) A(i,j) = idx ( 17) ( 18) ( 19)!$acc end kernels ( 20) print *, idx, A(1,1), A(M,N) ソースの引用は OpenAcc-standard.org から許可取得済 live-out スカラ変数 並列領域外でその値を参照する $ pgf90 -acc -Minfo live-out.f90 liveout: 11, Generating copyout(a(:,:)) 12, Loop is parallelizable 13, Inner sequential loop scheduled on accelerator Accelerator kernel generated 12,!$acc loop gang, vector(32)! blockidx%x threadidx%x 13,!$acc loop seq 14, Accelerator restriction: induction variable live-out from loop: idx 15, Accelerator restriction: induction variable live-out from loop: idx $ pgf90 -acc -Minfo live-out2.f90 liveout: 12, Loop is parallelizable 14, Loop is parallelizable Accelerator kernel generated 12,!$acc loop gang, vector(32)! blockidx%x threadidx%x 14,!$acc loop gang, vector(8)! blockidx%y threadidx%y 80 ローカル配列のプライベート化 (1) ( 12)!$acc kernels ( 13) do i = 1, M ( 14) do j = 1, N ( 15) do jj = 1, 10 ( 16) tmp(jj) = jj ( 17) end do ( 18) A(i,j) = sum(tmp) ( 19) ( 20) ( 21)!$acc end kernels tmp() 配列は i, j index に沿わない配列 $ pgf90 -acc -Minfo private.f90 private: 12, Generating copyout(a(:,:)) Generating copyout(tmp(:)) 13, Parallelization would require privatization of array 'tmp(:)' 14, Parallelization would require privatization of array 'tmp(:)' Accelerator kernel generated 13,!$acc loop seq IループとJループで並列化されない 14,!$acc loop seq 15, Loop is parallelizable 18, sum reduction inlined Loop is parallelizable ソースの引用は OpenAcc-standard.org から許可取得済 並列領域外でその値を参照する 81

42 ローカル配列のプライベート化 (2) ( 12)!$acc kernels ( 13) do i = 1, M ( 14)!$acc loop private(tmp) ( 15) do j = 1, N ( 16) do jj = 1, 10 ( 17) tmp(jj) = jj ( 18) end do ( 19) A(i,j) = sum(tmp) ( 20) ( 21) ( 22)!$acc end kernels tmp() 配列を j index を有する 2 次元配列にプロモート $ pgf90 -acc -Minfo private2.f90 private: 12, Generating copyout(a(:,:)) 13, Loop is parallelizable 15, Loop is parallelizable Accelerator kernel generated 13,!$acc loop gang, vector(16)! blockidx%x threadidx%x 15,!$acc loop gang, vector(16)! blockidx%y threadidx%y 16, Loop is parallelizable 19, sum reduction inlined Loop is parallelizable ソースの引用は OpenAcc-standard.org から許可取得済 82 関数 サブルーチンの呼び出し 並列化対象ループ内に 関数 サブルーチン が存在すると並列化できない これは GPUデバイス側の制約である device 用の linker が 存在してないこととハードウェアのサポートが無いことに因る ループ内に関数等をインライン展開する必要がある 手動でソース上でインライン展開 コンパイラオプション Minline or Mipa=inline で自動インライン function domul (x,y) result(mul) real(4) :: x,y real(4) :: mul mul = x*y end function!$acc kernels do i = 1,100 a(i) = float(i) * do i = 1,100 b(i) = domul(a(i),a(i))!$acc end kernels 並列化不可 83

43 ループ内の Function Call ( 1) function domul (x,y) result(mul) ( 2) real(4) :: x,y ( 3) real(4) :: mul ( 4) mul = x*y ( 5) end function ( 7) program main ( 8) real(4) :: a(100), b(100) ( 9)!$acc kernels ( 10) do i = 1,100 ( 11) a(i) = float(i) * ( 12) ( 14) do i = 1,100 ( 15) b(i) = domul(a(i),a(i)) ( 16) ( 17)!$acc end kernels ( 18) print *, b ( 19) end 並列化できず $ pgf90 -fast -acc -Minfo function_call.f90 PGF90-W-0155-Accelerator region ignored; see -Minfo messages (function_call.f90: 9) main: 9, Accelerator region ignored 14, Accelerator restriction: function/procedure calls are not supported 15, Accelerator restriction: unsupported call to 'domul' 84 Function Call ( 自動インライン化 -Minline) ( 7) program main ( 8) real(4) :: a(100), b(100) ( 9)!$acc kernels ( 10) do i = 1,100 ( 11) a(i) = float(i) * ( 12) ( 14) do i = 1,100 ( 15) b(i) = domul(a(i),a(i)) ( 16) ( 17)!$acc end kernels 自動インライン $ pgf90 -fast -acc -Minfo function_call.f90 -Minline main: 9, Generating copyout(b(:)) Generating copyout(a(:)) 10, Loop is parallelizable Accelerator kernel generated 10,!$acc loop gang, vector(96)! blockidx%x threadidx%x 14, Loop is parallelizable Accelerator kernel generated 並列化されたインライン化 14,!$acc loop gang, vector(96)! blockidx%x threadidx%x 15, domul inlined, size=2, file function_call.f90 (1) 85

44 Function Call (-Mipa=inline 使用 ) Filename: function_call_sub2.f90 ( 1) subroutine domul (x,y,mul) ( 2) real(4) :: x(100),y(100) ( 3) real(4) :: mul(100) ( 4) do i=1, 100 ( 5) mul(i) = x(i)*y(i) ( 6) end do ( 7) end subroutine -Mipa=inline を使ってインライン化 動インラインファイル名が異なる つのファイル間を Filename: function_call2.f90 ( 1) program main ( 2) real(4) :: a(100), b(100) ( 3)!$acc kernels ( 4) do i = 1,100 ( 5) a(i) = float(i) * ( 6) ( 7) ( 8) call domul (a,a,b) ( 9)!$acc end kernels ( 10) print *, b(1),b(100) ( 11) end 自$ pgf90 -fast -acc -Mipa=inline -Minfo function_call_sub2.f90 -c $ pgf90 -fast -acc -Mipa=inline -Minfo function_call_sub2.o function_call2.f90 IPA: no IPA optimizations for 1 source files IPA: Recompiling function_call2.o: stale object file main: 3, Generating copyout(a(:)) Generating copyout(b(:)) 4, Loop is parallelizable Accelerator kernel generated 4,!$acc loop gang, vector(96)! blockidx%x threadidx%x 8, domul inlined, size=5 (IPA) file function_call_sub2.f90 (1) 8, Loop is parallelizable Accelerator kernel generated 8,!$acc loop gang, vector(96)! blockidx%x threadidx%x 手続間最適化 IPA 86 ポインタを利用した演算を避ける (C 言語 ) Accelerate Compute 領域内のポインタを利用した演算ループは 並列化できない void memcpy(float *restrict A, *restrict B, int count) { float* ptra =A; float* ptrb =B; while (count --) { *ptra++ = *ptrb++; } return; } ソースの引用は OpenAcc-standard.org から許可取得済 void memcpy(float *restrict A, *restrict B, int count) { #pragma acc kernels { for ( int i=0 ; i <count; ++i ) { A[i] = B[i] ; } } return; 配列は添字表現へ 87

45 restrict 修飾子の利用 (C 言語 ) void vec_add_gpu( float *restrict r, float *a, float *b, int n ) { #pragma acc kernels for copyin(a[0:n],b[0:n]) copyout(r[0:n]) for( int i = 0; i < n; ++i ) r[i] = a[i] + b[i]; } float *restrict r : C99 restrict 修飾子の利用 C 言語は ポインタをかなり自由に使える言語であり 別名なども自由使用できる 各ポインタ間のオーバーラップもあり得る こうしたことが コンパイラの最適化を妨げる原因となっている *restrict を指定して 演算における データの依存性 競合 がないことをコンパイラに指示するために使用する もちろん 依存性がある場合は 並列化はできないため *restrict を使用してはならない 88 ランタイム エラー (Device error) call to cumemcpydtoh returned error 700: Launch failed!$acc region do i = 1, M do j = 1, N A(i,j) = B(i,j+1) << 配列境界外!$acc end region GPU 上で実行時 配列境界を越えたアクセスにより ランタイムがエラーを返した -Mbounds オプションで実 時チェック call to cumemcpy2d returned error 1: Invalid value parameter(n=1024,m=512) real :: A(M,N), B(M,N)...!$acc kernels loop copyout(a), copyin(b(0:n,1:m+1)) <<< Bad bounds for the copyin do i = 1, M do j = 1, N A(i,j) = B(i,j+1)!$acc end region 添字の誤り GPU デバイスへデータ転送時のディレクティブの記述ミス 89

46 PGI コンパイラ製品情報 URL ソフテック PGI コンパイラ製品ホームページ PGI アクセラレータ製品概要 PGI コンパイラ技術コラム PGI Accelerator Programming Model を使う CUBLAS CUFFT を CUDA Fortran から使う MPI 並列の話 その他 90 本ドキュメントに記述された各製品名は 各社の商標または登録商標です Copyright 2012 SofTek Systems Inc. All Rights Reserved. 91

Microsoft PowerPoint - GTC2012-SofTek.pptx

Microsoft PowerPoint - GTC2012-SofTek.pptx GTC Japan 2012 PGI Accelerator Compiler 実践! PGI OpenACC ディレクティブを使用したポーティング 2012 年 7 月 加藤努株式会社ソフテック 本日の話 OpenACC によるポーティングの実際 OpenACC ディレクティブ概略説明 Accelerator Programming Model Fortran プログラムによるポーティング ステップ三つのディレクティブの利用性能チューニング

More information

スライド 1

スライド 1 GTC Japan 2013 PGI Accelerator Compiler 新 OpenACC 2.0 の機能と PGI アクセラレータコンパイラ 2013 年 7 月 加藤努株式会社ソフテック 本日の話 OpenACC ディレクティブで出来ることを改めて知ろう! OpenACC 1.0 の復習 ディレクティブ操作で出来ることを再確認 OpenACC 2.0 の新機能 プログラミングの自由度の向上へ

More information

GPU チュートリアル :OpenACC 篇 Himeno benchmark を例題として 高エネルギー加速器研究機構 (KEK) 松古栄夫 (Hideo Matsufuru) 1 December 2018 HPC-Phys 理化学研究所 共通コードプロジェクト

GPU チュートリアル :OpenACC 篇 Himeno benchmark を例題として 高エネルギー加速器研究機構 (KEK) 松古栄夫 (Hideo Matsufuru) 1 December 2018 HPC-Phys 理化学研究所 共通コードプロジェクト GPU チュートリアル :OpenACC 篇 Himeno benchmark を例題として 高エネルギー加速器研究機構 (KEK) 松古栄夫 (Hideo Matsufuru) 1 December 2018 HPC-Phys 勉強会 @ 理化学研究所 共通コードプロジェクト Contents Hands On 環境について Introduction to GPU computing Introduction

More information

Microsoft PowerPoint - GPGPU実践基礎工学(web).pptx

Microsoft PowerPoint - GPGPU実践基礎工学(web).pptx GPU のプログラム構造 長岡技術科学大学電気電子情報工学専攻出川智啓 今回の内容 GPU プログラミング環境 (CUDA) GPU プログラムの実行の流れ CUDA によるプログラムの記述 カーネル (GPU で処理する関数 ) の構造 記述方法とその理由 GPU 固有のパラメータの確認 405 GPU(Graphics Processing Unit) とは 画像処理専用のハードウェア 具体的には画像処理用のチップ

More information

TSUBAME2.0 における GPU の 活用方法 東京工業大学学術国際情報センター丸山直也第 10 回 GPU コンピューティング講習会 2011 年 9 月 28 日

TSUBAME2.0 における GPU の 活用方法 東京工業大学学術国際情報センター丸山直也第 10 回 GPU コンピューティング講習会 2011 年 9 月 28 日 TSUBAME2.0 における GPU の 活用方法 東京工業大学学術国際情報センター丸山直也第 10 回 GPU コンピューティング講習会 2011 年 9 月 28 日 目次 1. TSUBAMEのGPU 環境 2. プログラム作成 3. プログラム実行 4. 性能解析 デバッグ サンプルコードは /work0/gsic/seminars/gpu- 2011-09- 28 からコピー可能です 1.

More information

CUDA 連携とライブラリの活用 2

CUDA 連携とライブラリの活用 2 1 09:30-10:00 受付 10:00-12:00 Reedbush-H ログイン GPU 入門 13:30-15:00 OpenACC 入門 15:15-16:45 OpenACC 最適化入門と演習 17:00-18:00 OpenACC の活用 (CUDA 連携とライブラリの活用 ) CUDA 連携とライブラリの活用 2 3 OpenACC 簡単にGPUプログラムが作成できる それなりの性能が得られる

More information

PGIコンパイラ導入手順

PGIコンパイラ導入手順 1 注意この資料は PGI compiler 18.10 が最新であるときに作成した資料を元にしています PGI compiler 19.4 がリリースされましたが インストール手順や利用手順は 18.10 と変わりません 資料中の 1810 を 194 に 18.10 を 19.4 に読み替えてください 2019 年 6 月版 2 大きく分けて以下の 3 つの方法が利用可能 1. 手元のウェブブラウザでダウンロードして

More information

Microsoft PowerPoint - GPU_computing_2013_01.pptx

Microsoft PowerPoint - GPU_computing_2013_01.pptx GPU コンピューティン No.1 導入 東京工業大学 学術国際情報センター 青木尊之 1 GPU とは 2 GPGPU (General-purpose computing on graphics processing units) GPU を画像処理以外の一般的計算に使う GPU の魅力 高性能 : ハイエンド GPU はピーク 4 TFLOPS 超 手軽さ : 普通の PC にも装着できる 低価格

More information

Slides: TimeGraph: GPU Scheduling for Real-Time Multi-Tasking Environments

Slides: TimeGraph: GPU Scheduling for Real-Time Multi-Tasking Environments 計算機アーキテクチャ第 11 回 マルチプロセッサ 本資料は授業用です 無断で転載することを禁じます 名古屋大学 大学院情報科学研究科 准教授加藤真平 デスクトップ ジョブレベル並列性 スーパーコンピュータ 並列処理プログラム プログラムの並列化 for (i = 0; i < N; i++) { x[i] = a[i] + b[i]; } プログラムの並列化 x[0] = a[0] + b[0];

More information

概要 OpenACC とは OpenACC について OpenMP, CUDA との違い OpenACC の指示文 並列化領域指定指示文 (kernels/parallel) データ移動指示文 ループ指示文 OpenACC の実用例 実習 コンパイラメッセージの見方 OpenACC プログラムの実装

概要 OpenACC とは OpenACC について OpenMP, CUDA との違い OpenACC の指示文 並列化領域指定指示文 (kernels/parallel) データ移動指示文 ループ指示文 OpenACC の実用例 実習 コンパイラメッセージの見方 OpenACC プログラムの実装 第 74 回お試しアカウント付き 並列プログラミング講習会 GPU プログラミング入門 in 名古屋 星野哲也 ( 助教 ) hoshino@cc.u-tokyo.ac.jp 大島聡史 ( 助教 ) ohshima@cc.u-tokyo.ac.jp 2016 年 3 月 14 日 ( 火 ) 東京大学情報基盤センター 概要 OpenACC とは OpenACC について OpenMP, CUDA との違い

More information

OpenACCによる並列化

OpenACCによる並列化 実習 OpenACC による ICCG ソルバーの並列化 1 ログイン Reedbush へのログイン $ ssh reedbush.cc.u-tokyo.ac.jp l txxxxx Module のロード $ module load pgi/17.3 cuda ログインするたびに必要です! ワークディレクトリに移動 $ cdw ターゲットプログラム /srcx OpenACC 用のディレクトリの作成

More information

Slide 1

Slide 1 CUDA プログラミングの基本 パート II - カーネル CUDA の基本の概要 パート I CUDAのソフトウェアスタックとコンパイル GPUのメモリ管理 パート II カーネルの起動 GPUコードの具体像 注 : 取り上げているのは基本事項のみです そのほか多数の API 関数についてはプログラミングガイドを ご覧ください GPU 上でのコードの実行 カーネルは C 関数 + 多少の制約 ホストメモリはアクセスできない戻り値型は

More information

1. GPU コンピューティング GPU コンピューティング GPUによる 汎用コンピューティング GPU = Graphics Processing Unit CUDA Compute Unified Device Architecture NVIDIA の GPU コンピューティング環境 Lin

1. GPU コンピューティング GPU コンピューティング GPUによる 汎用コンピューティング GPU = Graphics Processing Unit CUDA Compute Unified Device Architecture NVIDIA の GPU コンピューティング環境 Lin Windows で始める CUDA 入門 GTC 2013 チュートリアル エヌビディアジャパン CUDA エンジニア森野慎也 1. GPU コンピューティング GPU コンピューティング GPUによる 汎用コンピューティング GPU = Graphics Processing Unit CUDA Compute Unified Device Architecture NVIDIA の GPU コンピューティング環境

More information

Microsoft PowerPoint - 03_What is OpenMP 4.0 other_Jan18

Microsoft PowerPoint - 03_What is OpenMP 4.0 other_Jan18 OpenMP* 4.x における拡張 OpenMP 4.0 と 4.5 の機能拡張 内容 OpenMP* 3.1 から 4.0 への拡張 OpenMP* 4.0 から 4.5 への拡張 2 追加された機能 (3.1 -> 4.0) C/C++ 配列シンタックスの拡張 SIMD と SIMD 対応関数 デバイスオフロード task 構 の依存性 taskgroup 構 cancel 句と cancellation

More information

Microsoft PowerPoint - GDEP-GPG_softek_May24-1.pptx

Microsoft PowerPoint - GDEP-GPG_softek_May24-1.pptx G-DEP 第 3 回セミナー ツールで始める GPGPU なぜ ディレクティブベースのプログラミングが有望なのか? 失敗しない並列プログラミングの始め 2012 年 5 月 加藤努株式会社ソフテック なぜ GPU プログラミング? GPU computing 時代の本流に! 今 何が起きているのか? HPC アーキテクチャはどこへ向かうのか? 確実に移行中 Why? CPU + GPU ハイブリッド型へ

More information

Microsoft PowerPoint - suda.pptx

Microsoft PowerPoint - suda.pptx GPU の HWアーキテクチャと高性能化手法 須田礼仁 ( 東京大学 ) 2011/03/22 GPU 高性能プログラミング GPU のハードウェアを理解する CUDA のソフトウェアを理解する CUDA でプログラムを書くのは難しくないが, CUDA で高速なプログラムを書くのは難しい どうすれば遅くなるかを理解する! 効果が大きいものから順に説明します 1 高性能プログラミングの手順 1. 現在のコードの,

More information

07-二村幸孝・出口大輔.indd

07-二村幸孝・出口大輔.indd GPU Graphics Processing Units HPC High Performance Computing GPU GPGPU General-Purpose computation on GPU CPU GPU GPU *1 Intel Quad-Core Xeon E5472 3.0 GHz 2 6 MB L2 cache 1600 MHz FSB 80 GFlops 1 nvidia

More information

CUDA を用いた画像処理 画像処理を CUDA で並列化 基本的な並列化の考え方 目標 : 妥当な Naïve コードが書ける 最適化の初歩がわかる ブロックサイズ メモリアクセスパターン

CUDA を用いた画像処理 画像処理を CUDA で並列化 基本的な並列化の考え方 目標 : 妥当な Naïve コードが書ける 最適化の初歩がわかる ブロックサイズ メモリアクセスパターン CUDA 画像処理入門 エヌビディアジャパン CUDA エンジニア森野慎也 GTC Japan 2014 CUDA を用いた画像処理 画像処理を CUDA で並列化 基本的な並列化の考え方 目標 : 妥当な Naïve コードが書ける 最適化の初歩がわかる ブロックサイズ メモリアクセスパターン RGB Y( 輝度 ) 変換 カラー画像から グレイスケールへの変換 Y = 0.299 R + 0.587

More information

1 OpenCL OpenCL 1 OpenCL GPU ( ) 1 OpenCL Compute Units Elements OpenCL OpenCL SPMD (Single-Program, Multiple-Data) SPMD OpenCL work-item work-group N

1 OpenCL OpenCL 1 OpenCL GPU ( ) 1 OpenCL Compute Units Elements OpenCL OpenCL SPMD (Single-Program, Multiple-Data) SPMD OpenCL work-item work-group N GPU 1 1 2 1, 3 2, 3 (Graphics Unit: GPU) GPU GPU GPU Evaluation of GPU Computing Based on An Automatic Program Generation Technology Makoto Sugawara, 1 Katsuto Sato, 1 Kazuhiko Komatsu, 2 Hiroyuki Takizawa

More information

演習1: 演習準備

演習1: 演習準備 演習 1: 演習準備 2013 年 8 月 6 日神戸大学大学院システム情報学研究科森下浩二 1 演習 1 の内容 神戸大 X10(π-omputer) について システム概要 ログイン方法 コンパイルとジョブ実行方法 OpenMP の演習 ( 入門編 ) 1. parallel 構文 実行時ライブラリ関数 2. ループ構文 3. shared 節 private 節 4. reduction 節

More information

Vol.214-HPC-145 No /7/3 C #pragma acc directive-name [clause [[,] clause] ] new-line structured block Fortran!$acc directive-name [clause [[,] c

Vol.214-HPC-145 No /7/3 C #pragma acc directive-name [clause [[,] clause] ] new-line structured block Fortran!$acc directive-name [clause [[,] c Vol.214-HPC-145 No.45 214/7/3 OpenACC 1 3,1,2 1,2 GPU CUDA OpenCL OpenACC OpenACC High-level OpenACC CPU Intex Xeon Phi K2X GPU Intel Xeon Phi 27% K2X GPU 24% 1. TSUBAME2.5 CPU GPU CUDA OpenCL CPU OpenMP

More information

01_OpenMP_osx.indd

01_OpenMP_osx.indd OpenMP* / 1 1... 2 2... 3 3... 5 4... 7 5... 9 5.1... 9 5.2 OpenMP* API... 13 6... 17 7... 19 / 4 1 2 C/C++ OpenMP* 3 Fortran OpenMP* 4 PC 1 1 9.0 Linux* Windows* Xeon Itanium OS 1 2 2 WEB OS OS OS 1 OS

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション 1 サンプルソースコードは ITO の /home/tmp/gpu 以下に置いてあります 実質的に 演習の答え となるものもあるので注意 PGI compiler 19.4 で実行した場合の出力に準拠 18.10 でも 19.4 でも基本的には同じであるが 18.10 では出力されていた Accelerator kernel generated ( 並列実行カーネルが作成できた旨 ) が出力されなくなったことを反映

More information

NUMAの構成

NUMAの構成 GPU のプログラム 天野 アクセラレータとは? 特定の性質のプログラムを高速化するプロセッサ 典型的なアクセラレータ GPU(Graphic Processing Unit) Xeon Phi FPGA(Field Programmable Gate Array) 最近出て来た Deep Learning 用ニューロチップなど Domain Specific Architecture 1GPGPU:General

More information

ストリームを用いたコンカレントカーネルプログラミングと最適化 エヌビディアジャパン CUDAエンジニア森野慎也 GTC Japan 2014

ストリームを用いたコンカレントカーネルプログラミングと最適化 エヌビディアジャパン CUDAエンジニア森野慎也 GTC Japan 2014 ストリームを用いたコンカレントカーネルプログラミングと最適化 エヌビディアジャパン CUDAエンジニア森野慎也 GTC Japan 2014 コンカレントな処理の実行 システム内部の複数の処理を 平行に実行する CPU GPU メモリ転送 カーネル実行 複数のカーネル間 ストリーム GPU 上の処理キュー カーネル実行 メモリ転送の並列性 実行順序 DEFAULT STREAM Stream : GPU

More information

インテル(R) Visual Fortran Composer XE 2013 Windows版 入門ガイド

インテル(R) Visual Fortran Composer XE 2013 Windows版 入門ガイド Visual Fortran Composer XE 2013 Windows* エクセルソフト株式会社 www.xlsoft.com Rev. 1.1 (2012/12/10) Copyright 1998-2013 XLsoft Corporation. All Rights Reserved. 1 / 53 ... 3... 4... 4... 5 Visual Studio... 9...

More information

GPU GPU CPU CPU CPU GPU GPU N N CPU ( ) 1 GPU CPU GPU 2D 3D CPU GPU GPU GPGPU GPGPU 2 nvidia GPU CUDA 3 GPU 3.1 GPU Core 1

GPU GPU CPU CPU CPU GPU GPU N N CPU ( ) 1 GPU CPU GPU 2D 3D CPU GPU GPU GPGPU GPGPU 2 nvidia GPU CUDA 3 GPU 3.1 GPU Core 1 GPU 4 2010 8 28 1 GPU CPU CPU CPU GPU GPU N N CPU ( ) 1 GPU CPU GPU 2D 3D CPU GPU GPU GPGPU GPGPU 2 nvidia GPU CUDA 3 GPU 3.1 GPU Core 1 Register & Shared Memory ( ) CPU CPU(Intel Core i7 965) GPU(Tesla

More information

HPC143

HPC143 研究背景 GPUクラスタ 高性能 高いエネルギー効率 低価格 様々なHPCアプリケーションで用いられている TCA (Tightly Coupled Accelerators) 密結合並列演算加速機構 筑波大学HA-PACSクラスタ アクセラレータ GPU 間の直接通信 低レイテンシ 今後のHPCアプリは強スケーリングも重要 TCAとアクセラレータを搭載したシステムに おけるプログラミングモデル 例

More information

PowerPoint Presentation

PowerPoint Presentation ヘテロジニアスな環境におけるソフトウェア開発 Agenda 今日の概要 ヘテロジニアスな環境の登場 ホモジニアスからヘテロジニアスへ ヘテロジニアスなアーキテクチャ GPU CUDA OpenACC, XeonPhi 自分のプログラムを理解するために デバッガ 共通の操作体験 TotalView 続きはブースで より速く ホモジーニアスな並列 HPC 銀河生成 金融のリスク計算 車の衝突解析 製薬

More information

OpenMP¤òÍѤ¤¤¿ÊÂÎó·×»»¡Ê£±¡Ë

OpenMP¤òÍѤ¤¤¿ÊÂÎó·×»»¡Ê£±¡Ë 2012 5 24 scalar Open MP Hello World Do (omp do) (omp workshare) (shared, private) π (reduction) PU PU PU 2 16 OpenMP FORTRAN/C/C++ MPI OpenMP 1997 FORTRAN Ver. 1.0 API 1998 C/C++ Ver. 1.0 API 2000 FORTRAN

More information

OpenACC

OpenACC 109 OpenMP/OpenACC, hoshino @ cc.u-tokyo.ac.jp nakajima @ cc.u-tokyo.ac.jp 1 n Reedbush n $ ssh -Y reedbush.cc.u-tokyo.ac.jp l txxxxx n module n $ module load pgi/18.7 # n n $ cdw n OpenACC_samples n $

More information

OpenMP¤òÍѤ¤¤¿ÊÂÎó·×»»¡Ê£±¡Ë

OpenMP¤òÍѤ¤¤¿ÊÂÎó·×»»¡Ê£±¡Ë 2011 5 26 scalar Open MP Hello World Do (omp do) (omp workshare) (shared, private) π (reduction) scalar magny-cours, 48 scalar scalar 1 % scp. ssh / authorized keys 133. 30. 112. 246 2 48 % ssh 133.30.112.246

More information

CPU Levels in the memory hierarchy Level 1 Level 2... Increasing distance from the CPU in access time Level n Size of the memory at each level 1: 2.2

CPU Levels in the memory hierarchy Level 1 Level 2... Increasing distance from the CPU in access time Level n Size of the memory at each level 1: 2.2 FFT 1 Fourier fast Fourier transform FFT FFT FFT 1 FFT FFT 2 Fourier 2.1 Fourier FFT Fourier discrete Fourier transform DFT DFT n 1 y k = j=0 x j ω jk n, 0 k n 1 (1) x j y k ω n = e 2πi/n i = 1 (1) n DFT

More information

Microsoft PowerPoint - OpenMP入門.pptx

Microsoft PowerPoint - OpenMP入門.pptx OpenMP 入門 須田礼仁 2009/10/30 初版 OpenMP 共有メモリ並列処理の標準化 API http://openmp.org/ 最新版は 30 3.0 バージョンによる違いはあまり大きくない サポートしているバージョンはともかく csp で動きます gcc も対応しています やっぱり SPMD Single Program Multiple Data プログラム #pragma omp

More information

Slide 1

Slide 1 CUDA プログラミングの基本 パート I - ソフトウェアスタックとメモリ管理 CUDA の基本の概要 パート I CUDAのソフトウェアスタックとコンパイル GPUのメモリ管理 パートII カーネルの起動 GPUコードの具体項目 注 : 取り上げているのは基本事項のみです そのほか多数の API 関数についてはプログラミングガイドを ご覧ください CUDA インストレーション CUDA インストレーションの構成

More information

Microsoft PowerPoint - KHPCSS pptx

Microsoft PowerPoint - KHPCSS pptx KOBE HPC サマースクール 2018( 初級 ) 9. 1 対 1 通信関数, 集団通信関数 2018/8/8 KOBE HPC サマースクール 2018 1 2018/8/8 KOBE HPC サマースクール 2018 2 MPI プログラム (M-2):1 対 1 通信関数 問題 1 から 100 までの整数の和を 2 並列で求めなさい. プログラムの方針 プロセス0: 1から50までの和を求める.

More information

! 行行 CPUDSP PPESPECell/B.E. CPUGPU 行行 SIMD [SSE, AltiVec] 用 HPC CPUDSP PPESPE (Cell/B.E.) SPE CPUGPU GPU CPU DSP DSP PPE SPE SPE CPU DSP SPE 2

! 行行 CPUDSP PPESPECell/B.E. CPUGPU 行行 SIMD [SSE, AltiVec] 用 HPC CPUDSP PPESPE (Cell/B.E.) SPE CPUGPU GPU CPU DSP DSP PPE SPE SPE CPU DSP SPE 2 ! OpenCL [Open Computing Language] 言 [OpenCL C 言 ] CPU, GPU, Cell/B.E.,DSP 言 行行 [OpenCL Runtime] OpenCL C 言 API Khronos OpenCL Working Group AMD Broadcom Blizzard Apple ARM Codeplay Electronic Arts Freescale

More information

1.overview

1.overview 村井均 ( 理研 ) 2 はじめに 規模シミュレーションなどの計算を うためには クラスタのような分散メモリシステムの利 が 般的 並列プログラミングの現状 半は MPI (Message Passing Interface) を利 MPI はプログラミングコストが きい 標 性能と 産性を兼ね備えた並列プログラミング 語の開発 3 並列プログラミング 語 XcalableMP 次世代並列プログラミング

More information

XACCの概要

XACCの概要 2 global void kernel(int a[max], int llimit, int ulimit) {... } : int main(int argc, char *argv[]){ MPI_Int(&argc, &argc); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); dx

More information

3次多項式パラメタ推定計算の CUDAを用いた実装 (CUDAプログラミングの練習として) Implementation of the Estimation of the parameters of 3rd-order-Polynomial with CUDA

3次多項式パラメタ推定計算の CUDAを用いた実装 (CUDAプログラミングの練習として)  Implementation of the Estimation of the parameters of 3rd-order-Polynomial with CUDA 3 次多項式パラメタ推定計算の CUDA を用いた実装 (CUDA プログラミングの練習として ) Estimating the Parameters of 3rd-order-Polynomial with CUDA ISS 09/11/12 問題の選択 目的 CUDA プログラミングを経験 ( 試行錯誤と習得 ) 実際に CPU のみの場合と比べて高速化されることを体験 問題 ( インプリメントする内容

More information

Microsoft Word - openmp-txt.doc

Microsoft Word - openmp-txt.doc ( 付録 A) OpenMP チュートリアル OepnMP は 共有メモリマルチプロセッサ上のマルチスレッドプログラミングのための API です 本稿では OpenMP の簡単な解説とともにプログラム例をつかって説明します 詳しくは OpenMP の規約を決めている OpenMP ARB の http://www.openmp.org/ にある仕様書を参照してください 日本語訳は http://www.hpcc.jp/omni/spec.ja/

More information

GPGPU

GPGPU GPGPU 2013 1008 2015 1 23 Abstract In recent years, with the advance of microscope technology, the alive cells have been able to observe. On the other hand, from the standpoint of image processing, the

More information

概要 目的 CUDA Fortran の利用に関する基本的なノウハウを提供する 本チュートリアル受講後は Web 上で公開されている資料等を参照しながら独力で CUDA Fortran が利用できることが目標 対象 CUDA Fortran の利用に興味を抱いている方 前提とする知識 Fortran

概要 目的 CUDA Fortran の利用に関する基本的なノウハウを提供する 本チュートリアル受講後は Web 上で公開されている資料等を参照しながら独力で CUDA Fortran が利用できることが目標 対象 CUDA Fortran の利用に興味を抱いている方 前提とする知識 Fortran CUDA Fortran チュートリアル 2010 年 9 月 29 日 NEC 概要 目的 CUDA Fortran の利用に関する基本的なノウハウを提供する 本チュートリアル受講後は Web 上で公開されている資料等を参照しながら独力で CUDA Fortran が利用できることが目標 対象 CUDA Fortran の利用に興味を抱いている方 前提とする知識 Fortran を用いた Linux

More information

( CUDA CUDA CUDA CUDA ( NVIDIA CUDA I

(    CUDA CUDA CUDA CUDA (  NVIDIA CUDA I GPGPU (II) GPGPU CUDA 1 GPGPU CUDA(CUDA Unified Device Architecture) CUDA NVIDIA GPU *1 C/C++ (nvcc) CUDA NVIDIA GPU GPU CUDA CUDA 1 CUDA CUDA 2 CUDA NVIDIA GPU PC Windows Linux MaxOSX CUDA GPU CUDA NVIDIA

More information

<4D F736F F F696E74202D D F95C097F D834F E F93FC96E5284D F96E291E85F8DE391E52E >

<4D F736F F F696E74202D D F95C097F D834F E F93FC96E5284D F96E291E85F8DE391E52E > SX-ACE 並列プログラミング入門 (MPI) ( 演習補足資料 ) 大阪大学サイバーメディアセンター日本電気株式会社 演習問題の構成 ディレクトリ構成 MPI/ -- practice_1 演習問題 1 -- practice_2 演習問題 2 -- practice_3 演習問題 3 -- practice_4 演習問題 4 -- practice_5 演習問題 5 -- practice_6

More information

XcalableMP入門

XcalableMP入門 XcalableMP 1 HPC-Phys@, 2018 8 22 XcalableMP XMP XMP Lattice QCD!2 XMP MPI MPI!3 XMP 1/2 PCXMP MPI Fortran CCoarray C++ MPIMPI XMP OpenMP http://xcalablemp.org!4 XMP 2/2 SPMD (Single Program Multiple Data)

More information

コードのチューニング

コードのチューニング OpenMP による並列化実装 八木学 ( 理化学研究所計算科学研究センター ) KOBE HPC Spring School 2019 2019 年 3 月 14 日 スレッド並列とプロセス並列 スレッド並列 OpenMP 自動並列化 プロセス並列 MPI プロセス プロセス プロセス スレッドスレッドスレッドスレッド メモリ メモリ プロセス間通信 Private Private Private

More information

スライド 1

スライド 1 GPU クラスタによる格子 QCD 計算 広大理尾崎裕介 石川健一 1.1 Introduction Graphic Processing Units 1 チップに数百個の演算器 多数の演算器による並列計算 ~TFLOPS ( 単精度 ) CPU 数十 GFLOPS バンド幅 ~100GB/s コストパフォーマンス ~$400 GPU の開発環境 NVIDIA CUDA http://www.nvidia.co.jp/object/cuda_home_new_jp.html

More information

memo

memo 数理情報工学演習第一 C プログラミング演習 ( 第 5 回 ) 2015/05/11 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : プロトタイプ宣言 ヘッダーファイル, プログラムの分割 課題 : 疎行列 2 プロトタイプ宣言 3 C 言語では, 関数や変数は使用する前 ( ソースの上のほう ) に定義されている必要がある. double sub(int

More information

Microsoft PowerPoint - 09.pptx

Microsoft PowerPoint - 09.pptx 情報処理 Ⅱ 第 9 回 2014 年 12 月 22 日 ( 月 ) 関数とは なぜ関数 関数の分類 自作関数 : 自分で定義する. ユーザ関数 ユーザ定義関数 などともいう. 本日のテーマ ライブラリ関数 : 出来合いのもの.printf など. なぜ関数を定義するのか? 処理を共通化 ( 一般化 ) する プログラムの見通しをよくする 機能分割 ( モジュール化, 再利用 ) 責任 ( あるいは不具合の発生源

More information

XACC講習会

XACC講習会 www.xcalablemp.org 1 4, int array[max]; #pragma xmp nodes p(*) #pragma xmp template t(0:max-1) #pragma xmp distribute t(block) onto p #pragma xmp align array[i] with t(i) int array[max]; main(int argc,

More information

OpenMP (1) 1, 12 1 UNIX (FUJITSU GP7000F model 900), 13 1 (COMPAQ GS320) FUJITSU VPP5000/64 1 (a) (b) 1: ( 1(a))

OpenMP (1) 1, 12 1 UNIX (FUJITSU GP7000F model 900), 13 1 (COMPAQ GS320) FUJITSU VPP5000/64 1 (a) (b) 1: ( 1(a)) OpenMP (1) 1, 12 1 UNIX (FUJITSU GP7000F model 900), 13 1 (COMPAQ GS320) FUJITSU VPP5000/64 1 (a) (b) 1: ( 1(a)) E-mail: {nanri,amano}@cc.kyushu-u.ac.jp 1 ( ) 1. VPP Fortran[6] HPF[3] VPP Fortran 2. MPI[5]

More information

main.dvi

main.dvi PC 1 1 [1][2] [3][4] ( ) GPU(Graphics Processing Unit) GPU PC GPU PC ( 2 GPU ) GPU Harris Corner Detector[5] CPU ( ) ( ) CPU GPU 2 3 GPU 4 5 6 7 1 toyohiro@isc.kyutech.ac.jp 45 2 ( ) CPU ( ) ( ) () 2.1

More information

RX ファミリ用 C/C++ コンパイラ V.1.00 Release 02 ご使用上のお願い RX ファミリ用 C/C++ コンパイラの使用上の注意事項 4 件を連絡します #pragma option 使用時の 1 または 2 バイトの整数型の関数戻り値に関する注意事項 (RXC#012) 共用

RX ファミリ用 C/C++ コンパイラ V.1.00 Release 02 ご使用上のお願い RX ファミリ用 C/C++ コンパイラの使用上の注意事項 4 件を連絡します #pragma option 使用時の 1 または 2 バイトの整数型の関数戻り値に関する注意事項 (RXC#012) 共用 RX ファミリ用 C/C++ コンパイラ V.1.00 Release 02 ご使用上のお願い RX ファミリ用 C/C++ コンパイラの使用上の注意事項 4 件を連絡します #pragma option 使用時の 1 または 2 バイトの整数型の関数戻り値に関する注意事項 (RXC#012) 共用体型のローカル変数を文字列操作関数で操作する場合の注意事項 (RXC#013) 配列型構造体または共用体の配列型メンバから読み出した値を動的初期化に用いる場合の注意事項

More information

I I / 47

I I / 47 1 2013.07.18 1 I 2013 3 I 2013.07.18 1 / 47 A Flat MPI B 1 2 C: 2 I 2013.07.18 2 / 47 I 2013.07.18 3 / 47 #PJM -L "rscgrp=small" π-computer small: 12 large: 84 school: 24 84 16 = 1344 small school small

More information

(Microsoft PowerPoint \215u\213`4\201i\221\272\210\344\201j.pptx)

(Microsoft PowerPoint \215u\213`4\201i\221\272\210\344\201j.pptx) AICS 村井均 RIKEN AICS HPC Summer School 2012 8/7/2012 1 背景 OpenMP とは OpenMP の基本 OpenMP プログラミングにおける注意点 やや高度な話題 2 共有メモリマルチプロセッサシステムの普及 共有メモリマルチプロセッサシステムのための並列化指示文を共通化する必要性 各社で仕様が異なり 移植性がない そして いまやマルチコア プロセッサが主流となり

More information

02_C-C++_osx.indd

02_C-C++_osx.indd C/C++ OpenMP* / 2 C/C++ OpenMP* OpenMP* 9.0 1... 2 2... 3 3OpenMP*... 5 3.1... 5 3.2 OpenMP*... 6 3.3 OpenMP*... 8 4OpenMP*... 9 4.1... 9 4.2 OpenMP*... 9 4.3 OpenMP*... 10 4.4... 10 5OpenMP*... 11 5.1

More information

Microsoft PowerPoint - sales2.ppt

Microsoft PowerPoint - sales2.ppt 最適化とは何? CPU アーキテクチャに沿った形で最適な性能を抽出できるようにする技法 ( 性能向上技法 ) コンパイラによるプログラム最適化 コンパイラメーカの技量 経験量に依存 最適化ツールによるプログラム最適化 KAP (Kuck & Associates, Inc. ) 人によるプログラム最適化 アーキテクチャのボトルネックを知ること 3 使用コンパイラによる性能の違い MFLOPS 90

More information

memo

memo 計数工学プログラミング演習 ( 第 3 回 ) 2017/04/25 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 内容 ポインタの続き 引数の値渡しと参照渡し 構造体 2 ポインタで指されるメモリへのアクセス double **R; 型 R[i] と *(R+i) は同じ意味 意味 R double ** ポインタの配列 ( の先頭 ) へのポインタ R[i]

More information

XMPによる並列化実装2

XMPによる並列化実装2 2 3 C Fortran Exercise 1 Exercise 2 Serial init.c init.f90 XMP xmp_init.c xmp_init.f90 Serial laplace.c laplace.f90 XMP xmp_laplace.c xmp_laplace.f90 #include int a[10]; program init integer

More information

~~~~~~~~~~~~~~~~~~ wait Call CPU time 1, latch: library cache 7, latch: library cache lock 4, job scheduler co

~~~~~~~~~~~~~~~~~~ wait Call CPU time 1, latch: library cache 7, latch: library cache lock 4, job scheduler co 072 DB Magazine 2007 September ~~~~~~~~~~~~~~~~~~ wait Call CPU time 1,055 34.7 latch: library cache 7,278 750 103 24.7 latch: library cache lock 4,194 465 111 15.3 job scheduler coordinator slave wait

More information

Microsoft PowerPoint - 演習1:並列化と評価.pptx

Microsoft PowerPoint - 演習1:並列化と評価.pptx 講義 2& 演習 1 プログラム並列化と性能評価 神戸大学大学院システム情報学研究科横川三津夫 yokokawa@port.kobe-u.ac.jp 2014/3/5 RIKEN AICS HPC Spring School 2014: プログラム並列化と性能評価 1 2014/3/5 RIKEN AICS HPC Spring School 2014: プログラム並列化と性能評価 2 2 次元温度分布の計算

More information

Microsoft PowerPoint - CproNt02.ppt [互換モード]

Microsoft PowerPoint - CproNt02.ppt [互換モード] 第 2 章 C プログラムの書き方 CPro:02-01 概要 C プログラムの構成要素は関数 ( プログラム = 関数の集まり ) 関数は, ヘッダと本体からなる 使用する関数は, プログラムの先頭 ( 厳密には, 使用場所より前 ) で型宣言 ( プロトタイプ宣言 ) する 関数は仮引数を用いることができる ( なくてもよい ) 関数には戻り値がある ( なくてもよい void 型 ) コメント

More information

memo

memo 計数工学プログラミング演習 ( 第 3 回 ) 2016/04/26 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 内容 ポインタ malloc 構造体 2 ポインタ あるメモリ領域 ( アドレス ) を代入できる変数 型は一致している必要がある 定義時には値は不定 ( 何も指していない ) 実際にはどこかのメモリを指しているので, #include

More information

第12回講義(2019年7月17日)

第12回講義(2019年7月17日) スパコンプログラミング (1)(Ⅰ) 1 OpenACC の紹介 Reedbush-H お試し 東京大学情報基盤センター准教授塙敏博 2019 年 7 月 17 日 ( 水 )10:25 12:10 2019/7/16 スパコンプログラミング (1) (Ⅰ) 講義日程 ( 工学部共通科目 ) 1. 4 月 9 日 : ガイダンス 2. 4 月 16 日 l 並列数値処理の基本演算 ( 座学 ) 3.

More information

C プログラミング演習 1( 再 ) 2 講義では C プログラミングの基本を学び 演習では やや実践的なプログラミングを通して学ぶ

C プログラミング演習 1( 再 ) 2 講義では C プログラミングの基本を学び 演習では やや実践的なプログラミングを通して学ぶ C プログラミング演習 1( 再 ) 2 講義では C プログラミングの基本を学び 演習では やや実践的なプログラミングを通して学ぶ 今回のプログラミングの課題 次のステップによって 徐々に難易度の高いプログラムを作成する ( 参照用の番号は よくわかる C 言語 のページ番号 ) 1. キーボード入力された整数 10 個の中から最大のものを答える 2. 整数を要素とする配列 (p.57-59) に初期値を与えておき

More information

研究背景 大規模な演算を行うためには 分散メモリ型システムの利用が必須 Message Passing Interface MPI 並列プログラムの大半はMPIを利用 様々な実装 OpenMPI, MPICH, MVAPICH, MPI.NET プログラミングコストが高いため 生産性が悪い 新しい並

研究背景 大規模な演算を行うためには 分散メモリ型システムの利用が必須 Message Passing Interface MPI 並列プログラムの大半はMPIを利用 様々な実装 OpenMPI, MPICH, MVAPICH, MPI.NET プログラミングコストが高いため 生産性が悪い 新しい並 XcalableMPによる NAS Parallel Benchmarksの実装と評価 中尾 昌広 李 珍泌 朴 泰祐 佐藤 三久 筑波大学 計算科学研究センター 筑波大学大学院 システム情報工学研究科 研究背景 大規模な演算を行うためには 分散メモリ型システムの利用が必須 Message Passing Interface MPI 並列プログラムの大半はMPIを利用 様々な実装 OpenMPI,

More information

Slide 1

Slide 1 GPUコンピューティング入門 2015.08.26 エヌビディア合同会社 CUDAエンジニア 村上真奈 エヌビディアのGPUについて (20 分 ) GPUコンピューティングとは?(10 分 ) OpenACC 入門 (90 分 ) CUDA 入門 (90 分 ) Agenda 2 エヌビディアのGPUについて (20 分 ) GPUコンピューティングとは?(10 分 ) OpenACC 入門 (90

More information

strtok-count.eps

strtok-count.eps IoT FPGA 2016/12/1 IoT FPGA 200MHz 32 ASCII PCI Express FPGA OpenCL (Volvox) Volvox CPU 10 1 IoT (Internet of Things) 2020 208 [1] IoT IoT HTTP JSON ( Python Ruby) IoT IoT IoT (Hadoop [2] ) AI (Artificial

More information

情報処理概論(第二日目)

情報処理概論(第二日目) 情報処理概論 工学部物質科学工学科応用化学コース機能物質化学クラス 第 8 回 2005 年 6 月 9 日 前回の演習の解答例 多項式の計算 ( 前半 ): program poly implicit none integer, parameter :: number = 5 real(8), dimension(0:number) :: a real(8) :: x, total integer

More information

AICS 村井均 RIKEN AICS HPC Summer School /6/2013 1

AICS 村井均 RIKEN AICS HPC Summer School /6/2013 1 AICS 村井均 RIKEN AICS HPC Summer School 2013 8/6/2013 1 背景 OpenMP とは OpenMP の基本 OpenMP プログラミングにおける注意点 やや高度な話題 2 共有メモリマルチプロセッサシステムの普及 共有メモリマルチプロセッサシステムのための並列化指示文を共通化する必要性 各社で仕様が異なり 移植性がない そして いまやマルチコア プロセッサが主流となり

More information

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for embedded systems that use microcontrollers (MCUs)

More information

cp-7. 配列

cp-7. 配列 cp-7. 配列 (C プログラムの書き方を, パソコン演習で学ぶシリーズ ) https://www.kkaneko.jp/cc/adp/index.html 金子邦彦 1 本日の内容 例題 1. 月の日数配列とは. 配列の宣言. 配列の添え字. 例題 2. ベクトルの内積例題 3. 合計点と平均点例題 4. 棒グラフを描く配列と繰り返し計算の関係例題 5. 行列の和 2 次元配列 2 今日の到達目標

More information

TSUBAME2.0におけるGPUの 活用方法

TSUBAME2.0におけるGPUの 活用方法 GPU プログラミング 基礎編 東京工業大学学術国際情報センター 1. GPU コンピューティングと TSUBAME2.0 スーパーコンピュータ GPU コンピューティングとは グラフィックプロセッサ (GPU) は グラフィック ゲームの画像計算のために 進化を続けてきた 現在 CPU のコア数は 2~12 個に対し GPU 中には数百コア その GPU を一般アプリケーションの高速化に利用! GPGPU

More information

GPU CUDA CUDA 2010/06/28 1

GPU CUDA CUDA 2010/06/28 1 GPU CUDA CUDA 2010/06/28 1 GPU NVIDIA Mark Harris, Optimizing Parallel Reduction in CUDA http://developer.download.nvidia.com/ compute/cuda/1_1/website/data- Parallel_Algorithms.html#reduction CUDA SDK

More information

ex04_2012.ppt

ex04_2012.ppt 2012 年度計算機システム演習第 4 回 2012.05.07 第 2 回課題の補足 } TSUBAMEへのログイン } TSUBAMEは学内からのログインはパスワードで可能 } } } } しかし 演習室ではパスワードでログインできない設定 } 公開鍵認証でログイン 公開鍵, 秘密鍵の生成 } ターミナルを開く } $ ssh-keygen } Enter file in which to save

More information

復習 プログラミング 1 ( 第 4 回 ) 関数の利用 2 ループ処理 (while 文 ) 1. Chapter の補足 2 1. 関数とローカル変数 2. Chapter 3.1 の補足 1. Iteration, looping ( 反復処理 ) 2. ループ処理の例 実行例 3

復習 プログラミング 1 ( 第 4 回 ) 関数の利用 2 ループ処理 (while 文 ) 1. Chapter の補足 2 1. 関数とローカル変数 2. Chapter 3.1 の補足 1. Iteration, looping ( 反復処理 ) 2. ループ処理の例 実行例 3 復習 プログラミング 1 ( 第 4 回 ) 関数の利用 2 ループ処理 (while 文 ) 1. Chapter 4.1.1 の補足 2 1. 関数とローカル変数 2. Chapter 3.1 の補足 1. Iteration, looping ( 反復処理 ) 2. ループ処理の例 実行例 3. 3 種類の処理流れ制御 3. 演習 4. 宿題 処理の流れは逐次 条件分岐 反復処理の 3 タイプのみ

More information

Microsoft PowerPoint - 計算機言語 第7回.ppt

Microsoft PowerPoint - 計算機言語 第7回.ppt 計算機言語第 7 回 長宗高樹 目的 関数について理解する. 入力 X 関数 f 出力 Y Y=f(X) 関数の例 関数の型 #include int tasu(int a, int b); main(void) int x1, x2, y; x1 = 2; x2 = 3; y = tasu(x1,x2); 実引数 printf( %d + %d = %d, x1, x2, y);

More information

スライド 1

スライド 1 知能制御システム学 画像処理の高速化 OpenCV による基礎的な例 東北大学大学院情報科学研究科鏡慎吾 swk(at)ic.is.tohoku.ac.jp 2007.07.03 リアルタイム処理と高速化 リアルタイム = 高速 ではない 目標となる時間制約が定められているのがリアルタイム処理である.34 ms かかった処理が 33 ms に縮んだだけでも, それによって与えられた時間制約が満たされるのであれば,

More information

目次 1 はじめに 本文書の概要 PVF ソフトウェアと VISUAL STUDIO PVF ソフトウェアの種類 MICROSOFT VISUAL STUDIO の日本語化について VISUAL STUDIO

目次 1 はじめに 本文書の概要 PVF ソフトウェアと VISUAL STUDIO PVF ソフトウェアの種類 MICROSOFT VISUAL STUDIO の日本語化について VISUAL STUDIO PGI Visual Fortran のための Microsoft Visual Studio 導入ガイド 2016 年版 日本語環境の Visual Studio の構築について PGI インストール関係の日本語ドキュメントは 以下の URL に全てアーカイブしてありま す オンラインでご覧になりたい場合は 以下の URL にアクセスしてください http://www.softek.co.jp/spg/pgi/inst_document.html

More information

GPGPUクラスタの性能評価

GPGPUクラスタの性能評価 2008 年度理研 HPC シンポジウム第 3 世代 PC クラスタ GPGPU クラスタの性能評価 2009 年 3 月 12 日 富士通研究所成瀬彰 発表の概要 背景 GPGPU による高速化 CUDA の概要 GPU のメモリアクセス特性調査 姫野 BMT の高速化 GPGPU クラスタによる高速化 GPU Host 間のデータ転送 GPU-to-GPU の通信性能 GPGPU クラスタ上での姫野

More information

目次 1 はじめに 本文書の概要 WINDOWS 上での PVF ソフトウェアの実装 PVF コンパイラの利用方法 PVF コンパイラのコマンド オプションについて PVF コンパイラの起動 (Microsoft

目次 1 はじめに 本文書の概要 WINDOWS 上での PVF ソフトウェアの実装 PVF コンパイラの利用方法 PVF コンパイラのコマンド オプションについて PVF コンパイラの起動 (Microsoft PGI (Accelerator) Visual Fortran 2018 For Microsoft Visual Studio Windows 版 (Release 2018) - 入門ガイド - 2018 年 2 月版 (Rev. 18.1-A) 株式会社ソフテック HPC ソリューション部 (http://www.softek.co.jp/spg/) SofTek 目次 1 はじめに...

More information

デジタル表現論・第4回

デジタル表現論・第4回 デジタル表現論 第 4 回 劉雪峰 ( リュウシュウフォン ) 2016 年 5 月 2 日 劉 雪峰 ( リュウシュウフォン ) デジタル表現論 第 4 回 2016 年 5 月 2 日 1 / 14 本日の目標 Java プログラミングの基礎 出力の復習 メソッドの定義と使用 劉 雪峰 ( リュウシュウフォン ) デジタル表現論 第 4 回 2016 年 5 月 2 日 2 / 14 出力 Systemoutprint()

More information

program7app.ppt

program7app.ppt プログラム理論と言語第 7 回 ポインタと配列, 高階関数, まとめ 有村博紀 吉岡真治 公開スライド PDF( 情報知識ネットワーク研 HP/ 授業 ) http://www-ikn.ist.hokudai.ac.jp/~arim/pub/proriron/ 本スライドは,2015 北海道大学吉岡真治 プログラム理論と言語, に基づいて, 現著者の承諾のもとに, 改訂者 ( 有村 ) が加筆修正しています.

More information

CCS HPCサマーセミナー 並列数値計算アルゴリズム

CCS HPCサマーセミナー 並列数値計算アルゴリズム 大規模系での高速フーリエ変換 2 高橋大介 daisuke@cs.tsukuba.ac.jp 筑波大学計算科学研究センター 2016/6/2 計算科学技術特論 B 1 講義内容 並列三次元 FFT における自動チューニング 二次元分割を用いた並列三次元 FFT アルゴリズム GPU クラスタにおける並列三次元 FFT 2016/6/2 計算科学技術特論 B 2 並列三次元 FFT における 自動チューニング

More information

,4) 1 P% P%P=2.5 5%!%! (1) = (2) l l Figure 1 A compilation flow of the proposing sampling based architecture simulation

,4) 1 P% P%P=2.5 5%!%! (1) = (2) l l Figure 1 A compilation flow of the proposing sampling based architecture simulation 1 1 1 1 SPEC CPU 2000 EQUAKE 1.6 50 500 A Parallelizing Compiler Cooperative Multicore Architecture Simulator with Changeover Mechanism of Simulation Modes GAKUHO TAGUCHI 1 YOUICHI ABE 1 KEIJI KIMURA 1

More information

openmp1_Yaguchi_version_170530

openmp1_Yaguchi_version_170530 並列計算とは /OpenMP の初歩 (1) 今 の内容 なぜ並列計算が必要か? スーパーコンピュータの性能動向 1ExaFLOPS 次世代スハ コン 京 1PFLOPS 性能 1TFLOPS 1GFLOPS スカラー機ベクトル機ベクトル並列機並列機 X-MP ncube2 CRAY-1 S-810 SR8000 VPP500 CM-5 ASCI-5 ASCI-4 S3800 T3E-900 SR2201

More information

Intel Memory Protection Extensions(Intel MPX) x86, x CPU skylake 2015 Intel Software Development Emulator 本資料に登場する Intel は Intel Corp. の登録

Intel Memory Protection Extensions(Intel MPX) x86, x CPU skylake 2015 Intel Software Development Emulator 本資料に登場する Intel は Intel Corp. の登録 Monthly Research Intel Memory Protection Extensions http://www.ffri.jp Ver 1.00.01 1 Intel Memory Protection Extensions(Intel MPX) x86, x86-64 2015 2 CPU skylake 2015 Intel Software Development Emulator

More information

プログラミングI第10回

プログラミングI第10回 プログラミング 1 第 10 回 構造体 (3) 応用 リスト操作 この資料にあるサンプルプログラムは /home/course/prog1/public_html/2007/hw/lec/sources/ 下に置いてありますから 各自自分のディレクトリにコピーして コンパイル 実行してみてください Prog1 2007 Lec 101 Programming1 Group 19992007 データ構造

More information

.NETプログラマー早期育成ドリル ~VB編 付録 文法早見表~

.NETプログラマー早期育成ドリル ~VB編 付録 文法早見表~ .NET プログラマー早期育成ドリル VB 編 付録文法早見表 本資料は UUM01W:.NET プログラマー早期育成ドリル VB 編コードリーディング もしくは UUM02W:.NET プログラマー早期育成ドリル VB 編コードライティング を ご購入頂いた方にのみ提供される資料です 資料内容の転載はご遠慮下さい VB プログラミング文法早見表 < 基本文法 > 名前空間の定義 Namespace

More information

untitled

untitled A = QΛQ T A n n Λ Q A = XΛX 1 A n n Λ X GPGPU A 3 T Q T AQ = T (Q: ) T u i = λ i u i T {λ i } {u i } QR MR 3 v i = Q u i A {v i } A n = 9000 Quad Core Xeon 2 LAPACK (4/3) n 3 O(n 2 ) O(n 3 ) A {v i }

More information

MATLAB® における並列・分散コンピューティング ~ Parallel Computing Toolbox™ & MATLAB Distributed Computing Server™ ~

MATLAB® における並列・分散コンピューティング ~ Parallel Computing Toolbox™ & MATLAB Distributed Computing Server™ ~ MATLAB における並列 分散コンピューティング ~ Parallel Computing Toolbox & MATLAB Distributed Computing Server ~ MathWorks Japan Application Engineering Group Takashi Yoshida 2016 The MathWorks, Inc. 1 System Configuration

More information

熊本大学学術リポジトリ Kumamoto University Repositor Title GPGPU による高速演算について Author(s) 榎本, 昌一 Citation Issue date Type URL Presentation

熊本大学学術リポジトリ Kumamoto University Repositor Title GPGPU による高速演算について Author(s) 榎本, 昌一 Citation Issue date Type URL Presentation 熊本大学学術リポジトリ Kumamoto University Repositor Title GPGPU による高速演算について Author(s) 榎本, 昌一 Citation Issue date 2011-03-17 Type URL Presentation http://hdl.handle.net/2298/23539 Right GPGPU による高速演算について 榎本昌一 東京大学大学院工学系研究科システム創成学専攻

More information

第9回 配列(array)型の変数

第9回 配列(array)型の変数 第 12 回 配列型の変数 情報処理演習 ( テキスト : 第 4 章, 第 8 章 ) 今日の内容 1. 配列の必要性 2. 配列の宣言 3. 配列変数のイメージ 4. 配列変数を使用した例 5. 範囲を超えた添字を使うと? 6. 多次元配列変数 7. 多次元配列変数を使用した例 8. データのソーティング 9. 今日の練習問題 多数のデータ処理 1. 配列の必要性 ( テキスト 31 ページ )

More information

名称 : 日本 GPU コンピューティングパートナーシップ (G-DEP) 所在 : 東京都文京区本郷 7 丁目 3 番 1 号東京大学アントレプレナープラザ, 他工場 URL アライアンスパートナー コアテクノロジーパートナー NVIDIA JAPAN ソリュ

名称 : 日本 GPU コンピューティングパートナーシップ (G-DEP) 所在 : 東京都文京区本郷 7 丁目 3 番 1 号東京大学アントレプレナープラザ, 他工場 URL   アライアンスパートナー コアテクノロジーパートナー NVIDIA JAPAN ソリュ GPUDirect の現状整理 multi-gpu に取組むために G-DEP チーフエンジニア河井博紀 (kawai@gdep.jp) 名称 : 日本 GPU コンピューティングパートナーシップ (G-DEP) 所在 : 東京都文京区本郷 7 丁目 3 番 1 号東京大学アントレプレナープラザ, 他工場 URL http://www.gdep.jp アライアンスパートナー コアテクノロジーパートナー

More information

DO 時間積分 START 反変速度の計算 contravariant_velocity 移流項の計算 advection_adams_bashforth_2nd DO implicit loop( 陰解法 ) 速度勾配, 温度勾配の計算 gradient_cell_center_surface 速

DO 時間積分 START 反変速度の計算 contravariant_velocity 移流項の計算 advection_adams_bashforth_2nd DO implicit loop( 陰解法 ) 速度勾配, 温度勾配の計算 gradient_cell_center_surface 速 1 1, 2 1, 2 3 2, 3 4 GP LES ASUCA LES NVIDIA CUDA LES 1. Graphics Processing Unit GP General-Purpose SIMT Single Instruction Multiple Threads 1 2 3 4 1),2) LES Large Eddy Simulation 3) ASUCA 4) LES LES

More information

修士論文

修士論文 AVX を用いた倍々精度疎行列ベクトル積の高速化 菱沼利彰 1 藤井昭宏 1 田中輝雄 1 長谷川秀彦 2 1 工学院大学 2 筑波大学 1 目次 1. 研究背景 目的 2. 実装, 実験環境 3. 実験 - 倍々精度ベクトル演算 - 4. 実験 - 倍々精度疎行列ベクトル積 - 5. まとめ 多倍長精度計算フォーラム 2 目次 1. 研究背景 目的 2. 実装, 実験環境 3. 実験 - 倍々精度ベクトル演算

More information

ex05_2012.pptx

ex05_2012.pptx 2012 年度計算機システム演習第 5 回 2012.05.25 高水準言語 (C 言語 ) アセンブリ言語 (MIPS) 機械語 (MIPS) コンパイラ アセンブラ 今日の内容 サブルーチンの実装 Outline } ジャンプ 分岐命令 } j, jr, jal } レジスタ衝突 回避 } caller-save } callee-save 分岐命令 ( 復習 ) } j label } Jump

More information