在乒乓程序下面,rc
變量有什麼用?它不斷更新,但從未使用過。
再加上MPI_Get_Count()
是做什麼的?MPI'rc'變量和MPI_Get_Count變量的原因()
#include "mpi.h"
#include <stdio.h>
int main(int argc, char * argv [])
int numtasks, rank, dest, source, rc, count, tag=1;
char inmsg, outmsg;
MPI_Status Stat ;
MPI_Init (&argc,&argv);
MPI_Comm_size (MPI_COMM_WORLD, &numtasks);
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
if (rank == 0) {
dest = source = 1;outmsg=’x’;
rc = MPI_Send (&outmsg, 1, MPI_CHAR, dest, tag, MPI_COMM_WORLD);
rc = MPI_Recv (&inmsg, 1, MPI_CHAR, source, tag, MPI_COMM_WORLD, &Stat);
}
else if (rank == 1) {
dest = source = 0;outmsg=’y’;
rc = MPI_Recv (&inmsg, 1, MPI_CHAR, source, tag, MPI_COMM_WORLD, &Stat);
rc = MPI_Send (&outmsg, 1, MPI_CHAR, dest, tag, MPI_COMM_WORLD);
}
rc = MPI_Get_count (&Stat, MPI_CHAR, &count);
printf("Task %d: Received %d char(s) from task %d with tag %d \n", rank, count, Stat.MPI_SOURCE,Stat.MPI_TAG);
MPI_Finalize();
}
如果你的Google「MPI_Get_count」,第一個結果回答你的問題。 – suszterpatt 2012-04-20 15:16:15
[this](http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Get_count.html)? '獲取「頂級」元素的數量?那麼和「尺寸」不一樣嗎? – 2012-04-20 15:18:33
我的意思是'MPI_Comm_size()' – 2012-04-20 16:10:04