a clash of APIs -- MPI requires int's, but the ORTE DPS requires
size_t's. Specifically, we need to orte_dps.unload(), which fills a
size_t. We then need to PML send (i.e., MPI_Send) that value around.
However, there's no such thing as MPI_SIZE_T as a datatype, and that
would hose us in heterogeneous situations, anyway. So the compromise
was to make ompi_sizet2int(), a function what does the [potenial]
downcast. On 32 bit architectures, this is no big deal -- it's a
simple assignment. On 64 bit architectures (or, more specifically,
where sizeof(size_t) > sizeof(int)), it does the dowcast in a
compiler-safe manner, and does a check to see if we truncated. If we
truncated, in a developer build, we'll abort(). If this is not a
developer build, print out a nasty warning.
The rationale here is as followes:
- this is a clash of the API's. There's unfortunately nothing that we
can do about this at the moment.
- hence, we have to do the downcast.
- but we might as well be "safe" about it -- assuming that
orte_dps.unload() never gives us back a value >sizeof(int) (which is
a pretty safe assumption -- if we get that large of a value, we have
other problems, or we're on fundamentally different types of
hardware and I suspect a lot of the rest of the code base will have
problems as well!), we should be able to downcast safely.
- if there is a mistake in code somewhere such that:
- we can't downcast safely (i.e., we legitmately have a size_t value
that is too large for an int)
- we truncate when the value should not have been that large
the conversion function will detect this and print out an error. So
we won't silently introduce any new errors into the code base --
they will be loud and obvious.
- although comm.c is currently the only place where we need this, I
suspect that there will be a small number of other places where
similar situations occur. I intend to bring this right over to the
trunk, so it was simpler to make this functionality be a subroutine
so that we can use it elsewhere if/when necessary.
Final note: src/attribute/attribute.c does something *similar*
(downcasting when sizeof(void*) > sizeof(int), but is different enough
that it would have been painful to make one unified interface. This
does not rule it out for the future, however (especially if we find
more places in the tree that need this kind of functionality).
This commit was SVN r6246.
so that I can next rename all the files under mca/btl using "svn mv" which is
not possible until after the initial "svn mv bmi btl" is checked in.
This commit was SVN r6220.