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

Size: px
Start display at page:

Download "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"

Transcription

1 MPI MPI MPI ( ) (Allreduce ) CPU 1

2 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 parallelization) 100% MPI Mac OS X 2 $ echo Hello Hello Hello mpirun $ mpirun -np 2 echo Hello Hello Hello Hello mpirun -np -np 2 Hello -np 4 4 Hello 4 1 OpenMP OpenMPI OpenMPI MPI OpenMP 2

3 MPI SPMD (Single Program Multiple Data) mpitest.cc main( argc,char **argv){ rank; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&rank); prf("my rank = %d\n",rank); mpic++ $ mpic++ mpitest.cc My rank = 0 My rank = 1 My rank = 2 My rank = 3 mpi.h MPI C/C++ MPI_Init MPI_Finalize MPI_Init main MPI MPI_ MPI_Comm_rank MPI_COMM_WORLD (Rank) MPI OpenMP OpenMP MPI MPI MPI mpic++(macos X) mpcc(aix IBM ) mpic++ g++ icc icpc $ icpc mpitest.cc -I/usr/local/include -L/usr/local/lib -lmpich -lrt ( ) 3

4 3 MPI MPI MPI MPI List 1: ( ) #include <stdlib.h> double myrand(void){ return (double)rand()/(double)rand_max; double calc_pi( seed, trial){ srand(seed); n = 0; for( i=0;i<trial;i++){ double x = myrand(); double y = myrand(); if(x*x + y*y < 1.0){ n++; return 4.0*(double)n/(double)trial; main( argc, char **argv){ double pi = calc_pi(1, ); prf("%f \n",pi); calc_pi seed trial $./a.out main MPI_Init MPI_Finalize 3. MPI_Comm_rank 4. calc_pi 4

5 List 2: ( 1) #include <stdlib.h> double myrand(void){ return (double)rand()/(double)rand_max; double calc_pi( seed, trial){ srand(seed); n = 0; for( i=0;i<trial;i++){ double x = myrand(); double y = myrand(); if(x*x + y*y < 1.0){ n++; return 4.0*(double)n/(double)trial; main( argc, char **argv){ rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); double pi = calc_pi(rank, ); prf("rank=%d: pi = %f \n",rank,pi); 4 rank=0: pi = rank=3: pi = rank=1: pi = rank=2: pi = rank=1 MPI_Comm_size main List 3: ( ) main( argc, char **argv){ rank, size; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); double pi = calc_pi(rank, ); prf("rank=%d:/%d pi = %f \n",rank,size,pi); 5

