資源簡介
中科院課程:高性能并行計算
主講人:遲學斌
課程課件,課程源碼,課程考試題猜測以及答案

代碼片段和文件信息
//*使用MPI_Sendrecv()MPI_Send()MPI_Recv()實現MPI_Alltoall*//
#include?“mpi.h“
#include?“stdio.h“
#define??maxlen?10
//ALLtoAll?函數
int??My_Alltoall(int??*sendBufferint?sendcntMPI_Datatype?sendtype
?????????????????int?*receiveBufferint?recvcntMPI_Datatype?recvtypeMPI_Comm?commint?rankint?size)
{
??int?i;
??int?j;
??MPI_Status?status;
??if(size!=sendcnt||sendtype!=recvtype)
??????return?0;
??for(i=0;i ??{
?????if(rank==i)
?????{
???????MPI_Sendrecv(&sendBuffer[i]1sendtypei99&receiveBuffer[i]1recvtypei99comm&status);
?????}
?????else
?????{
???????MPI_Send(&sendBuffer[i]1sendtypeiicomm);
???????MPI_Recv(&receiveBuffer[i]1recvtypeirankcomm&status);?
?????}
?????
?}
return?1;??
}
int?main(int?argcchar?*argv[])
{
???int?ranksize;
???MPI_Status?status;
???
???int?sendBuffer[maxlen]receiveBuffer[maxlen];
???int?ij;
???int?count;
??
???MPI_Init(&argc&argv);
???MPI_Comm_rank(MPI_COMM_WORLD&rank);
???MPI_Comm_size(MPI_COMM_WORLD&size);
//判斷進程數是否合法
????if(?size?1?||?size?>?10?)???
?????{?if(?rank?==?0?)?printf(“Please?input?a??number?between?1-10\n“);
???????MPI_Finalize();
???????return?0;
??????}
???count=size;
???for(i=0;i ???{
???????sendBuffer[i]=(rank+1)*(i+1);?//初始化發送緩沖區
???????receiveBuffer[i]=0; ?//初始化接收緩沖區
???}
??????
???My_Alltoall(sendBuffercountMPI_INTreceiveBuffercountMPI_INTMPI_COMM_WORLDranksize);
???
???if(rank==0)
???{
?????for(i=0;i ?????{
???????printf(“%d\t“receiveBuffer[i]);
?????}
??}
???MPI_Finalize();
???return?(0);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????10587??2010-06-06?16:39??高性能并行計算\exams.rar
?????文件?????5024074??2010-06-05?09:31??高性能并行計算\MPI.rar
?????文件??????943249??2010-06-01?22:44??高性能并行計算\mpi并行編程技術郁志輝.pdf
?????目錄???????????0??2010-06-20?16:29??高性能并行計算\并行計算復習提綱與答案\
?????文件????????1578??2010-06-09?13:49??高性能并行計算\并行計算復習提綱與答案\1.MyAlltoall.c
?????文件????????1266??2010-06-09?14:13??高性能并行計算\并行計算復習提綱與答案\2.Lower.c
?????文件????????1409??2010-06-08?16:33??高性能并行計算\并行計算復習提綱與答案\3.myfox.c
?????文件?????????755??2010-06-09?15:34??高性能并行計算\并行計算復習提綱與答案\4.spit.c
?????文件?????????247??2010-06-09?13:46??高性能并行計算\并行計算復習提綱與答案\并行計算復習提綱.txt
?????文件????????2960??2009-06-03?10:23??高性能并行計算\并行計算復習提綱與答案\課后習題?Page119?crecomm.c
?????目錄???????????0??2010-06-20?16:28??高性能并行計算\并行計算復習提綱與答案\另一版本\
?????文件????????2051??2010-06-08?16:36??高性能并行計算\并行計算復習提綱與答案\另一版本\myall.c
?????文件????????1409??2010-06-08?16:33??高性能并行計算\并行計算復習提綱與答案\另一版本\myfox.c
?????文件?????????799??2010-06-08?16:30??高性能并行計算\并行計算復習提綱與答案\另一版本\mygroup.c
?????文件????????1045??2010-06-08?16:27??高性能并行計算\并行計算復習提綱與答案\另一版本\mysum.c
?????文件????????2514??2010-06-08?16:34??高性能并行計算\并行計算復習提綱與答案\另一版本\xiti5_2.c
?????文件?????2217139??2010-05-19?19:46??高性能并行計算\高性能并行計算.pdf
- 上一篇:使用cadence仿真DDR3詳解
- 下一篇:PJL命令參考手冊
評論
共有 條評論