troubleshooting Question

Is there any reason why an MPI program might freeze at MPI_Finalize()?

Avatar of ctangent
ctangent asked on
C
15 Comments1 Solution2419 ViewsLast Modified:
I wrote a program that seems to run fine and produce all the necessary output, but the program (master and all of the slaves) freeze at the MPI_Finalize() call.  I placed a printf statement before MPI_Finalize() and the master and all of the slaves print this out, but they never print out the printf statement after the MPI_Finalize() and before the return 0.  Does anyone have any clue what could possibly cause this problem?  (urgent problem)

The Main function is below:

int main(int argc, char **argv)
{
  int rank, numprocs;
  char charBuffer[CHAR_BUFFER_SIZE];
  int i;

  MPI_Status status;

  globals.position = 0;
  globals.extpos = 0;
 
  MPI_Init(&argc, &argv); /* Initialize MPI */
  MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* get my rank */
  MPI_Comm_size(MPI_COMM_WORLD, &numprocs); /* get numprocs */


  /* mpi barrier - wait for all processes to begin! */
  MPI_Barrier(MPI_COMM_WORLD);
 
  if(rank==0){ // master!
    // if problem, exit
    // if error, pars_args returns false
    if(parse_args(argc, argv) == 0){
      // exit program
     
      killAllSlaves(numprocs);

      printf("argc: %d\nargv: %s\n", argc, argv[0]);
      // now exit yourself!!!
      printf("failure\n");
     
      MPI_Finalize();
      return 1;
    }
    else{
      // initialize version information
      globals.version[0] = '\0';
      strcpy(globals.version,"7.5 \0");
      globals.major_n = 7;
      globals.minor_n = 5;
     
      master(numprocs, rank);
    }

  }
  else{ // slaves!
    slave(numprocs, rank);
  }
  printf("ABOUT TO EXIT::rank %d\n",rank); // MASTER AND ALL SLAVES PRINT THIS
  MPI_Finalize();
  printf("EXIT::rank %d\n",rank); // NO ONE PRINTS THIS
  return 0;
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros