MPI 学习笔记

  • 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_FLOAT float
MPI_DOUBLE double
  • 5
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值