44 6 MPI 4 : #LIB=-lmpich -lm 5 : LIB=-lmpi -lm 7 : mpi1: mpi1.c 8 : $(CC) -o mpi1 mpi1.c $(LIB) 9 : 10 : clean: 11 : -$(DEL) mpi1 make mpi1 1 % mpiru

Similar documents
58 7 MPI 7 : main(int argc, char *argv[]) 8 : { 9 : int num_procs, myrank; 10 : double a, b; 11 : int tag = 0; 12 : MPI_Status status; 13 : 1 MPI_Init

86 8 MPIBNCpack 15 : int n, myid, numprocs, i; 16 : double pi, start_x, end_x; 17 : double startwtime = 0.0, endwtime; 18 : int namelen; 19 : char pro

115 9 MPIBNCpack 9.1 BNCpack 1CPU X = , B =

DKA ( 1) 1 n i=1 α i c n 1 = 0 ( 1) 2 n i 1 <i 2 α i1 α i2 c n 2 = 0 ( 1) 3 n i 1 <i 2 <i 3 α i1 α i2 α i3 c n 3 = 0. ( 1) n 1 n i 1 <i 2 < <i

Krylov (b) x k+1 := x k + α k p k (c) r k+1 := r k α k Ap k ( := b Ax k+1 ) (d) β k := r k r k 2 2 (e) : r k 2 / r 0 2 < ε R (f) p k+1 :=

目 目 用方 用 用 方

para02-2.dvi

2 T 1 N n T n α = T 1 nt n (1) α = 1 100% OpenMP MPI OpenMP OpenMP MPI (Message Passing Interface) MPI MPICH OpenMPI 1 OpenMP MPI MPI (trivial p

NUMAの構成

WinHPC ppt

スライド 1

Microsoft PowerPoint 並列アルゴリズム04.ppt

MPI

演習 II 2 つの講義の演習 奇数回 : 連続系アルゴリズム 部分 偶数回 : 計算量理論 部分 連続系アルゴリズム部分は全 8 回を予定 前半 2 回 高性能計算 後半 6 回 数値計算 4 回以上の課題提出 ( プログラム + 考察レポート ) で単位

chap2.ppt

MPI usage

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

Microsoft PowerPoint - KHPCSS pptx

Microsoft PowerPoint - 講義:片方向通信.pptx

120802_MPI.ppt

<4D F736F F F696E74202D C097F B A E B93C782DD8EE682E890EA97705D>

<4D F736F F F696E74202D C097F B A E B93C782DD8EE682E890EA97705D>

スライド 1

情報処理演習 II

Microsoft PowerPoint - 演習2:MPI初歩.pptx

演習準備 2014 年 3 月 5 日神戸大学大学院システム情報学研究科森下浩二 1 RIKEN AICS HPC Spring School /3/5

講義の流れ 並列プログラムの概要 通常のプログラムと並列プログラムの違い 並列プログラム作成手段と並列計算機の構造 OpenMP による並列プログラム作成 処理を複数コアに分割して並列実行する方法 MPI による並列プログラム作成 ( 午後 ) プロセス間通信による並列処理 処理の分割 + データの

課題 S1 解説 C 言語編 中島研吾 東京大学情報基盤センター

コードのチューニング

Microsoft PowerPoint MPI.v...O...~...O.e.L.X.g(...Q..)

GNU開発ツール

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

Gfarm/MPI-IOの 概要と使い方

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

untitled

Microsoft PowerPoint - 講義:コミュニケータ.pptx

C/C++ FORTRAN FORTRAN MPI MPI MPI UNIX Windows (SIMD Single Instruction Multipule Data) SMP(Symmetric Multi Processor) MPI (thread) OpenMP[5]

±é½¬£²¡§£Í£Ð£É½éÊâ

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

1 (bit ) ( ) PC WS CPU IEEE754 standard ( 24bit) ( 53bit)

新版明解C言語 実践編

comment.dvi

BW BW

r07.dvi

スライド 1

ohp07.dvi

:30 12:00 I. I VI II. III. IV. a d V. VI

かし, 異なったプロセス間でデータを共有するためには, プロセス間通信や特殊な共有メモリ領域を 利用する必要がある. このためマルチプロセッサマシンの利点を最大に引き出すことができない. こ の問題はマルチスレッドを用いることで解決できる. マルチスレッドとは,1 つのプロセスの中に複 数のスレッド

¥Ñ¥Ã¥±¡¼¥¸ Rhpc ¤Î¾õ¶·

double float

スライド 1

コードのチューニング

XMPによる並列化実装2

Microsoft Word - C.....u.K...doc

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

<4D F736F F F696E74202D C097F B A E B93C782DD8EE682E890EA97705D>

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E

新・明解C言語 ポインタ完全攻略

tuat1.dvi

C

Microsoft PowerPoint - ishikawa.ppt

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

smpp_resume.dvi

新・明解C言語 実践編

2002 avidemux MPEG-4 : : : G99P045-1

MPI () MPIMessage Passing Interface MPI MPI OpenMP 7 ( ) 1

file:///D|/C言語の擬似クラス.txt

ex01.dvi

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

ohp03.dvi

Prog1_6th

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

実際の株価データを用いたオプション料の計算

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

‚æ4›ñ

XcalableMP入門

‚æ2›ñ C„¾„ê‡Ìš|

橡Pro PDF

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

Fundamental MPI 1 概要 MPI とは MPI の基礎 :Hello World 全体データと局所データ グループ通信 (Collective Communication) 1 対 1 通信 (Point-to-Point Communication)

内容に関するご質問は まで お願いします [Oakforest-PACS(OFP) 編 ] 第 85 回お試しアカウント付き並列プログラミング講習会 ライブラリ利用 : 科学技術計算の効率化入門 スパコンへのログイン テストプログラム起動 東京大学情報基盤セ

Fundamental MPI 1 概要 MPI とは MPI の基礎 :Hello World 全体データと局所データタ グループ通信 (Collective Communication) 1 対 1 通信 (Point-to-Point Communication)

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b


AutoTuned-RB

:30 12:00 I. I VI II. III. IV. a d V. VI

Microsoft Word - 計算科学演習第1回3.doc

PowerPoint プレゼンテーション

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena

Taro-リストⅠ(公開版).jtd

86

ex14.dvi

XACC講習会

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n

Microsoft PowerPoint - kougi9.ppt

Baud Rate 9600 Parity NONE Number of Data Bits 8 Number of Stop Bits 1 Flow Control NONE 1 RS232C 200mm 2,000mm DIMM ( ) Telescope East/West LX200 * 1

kiso2-09.key

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

C 2 / 21 1 y = x 1.1 lagrange.c 1 / Laglange / 2 #include <stdio.h> 3 #include <math.h> 4 int main() 5 { 6 float x[10], y[10]; 7 float xx, pn, p; 8 in

Transcription:

43 6 MPI MPI(Message Passing Interface) MPI 1CPU/1 PC Cluster MPICH[5] 6.1 MPI MPI MPI 1 : #include <stdio.h> 2 : #include <stdlib.h> 3 : #include <math.h> 4 : 5 : #include "mpi.h" 7 : int main(int argc, char *argv[]) 8 : { 9 : MPI_Init(&argc, &argv); 10 : 11 : printf("\n"); 12 : 13 : MPI_Finalize(); 14 : 15 : return EXIT_SUCCESS; 1 } 17 : Makefile MPICH 1 : CC=mpicc 2 : DEL=rm 3 :

44 6 MPI 4 : #LIB=-lmpich -lm 5 : LIB=-lmpi -lm 7 : mpi1: mpi1.c 8 : $(CC) -o mpi1 mpi1.c $(LIB) 9 : 10 : clean: 11 : -$(DEL) mpi1 make mpi1 1 % mpirun -np 1./mpi1 % 2, 4, 8 % mpirun -np 2./mpi1 % mpirun -np 4./mpi1 % mpirun -np 8./mpi1 %

6.2. ( ) 45 MPI ( ) mpirun (SPMD ) prinf 0 6.2 ( ) Makefile 1 : #include <stdio.h> 2 : #include <stdlib.h> 3 : #include <math.h> 4 : 5 : #include "mpi.h" 7 : int main(int argc, char *argv[]) 8 : { 9 : int namelen, num_procs, myrank; 10 : char processor_name[mpi_max_processor_name]; 11 : 12 : MPI_Init(&argc, &argv); 13 : 14 : MPI_Comm_size(MPI_COMM_WORLD, &num_procs); 15 : MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 1 MPI_Get_processor_name(processor_name, &namelen); 17 : 18 : printf(" at Process %d of %d on %s\n", myrank, nu m_procs, processor_name); 19 : 20 : MPI_Finalize(); 21 : 22 : return EXIT_SUCCESS; 23 : } 24 : 8 PC Cluster % mpirun -np 8./mpi2

46 6 MPI Process 0 of 8 on cs-southpole Process 4 of 8 on cs-room443-b04 Process 2 of 8 on cs-room443-b02 Process 6 of 8 on cs-room443-s03 Process 3 of 8 on cs-room443-b03 Process 7 of 8 on cs-room443-s04 Process 1 of 8 on cs-room443-b01 Process 5 of 8 on cs-room443-s02 % IEEE754 5 1 : #include <stdio.h> 2 : #include <stdlib.h> 3 : #include <math.h> 4 : 5 : #include "mpi.h" 7 : int main(int argc, char *argv[]) 8 : { 9 : int num_procs, myrank; 10 : double a, b; 11 : 12 : MPI_Init(&argc, &argv); 13 : 14 : MPI_Comm_size(MPI_COMM_WORLD, &num_procs); 15 : MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 1 17 : a = 1.0; 18 : b = 3.14159; 19 : 20 : switch(myrank % 4)

6.2. ( ) 47 21 : { 22 : case 0: printf("%2d: %e + %e = %e\n", myrank, a, b, a + b ); break; 23 : case 1: printf("%2d: %e - %e = %e\n", myrank, a, b, a - b ); break; 24 : case 2: printf("%2d: %e * %e = %e\n", myrank, a, b, a * b ); break; 25 : case 3: printf("%2d: %e / %e = %e\n", myrank, a, b, a / b ); break; 2 default: printf("%2d: No Computation\n", myrank); break; 27 : } 28 : 29 : MPI_Finalize(); 30 : 31 : return EXIT_SUCCESS; 32 : } 33 : 5 % mpirun -np 5./mpi3 1.000000e+00 + 3.141590e+00 = 4.141590e+00 1.000000e+00 * 3.141590e+00 = 3.141590e+00 1.000000e+00-3.141590e+00 = -2.141590e+00 1.000000e+00 / 3.141590e+00 = 3.183102e-01 No Computation % 1 : #include <stdio.h> 2 : #include <stdlib.h> 3 : #include <math.h> 4 : 5 : #include "mpi.h" 7 : int main(int argc, char *argv[]) 8 : { 9 : int num_procs, myrank; 10 : double a[128], b[128]; 11 : 12 : MPI_Init(&argc, &argv);

48 6 MPI 13 : 14 : MPI_Comm_size(MPI_COMM_WORLD, &num_procs); 15 : MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 1 17 : a[myrank] = num_procs - myrank; 18 : b[myrank] = myrank; 19 : 20 : printf("%e + %e = %e\n", a[myrank], b[myrank], a[myrank] + b[ myrank]); 21 : 22 : MPI_Finalize(); 23 : 24 : return EXIT_SUCCESS; 25 : } 2 8 % mpirun -np 8./mpi4 8.000000e+00 + 0.000000e+00 = 8.000000e+00 6.000000e+00 + 2.000000e+00 = 8.000000e+00 4.000000e+00 + 4.000000e+00 = 8.000000e+00 2.000000e+00 + 6.000000e+00 = 8.000000e+00 7.000000e+00 + 1.000000e+00 = 8.000000e+00 5.000000e+00 + 3.000000e+00 = 8.000000e+00 3.000000e+00 + 5.000000e+00 = 8.000000e+00 1.000000e+00 + 7.000000e+00 = 8.000000e+00 % 6.3 1 1 1 1 MPI Send/MPI Recv MPI Send MPI Send(

6.3. 1 1 49 (void *), int, MPI Datatype, int, int, MPI Comm ) MPI Recv MPI Recv( (void *), int, MPI Datatype, int, int, MPI Comm MPI Status * ) 0(PE0) 1(PE1) IEEE754 1 : #include <stdio.h> 2 : #include <stdlib.h> 3 : #include <math.h> 4 : 5 : #include "mpi.h" 7 : int main(int argc, char *argv[]) 8 : { 9 : int num_procs, myrank; 10 : double a, b; 11 : int tag = 0; 12 : MPI_Status status;

