[MPICH2-dev] MPICH2 problem with scanf

Jayesh Krishna jayesh at mcs.anl.gov
Wed Apr 11 09:43:07 CDT 2007


Hi,
 Could you please send us the complete test program (in the example below the string length is read into a variable named "l" and the variable transmitted is called "length")?  

Regards,
Jayesh

-----Original Message-----
From: owner-mpich2-dev at mcs.anl.gov [mailto:owner-mpich2-dev at mcs.anl.gov] On Behalf Of Chen Brian
Sent: Tuesday, April 10, 2007 4:28 PM
To: mpich2-dev at mcs.anl.gov
Subject: [MPICH2-dev] MPICH2 problem with scanf

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