采用 MPI_Send 和 MPI_Recv 编写代码来实现 MPI_Allgather 的功能
来源:互联网 发布:淘宝几心可以开直通车 编辑:程序博客网 时间:2024/06/09 19:51
MPI_Allgather实现
#include "stdio.h"#include "mpi.h"int main( int argc, char* argv[] ){ int i; int rank, nproc; int isend, irecv[32]; double start_time, end_time, time, cputime; MPI_Init( &argc, &argv ); start_time = MPI_Wtime();MPI_Comm_size( MPI_COMM_WORLD, &nproc ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); isend = rank + 1; MPI_Allgather(&isend, 1, MPI_INT, irecv, 1, MPI_INT, MPI_COMM_WORLD); for(i=0; i<nproc; i++) printf("My rank = %d irecv = %d\n", rank, irecv[i]); end_time = MPI_Wtime(); cputime = end_time - start_time; MPI_Reduce(&cputime,&time,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD); if(rank == 0) printf("time is %f s.\n",time/nproc); MPI_Finalize(); }
采用 MPI_Send 和 MPI_Recv 编写代码来实现
#include "time.h"#include "stdio.h"#include "mpi.h"int main(int argc,char * argv[]){ int i; int rank, nproc; int send, recv[32]; MPI_Status status; double start_time, end_time, time, cputime; MPI_Init( &argc, &argv ); start_time = MPI_Wtime(); MPI_Comm_size( MPI_COMM_WORLD, &nproc ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); send = rank + 1; for(i=0;i<nproc;i++){MPI_Send(&send,1,MPI_INT,i,rank,MPI_COMM_WORLD); } for(i=0;i<nproc;i++){MPI_Recv(recv+i,1,MPI_INT,i,i,MPI_COMM_WORLD,&status); } for(i=0; i<nproc; i++) printf("My rank = %d recv = %d\n", rank, recv[i]); end_time = MPI_Wtime(); cputime = end_time - start_time; MPI_Reduce(&cputime,&time,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD); if(rank == 0) printf("time is %f s.\n",time/nproc); MPI_Finalize();}
0 0
- 采用 MPI_Send 和 MPI_Recv 编写代码来实现 MPI_Allgather 的功能
- 采用MPI_Send 和MPI_Recv 编写代码来实现包括MPI_Bcast、MPI_Alltoall、MPI_Gather、MPI_Scatter 等MPI 群集通信函数的功能
- 用MPI_Send和MPI_Recv实现简单集群通信函数
- MPI用MPI_Send, MPI_Recv实现MPI_Alltoall的块方法
- MPI_Send和MPI_Recv(初识1)
- MPI_Send和MPI_Recv影响下程序的执行顺序是怎样的?
- 我的并行计算之路(二)MPI点对点通信MPI_Send和MPI_Recv
- Example-2-MPI_Scatterv,MPI_Send,MPI_Recv
- 关于MPI_Send与MPI_Recv语义
- mpi_allgather实现
- MPI程序例子 test_8_1_2.c -- 对等模式的MPI程序,Jacobi迭代 (MPI_Send、MPI_Recv)
- MPI程序例子:对等模式的MPI程序,Jacobi迭代 (MPI_Send、MPI_Recv)
- 自己编写代码实现atoi和itoa函数的功能
- 自己编写代码实现atoi和itoa函数的功能
- 编写实现strstr()函数功能的代码
- 文件上传功能的实现1(采用自编写的JavaBean组件)
- 请编写实现malloc()内存分配函数功能一样的代码。给出一个函数来复制两个字符串A和B。字符串A的后几个字节和字符串B的前几个字节重叠。
- 自己编写代码实现常用字符串函数的功能
- 记informix转oracle的一些修改点
- 常备CSS样式
- libSVM在matlab下的使用安装
- Xmanager简单应用!
- poj 1789 Truck History 最小生成树
- 采用 MPI_Send 和 MPI_Recv 编写代码来实现 MPI_Allgather 的功能
- Android SQlite性能优化
- WordPress自定义字段
- A* Pathfinding for Beginners
- vc++加载透明png图片方法——GDI+和CImage两种
- hitTest:(CGPoint)point withEvent:(UIEvent *)event
- 程序员技术练级攻略
- MFC学习(24)线程锁的概念函数EnterCriticalSection和LeaveCriticalSection的用法
- 正则表达式:网站源码匹配图片地址