Discussion:
MPI_COMM_NULL and MPI_COMM_RANK
(too old to reply)
ciccio
2008-06-11 13:56:10 UTC
Permalink
Hi,

I was wondering about the following,

Why does MPI_COMM_RANK and MPI_COMM_SIZE not work on an MPI_COMM_NULL
communicator? I expected that it would return MPI_UNDEFINED, but it mainly
gives errors.

So my second question related to this is then obviously "How do you handle
MPI_COMM_NULL comunicators (f.i coming from MPI_COMM_SPLIT). Is it
necesarry to explicit check everytime if the comunicator is MPI_COMM_NULL
every time you do point-to-point communications or other communicator
operations?

Thanks for the help
--
"Rome wasn't burned in a day. "
d***@csclub.uwaterloo.ca.invalid
2008-06-12 01:24:40 UTC
Permalink
Post by ciccio
Hi,
I was wondering about the following,
Why does MPI_COMM_RANK and MPI_COMM_SIZE not work on an MPI_COMM_NULL
communicator? I expected that it would return MPI_UNDEFINED, but it mainly
gives errors.
Because MPI_COMM_NULL is defined to be an invalid handle.
Since MPI_Comm_rank and MPI_Comm_size don't have behavior defined when
you give them an invalid handle, giving them one is an error, so having
them report an error shouldn't be surprising.
Post by ciccio
So my second question related to this is then obviously "How do you handle
MPI_COMM_NULL comunicators (f.i coming from MPI_COMM_SPLIT). Is it
necesarry to explicit check everytime if the comunicator is MPI_COMM_NULL
every time you do point-to-point communications or other communicator
operations?
Check it when you create the communicator, and decide whether to use it
at that point.
I can't think of any case where you should get MPI_COMM_NULL unexpectedly,
and if you're making a call that can reasonably be expected to return
it, you should be prepared to handle that by doing something different
(since you obviously know you don't have anything to communicate with)
rather than by proceeding with an invalid handle.


dave
--
Dave Vandervies dj3vande at eskimo dot com
Post by ciccio
(Or, if you prefer, programming is defrosted mathematics.)
So, if you leave your math alone for too long, does it become freezer burnt?
--Richard Heathfield and Clever Monkey in comp.lang.c
Georg Bisseling
2008-06-12 15:05:30 UTC
Permalink
Post by d***@csclub.uwaterloo.ca.invalid
I can't think of any case where you should get MPI_COMM_NULL unexpectedly,
and if you're making a call that can reasonably be expected to return
it, you should be prepared to handle that by doing something different
(since you obviously know you don't have anything to communicate with)
rather than by proceeding with an invalid handle.
Dave, what you wrote makes perfect sense.

But having MPI_COMM_NULL and MPI_PROC_NULL with totally different behavior
really muddies the waters. (MPI_PROC_NULL should go away!)
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
d***@csclub.uwaterloo.ca.invalid
2008-06-12 16:41:57 UTC
Permalink
Post by Georg Bisseling
But having MPI_COMM_NULL and MPI_PROC_NULL with totally different behavior
really muddies the waters. (MPI_PROC_NULL should go away!)
That may be true.
But I've only read the MPI spec.
To get changes made you'll have to talk to the people who wrote it.


dave
--
Dave Vandervies dj3vande at eskimo dot com
To skin your window, you must first catch your window. Unfortunately,
try/catch are C++ only, and therefore off-topic in comp.lang.c.
--Richard Bos in comp.lang.c
David Cronk
2008-06-13 17:42:40 UTC
Permalink
Post by d***@csclub.uwaterloo.ca.invalid
Post by Georg Bisseling
But having MPI_COMM_NULL and MPI_PROC_NULL with totally different behavior
really muddies the waters. (MPI_PROC_NULL should go away!)
That may be true.
But I've only read the MPI spec.
To get changes made you'll have to talk to the people who wrote it.
dave
Well, they are totally different things so they should have totally
different behaviors. COMM_NULL is needed (and used) only as a return
value when no valid handle can be returned. Thus, it is needed.
PROC_NULL is also needed because if you used COMM_NULL there is no way
of knowing what processes are involved in an extended collective call.
Also, PROC_NULL can be very handy in eliminating the requirement to
check for source or destination validity.

COMM_NULL is an return value, PROC_NULL is an input value. I don't see
how this muddies any waters.

Dave.
--
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
Georg Bisseling
2008-06-16 13:39:21 UTC
Permalink
Post by David Cronk
COMM_NULL is an return value, PROC_NULL is an input value. I don't see
how this muddies any waters.
Because you dived in too far!
SCNR
d***@csclub.uwaterloo.ca.invalid
2008-06-16 20:22:12 UTC
Permalink
Post by David Cronk
Post by Georg Bisseling
But having MPI_COMM_NULL and MPI_PROC_NULL with totally different behavior
really muddies the waters. (MPI_PROC_NULL should go away!)
COMM_NULL is an return value, PROC_NULL is an input value. I don't see
how this muddies any waters.
If I'm understanding the complaint correctly, this difference is
exactly the problem: Why is PROC_NULL an acceptable value for calls
expecting a process identifier, but COMM_NULL is not an acceptable
value for calls expecting a communicator handle?

(Being a C programmer, I have (by necessity) wrapped my brain around
"handling of NULL differs between functions" by now, but it's not hard
to see why it would muddy the waters for somebody who hasn't
internalized that.)


dave
--
Dave Vandervies dj3vande at eskimo dot com
There's simply too much knowledge hidden in there. It's merely
knock-your-socks-off good instead of being blow-your-brain-apart good.
--Shriram Krishnamurthi in comp.lang.scheme
Loading...