Quantcast
Channel: Clusters and HPC Technology
Viewing all articles
Browse latest Browse all 927

Multi-threading with Intel MPI

$
0
0

I am trying to establish communication between threads on different processes using Intel MPI.

However, it does not seem to work as I would expect it to.

Here's the code snippet:

             MPI_Comm_dup(MPI_COMM_WORLD, &dup_world_comm0);

             MPI_Comm_group(dup_world_comm0, &world_group0);

             MPI_Comm_create(dup_world_comm0, world_group0, &world_comm0); 

              /*inside a thread*/

               if (myrank == 0) {//process 0
                        i = find_sum();
                        if (index == 0) {//thread id 0
                                MPI_Send(&i, 1, MPI_INT, 1, 1, world_comm0);
                                MPI_Recv(&y, 1, MPI_INT, 1, 1, world_comm0, &status);
                        }
                }

                if (myrank == 1) {//process 1
                        if (index == 0) {//thread id 0
                                MPI_Recv(&i, 1, MPI_INT, 0, 1, world_comm0, &status);
                                MPI_Send(&i, 1, MPI_INT, 0, 1, world_comm0);
                        }
                }

------------------------------------

I am spawning a single thread on each process and am trying to establish some communication between these threads using MPI_Send/Recv.

But, many a times, the execution hangs on MPI_Recv or MPI_Send in process 1.

Is their something that I am missing here or doing wrong  or is the library not supposed to work in this way with threads?

I have attached the code file for reference.

Thanks.

Fichier attachéTaille
Téléchargementtest_MPI_thread.cpp6.65 Ko

Viewing all articles
Browse latest Browse all 927

Trending Articles