11050427-0_Vol16No3.indd



Similar documents
_Vol16No2.indd

untitled

倍々精度RgemmのnVidia C2050上への実装と応用

線形代数演算ライブラリBLASとLAPACKの 基礎と実践1

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

線形代数演算ライブラリBLASとLAPACKの 基礎と実践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

211 年ハイパフォーマンスコンピューティングと計算科学シンポジウム Computing Symposium 211 HPCS /1/18 a a 1 a 2 a 3 a a GPU Graphics Processing Unit GPU CPU GPU GPGPU G

1 GPU GPGPU GPU CPU 2 GPU 2007 NVIDIA GPGPU CUDA[3] GPGPU CUDA GPGPU CUDA GPGPU GPU GPU GPU Graphics Processing Unit LSI LSI CPU ( ) DRAM GPU LSI GPU

理研スーパーコンピュータ・システム

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

線形代数演算ライブラリBLASとLAPACKの 基礎と実践1

Microsoft PowerPoint - GPU_computing_2013_01.pptx

4 倍精度基本線形代数ルーチン群 QPBLAS の紹介 [index] 1. Introduction 2. Double-double algorithm 3. QPBLAS 4. QPBLAS-GPU 5. Summary 佐々成正 1, 山田進 1, 町田昌彦 1, 今村俊幸 2, 奥田洋司

GPU.....

! 行行 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

main.dvi


2 2.1 Mac OS CPU Mac OS tar zxf zpares_0.9.6.tar.gz cd zpares_0.9.6 Mac Makefile Mekefile.inc cp Makefile.inc/make.inc.gfortran.seq.macosx make

HP Workstation 総合カタログ

AMD/ATI Radeon HD 5870 GPU DEGIMA LINPACK HD 5870 GPU DEGIMA LINPACK GFlops/Watt GFlops/Watt Abstract GPU Computing has lately attracted

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

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

23 Fig. 2: hwmodulev2 3. Reconfigurable HPC 3.1 hw/sw hw/sw hw/sw FPGA PC FPGA PC FPGA HPC FPGA FPGA hw/sw hw/sw hw- Module FPGA hwmodule hw/sw FPGA h

64bit SSE2 SSE2 FPU Visual C++ 64bit Inline Assembler 4 FPU SSE2 4.1 FPU Control Word FPU 16bit R R R IC RC(2) PC(2) R R PM UM OM ZM DM IM R: reserved

GPU n Graphics Processing Unit CG CAD

高性能計算研究室の紹介 High Performance Computing Lab.

