[mpich-discuss] question in MPI_Info_get
Junchao Zhang
jczhang at mcs.anl.gov
Mon Feb 2 14:54:12 CST 2015
Hi, Hajime,
MPI spec also says "valuelen is the number of characters available in
value". So it seems if you should pass valuelen = 4 if value is a buffer of
4 bytes.
I am also confused by "In C, valuelen should be one less than the amount
of allocated space to allow for the null terminator". So I leave the
question for others.
Interestingly, for MPI_Info_get_valuelen(), MPI spec says "The length
returned in C does not include the end-of-string".
BTW, I found MPICH and OpenMPI have the same behavior.
--Junchao Zhang
On Sun, Feb 1, 2015 at 12:13 AM, Hajime Fujita <hfujita at uchicago.edu> wrote:
> Hello,
>
> I came across some question about a behavior of MPI_Info_get in MPICH.
>
> If I knew the size of the value, what should I pass to MPI_Info_get as
> `valuelen`?
> Suppose I have 3-byte value in the info object, and I allocate 4-byte
> buffer including a space for null-termination. Then I think I should
> specify 3 as valuelen to retrieve the whole value, as the MPI-3
> specifications says
> "In C, valuelen should be one less than the amount of allocated space to
> allow for the null terminator.”
>
> However, when I run the attached program in MPICH 3.1.1, I get:
> $ ./test
> key found: vaule=va # The last character ‘l’ is missing
>
> If I specify `sizeof(buff)` as valuelen, it shows “val” correctly.
>
> So apparently MPICH thinks valuelen includes null terminator.
> Am I missing anything, or any misunderstanding here?
>
>
>
> Thank you in advance,
> Hajime
>
> --
> Hajime Fujita
> Postdoctoral Scholar, Large-Scale Systems Group
> Department of Computer Science, The University of Chicago
> http://www.cs.uchicago.edu/people/hfujita
> _______________________________________________
> discuss mailing list discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20150202/ecb68024/attachment.html>
-------------- next part --------------
_______________________________________________
discuss mailing list discuss at mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss
More information about the discuss
mailing list