Changes between Version 1 and Version 2 of mpich


Ignore:
Timestamp:
May 23, 2008, 11:33:51 AM (16 years ago)
Author:
wade
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • mpich

    v1 v2  
    1 Not available
     1[[PageOutline]]
     2= Introduction =
     3MPI ( Message Passing Interface) ,一個用於平行計算的平臺。[[BR]]
     4[http://www-unix.mcs.anl.gov/mpi/mpich1/docs.html doc][[BR]]
     5[https://computing.llnl.gov/tutorials/parallel_comp/ LLNL參考資料]
     6
     7
     8= Classifying of parallel computers  =
     9 * SISD(Single-Instruction Single-Data)
     10    如普通的單核心 PC ,只有單一指令與資料,ex: a = 1 + 1。
     11 * SIMD(Single-Instruction Multiple-Data)
     12    同一組指令,多組資料,ex: a = b + 1, b 是一組陣列,則同一時間就可以計算完成。而不需要算完 b[1] + 1,再算 b[1] + 1…再算 b[n] + 1。
     13 * MISD(ultiple-Instruction Single-Data)
     14    多組指令,單一組資料,ex: a = (2 + 3) + (2 - 3) + (2 * 3) + (2 / 3),則四臺機器各執行 2 跟 3 的操作指令 「=」、「-」、「*」及「/」中的一種,用的資料是 2 跟 3。 
     15 * MIMD(Multiple-Instruction Multiple-Data)
     16    多組指令,多組資料,ex: a = (b + c) + (d - e) + (f * g),如果有三臺機器可分別執行(b + c) 、 (d - e) 及 (f * g),則三個運算可同時進行。
     17
     18
     19= Design =
     20指令及資料量切割的越小越有助於平行運算,但切割過小將會使傳輸次數及傳輸量增大,而且每次傳輸所需要的時間遠大於每次的計算,因此在設計程式為了得最高效能,須考慮到計算量、計算進度、傳輸量及傳輸速度。
     21
     22
     23= Communication =
     24 * Point to point communication
     25   主要用在 one to one ,特定指定機器與機器間的傳送,傳送與接收的次數要相同,同一筆資料可以分多次傳送,但是每次傳送皆需花費時間,要考慮網路速度及機器處理能力。
     26   * Command
     27     * [wiki:mpich/MPI_Send MPI_Send]
     28     * [wiki:mpich/MPI_Recv MPI_Recv]
     29   * Demo
     30     * [wiki:mpich/point_to_point/demo1 demo1]
     31   * note
     32     * tag 的用意在於區別同一個發送端發送多筆同一種類型的資料給同一個接收者。[[BR]]
     33       以下圖為例, node 0 發送了兩個資料類型相同的 x 及 y ,而 node 0 則無法判別它收到的是來自 node 0 的 x 還是 y 。
     34       [[Image(mpi-fig-1.png)]][[BR]][[BR]]
     35       這時我們就需要使用到 tag1 及 tag2 來區別。[[BR]]
     36       [[Image(mpi-fig-2.png)]][[BR]]
     37
     38
     39 * Collective communication
     40   * MPI_Scatter、MPI_Gather、MPI_Allgather、MPI_Reduce、MPI_Allreduce、 MPI_Barrier
     41
     42
     43
     44= API =
     45== Constants ==
     46 * [wiki:mpich/constants#Cdatatypes Data types (C datatypes)]
     47 * [wiki:mpich/constants#Communicators Communicators]
     48== MPI_Wtime  ==
     49取得系統時間:
     50{{{
     51MPI_Init();
     52MPI_Comm_size (MPI_COMM_WORLD, &nproc);
     53MPI_Comm_rank (MPI_COMM_WORLD, &myid);
     54MPI_Barrier  (MPI_COMM_WORLD);
     55time1=MPI_Wtime()
     56. . .
     57time2=MPI_Wtime() – time1;
     58printf (“myid, clock time= %f\t%f\n”, myid,time2);
     59MPI_Finalize();
     60Return 0;
     61}}}
     62
     63
     64= DEMO_1 =
     65{{{
     66#include <stdio.h>
     67#include <mpi.h>     
     68int nproc, myid;       
     69main (argc, argv)
     70int argc;
     71char **argv;
     72{
     73   MPI_Init(&argc, &argv);
     74   MPI_Comm_size (MPI_COMM_WORLD,  &nproc);
     75   MPI_Comm_rank (MPI_COMM_WORLD,  &myid);
     76   ………
     77   
     78   MPI_Finalize();
     79   return 0;
     80}}}
     81#include <mpi.h>  mpich 的 head file。[[BR]]
     82nproc  此次運算中,參與的 cpu 的總數。[[BR]]
     83myid  此次運算中,目前本身是第幾顆 cpu。[[BR]]
     84MPI_Init(&argc, &argv)  初始化使用 mpi 的環境。[[BR]]
     85MPI_Comm_size(MPI_COMM_WORLD,  &nproc)  回傳此次運算中,參與的 cpu 總數。[[BR]]
     86MPI_Comm_rank (MPI_COMM_WORLD,  &myid)  回傳目前自己是第幾個 cpu。[[BR]]
     87MPI_Finalize()  結束平行運算
     88
     89= Bench mark =
     90
     91 * https://wiki.rocksclusters.org/wiki/index.php/Intel_MPI_Benchmark
     92 * [http://www.spec.org/mpi2007/results/ Standard Performance Evaluation Corporation -  SPEC MPI Results 2007]