芙蓉妹妹 - 云代码空间
——
#include<stdio.h> #include "mpi.h" int main(int argc, char** argv) { MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank, data[3], i; MPI_Comm_rank(comm, &rank); MPI_Status status; if(rank == 0) { for(i = 0; i < 3; i++) data[i] = i + 1; } MPI_Bcast(data,3,MPI_INT,0,comm); printf("process %d recv :",rank); for(i = 0;i< 3; i++) printf(" %d",data[i]); putchar('\n'); MPI_Finalize(); return 0; }MPI_BCAST(buffer,count,datatype,root,comm) ;