Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenMPI gets waiting for ever
    primarykey
    data
    text
    <p>when i execute this code i have no response, it gets waiting for ever, process 1 is sending data to the root process but the root process doesn't receive it (or almost that is what i think).</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include "mpi.h" void my_parallel_function(int v[], int size, int rank) { MPI_Status status; int i; if(rank==0) { MPI_Send(&amp;v[0], 10, MPI_INT, 1, 1, MPI_COMM_WORLD); } else { MPI_Recv(&amp;v[0], 10, MPI_INT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD,&amp;status); for(i=0;i&lt;10;i++) { //change the value v[i] = i; //printf("hola soy nodo: %d\n", i); } MPI_Send(&amp;v[0], 10, MPI_INT, 0, 2, MPI_COMM_WORLD); } if(rank==0) { MPI_Recv(&amp;v[0], 10, MPI_INT, MPI_ANY_SOURCE, 2, MPI_COMM_WORLD,&amp;status); for(i=1;i&lt;size;i++) { printf("\nvalue of item %d: %d\n", i, v[i]); } } } void simpleFunction() { printf("Hi i am a simple function\n"); } int main(int argc, char *argv[]) { int rank, size; MPI_Init(&amp;argc, &amp;argv); MPI_Comm_size(MPI_COMM_WORLD, &amp;size); MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank); MPI_Status status; int vect[10]; int op=1; while(op != 0) { //system("clear"); printf("Welcome to example program!\n\n"); printf("\t1.- Call Parallel Function\n"); printf("\t2.- Call another Function\n"); printf("\t0.- Exit\n\t"); printf("\n\n\tEnter option:"); scanf("%d", &amp;op); switch(op) { case 1: my_parallel_function(vect, size, rank); printf("Parallel function called successfully\n\n"); break; case 2: simpleFunction(); printf("Function called successfully\n\n"); break; } } MPI_Finalize(); return 0; } </code></pre> <p>I am executing with -np 2</p> <p>I think this is not woking as it should: <code>MPI_Recv(&amp;v[0], 10, MPI_INT, MPI_ANY_SOURCE, 2, MPI_COMM_WORLD,&amp;status);</code></p> <p>Any idea? thank you very much.</p> <p><strong>EDITED: But when i remove the if(rank==0) i get all the i/o of the slave processes, that means tons of times menu printing. I am novice in OpenMPI, how can solve this problem?.</strong></p> <p>Thank you very much!.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload