CMake
cmake_minim_required(VERSION 3.0)
project(TEST)
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
add_executable(hello hello.cpp)
target_link_libraries(hello ${MPI_LIBRARIES})
int MPI_Ssend(const void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm);
int MPI_Recv(void *buf, int count, MPI_Datatype datatype,
int source, int tag, MPI_Comm comm, MPI_Status *status);
comm : 沟通器
tag : 信息标签
dest/source : 在该沟通器中的发送者和接受者的等级号
datatype : 所发送的数据的类型
count :发送和接受的数据数量
buf : 发送/接收的数据的开始地址
进程2发给进程3一个int型数字 :1
#include
#include
int main(int argc, char** argv) {
MPI_Init(&argc, &argv);
int wrank; MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
int witness = 0; if (wrank==2)
{<