[MPICH2-dev] MPICH2 problem with scanf

Chen Brian bchennz at hotmail.com
Tue Apr 10 16:28:23 CDT 2007


Hi,
I am working on a school assignment with MPICH2. I am using scanf to read a 
string from stdio. When inputting a large string, I found that mpiexec 
starts to gobble up lots of memory(by the look of task manager in windows) 
before freezing. This does not happen in MPICH1 or relatively smaller size 
input in MPICH2. Below is the code i tried...

input = (char *)malloc(20000000);
// initialise MPI environment
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);

if (myid == 0)
{
   // read from input
  scanf("%s", input);

  // get string length
  l = strlen(input);
}

// broadcast input & length to other processes
MPI_Bcast(&length, 1, MPI_INT, MASTER, MPI_COMM_WORLD);
MPI_Bcast(input, length + 1, MPI_CHAR, MASTER, MPI_COMM_WORLD);

free(input);
// close MPI environment
MPI_Finalize();

The large string is entered via stdio redirection from a file. Does anyone 
know the problem? I am new to MPICH and any help with be very appreciated.

Regards

_________________________________________________________________
現在就用 Live.com:全方位個人化首頁 http://www.live.com 




More information about the mpich2-dev mailing list