50 6 MPI 13 : 14 : MPI_Init(&argc, &argv); 15 : 1 MPI_Comm_size(MPI_COMM_WORLD, &num_procs); 17 : MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 18 : 19 : a = 0; 20 : b = 0; 21 : if(myrank == 0) 22 : { 23 : a = 1.0; 24 : MPI_Send((void *)&a, 1, MPI_DOUBLE, 1, tag, MPI_COMM_WORL D); 25 : } 2 else if(myrank == 1) 27 : { 28 : MPI_Recv((void *)&b, 1, MPI_DOUBLE, 0, tag, MPI_COMM_WORL D, &status); 29 : } 30 : 31 : printf("process %d: a = %e, b = %e\n", myrank, a, b); 32 : 33 : MPI_Finalize(); 34 : 35 : return EXIT_SUCCESS; 3 } 37 : mpi-sr 2 % mpirun -np 2./mpi-sr Process 0: a = 1.000000e+00, b = 0.000000e+00 Process 1: a = 0.000000e+00, b = 1.000000e+00 % 6.1 6.4 MPI mpi-sr.c MPIBNCpack Makefile 1 : CC=mpicc

6.4. MPI 51 a=1 MPI_Send PE0 PE1 b=1 MPI_Recv a=1 時間の流れ b=1 時間の流れ 6.1: mpi-sr.c

