MPI基础知识

来源:互联网 发布:北京php培训公司排名 编辑:程序博客网 时间:2024/05/17 23:01

MPI6个常用的函数:

1. MPI_Init(...);

2. MPI_Comm_size(....);

3. MPI_Comm_rank(....);

4. MPI_Send(....);

5. MPI_Recv(.....);

6. MPI_Finalize();


MPI集群通信函数

1. 广播broadcast

int MPI_Bcast (
void *buffer,/*发送/接收buf*/
int count, /*元素个数*/
MPI_Datatype datatype,
int root, /*指定根进程*/
MPI_Comm comm)
根进程既是发送缓冲区也是接收缓冲区


2. 数据收集 gather

int MPI_Gather(void* sendbuf, int sendcount,
MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, int root, MPI_Comm comm)


3. 数据散发 scatter

int MPI_Scatter(void* sendbuf, int sendcount,
MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, int root, MPI_Comm comm)

sendbuf       待发送数据首地址
sendcounts  待发送数据数量
sendtype      待发送数据的类型
recvbuf         接收到数据的存放位置
recvcount     接收的数据数量
recvtype       接收数据的类型
root               根进程号
comm           通信器名字


4. 数据归约 reduce
对组中所有进程的发送缓冲区中的数据用OP参数指定的操
作进行运算,并将结果送回到根进程的接收缓冲区中.
int MPI_Reduce ( void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm
comm )
操作符 含义
MPI_MAX 最大
MPI_MIN 最小
MPI_SUM 求合
MPI_PROD 乘积
MPI_LAND 逻辑与
MPI_BAND 按位与
MPI_LOR 逻辑或
MPI_BOR 按位或
MPI_LXOR 逻辑异或
MPI_BXOR 按位异或
MPI_MAXLOC max value and location
MPI_MINLOC min value and location





0 0
原创粉丝点击