<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18812"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=765111014-30092009><FONT color=#0000ff
size=2 face=Arial><FONT color=#000000 size=3 face="Times New Roman">Bill's
recent commits to the trunk have fixed both the attribute problem when
--with-aint-size=8 is set and errors in the use of the segment routines in the
ch3 code (which caused failures in the tests when sizeof(MPI_Aint) was different
from the sizeof(MPIDI_msg_sz_t)). </FONT></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=765111014-30092009></SPAN>R<SPAN
class=765111014-30092009>ajeev</SPAN><BR></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> mpich2-dev-bounces@mcs.anl.gov
[mailto:mpich2-dev-bounces@mcs.anl.gov] <B>On Behalf Of </B>Joe
Ratterman<BR><B>Sent:</B> Thursday, July 16, 2009 4:56 PM<BR><B>To:</B> MPICH2
Dev<BR><B>Subject:</B> [mpich2-dev] fandcattrf90 test on
BGP<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=gmail_quote>
<DIV class=gmail_quote>(This is a re-send; I got a pile of python errors on
the last try)</DIV><BR>
<DIV><A
href="https://svn.mcs.anl.gov/repos/mpi/mpich2/trunk/test/mpi/f90/attr/fandcattrf90.f90"
target=_blank>https://svn.mcs.anl.gov/repos/mpi/mpich2/trunk/test/mpi/f90/attr/fandcattrf90.f90</A></DIV>
<DIV><A
href="https://svn.mcs.anl.gov/repos/mpi/mpich2/trunk/test/mpi/f90/attr/fandcattrc.c"
target=_blank>https://svn.mcs.anl.gov/repos/mpi/mpich2/trunk/test/mpi/f90/attr/fandcattrc.c</A></DIV>
<DIV><BR></DIV>This test creates an attribute in F90, sets it in F90, and then
reads it back in C. It was getting the wrong answer:
<DIV><FONT face="'courier new', monospace">Expected:
5555 (0x15b3)</FONT></DIV>
<DIV><FONT face="'courier new', monospace">Actual:
23858543329280 (0x15b300000000)</FONT></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><B>fandcattrf90.f90 excerpt</B></DIV>
<DIV><BR></DIV>
<BLOCKQUOTE
style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 40px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px"><FONT
face="'courier new', monospace"> program
main<BR> use mpi<BR>
integer (kind=MPI_ADDRESS_KIND) val<BR><BR>
errs = 0<BR> call
mpi_init(ierr)<BR> commextra = 1001<BR>
call mpi_comm_create_keyval( mycopyfn, mydelfn,
&<BR> &
fcomm2_keyval,
commextra, ierr )<BR> val = 5555<BR>
call mpi_comm_set_attr( MPI_COMM_WORLD, fcomm2_keyval, val,
ierr )<BR> call chkcomm2inc( fcomm2_keyval, 5555,
errs )</FONT></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><B>fandcattrc.c excerpt</B></DIV>
<DIV><BR></DIV>
<BLOCKQUOTE
style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 40px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px"><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">int chkcomm2inc_ (int
*keyval, const int *expected, int *ierr)</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">{</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px"> int
flag;</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">
MPI_Aint *val;</SPAN><BR><FONT size=2 face="'courier new'"><SPAN
style="FONT-SIZE: 10px"><BR></SPAN></FONT><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px"> /*
See Example 16.19 in MPI 2.2, part B. The use of MPI_Aint
*val</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">
and the address of val in the get_attr call is correct, as
is</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">
the use of *val to access the value. */</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">
MPI_Comm_get_attr( MPI_COMM_WORLD, *keyval, &val, &flag
);</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px"> if
(!flag) {</SPAN><BR><SPAN style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace">*ierr = 1;</FONT><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">
}</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px"> else
{</SPAN><BR><SPAN style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace">if (*val != *expected) {</FONT><BR><SPAN
style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace"> /* In some cases, using printf
from a c routine linked </FONT><BR><SPAN style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace"> with a Fortran routine
can cause linking difficulties.</FONT><BR><SPAN
style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace"> To avoid problems in
running the tests, this print</FONT><BR><SPAN style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace"> is commented out
*/</FONT><BR><SPAN style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace"> /* printf( "Val = %x, expected
= %d\n", val, *expected ); */</FONT><BR><SPAN style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace"> *ierr = *ierr +
1;</FONT><BR><SPAN style="WHITE-SPACE: pre"><FONT
face="'courier new', monospace"></FONT></SPAN><FONT
face="'courier new', monospace">}</FONT><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">
}</SPAN><BR><SPAN
style="FONT-FAMILY: 'courier new'; FONT-SIZE: 10px">}</SPAN></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV>BGP has an 8-byte MPI_Aint and a 4-byte void*, which seems to be the root
of the problem. MPI_Comm_get_attr() stores the integer data in a void*
internally. That means that there are only 4 bytes of actual data, but
*(MPI_Aint*)val tries to read 8 bytes. Effectively, that means that
MPI_Comm_get_attr() only returns an int*. This is a problem caused by
assuming that everything--specifically including MPI_Aint values--will fit in
the space used by a void*. The solution is to store all attributes in an
MPI_Aint. Since an MPI_Aint clearly cannot be smaller than a void*, this will
work fine. There is already special code to handle the case of storing a
4-byte big-endian int in a 8-byte void*, so a 4-byte void* in a 8-byte
MPI_Aint would be very similar.</DIV>
<DIV>
<DIV><BR></DIV>
<DIV>One idea that strikes me as really good is to change the "value" field in
the MPID_Attribute structure to be a union of int, void*, and MPI_Aint types
with three different names. That would get rid of the <I>interesting</I>
work that is required to handle 8-byte void* and 4-byte ints. It would
also make it easier to add MPI_Aint changes. You wouldn't have to worry
about the strangeness of storing an integer type in a pointer type, and it
would automatically handle any differences in the sizes of the elements.
You already track the data type, so you would know into which element
the attribute should be stored.</DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV>Comments or questions?</DIV>
<DIV><BR></DIV><FONT color=#888888>
<DIV>Joe Ratterman</DIV>
<DIV><A href="mailto:jratt@us.ibm.com"
target=_blank>jratt@us.ibm.com</A></DIV></FONT></DIV></DIV><BR></BLOCKQUOTE></BODY></HTML>