Newsgroups: comp.parallel.mpi
From: nevin@colon.cis.ohio-state.edu (Nicholas Nevin)
Subject: Re: Problem with MPI_Scatter on LAM implementation
Organization: Ohio State University, Computer and Information Science
Date: 17 Aug 1995 13:32:44 -0400
Message-ID: <yc1d9e4307d.fsf@colon.cis.ohio-state.edu>

In article <40titc$qfo@news.uncc.edu> sdblackb@uncc.edu (Stuart D Blackburn) writes:
> 	I am trying to port a PVM program to MPI (in particular,
> the LAM implementation of MPI.) The program is hanging up at
> the MPI_Scatter call, and I can not see why. Below is the code
> in question:
> 
[ some code deleted ]
>
>     int me, numprocs;
>     float *data, my_data[NUM_RANK +2][Height+2][Width+2];
>   
>     	/* enroll in MPI */
>     	MPI_Init( &argc, &argv);
>      	/* world communicator/group setup */
>     	MPI_Comm_size(MPI_COMM_WORLD, &numprocs);  	
>     	MPI_Comm_rank(MPI_COMM_WORLD, &me);  	
> 
[ some code deleted ]
>  	       	/* Scatter the data array */
> 	        MPI_Scatter(&data, NUM_RANK*(Width+2)*(Height+2), MPI_FLOAT,
                            ^
                        this should not be here

> 	         &(my_data[1][0][0]), NUM_RANK*(Width+2)*(Height+2), MPI_FLOAT, 
> 	         0, MPI_COMM_WORLD);
> 
> 	} else { /* I am a slave */
> 	
>  	       	/* Receive my portion of the data array */
>  		MPI_Scatter(&data, NUM_RANK*(Width+2)*(Height+2), MPI_FLOAT,
                            ^
                        this should not be here

> 	         &(my_data[1][0][0]), NUM_RANK*(Width+2)*(Height+2), MPI_FLOAT,
> 	         0, MPI_COMM_WORLD);
> 	}
> 

This is not a LAM problem but a problem in your C code.  The problem is
in the first argument to MPI_Scatter. It should be a pointer to the
sendbuf. They way you have written it you are passing a pointer to a
pointer to the sendbuf since the variable "data" is already in itself a
pointer to the sendbuf.

Try this rather  MPI_Scatter(data, .... 

I ran your code with this change in both MPI_Scatter calls and it ran to
completion just fine.

---nick.

-=-
Nick Nevin				nevin@tbag.osc.edu
Ohio Supercomputer Center		http://www.osc.edu/lam.html