( CUDA CUDA CUDA CUDA ( NVIDIA CUDA I

高性能計算研究室の紹介 High Performance Computing Lab.

Slide 1

rank ”«‘‚“™z‡Ì GPU ‡É‡æ‡éŁÀŠñ›»

GPGPU

スパコンに通じる並列プログラミングの基礎

第52回日本生殖医学会総会・学術講演会

H1-4

Untitled

スパコンに通じる並列プログラミングの基礎

HPEハイパフォーマンスコンピューティング ソリューション

KBLAS[7] *1., CUBLAS.,,, Byte/flop., [13] 1 2. (AT). GPU AT,, GPU SYMV., SYMV CUDABLAS., (double, float) (cu- FloatComplex, cudoublecomplex).,, DD(dou

HP xw9400 Workstation

スパコンに通じる並列プログラミングの基礎

<4D F736F F F696E74202D2091E63489F15F436F6D C982E682E992B48D8291AC92B489B F090CD2888F38DFC E B8CDD8

GPUコンピューティング講習会パート1

0530cmsi教育計算科学技術特論a_中田真秀 (nakata maho's conflicted copy) (6)

第101回 日本美容外科学会誌/nbgkp‐01(大扉)

27巻3号/FUJSYU03‐107(プログラム)

パーキンソン病治療ガイドライン2002

tnbp59-20_Web:P1/ky108679509610002943

2008 ( 13 ) C LAPACK 2008 ( 13 )C LAPACK p. 1

Images per Second Images per Second VOLTA: ディープラーニングにおける大きな飛躍 ResNet-50 トレーニング 2.4x faster ResNet-50 推論 TensorRT - 7ms レイテンシ 3.7x faster P100 V100 P10

64bit SSE2 SSE2 FPU Visual C++ 64bit Inline Assembler 4 FPU SSE2 4.1 FPU Control Word FPU 16bit R R R IC RC(2) PC(2) R R PM UM OM ZM DM IM R: reserved

HP Workstation 総合カタログ

スライド 1

GPGPU によるアクセラレーション環境について

PowerPoint プレゼンテーション

B 2 Thin Q=3 0 0 P= N ( )P Q = 2 3 ( )6 N N TSUB- Hub PCI-Express (PCIe) Gen 2 x8 AME1 5) 3 GPU Socket 0 High-performance Linpack 1

PowerPoint プレゼンテーション

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

HP Workstation Xeon 5600

プリント

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


ストリーミング SIMD 拡張命令2 (SSE2) を使用した SAXPY/DAXPY

Microsoft PowerPoint - NxLec ppt

3.2 Linux root vi(vim) vi emacs emacs 4 Linux Kernel Linux Git 4.1 Git Git Linux Linux Linus Fedora root yum install global(debian Ubuntu apt-get inst

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

GPUを用いたN体計算

Transcription:

2599 チュートリアル BLAS, LAPACK 2 2 GPU BLAS, LAPACKチュートリアル パート2 (GPU 編 ) 中 田 真 秀 1 はじめに GPU Graphics Processing Unit BLAS, LAPACK GPU GPU NVIDIA AMD AMD RADEON HD NVIDIA NVIDIA GPU NVIDIA C2050 BLAS, LAPACK cublas, MAGMA CULA 1 BLAS, LAPACK pdf [1] 筆 者 紹 介 BLAS, LAPACK http://accc.riken.jp/maho/ 2 GPU, GPGPU とは? CPU CAD CAE Graphics Processing Unit GPU General-purpose computing on graphics processing units; GPGPU CPU 10 Flops FLoting Point per Second; Intel Core i7 2600K 100GFlops AMD RADEON HD6990 1.37TFlops, NVIDIA C2050 515GFlops GPU CPU 5 10 3 コンピュータの 基 本 原 理 と 高 速 な 計 算 GPU GPU BLAS, LAPACK (1)コンピュータの 基 本 原 理 27

2600 CPU 1 (3) 入 出 力 からCPUで 計 算 させるまで CPU 2 図 1 フォン ノイマン 型 コンピュータの 概 念 図 いくつ かの 基 本 となる 部 分 から 成 る (Wikipediaより 改 変 ) (2)どこがボトルネックかを 知 ろう CPU CPU CPU Intel Core i7 920 50GFlops 400Gbytes/ PC3-8500 17Gbyes/ 25 CPU BLAS Level 1, 2 - - 再 利 用 がほとんどできな い PC3-8500 2 4GFlops CPU Level 3 - 再 利 用 しやすい CPU CPU Intel Core i7 920 50GFlops 図 2 ハードディスクからレジスタまでの 非 常 に 大 まかな データ 転 送 スピード( 左 側 )とデバイスと( 中 側 )と 容 量 ( 右 側 ) 4 GPU(NVIDIA C2050)のアーキテクチャと 長 所 と 短 所 NVIDIA C2050 GPU (1)NVIDIA C2050(GPU)の 長 所 : 演 算 が 高 速 : 多 く のプロセッサを 搭 載 NVIDIA GPU 3 SP SP NVIDIA C2050 1.15GHz 448 SP 448 1.15=515GFlops Level 3 BLAS SP 28 計 算 工 学

BLAS, LAPACK 2 GPU 2601 図 3 NVIDIA 社 製 のGPUのアーキテクチャ 概 略 : 多 数 のストリーミングプロセッサ ビデオメモリの バンド 幅 が 高 いのが 特 徴 (2)GPU(C2050)の 長 所 : メモリが 高 速 であること NVIDIA C2050 GDDR5 144GBytes/ PC3-8500 17Gbytes/ 8.5 GPU Level 1, 2 BLAS Level 3 BLAS (3)GPU(C2050)の 短 所 : PCIeバスが 低 速 であること GPU CPU PCIe 8GB/ sec GPU 20 4 図 4 CPU-GPUの 転 送 はPCIeを 介 して 行 うが PCIe バスの 転 送 速 度 が 遅 い(PCIe 8GB/s, GPUメモリ 144GB/s, CPUメモリ17.5GB/s) (4)C2050(GPU)の 短 所 : プログラミングが 複 雑 GPU CUDA GPU 5 NVIDIA C2050でのBLAS, LAPACK 実 習 NVIDIA C2050 BLAS, LAPACK cublas MAGMA NVIDIA C2050 CUDAToolkit 3.2, MAGMA, GotoBLAS2 Intel MKL, OS x86-64 64bit Linux GPU BLAS LAPACK CPU 5 10GotoBLAS2 Intel MKL GPU CPU kernel ; (1)cuBLAS 実 習 cublas [2] NVIDIA CUDA BLAS FORTRAN/C/C++ MAGMA cublas GPU PCIe GPU GPU CPU-GPU PCIe PCIe PCIe-CPU BLAS Level 1, 2 CPU-GPU 29

2602 cublas GPU 5 cublasdgemm cublas BLAS C/C++ 1 FORTRAN ; column-major FORTRAN ; GPU lda 32 MAGMA testing_dgemm.cpp 図 5 cublas 特 有 のGPUの 制 御 の 図 - dgemm cublas C++ 6 $ nvcc -o dgemm_demo dgemm_demo.cpp -lpthread -lcublas \ -lcudart -L/usr/local/cuda/lib64 -L/usr/lib64 $./dgemm_demo # dgemm demo... A =[ [ 1.00e+00, 8.00e+00, 3.00e+00];\ [ 2.00e+00, 1.00e+01, 8.00e+00];\ [ 9.00e+00, -5.00e+00, -1.00e+00] ] B =[ [ 9.00e+00, 8.00e+00, 3.00e+00];\ [ 3.00e+00, 1.10e+01, 2.30e+00];\ [ -8.00e+00, 6.00e+00, 1.00e+00] ] C =[ [ 3.00e+00, 3.00e+00, 1.20e+00];\ [ 8.00e+00, 4.00e+00, 8.00e+00];\ [ 6.00e+00, 1.00e+00, -2.00e+00] ] alpha = 3.000e+00 beta = -2.000e+00 ans=[ [ 2.10e+01, 3.36e+02, 7.08e+01];\ [ -6.40e+01, 5.14e+02, 9.50e+01];\ [ 2.10e+02, 3.10e+01, 4.75e+01] ] #you can check by Matlab by: alpha * A * B + beta * C = // dgemm CUDA test public domain #include <stdio.h> #include <stdlib.h> #include <math.h> #include "cublas.h" //Matlab/Octave format void printmat(int N, int M, double *A, int LDA) { double mtmp; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { mtmp = A[i + j * LDA]; printf("%5.2e", mtmp); if (j < M - 1) printf(", "); if (i < N - 1) printf("]; "); else printf("] "); printf("]"); int main() { int n = 3; double alpha, beta; cublasstatus stata, statb, statc; double *deva, *devb, *devc; double *A = new double[n*n]; double *B = new double[n*n]; double *C = new double[n*n]; cublasinit(); stata = cublasalloc (n*n, sizeof(*a), (void**)&deva); statb = cublasalloc (n*n, sizeof(*b), (void**)&devb); statc = cublasalloc (n*n, sizeof(*c), (void**)&devc); A[0+0*n]=1; A[0+1*n]= 8; A[0+2*n]= 3; A[1+0*n]=2; A[1+1*n]=10; A[1+2*n]= 8; A[2+0*n]=9; A[2+1*n]=-5; A[2+2*n]=-1; B[0+0*n]= 9; B[0+1*n]= 8; B[0+2*n]=3; B[1+0*n]= 3; B[1+1*n]=11; B[1+2*n]=2.3; B[2+0*n]=-8; B[2+1*n]= 6; B[2+2*n]=1; C[0+0*n]=3; C[0+1*n]=3; C[0+2*n]=1.2; C[1+0*n]=8; C[1+1*n]=4; C[1+2*n]=8; C[2+0*n]=6; C[2+1*n]=1; C[2+2*n]=-2; 30 計 算 工 学

BLAS, LAPACK 2 GPU 2603 stata = cublassetmatrix (n, n, sizeof(*a), A, n, deva, n); statb = cublassetmatrix (n, n, sizeof(*b), B, n, devb, n); statc = cublassetmatrix (n, n, sizeof(*c), C, n, devc, n); printf("# dgemm demo...\n"); printf("a =");printmat(n,n,a,n);printf("\n"); printf("b =");printmat(n,n,b,n);printf("\n"); printf("c =");printmat(n,n,c,n);printf("\n"); alpha = 3.0; beta = -2.0; cublasdgemm('n', 'n', n, n, n, alpha, deva, n, devb, n, beta, devc, n); stata = cublasgetmatrix (n, n, sizeof(*a), deva, n, A, n); statb = cublasgetmatrix (n, n, sizeof(*b), devb, n, B, n); statc = cublasgetmatrix (n, n, sizeof(*c), devc, n, C, n); printf("alpha = %5.3e\n", alpha); printf("beta = %5.3e\n", beta); printf("ans="); printmat(n,n,c,n); printf("\n"); printf("#you can check by Matlab by:\n"); printf("alpha * A * B + beta * C =\n"); cublasfree (deva); cublasfree (devb); cublasfree (devc); cublasshutdown(); delete[]c; delete[]b; delete[]a; 図 6 C++でのcuBLASを 用 いたdgemmのサンプル 行 列 - 行 列 積 を 求 める ファイル 名 は dgemm_demo. cpp とすること (2)MAGMA 実 習 MAGMA [3] Stanimire Tomov NVIDIA GPU CUDA CPU GPU CPU 2011/4/6 1.0.0RC5 RC5 5 cublas BLAS, LAPACK API LAPACK LU Cholesky QR 32 BLAS dgemm cublas 3 BSD MAGMA [3] $ cd /home/maho $ tar xvfz magma_1.0.0-rc5.tar.gz... $ cd magma_1.0.0-rc5/ $ less README ( ) $ emacs make.inc.goto (GotoBLAS2, ) $ cp make.inc.goto make.inc (GotoBLAS2 ) $ emacs make.inc.mkl (Intel MKL, ) $ cp make.inc.mkl make.inc (Intel MKL ) $ make... testing_cgehrd.o testing_zhetrd.o testing_cgeqrs\ _gpu.o testing_dsytrd.o testing_cgebrd.o testing_\ zgehrd.o testing_zpotrf_gpu.o testing_dsposv_gpu.o\ testing_zgesv_gpu.o make[1]: Leaving directory '/home/maho/magma_1.0.0\ -rc5/testing' $ MAGMA MAGMA 1.0.0RC5 dgemm C2050 7 GPU 2000 300GFlops CPU-GPU CPU-GPU 50GFlops 400 100GFlops 700 CPU BLAS 10% GPU 1000 cublas3.2 MAGMA dgemm 31

2604 GFLOPS 300 250 200 150 100 50 Kernel Overall 0 0 2000 4000 6000 8000 10000 Dimension 図 7 MAGMA1.0.0RC5のdgemmのC2050で の 正 方 行 列 の ベ ン チ マ ー ク KernelはGPUの み の パ フォーマンス OverallはCPU-GPU 転 送 も 含 ん だパフォーマンス 値 2000 次 元 より 大 きいと 約 300GFlops 出 る CPU-GPU 転 送 を 含 む 場 合 50GFlops, 100GFlopsを 越 え る の は400 次 元 700 次 元 付 近 からとなる LAPACK dgetrf MAGMA LU A L U A = LU LU //LU factorization MAGMA public domain #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <cuda.h> #include <cublas.h> #include <cuda_runtime_api.h> #include "magma.h" #include "magma_lapack.h" #include "testings.h" //Matlab/Octave format void printmat(int N, int M, double *A, int LDA) { double mtmp; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { mtmp = A[i + j * LDA]; printf("%5.2e", mtmp); if (j < M - 1) printf(", "); if (i < N - 1) printf("]; "); else printf("] "); printf("]"); int main() { int M=3, N=3, lda, min_mn, nb; magma_int_t *ipiv, info; double *A; min_mn = min(m,n); nb = magma_get_dgetrf_nb(min_mn); lda = N; TESTING_CUDA_INIT(); TESTING_MALLOC(ipiv, magma_int_t, min_mn); TESTING_HOSTALLOC( A, double, M*N); LU A[0+0*lda]=1; A[0+1*lda]= 8; A[0+2*lda]= 3; A[1+0*lda]=2; A[1+1*lda]=10; A[1+2*lda]= 8; A[2+0*lda]=9; A[2+1*lda]=-5; A[2+2*lda]=-1; printf("a =");printmat(m,n,a,lda);printf("\n"); magma_dgetrf( M, N, A, lda, ipiv, &info); printf("lu =");printmat(m,n,a,lda);printf("\n"); MAGMA GPU CPU-GPU CPU LU CPU-GPU 8 Intel MKL [4] TESTING_FREE( ipiv ); TESTING_HOSTFREE( A ); TESTING_CUDA_FINALIZE(); 図 8 C++でのMAGMAを 用 いたdgetrfのサンプル LU 分 解 を 求 める ファイル 名 は testing_dgetrf. cpp とすること 32 計 算 工 学

BLAS, LAPACK 2 GPU 2605 GotoBLAS2 $ nvcc -o testing_dgetrf testing_dgetrf.cpp -I/home/ maho/\ magma_1.0.0-rc5/testing/ -I/home/maho/ magma_1.0.0-rc5/\ include/ -L/usr/local/cuda/lib64 -L/usr/lib64 -L/home/ maho/\ magma_1.0.0-rc5/lib/ -L/home/maho/GotoBLAS2 -lcuda -lmagma\ -lmagmablas -lmagma -lcublas -lgoto2 Intel MKL $ nvcc -o testing_dgetrf testing_dgetrf.cpp -I/home/ maho/\ magma_1.0.0-rc5/testing/ -I/home/maho/magma_1.0.0-rc5/ include/\ -L/usr/local/cuda/lib64 -L/usr/lib64 -L/home/maho/\ magma_1.0.0-rc5/lib/ -L/opt/intel/Compiler/11.1/072/ mkl/lib/\ em64t/ -lcuda -lmagma -lmagmablas -lmagma -lcublas \ -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core \ /opt/intel/compiler/11.1/072/lib/intel64/libiomp5.a\ -lpthread $./testing_dgetrf device 0: Tesla C2050, 1147.0 MHz clock, 2687.2 MB memory A =[ [ 1.00e+00, 8.00e+00, 3.00e+00]; \ [ 2.00e+00, 1.00e+01, 8.00e+00]; \ [ 9.00e+00, -5.00e+00, -1.00e+00] ] LU =[ [ 9.00e+00, -5.00e+00, -1.00e+00]; \ [ 2.22e-01, 1.11e+01, 8.22e+00];\ [ 1.11e-01, 7.70e-01, -3.22e+00] ] LU U 1 L MAGMA TESTING... CUDA dgetrf LAPACK magma_dgetrf M, N, A, lda, ipiv, &info ; LAPACK magma_get_dgetrf_nb min_mn ; LAPACK MAGMA 6 終 わりに GPU NVIDIA C2050 BLAS, LAPACK cublas, MAGMA GPU BLAS, LAPACK MAGMA BLAS, LAPACK 謝 辞 参 考 文 献 [1] http://www.jsces.org/issue/journal/pdf/nakata-0411.pdf [2] http://developer.download.nvidia.com/compute/devzone/ docs/html/cudalibraries/doc/cublas_library.pdf [3] http://icl.cs.utk.edu/magma [4] http://software.intel.com/en-us/articles/intel-mkl-link-lineadvisor/ 33