As George pointed out earlier, there is no construct in C able to tell
you if a random number is a valid C pointer, i.e., is a valid memory
address. -1, once casted to a pointer, would correspond to the adress
0xffff...f .
It would probably be better to ajust the initial code in order to use
MPI_DATATYPE_NULL, which would be more standard compliant, and less
implementation dependant. Also, this stands as well for any MPI_*_NULL,
as these handlers are opaque, and corresponding to differents types
depending on the library you are using.
The standard does not define what these handlers are corresponding to,
letting the implementor defining these symbols. So using them is the
only way to ensure portability through implementations.
Clément
On 06/02/2017 04:46 PM, Dahai Guo wrote:
Is it easy to update *ompi_datatype_is_valid* to judge invalid
datatypes, such as -1?
Dahai
On Fri, Jun 2, 2017 at 9:00 AM, Gilles Gouaillardet
<gilles.gouaillar...@gmail.com <mailto:gilles.gouaillar...@gmail.com>>
wrote:
MPI_Datatype is a opaque handler, and -1 is a (signed) integer, so
what you are trying is very likely to have an undefined behavior per
the standard.
if this seems to work with MPICH, this is not portable anyway, and
will very likely cause a crash with OpenMPI
Cheers,
Gilles
On Fri, Jun 2, 2017 at 10:41 PM, Dahai Guo <dahai....@gmail.com
<mailto:dahai....@gmail.com>> wrote:
> so you are saying that a user should NOT define send/recv data
type as -1,
> in openmpi?
>
> Dahai
>
> On Thu, Jun 1, 2017 at 6:59 PM, Gilles Gouaillardet
<gil...@rist.or.jp <mailto:gil...@rist.or.jp>>
> wrote:
>>
>> +1
>>
>>
>> MPI_Datatype is an opaque handler, and in Open MPI, this is an
>> ompi_datatype_t *
>>
>> so we can only test for NULL pointers or MPI_DATATYPE_NULL that
cannot be
>> used per the standard.
>>
>>
>> fwiw, and iirc, MPICH made an other design choice and
MPI_Datatype is a
>> number, so the mpich equivalent of ompi_datatype_is_valid()
>>
>> might be able to handle random values without crashing.
>>
>>
>> Cheers,
>>
>>
>> Gilles
>>
>>
>> On 6/2/2017 7:36 AM, George Bosilca wrote:
>>>
>>> You have to pass it an allocated datatype, and it tells you if the
>>> pointer object is a valid MPI datatype for communications (aka
it has a
>>> corresponding type with a well defined size, extent and
alignment).
>>>
>>> There is no construct in C able to tell you if a random number
if a valid
>>> C "object".
>>>
>>> George.
>>>
>>>
>>> On Thu, Jun 1, 2017 at 5:42 PM, Dahai Guo <dahai....@gmail.com
<mailto:dahai....@gmail.com>
>>> <mailto:dahai....@gmail.com <mailto:dahai....@gmail.com>>> wrote:
>>>
>>> Hi,
>>>
>>> if I insert following lines somewhere openmpi, such
>>> as ompi/mpi/c/iscatter.c
>>>
>>> printf(" --- in MPI_Iscatter\n");
>>> //MPI_Datatype dt00 = (MPI_Datatype) MPI_INT;
>>> *MPI_Datatype dt00 = (MPI_Datatype) -1;*
>>> if(*!ompi_datatype_is_valid(dt00)* ) {
>>> printf(" --- dt00 is NOT valid \n");
>>> }
>>>
>>> The attached test code will give the errors:
>>>
>>> *** Process received signal ***
>>> Signal: Segmentation fault (11)
>>> Signal code: Address not mapped (1)
>>> Failing at address: 0xf
>>> [ 0] [0x3fff9d480478]
>>> ...
>>>
>>> Is it a bug in the function *ompi_datatype_is_valid(..) *?
or I
>>> miss something?
>>>
>>> Dahai
>>>
>>> _______________________________________________
>>> devel mailing list
>>> devel@lists.open-mpi.org <mailto:devel@lists.open-mpi.org>
<mailto:devel@lists.open-mpi.org <mailto:devel@lists.open-mpi.org>>
>>> https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
<https://rfd.newmexicoconsortium.org/mailman/listinfo/devel>
>>>
<https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
<https://rfd.newmexicoconsortium.org/mailman/listinfo/devel>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> devel mailing list
>>> devel@lists.open-mpi.org <mailto:devel@lists.open-mpi.org>
>>> https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
<https://rfd.newmexicoconsortium.org/mailman/listinfo/devel>
>>
>>
>> _______________________________________________
>> devel mailing list
>> devel@lists.open-mpi.org <mailto:devel@lists.open-mpi.org>
>> https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
<https://rfd.newmexicoconsortium.org/mailman/listinfo/devel>
>
>
>
> _______________________________________________
> devel mailing list
> devel@lists.open-mpi.org <mailto:devel@lists.open-mpi.org>
> https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
<https://rfd.newmexicoconsortium.org/mailman/listinfo/devel>
_______________________________________________
devel mailing list
devel@lists.open-mpi.org <mailto:devel@lists.open-mpi.org>
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
<https://rfd.newmexicoconsortium.org/mailman/listinfo/devel>
_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel
_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel