Discussion:
Help! Passing pointer to int list between MPI_Send and MPI_Recv
(too old to reply)
VanJay011379
2007-01-04 00:36:07 UTC
Permalink
Hi,

I have a simple program to pass an array and the array size between two
different processors.

The main function works as follows. If the rank is 0, it is the
coordinator, if greater than 0, it is the worker.

I have the coordinator dynamically allocate memory to an int pointer.
I am trying to pass this pointer between the coordinator and the
worker. I think I am having an syntactical issue.

My code is at http://gis.sis.pitt.edu/temp/chris/mpi/simple2/test.c
The output is at
http://gis.sis.pitt.edu/temp/chris/mpi/simple2/test2.out

What am I doing wrong? This had me tied up for hours.

Cheers,

Chris
Christian
2007-01-04 10:22:38 UTC
Permalink
Post by VanJay011379
What am I doing wrong? This had me tied up for hours.
You seem to mix basics, and therefore make some "beginners" mistakes.
Post by VanJay011379
I have the coordinator dynamically allocate memory to an int pointer.
I am trying to pass this pointer between the coordinator and the
worker. I think I am having an syntactical issue.
Passing a pointer between MPI processes is usually a bad idea because
they become useless on the other nodes (MPI _processes_ have different
address spaces - contrary to multi-_threaded_ programming). Instead,
you should distribute the integer array itself (meaning with all
'sizeOfList' integers) to your workers. Don't forget to allocate the
array on all nodes (not only the coordinator)!

Christian
David Cronk
2007-01-04 15:36:20 UTC
Permalink
Simply remove the "&" from in front of availableList in the send call.
It is already a pointer. The way you have it you are trying to send
data starting at the location of the pointer rather than the start of
the array.

Hope this helps.

Dave.
Post by VanJay011379
Hi,
I have a simple program to pass an array and the array size between two
different processors.
The main function works as follows. If the rank is 0, it is the
coordinator, if greater than 0, it is the worker.
I have the coordinator dynamically allocate memory to an int pointer.
I am trying to pass this pointer between the coordinator and the
worker. I think I am having an syntactical issue.
My code is at http://gis.sis.pitt.edu/temp/chris/mpi/simple2/test.c
The output is at
http://gis.sis.pitt.edu/temp/chris/mpi/simple2/test2.out
What am I doing wrong? This had me tied up for hours.
Cheers,
Chris
--
Dr. David Cronk, Ph.D. phone: (865) 974-3735
Research Director fax: (865) 974-8296
Innovative Computing Lab http://www.cs.utk.edu/~cronk
University of Tennessee, Knoxville
Loading...