52 6 MPI 2 : DEL=rm 3 : 4 : INC=-I/usr/local/include 5 : LIBDIR=-L/usr/local/lib 7 : #LIB=-lmpibnc -lmpich -lbnc -lmpfr -lgmp -lm 8 : LIB=$(LIBDIR) -lmpibnc -lmpi -lbnc -lmpfr -lgmp -lm 9 : 10 : mpi-sr-gmp: mpi-sr-gmp.c 11 : $(CC) $(INC) -o mpi-sr-gmp mpi-sr-gmp.c $(LIB) 12 : 13 : clean: 14 : -$(DEL) mpi-sr-gmp 1 : #include <stdio.h> 2 : #include <stdlib.h> 3 : #include <math.h> 4 : 5 : #include "mpi.h" 7 : #define USE_GMP 8 : #define USE_MPFR 9 : #include "gmp.h" 10 : #include "mpfr.h" 11 : #include "mpi_bnc.h" 12 : 13 : main(int argc, char *argv[]) 14 : { 15 : int num_procs, myrank; 1 mpf_t a, b; 17 : void *buf; 18 : int tag = 0; 19 : MPI_Status status; 20 : 21 : MPI_Init(&argc, &argv); 22 : 23 : _mpi_set_bnc_default_prec_decimal(50, MPI_COMM_WORLD); 24 : commit_mpf(&(mpi_mpf), ceil(50/log10(2.0)), MPI_COMM_WORLD); 25 : 2 MPI_Comm_size(MPI_COMM_WORLD, &num_procs); 27 : MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 28 : 29 : mpf_init_set_ui(a, 0);

