none
finalising all the processes RRS feed

  • General discussion

  • my code is similar to pi code

    i.e,for(n=myrank;n<=1000;n+=size)

    {

    if(i got the answer here then)

    goto label;

    }

    }

    LABEL:

    MPI_FINALIZE();

    RETURN 0;

    }

    //THE ABOVE IS MY CODE

    HERE WHAT I WANT IS I AM COMPARING THE STRINGS

    IF I GOT THE ANSWER AT ANY POINT THEN I AM USING GOTO LABEL TO DISPLAY THERESULT AND QUIT THAT PROCESS ;

    BUT I WANT ALL THE PROCESSES TO BE COME OUT OF THAT FOR LOOP

    AND ATLAST PROCESS WITH RANK ZERO HAS TO PRINT THE TIME THEN QUIT

    WHAT CAN I DO NOW BECASE IF I USE GOTO LABEL ONLY THE RESPECTIVE PROCESS IS QUITTING NOT ALL

    PLEASE HELP ME IAM STUCK

     


    farooq
    Sunday, March 6, 2011 7:04 AM

All replies

  • Hi,

    First let me clarify my understanding of your problem: you want the current process to do the string comparison in the loop, for other processes, you don't care.

    If the above is true, can you try the following logic:

    if(current-rank == myrank) {
      for(n=myrank;n<=1000;n+=size)
      {

      if(i got the answer here then)

       goto label;

      }
     }
    }

    LABEL:
    if (current-rank == 0) print results.

    MPI_FINALIZE();

    RETURN 0;

    Wednesday, March 9, 2011 2:34 PM