- message passing model
- the Message Passing Interface (MPI) - standard interface
- MPI is only a definition for an interface
几个重要的概念
- communicator: 由一系列进程组成,拥有沟通的能力
- 每个进程都有 rank 沟通交流靠秩 + tag(标记信息)
- point-to-point communications | collective communications
编程篇
假设有个.c 文件 mpi
mpicc mpi_hello_world.c -o hello_world
mpirun -np 4 -f host_file hello_world //np 是processing的数量
//host_file 记录着集群的信息
host_file
Ailab1
Ailab2
Ailab3
如果不想平均分,想根据核数来
host_file
Ailab1:2
Ailab2:2
Ailab3:2
即可 有限Ailab1的两核,用完了再下一个
- Sending and receiving are the two foundational concepts of MPI.
- MPI allows senders and receivers to also specify message IDs with the message (known as tags)
send 和 recive 的原型
MPI_Send(
void* data,
int count, // 送出了这么多 exactly
MPI_Datatype datatype,
int destination,
int tag,
MPI_Comm communicator)
MPI_Recv(
void* data,
int count, // 最多接受这么多 at most
MPI_Datatype datatype,
int source,
int tag,
MPI_Comm communicator,
MPI_Status* status)
mpi datatype
| MPI datatype | C equivalent |
|---|---|
| MPI_SHORT | short int |
| MPI_INT | int |
| MPI_LONG | long int |
| MPI_LONG_LONG | long long int |
| MPI_UNSIGNED_CHAR | unsigned char |
| MPI_UNSIGNED_SHORT | unsigned short int |
| MPI_UNSIGNED | unsigned int |
| MPI_UNSIGNED_LONG | unsigned long int |
| MPI_UNSIGNED_LONG_LONG | unsigned long long int |

本文是一篇关于MPI(Message Passing Interface)的学习笔记,详细介绍了MPI的基础概念,如communicator、rank和tag。讲解了点对点通信的基本操作send和receive,以及如何处理动态传输和避免死锁。同时,深入探讨了MPI的集体通信,如broadcast、scatter、gather和reduce操作,以及如何创建和操作通讯器。
最低0.47元/天 解锁文章
451

被折叠的 条评论
为什么被折叠?