6.4. MPI 53 30 : mpf_init_set_ui(b, 0); 31 : if(myrank == 0) 32 : { 33 : mpf_set_ui(a, 1); 34 : buf = allocbuf_mpf(mpf_get_prec(a), 1); 35 : pack_mpf(a, 1, buf); 3 MPI_Send(buf, 1, MPI_MPF, 1, tag, MPI_COMM_WORLD); 37 : } 38 : else if(myrank == 1) 39 : { 40 : buf = allocbuf_mpf(mpf_get_prec(b), 1); 41 : MPI_Recv(buf, 1, MPI_MPF, 0, tag, MPI_COMM_WORLD, &status ); 42 : unpack_mpf(buf, b, 1); 43 : } 44 : 45 : printf("process %d: a = ", myrank); 4 mpf_out_str(stdout, 10, 0, a); 47 : printf(", b = "); 48 : mpf_out_str(stdout, 10, 0, b); 49 : printf("\n"); 50 : 51 : mpf_clear(a); 52 : mpf_clear(b); 53 : free_mpf(&(mpi_mpf)); 54 : 55 : MPI_Finalize(); 5 57 : return EXIT_SUCCESS; 58 : } 59 : 6.2 10 50 % mpirun -np 2./mpi-sr-gmp ------------------------------------------------------------------------------- BNC Default Precision : 167 bits(50.3 decimal digits) BNC Default Rounding Mode: Round to Nearest ------------------------------------------------------------------------------- Process 0: a = 1.0000000000000000000000000000000000000000000000000, b = 0 Process 1: a = 0, b = 1.0000000000000000000000000000000000000000000000000

54 6 MPI _mpfr_prec _mpfr_sign _mpfr_exp *_mpfr_d mpfr_t data type PE0 0 1 pack_mpf void * _mpfr_prec _mpfr_sign _mpfr_exp 0 1 send/recv void * _mpfr_prec _mpfr_sign _mpfr_exp 0 1 unpack_mpf _mpfr_size _mpfr_prec _mpfr_exp *_mpfr_d mpfr_t data type 0 1 PE1 6.2: FP 1. mpi4.c (rand() ) IEEE754 2. mpi-sr.c b 1 a ( 6.3 ) % mpirun -np 8./mpi-sr1 Process 0: a = 1.000000e+00, b = 0.000000e+00 Process 2: a = 3.000000e+00, b = 2.000000e+00 Process 3: a = 4.000000e+00, b = 3.000000e+00 Process 4: a = 5.000000e+00, b = 4.000000e+00 Process 7: a = 0.000000e+00, b = 7.000000e+00 Process 6: a = 7.000000e+00, b = 6.000000e+00 Process 1: a = 2.000000e+00, b = 1.000000e+00 Process 5: a = 6.000000e+00, b = 5.000000e+00 % 3. mpi-sr-gmp.c

6.4. MPI 55 PE0 PE1 PE2 PE3 PE4 PE5 PE6 PE7 a=1 b=1 a=1+1 b=2 a=2+1 b=3 a=3+1 b=4 a=4+1 b=5 a=5+1 b=6 a=6+1 b=7 a=1 a=2 b=1 a=3 b=2 a=4 b=3 a=5 b=4 a=6 b=5 a=7 b=6 b=7 6.3: mpi-sr1.c