[問題] MPI平行程式的問題

看板C_and_CPP作者 (56好棒)時間15年前 (2010/11/13 14:14), 編輯推噓1(1010)
留言11則, 5人參與, 最新討論串1/1
#include "mpi.h" #include <stdio.h> int main (int argc, char *argv[]) { int i; int id; int p; void check_circuit (int, int); MPI_Init (&argc, &argv); MPI_Comm_rank (MPI_COMM_WORLD, &id); MPI_Comm_size (MPI_COMM_WORLD, &p); for (i = id; i < 65536; i += p check_circuit (id, i); printf ("Process %d is done\n", id); fflush (stdout); MPI_Finalize(); return 0; } 請問程式裡的MPI_COMM_WORLD代表什麼意思? 還有MPI_Comm_rank (MPI_COMM_WORLD, &id)和MPI_Comm_size (MPI_COMM_WORLD, &p) 這兩個函式的功能是在做什麼的? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.143.24.60

11/13 14:21, , 1F
去查 MPI 的說明或教學裡面一定會說...
11/13 14:21, 1F

11/13 14:29, , 2F
看起來像是first MPI program之類的範例...XD
11/13 14:29, 2F

11/13 18:23, , 3F
先說你是不是在修平行程式 XD
11/13 18:23, 3F

11/13 18:25, , 4F
沒記錯的話 comm 類似分 group 的概念,rank 就是 id。
11/13 18:25, 4F

11/14 00:29, , 5F
mpi_comm_world是所有CPU的Communicator
11/14 00:29, 5F

11/14 00:29, , 6F
在沒有做小Group的前提下
11/14 00:29, 6F

11/14 00:31, , 7F
Mpi_comm_rank()是取得CPU的編號
11/14 00:31, 7F

11/14 00:31, , 8F
MPI_COMM_SIZE()是去要求用P顆CPU
11/14 00:31, 8F


11/14 00:32, , 10F
英文跟GOOGLE大神很友善的!!!
11/14 00:32, 10F

11/15 10:21, , 11F
感謝
11/15 10:21, 11F
文章代碼(AID): #1CtYpVld (C_and_CPP)