Openmpi mpmd get communication size

前端 未结 3 1836
名媛妹妹
名媛妹妹 2020-12-06 23:12

I have two openmpi programs which I start like this

mpirun -n 4 ./prog1 : -n 2 ./prog2

Now how do I use MPI_Comm_size(MPI_COMM_WORLD,

3条回答
  •  不知归路
    2020-12-06 23:46

    Since you are using Open MPI, there is a very simple OMPI-specific solution:

    #include 
    
    MPI_Comm appcomm;
    int app_id = atoi(getenv("OMPI_MCA_orte_app_num"));
    MPI_Comm_split(MPI_COMM_WORLD, app_id, 0, &appcomm);
    

    There will be now as many different appcomm communicators as there are application contexts.

提交回复
热议问题