Your question actually doesn't make sense in an MPI application. In MPI, you 
would have two independent processes running. One does the send, and the other 
does the receive. Both processes are running all the time, each on its own 
processor.

So you don't "switch" to another processor - the receiving process simply sits 
waiting for the message to arrive from the sender, and then proceeds to do the 
desired actions.


On Feb 19, 2011, at 9:37 AM, Alexandre Barrozo wrote:

> Hi everybody,
> 
> I'm trying to write a routine that, if a certain condition is met, it 
> transfers a specific string from processor A to processor B. However, during 
> this transfer, I have to access the  processor B within the same function 
> (the function was accessed on A, but I need to go to B to put the transferred 
> string on it's right place). The problem is that I have no idea how to change 
> between processors while using one of them. Here's a sample of the code:
> 
> for ( int j = 0; j < atom->nlocal; j++ )
>     {
>         if ( rank != atom->tag[j] ) //condition for transfer
>         { 
>             dest = atom->tag[j];       //the one who needs to deliver to 
> receive
> 
>             atom->tag[j] = rank;
> 
>             MPI_Isend( noisez[j], noisesize, MPI_DOUBLE, rank, 0, world, 
> &request);
>         }
>     }
> 
> /*  I know this doesn't work, but it's just to get the idea of what I'm 
> trying to do  */
> 
>     if( rank == dest ) //trying to access the destination processor
>         {
>              for ( int n = 0; n < atom->nlocal; n++ )
>             {
>               if( n =! atomtag[n] )    
>               {
> 
>                 MPI_Irecv( noisez[n], noisesize, MPI_DOUBLE, flag2, 0, world, 
> &request);
>                 MPI_Wait(&request,&stat);
>                 for ( int m = n; m < atom->nlocal; m++ )
>                     atomtag[m] = m;
>                 break;
>               }
>               else if ( n == atom->nlocal -1)
>               {
> 
>                 MPI_Irecv( noisez[atom->nlocal], noisesize, MPI_DOUBLE, 
> flag2, 0, world, &request);
>                 MPI_Wait(&request,&stat);
>              }
>             }
>         }
> 
> Is there any function to call another processor while using one of them?
> 
> Regards,
> 
> Alexandre
> _______________________________________________
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users


Reply via email to