6 2 4 $ mpirun -np 2./a.out rank=0/2 pi = rank=1/2 pi = rank=1/4 pi = rank=0/4 pi = rank=2/4 pi = rank=3/4 pi = ,2,3 0 0 MPI MPI_Allreduce List 4: ( 3) main( argc, char **argv){ rank, procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &procs); double pi = calc_pi(rank, ); prf("rank=%d/%d pi = %f \n",rank,procs,pi); MPI_Barrier(MPI_COMM_WORLD); double sum = 0; MPI_Allreduce(&pi, &sum, 1, MPI_DOUBLE, MPI_SUM,MPI_COMM_WORLD); sum = sum / (double)procs; if (0==rank){ prf("average = %f\n",sum); rank=0/4 pi = rank=1/4 pi = rank=2/4 pi = rank=3/4 pi = average = ( ) MPI_Allreduce MPI_Allreduce(void* senddata, void* recvdata, count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) senddata recvdata count datatype ( double MPI_DOUBLE) op ( MPI_SUM) MPI_COMM_WORLD MPI_Allreduce 6

7 pi ( ) sum sum MPI_Reduce MPI_Reduce MPI_Allreduce MPI_Reduce List 5: ( 3) main( argc, char **argv){ rank, procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &procs); double pi = calc_pi(rank, ); prf("rank=%d/%d pi = %f \n",rank,procs,pi); MPI_Barrier(MPI_COMM_WORLD); double sum = 0; MPI_Reduce(&pi, &sum, 1, MPI_DOUBLE, MPI_SUM, 0,MPI_COMM_WORLD); if (0==rank){ sum = sum / (double)procs; prf("average = %f\n",sum); ( 0 ) sum 0 MPI_Allreduce MPI C List 6: (C ) main( argc, char **argv){ 2 C/C++ ( & ) Fortran ( ) 7

8 value = 0; scanf("%d",&value); prf("value = %d\n",value); C++ List 7: (C++ ) #include <iostream> main( argc, char **argv){ value = 0; std::cin >> value; std::cout << "value = " << value << std::endl; $./a.out 123 value = List 8: main( argc, char **argv){ rank = 0; MPI_Comm_rank(MPI_COMM_WORLD,&rank); value = 0; if(0 == rank){ scanf("%d",&value); MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD); prf("rank = %d: value = %d\n",rank, value); MPI_Bcast MPI_Bcast(void *buffer, count, MPI_Datatype datatype, root, MPI_Comm comm ) buffer ( ) count root ( 0 ) rank = 0: value = 123 8

9 rank = 1: value = 123 rank = 2: value = 123 rank = 3: value = 123 ( ) (double ) parameter parameter List 9: struct parameter{ seed; double temperature; ; main( argc, char **argv){ rank = 0; MPI_Comm_rank(MPI_COMM_WORLD,&rank); parameter param; if(0 == rank){ scanf("%d",&param.seed); scanf("%lf",&param.temperature); MPI_Bcast(&param, sizeof(param), MPI_BYTE, 0, MPI_COMM_WORLD); prf("rank = %d: seed = %d temperature = %f\n",rank, param.seed, param. temperature); sizeof MPI_BYTE rank = 0: seed = 123 temperature = rank = 1: seed = 123 temperature = rank = 2: seed = 123 temperature = rank = 3: seed = 123 temperature = input.cfg $ cat input.cfg < input.cfg rank = 0: seed = 123 temperature = rank = 1: seed = 123 temperature = rank = 2: seed = 123 temperature = rank = 3: seed = 123 temperature = C C++ 9

10 List 10: (C++ ) #include <iostream> struct parameter{ seed; double temperature; ; main( argc, char **argv){ rank = 0; MPI_Comm_rank(MPI_COMM_WORLD,&rank); parameter param; if(0 == rank){ std::cin >> param.seed; std::cin >> param.temperature; MPI_Bcast(&param, sizeof(param), MPI_BYTE, 0, MPI_COMM_WORLD); std::cout << "rank = " << rank; std::cout << " seed = " << param.seed; std::cout << " temperature = " << param.temperature << std::endl; 4.2 ( ) MPI conf.000.dat,conf.001.dat List 11: (C ) main(void){ const SIZE = 10; array[size]; for( i=0;i<size;i++){ array[i] = i; FILE *fp = fopen("data.dat","w"); for( i=0;i<size;i++){ fprf(fp,"%d\n",array[i]); fclose(fp); #include <iostream> #include <fstream> main(void){ List 12: (C++ ) 10

11 const SIZE = 10; array[size]; for( i=0;i<size;i++){ array[i] = i; std::ofstream ofs("data.dat"); for( i=0;i<size;i++){ ofs << array[i] << std::endl; $./a.out $ cat data.dat array data.dat ( 0 ) ( SIZE 2 ) List 13: (C ) main( argc, char **argv){ rank, procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &procs); const SIZE = 2; array[size]; for( i=0;i<size;i++){ array[i] = rank; FILE *fp; if(0 == rank){ fp = fopen("data.dat","w"); fclose(fp); for( j=0;j<procs;j++){ MPI_Barrier(MPI_COMM_WORLD); if(j!= rank)continue; fp = fopen("data.dat","a"); for( i=0;i<size;i++){ fprf(fp,"%d\n",array[i]); fclose(fp); 11

12 $ cat data.dat data.dat C++ List 14: (C++ ) #include <iostream> #include <fstream> main( argc, char** argv){ rank, procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &procs); const SIZE = 2; array[size]; for( i=0;i<size;i++){ array[i] = rank; if(0==rank){ std::ofstream ofs("data.dat"); ofs.close(); for( j=0;j<procs;j++){ MPI_Barrier(MPI_COMM_WORLD); if(j!=rank)continue; std::ofstream ofs("data.dat",std::ios::app); for( i=0;i<size;i++){ ofs << array[i] << std::endl; ofs.close(); 4.3 (Allreduce ) 12

13 double double List 15: (C ) main( argc, char **argv){ const SIZE = 10; double data[size]; for( i=0;i<size;i++){ data[i] = (double)i; FILE *fp = fopen("data.dat","wb"); fwrite(data,sizeof(double),size,fp); fclose(fp); data.dat hexdump 3 $./a.out $ hexdump -v -e "%f\n" data.dat data 0 0 List 16: Gather(C ) main( argc, char **argv){ rank,procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &procs); const SIZE = 2; double data[size]; for( i=0;i<size;i++){ data[i] = (double)rank; double *buf; if(0==rank){ buf = new double[size*procs]; MPI_Gather(data, SIZE, MPI_DOUBLE, buf, SIZE, MPI_DOUBLE, 0, MPI_COMM_WORLD); if(0==rank){ 3 hexdump c prf hexdump *( ) -v 13

14 FILE *fp = fopen("data.dat","wb"); fwrite(buf,sizeof(double),size*procs,fp); fclose(fp); delete [] buf; 0 MPI_Gather data buf MPI_Gather MPI_Gather(void *sendbuffer, sendcount, MPI_Datatype sendtype, void *recvbuffer, recvcount, MPI_Datatype recvtype, root, MPI_Comm comm ) sendcount recvcount sendtype recvtype root $ hexdump -v -e "%f\n" data.dat C++ #include <iostream> #include <fstream> List 17: (C++ ) main( argc, char **argv){ const SIZE = 10; double data[size]; for( i=0;i<size;i++){ data[i] = (double)i; std::ofstream ofs("data.dat", std::ios::binary); ofs.write((char*)data,sizeof(double)*size); #include <iostream> #include <fstream> List 18: Gather(C++ ) main( argc, char **argv){ rank,procs; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &procs); const SIZE = 2; double data[size]; 14

15 for( i=0;i<size;i++){ data[i] = (double)rank; double *buf; if(0==rank){ buf = new double[size*procs]; MPI_Gather(data, SIZE, MPI_DOUBLE, buf, SIZE, MPI_DOUBLE, 0, MPI_COMM_WORLD); if(0==rank){ std::ofstream ofs("data.dat",std::ios::binary); ofs.write((char*)buf,sizeof(double)*size*procs); delete [] buf; MPI_Send MPI_Recv 0 1 List 19: main( argc, char **argv){ rank; MPI_Comm_rank(MPI_COMM_WORLD,&rank); send_value = rank; recv_value = -1; const TAG = 0; MPI_Status st; if(0==rank){ MPI_Send(&send_value, 1, MPI_INT, 1, TAG, MPI_COMM_WORLD); else if(1==rank){ MPI_Recv(&recv_value, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD,&st); prf("rank = %d: recv_value = %d\n",rank, recv_value); $ mpirun -np 2./a.out rank = 0: recv_value = -1 rank = 1: recv_value = 0 MPI_Send MPI_Recv MPI_Send(void *sendbuffer, sendcount, MPI_Datatype sendtype, sendtag, dest, MPI_Comm comm ) MPI_Recv(void *recvbuffer, recvcount, MPI_Datatype recvtype, recvtag, src, MPI_Status *st, MPI_Comm comm ) sendbuffer recvbuffer sendcount recvcount sendtype recvtype tag 15

16 0 MPI_Status MPI_Send MPI_Recv 4 rank = 0: recv_value = -1 rank = 1: recv_value = 0 rank = 2: recv_value = -1 rank = 3: recv_value = List 20: main( argc, char **argv){ rank; MPI_Comm_rank(MPI_COMM_WORLD,&rank); send_value = rank; recv_value = -1; const TAG = 0; MPI_Status st; if(0==rank){ MPI_Send(&send_value, 1, MPI_INT, 1, TAG, MPI_COMM_WORLD); MPI_Recv(&recv_value, 1, MPI_INT, 1, TAG, MPI_COMM_WORLD,&st); else if(1==rank){ MPI_Send(&send_value, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD); MPI_Recv(&recv_value, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD,&st); prf("rank = %d: recv_value = %d\n",rank, recv_value); MPI_Send MPI_Recv 0 1 List 21: main( argc, char **argv){ rank; MPI_Comm_rank(MPI_COMM_WORLD,&rank); send_value = rank; recv_value = -1; const TAG = 0; MPI_Status st; if(0==rank){ MPI_Send(&send_value, 1, MPI_INT, 1, TAG, MPI_COMM_WORLD); 4 MPI 16

17 MPI_Recv(&recv_value, 1, MPI_INT, 1, TAG, MPI_COMM_WORLD,&st); else if(1==rank){ MPI_Recv(&recv_value, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD,&st); MPI_Send(&send_value, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD); prf("rank = %d: recv_value = %d\n",rank, recv_value); $ mpirun -np 2./a.out rank = 0: recv_value = 1 rank = 1: recv_value = 0 MPI_Sendrecv MPI_Sendrecv MPI_Sendrecv(void *sendbuf, sendcount, MPI_Datatype sendtype, dest, sendtag, void *recvbuf, recvcount, MPI_Datatype recvtype, src, recvtag, MPI_Comm comm, MPI_Status *status ) MPI_Send MPI_Recv MPI_Sendrecv List 22: Sendrecv main( argc, char **argv){ rank; MPI_Comm_rank(MPI_COMM_WORLD,&rank); send_value = rank; recv_value = -1; const TAG = 0; MPI_Status st; if(0==rank){ MPI_Sendrecv(&send_value, 1, MPI_INT, 1, TAG, &recv_value, 1, MPI_INT, 1, TAG, MPI_COMM_WORLD,&st); else if(1==rank){ MPI_Sendrecv(&send_value, 1, MPI_INT, 0, TAG, &recv_value, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD,&st); prf("rank = %d: recv_value = %d\n",rank, recv_value); MPI_Sendrecv List 23: Sendrecv main( argc, char **argv){ rank, procs; MPI_Comm_rank(MPI_COMM_WORLD,&rank); 17

18 MPI_Comm_size(MPI_COMM_WORLD,&procs); send_value = rank; recv_value = -1; dest_rank = (rank+1)%procs; src_rank = (rank-1+procs)%procs; const TAG = 0; MPI_Status st; MPI_Sendrecv(&send_value, 1, MPI_INT, dest_rank, TAG, &recv_value, 1, MPI_INT, src_rank, TAG, MPI_COMM_WORLD,&st); prf("rank = %d: recv_value = %d\n",rank, recv_value); if if if rank = 0: recv_value = 3 rank = 1: recv_value = 0 rank = 2: recv_value = 1 rank = 3: recv_value = MPI_Sendrecv MPI_Send MPI_Recv MPI_Sendrecv 5.2 MPI_Send MPI_Recv MPI_Isend MPI_Irecv MPI_REQUEST_MAX MPI_Request_free 6 MPI 18

目 目 用方 用 用 方

目 目 用方 用 用 方 大 生 大 工 目 目 用方 用 用 方 用 方 MS-MPI MPI.NET MPICH MPICH2 LAM/MPI Ver. 2 2 1 2 1 C C++ Fortan.NET C# C C++ Fortan 用 行 用 用 用 行 用 言 言 言 行 生 方 方 一 行 高 行 行 文 用 行 If ( rank == 0 ) { // 0 } else if (rank == 1) {

More information

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

演習 II 2 つの講義の演習 奇数回 : 連続系アルゴリズム 部分 偶数回 : 計算量理論 部分 連続系アルゴリズム部分は全 8 回を予定 前半 2 回 高性能計算 後半 6 回 数値計算 4 回以上の課題提出 ( プログラム + 考察レポート ) で単位 演習 II ( 連続系アルゴリズム ) 第 1 回 : MPI 須田研究室 M2 本谷徹 [email protected] 2012/10/05 2012/10/18 補足 訂正 演習 II 2 つの講義の演習 奇数回 : 連続系アルゴリズム 部分 偶数回 : 計算量理論 部分 連続系アルゴリズム部分は全 8 回を予定 前半 2 回 高性能計算 後半 6 回 数値計算 4 回以上の課題提出

More information

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

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 43 6 MPI MPI(Message Passing Interface) MPI 1CPU/1 PC Cluster MPICH[5] 6.1 MPI MPI MPI 1 : #include 2 : #include 3 : #include 4 : 5 : #include "mpi.h" 7 : int main(int argc,

More information

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

C/C++ FORTRAN FORTRAN MPI MPI MPI UNIX Windows (SIMD Single Instruction Multipule Data) SMP(Symmetric Multi Processor) MPI (thread) OpenMP[5] MPI ( ) [email protected] 1 ( ) MPI MPI Message Passing Interface[2] MPI MPICH[3],LAM/MPI[4] (MIMDMultiple Instruction Multipule Data) Message Passing ( ) (MPI (rank) PE(Processing Element)

More information

WinHPC ppt

WinHPC ppt MPI.NET C# 2 2009 1 20 MPI.NET MPI.NET C# MPI.NET C# MPI MPI.NET 1 1 MPI.NET C# Hello World MPI.NET.NET Framework.NET C# API C# Microsoft.NET java.net (Visual Basic.NET Visual C++) C# class Helloworld

More information

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

Microsoft PowerPoint - 演習2:MPI初歩.pptx 演習 2:MPI 初歩 - 並列に計算する - 2013 年 8 月 6 日 神戸大学大学院システム情報学研究科計算科学専攻横川三津夫 MPI( メッセージ パッシング インターフェース ) を使おう! [ 演習 2 の内容 ] はじめの一歩課題 1: Hello, world を並列に出力する. 課題 2: プロセス 0 からのメッセージを受け取る (1 対 1 通信 ). 部分に分けて計算しよう課題

More information

コードのチューニング

コードのチューニング MPI による並列化実装 ~ ハイブリッド並列 ~ 八木学 ( 理化学研究所計算科学研究センター ) KOBE HPC Spring School 2019 2019 年 3 月 14 日 MPI とは Message Passing Interface 分散メモリのプロセス間の通信規格(API) SPMD(Single Program Multi Data) が基本 - 各プロセスが 同じことをやる

More information

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

±é½¬£²¡§£Í£Ð£É½éÊâ 2012 8 7 1 / 52 MPI Hello World I ( ) Hello World II ( ) I ( ) II ( ) ( sendrecv) π ( ) MPI fortran C wget http://www.na.scitec.kobe-u.ac.jp/ yaguchi/riken2012/enshu2.zip unzip enshu2.zip 2 / 52 FORTRAN

More information

main() {... } main() { main() { main() {......... } } } main() { main() { main() {......... } } } main() { if(rank==)... } main() { if(rank==)... } main() { if(rank==x)... } P(N) P(N) / P(M) * ( M / N

More information

86

86 86 86 86 main() {... } main() { main() { main() {......... } } } 86 main() { main() { main() {......... } } } main() { if(rank==)... } main() { if(rank==)... } main() { if(rank==x)... } 86 P(N) P(N) /

More information

untitled

untitled RIKEN AICS Summer School 3 4 MPI 2012 8 8 1 6 MPI MPI 2 allocatable 2 Fox mpi_sendrecv 3 3 FFT mpi_alltoall MPI_PROC_NULL 4 FX10 /home/guest/guest07/school/ 5 1 A (i, j) i+j x i i y = Ax A x y y 1 y i

More information

MPI usage

MPI usage MPI (Version 0.99 2006 11 8 ) 1 1 MPI ( Message Passing Interface ) 1 1.1 MPI................................. 1 1.2............................... 2 1.2.1 MPI GATHER.......................... 2 1.2.2

More information

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

Microsoft PowerPoint - 講義:片方向通信.pptx MPI( 片方向通信 ) 09 年 3 月 5 日 神戸大学大学院システム情報学研究科計算科学専攻横川三津夫 09/3/5 KOBE HPC Spring School 09 分散メモリ型並列計算機 複数のプロセッサがネットワークで接続されており, れぞれのプロセッサ (PE) が, メモリを持っている. 各 PE が自分のメモリ領域のみアクセス可能 特徴数千から数万 PE 規模の並列システムが可能

More information

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

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

More information

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

¥Ñ¥Ã¥±¡¼¥¸ Rhpc ¤Î¾õ¶· Rhpc COM-ONE 2015 R 27 12 5 1 / 29 1 2 Rhpc 3 forign MPI 4 Windows 5 2 / 29 1 2 Rhpc 3 forign MPI 4 Windows 5 3 / 29 Rhpc, R HPC Rhpc, ( ), snow..., Rhpc worker call Rhpc lapply 4 / 29 1 2 Rhpc 3 forign

More information

Microsoft PowerPoint _MPI-03.pptx

Microsoft PowerPoint _MPI-03.pptx 計算科学演習 Ⅰ ( 第 11 回 ) MPI を いた並列計算 (III) 神戸大学大学院システム情報学研究科横川三津夫 [email protected] 2014/07/03 計算科学演習 Ⅰ:MPI を用いた並列計算 (III) 1 2014/07/03 計算科学演習 Ⅰ:MPI を用いた並列計算 (III) 2 今週の講義の概要 1. 前回課題の解説 2. 部分配列とローカルインデックス

More information

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

Microsoft PowerPoint 並列アルゴリズム04.ppt 並列アルゴリズム 2005 年後期火曜 2 限 青柳睦 [email protected] http://server-500.cc.kyushu-u.ac.jp/ 11 月 8 日 ( 火 ) 5. MPI の基礎 6. 並列処理の性能評価 1 もくじ 1. 序並列計算機の現状 2. 計算方式およびアーキテクチュアの分類 3. 並列計算の目的と課題 4. 数値計算における各種の並列化

More information

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

<4D F736F F F696E74202D C097F B A E B93C782DD8EE682E890EA97705D> 並列アルゴリズム 2005 年後期火曜 2 限青柳睦 [email protected] http//server-500.cc.kyushu-u.ac.jp/ 11 月 29( 火 ) 7. 集団通信 (Collective Communication) 8. 領域分割 (Domain Decomposition) 1 もくじ 1. 序並列計算機の現状 2. 計算方式およびアーキテクチュアの分類

More information

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

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 57 7 MPI MPI 1 1 7.1 Bcast( ) allocate Bcast a=1 PE0 a=1 PE1 a=1 PE2 a=1 PE3 7.1: Bcast 58 7 MPI 7 : main(int argc, char *argv[]) 8 : { 9 : int num_procs, myrank; 10 : double a, b; 11 : int tag = 0; 12

More information

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

Microsoft PowerPoint - MPIprog-C2.ppt [互換モード] MPI によるプログラミング概要 ( その ) C 言語編 RIKEN AICS HPC Summer School 01 中島研吾 ( 東大 情報基盤センター ) 横川三津夫 ( 神戸大学 計算科学教育センター ) 1 概要 MPI とは MPI の基礎 :Hello World 全体データと局所データ グループ通信 (Collective Communication) 1 対 1 通信 (Peer-to-Peer

More information

MPI MPI MPI.NET C# MPI Version2

MPI MPI MPI.NET C# MPI Version2 MPI.NET C# 2 2009 2 27 MPI MPI MPI.NET C# MPI Version2 MPI (Message Passing Interface) MPI MPI Version 1 1994 1 1 1 1 ID MPI MPI_Send MPI_Recv if(rank == 0){ // 0 MPI_Send(); } else if(rank == 1){ // 1

More information

演習準備

演習準備 演習準備 2014 年 3 月 5 日神戸大学大学院システム情報学研究科森下浩二 1 演習準備の内容 神戸大 FX10(π-Computer) 利用準備 システム概要 ログイン方法 コンパイルとジョブ実行方法 MPI 復習 1. MPIプログラムの基本構成 2. 並列実行 3. 1 対 1 通信 集団通信 4. データ 処理分割 5. 計算時間計測 2 神戸大 FX10(π-Computer) 利用準備

More information

120802_MPI.ppt

120802_MPI.ppt CPU CPU CPU CPU CPU SMP Symmetric MultiProcessing CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU CP OpenMP MPI MPI CPU CPU CPU CPU CPU CPU CPU CPU CPU CPU MPI MPI+OpenMP CPU CPU CPU CPU CPU CPU CPU CP

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

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

Fundamental MPI 1 概要 MPI とは MPI の基礎 :Hello World 全体データと局所データタ グループ通信 (Collective Communication) 1 対 1 通信 (Point-to-Point Communication) MPI 超 入門 (C 言語編 ) 東京大学情報基盤センター FOTRAN 編は以下 http://nkl.cc.u-tokyo.ac.jp/seminars/t2kfvm/mpiprogf.pdf tokyo pdf Fundamental MPI 1 概要 MPI とは MPI の基礎 :Hello World 全体データと局所データタ グループ通信 (Collective Communication)

More information

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

Fundamental MPI 1 概要 MPI とは MPI の基礎 :Hello World 全体データと局所データタ グループ通信 (Collective Communication) 1 対 1 通信 (Point-to-Point Communication) MPI 超 入門 (FORTRAN 編 ) 東京大学情報基盤センター Fundamental MPI 1 概要 MPI とは MPI の基礎 :Hello World 全体データと局所データタ グループ通信 (Collective Communication) 1 対 1 通信 (Point-to-Point Communication) Fundamental MPI 2 MPI とは (1/2)

More information

2012 6 1 MPI 1995 8 2002 2003 ( 2) MPI http://accc.riken.jp/hpc/training.html iii 1 1 1-1.......................................... 2 1-2........................................... 4 2 9 2-1...............................................

More information

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

情報処理概論(第二日目) 1 並列プログラミング超入門講習会 九州大学情報基盤研究開発センター MPI コース 2 並列計算機の構成 計算ノード ネットワーク CPU コア メモリ アクセラレータ (GPU 等 ) 例 : スーパーコンピュータシステム ITO サブシステム B ノード数 CPU 数 / ノードコア数 / CPU GPU 数 / ノード 128 2 18 4 MPI (Message Passing Interface)

More information

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

Microsoft PowerPoint - MPIprog-F2.ppt [互換モード] MPI によるプログラミング概要 ( その ) Fortran 言語編 RIKEN AICS HPC Summer School 01 中島研吾 ( 東大 情報基盤センター ) 横川三津夫 ( 神戸大学 計算科学教育センター ) 1 概要 MPI とは MPI の基礎 :Hello World 全体データと局所データ グループ通信 (Collective Communication) 1 対 1 通信

More information

Page 2 本資料は, 東北大学サイバーサイエンスセンターと NEC の共同により作成され, 大阪大学サイバーメディアセンターの環境で実行確認を行い, 修正を加えたものです. 無断転載等は, ご遠慮下さい.

Page 2 本資料は, 東北大学サイバーサイエンスセンターと NEC の共同により作成され, 大阪大学サイバーメディアセンターの環境で実行確認を行い, 修正を加えたものです. 無断転載等は, ご遠慮下さい. H26 年度 MPI プログラミング入門 2015 年 1 月 27 日 大坂大学サイバーメディアセンター 日本電気株式会社 Page 2 本資料は, 東北大学サイバーサイエンスセンターと NEC の共同により作成され, 大阪大学サイバーメディアセンターの環境で実行確認を行い, 修正を加えたものです. 無断転載等は, ご遠慮下さい. 目次 1. 並列化概要 2. MPI 概要 3. 演習問題 1 4.

More information

MPI によるプログラミング概要 C 言語編 中島研吾 東京大学情報基盤センター

MPI によるプログラミング概要 C 言語編 中島研吾 東京大学情報基盤センター MPI によるプログラミング概要 C 言語編 中島研吾 東京大学情報基盤センター 1 並列計算の意義 目的 並列計算機の使用によって, より大規模で詳細なシミュレーションを高速に実施することが可能になり, 新しい科学の開拓が期待される 並列計算の目的 高速 大規模 大規模 の方が 新しい科学 という観点からのウェイトとしては高い しかし, 高速 ももちろん重要である + 複雑 理想 :Scalable

More information

Microsoft PowerPoint - S1-ref-F.ppt [互換モード]

Microsoft PowerPoint - S1-ref-F.ppt [互換モード] 課題 S1 解説 Fortran 言語編 RIKEN AICS HPC Summer School 2014 中島研吾 ( 東大 情報基盤センター ) 横川三津夫 ( 神戸大 計算科学教育センター ) MPI Programming 課題 S1 (1/2) /a1.0~a1.3, /a2.0~a2.3 から局所ベクトル情報を読み込み, 全体ベクトルのノルム ( x ) を求めるプログラムを作成する

More information

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

115 9 MPIBNCpack 9.1 BNCpack 1CPU X = , B = 115 9 MPIBNCpack 9.1 BNCpack 1CPU 1 2 3 4 5 25 24 23 22 21 6 7 8 9 10 20 19 18 17 16 X = 11 12 13 14 15, B = 15 14 13 12 11 16 17 18 19 20 10 9 8 7 6 21 22 23 24 25 5 4 3 2 1 C = XB X dmat1 B dmat2 C dmat

More information

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

Microsoft PowerPoint - MPIprog-F1.ppt [互換モード] MPI によるプログラミング概要 ( その 1) Fortran 言語編 RIKEN AICS HPC Summer School 2015 中島研吾 ( 東大 情報基盤センター ) 横川三津夫 ( 神戸大 計算科学教育センター ) 1 本 school の目的 並列計算機の使用によって, より大規模で詳細なシミュレーションを高速に実施することが可能になり, 新しい科学の開拓が期待される 並列計算の目的

More information

untitled

untitled I 9 MPI (II) 2012 6 14 .. MPI. 1-3 sum100.f90 4 istart=myrank*25+1 iend=(myrank+1)*25 0 1 2 3 mpi_recv 3 isum1 1 isum /tmp/120614/sum100_4.f90 program sum100_4 use mpi implicit none integer :: i,istart,iend,isum,isum1,ip

More information

cpp1.dvi

cpp1.dvi 2017 c 1 C++ (1) C C++, C++, C 11, 12 13 (1) 14 (2) 11 1 n C++ //, [List 11] 1: #include // C 2: 3: int main(void) { 4: std::cout

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション AICS 公開ソフトウェア講習会 15 回 表題通信ライブラリと I/O ライブラリ 場所 AICS R104-2 時間 2016/03/23 ( 水 ) 13:30-17:00 13:30-13:40 全体説明 13:40-14:10 PRDMA 14:10-14:40 MPICH 14:40-15:10 PVAS 15:10-15:30 休憩 15:30-16:00 Carp 16:00-16:30

More information

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

1-4 int a; std::cin >> a; std::cout << a =  << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >> 1 C++ 1.1 C C++ C++ C C C++ 1.1.1 C printf() scanf() C++ C hello world printf() 1-1 #include printf( "hello world\n" ); C++ 1-2 std::cout

More information

programmingII2019-v01

programmingII2019-v01 II 2019 2Q A 6/11 6/18 6/25 7/2 7/9 7/16 7/23 B 6/12 6/19 6/24 7/3 7/10 7/17 7/24 x = 0 dv(t) dt = g Z t2 t 1 dv(t) dt dt = Z t2 t 1 gdt g v(t 2 ) = v(t 1 ) + g(t 2 t 1 ) v v(t) x g(t 2 t 1 ) t 1 t 2

More information

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

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 149 11 DKA IEEE754 11.1 DKA n p(x) = a n x n + a n 1 x n 1 + + a 0 (11.1) p(x) = 0 (11.2) p n (x) q n (x) = x n + c n 1 x n 1 + + c 1 x + c 0 q n (x) = 0 (11.3) c i = a i a n (i = 0, 1,..., n 1) (11.3)

More information

超初心者用

超初心者用 3 1999 10 13 1. 2. hello.c printf( Hello, world! n ); cc hello.c a.out./a.out Hello, world printf( Hello, world! n ); 2 Hello, world printf n printf 3. ( ) int num; num = 100; num 100 100 num int num num

More information

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology I117 8 1 School of Information Science, Japan Advanced Institute of Science and Technology : CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and

More information

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

Microsoft Word - 計算科学演習第1回3.doc スーパーコンピュータの基本的操作方法 2009 年 9 月 10 日高橋康人 1. スーパーコンピュータへのログイン方法 本演習では,X 端末ソフト Exceed on Demand を使用するが, 必要に応じて SSH クライアント putty,ftp クライアント WinSCP や FileZilla を使用して構わない Exceed on Demand を起動し, 以下のとおり設定 ( 各自のユーザ

More information

double float

double float 2015 3 13 1 2 2 3 2.1.......................... 3 2.2............................. 3 3 4 3.1............................... 4 3.2 double float......................... 5 3.3 main.......................

More information

nakao

nakao Fortran+Python 4 Fortran, 2018 12 12 !2 Python!3 Python 2018 IEEE spectrum https://spectrum.ieee.org/static/interactive-the-top-programming-languages-2018!4 Python print("hello World!") if x == 10: print

More information

MPI によるプログラミング概要 Fortran 編 中島研吾 東京大学情報基盤センター

MPI によるプログラミング概要 Fortran 編 中島研吾 東京大学情報基盤センター MPI によるプログラミング概要 Fortran 編 中島研吾 東京大学情報基盤センター 1 並列計算の意義 目的 並列計算機の使用によって, より大規模で詳細なシミュレーションを高速に実施することが可能になり, 新しい科学の開拓が期待される 並列計算の目的 高速 大規模 大規模 の方が 新しい科学 という観点からのウェイトとしては高い しかし, 高速 ももちろん重要である + 複雑 理想 :Scalable

More information

Microsoft PowerPoint - 阪大CMSI pptx

Microsoft PowerPoint - 阪大CMSI pptx 内容に関する質問は [email protected] まで 第 2 回 MPI の基礎 名古屋大学情報基盤センター 片桐孝洋 1 講義日程と内容について (1 学期 : 木曜 3 限 ) 第 1 回 : プログラム高速化の基礎 2017 年 4 月 13 日 イントロダクション ループアンローリング キャッシュブロック化 数値計算ライブラリの利用 その他第 2 回 :MPIの基礎

More information

r03.dvi

r03.dvi 19 ( ) 019.4.0 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void... argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0 a a \0 b b b \0 c c c \0 1: // argdemo1.c ---

More information

ohp03.dvi

ohp03.dvi 19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0

More information