📜  带有 mpi 的在线 c 编译器 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:05.848000             🧑  作者: Mango

代码示例2
#include 
#include 

using namespace std;

int main( int argc, char ** argv)
{
    int rank, size;
    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    

    char message[255];
    char nadawanie[255];
    
    if(rank==0)
        {
            cin>>nadawanie;
            MPI_Send(&nadawanie, 255, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
        }
    else if(rank == 1)
        {
            MPI_Recv(&message, 255, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD_ MPI_STATUS_IGNORE);
            cout << message << endl;
        }

}