[mpich2-dev] [PATCH 1/1] Issue 4120: Fix attr alignment check from MPI_Aint to long alignment

Jeff Parker jjparker at us.ibm.com
Mon Mar 24 16:12:50 CDT 2008


On 03/23/2008 04:26 PM, William Gropp wrote:
"This one is system-specific - some systems will require the MPI_Aint 
alignment.   This should probably be abstracted out and set based on the 
requirements of the system."

Are you saying that on some systems, "long" is not the size of a pointer, 
whereas "MPI_Aint" is?  Are there really such systems that we need to be 
concerned about?  Standard C specifies that long and pointers are the same 
size.

Assuming it needs to be configurable, I propose adding another 
configure.in variable that is the numeric datatype of an attribute value. 
MPI_Aint is supposed to be that datatype, but since MPI_Aint  is also used 
for offsets, extents, etc. requiring that it be 8 bytes, we must define 
something else.  MPI_Aint must be the datatype of an extent as spec'd for 
MPI_Type_get_extent().

Jeff Parker
IBM Blue Gene Messaging




William Gropp <gropp at mcs.anl.gov> 
Sent by: owner-mpich2-dev at mcs.anl.gov
03/23/2008 04:26 PM
Please respond to
mpich2-dev at mcs.anl.gov


To
mpich2-dev at mcs.anl.gov
cc
Jeff Parker/Rochester/IBM at IBMUS
Subject
Re: [mpich2-dev] [PATCH 1/1] Issue 4120: Fix attr alignment check from 
MPI_Aint to long alignment






This one is system-specific - some systems will require the MPI_Aint 
alignment.   This should probably be abstracted out and set based on the 
requirements of the system.

Bill

On Mar 21, 2008, at 10:14 AM, Jeff Parker wrote:

In the mpi/attr code, there were checks to ensure the attribute was 
aligned on a void*
boundary.  This check anded the pointer with sizeof(MPI_Aint)-1.  In the 
case of an
MPI_Aint being 8 bytes, this was forcing the attribute to be on an 8-byte 
boundary, when
in fact a 4-byte boundary would do.  Changed the and operation to use 
sizeof(long)-1 instead.

Signed-off-by: Jeff Parker <jjparker at us.ibm.com>
---
 lib/mpi/mpich2/src/mpi/attr/attr_get.c      |    7 +++++--
 lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c |    7 +++++--
 lib/mpi/mpich2/src/mpi/attr/type_get_attr.c |    7 +++++--
 lib/mpi/mpich2/src/mpi/attr/win_get_attr.c  |    9 ++++++---
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/lib/mpi/mpich2/src/mpi/attr/attr_get.c 
b/lib/mpi/mpich2/src/mpi/attr/attr_get.c
index 095c979..cc39822 100644
--- a/lib/mpi/mpich2/src/mpi/attr/attr_get.c
+++ b/lib/mpi/mpich2/src/mpi/attr/attr_get.c
@@ -93,8 +93,11 @@ int MPI_Attr_get(MPI_Comm comm, int keyval, void 
*attr_value, int *flag)
        int when the address of a pointer (or an address-sized int)
        should have been used.  We can test for this specific
        case.  Note that this code assumes sizeof(MPI_Aint) is 
-       a power of 2. */
-     if (MPI_VOID_PTR_CAST_TO_MPI_AINT attr_value & (sizeof(MPI_Aint)-1)) 
{
+       a power of 2. Note that this formerly used MPI_Aint for the
+               address sized int, but since this is configurable and 
could
+               be larger than a pointer, we use long for the check, since
+               long is expected to be the size of a pointer.*/
+     if (MPI_VOID_PTR_CAST_TO_MPI_AINT attr_value & (sizeof(long)-1)) {
  MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
      }
 #           endif
diff --git a/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c 
b/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c
index ce5c836..b243968 100644
--- a/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c
+++ b/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c
@@ -85,8 +85,11 @@ int MPI_Comm_get_attr(MPI_Comm comm, int comm_keyval, 
void *attribute_val, int *
        int when the address of a pointer (or an address-sized int)
        should have been used.  We can test for this specific
        case.  Note that this code assumes sizeof(MPI_Aint) is 
-       a power of 2. */
-     if (MPI_VOID_PTR_CAST_TO_MPI_AINT attribute_val & 
(sizeof(MPI_Aint)-1)) {
+       a power of 2. Note that this formerly used MPI_Aint for the
+               address sized int, but since this is configurable and 
could
+               be larger than a pointer, we use long for the check, since
+               long is expected to be the size of a pointer. */
+     if (MPI_VOID_PTR_CAST_TO_MPI_AINT attribute_val & (sizeof(long)-1)) 
{
  MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
      }
 #           endif
diff --git a/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c 
b/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c
index 7547bbb..7a41051 100644
--- a/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c
+++ b/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c
@@ -87,8 +87,11 @@ int MPI_Type_get_attr(MPI_Datatype type, int 
type_keyval, void *attribute_val,
        int when the address of a pointer (or an address-sized int)
        should have been used.  We can test for this specific
        case.  Note that this code assumes sizeof(MPI_Aint) is 
-       a power of 2. */
-     if (MPI_VOID_PTR_CAST_TO_MPI_AINT attribute_val & 
(sizeof(MPI_Aint)-1)) {
+       a power of 2. Note that this formerly used MPI_Aint for the
+               address sized int, but since this is configurable and 
could
+               be larger than a pointer, we use long for the check, since
+               long is expected to be the size of a pointer. */
+     if (MPI_VOID_PTR_CAST_TO_MPI_AINT attribute_val & (sizeof(long)-1)) 
{
  MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
      }
 #           endif
diff --git a/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c 
b/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c
index 5fbef66..921f018 100644
--- a/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c
+++ b/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c
@@ -82,9 +82,12 @@ int MPI_Win_get_attr(MPI_Win win, int win_keyval, void 
*attribute_val,
             /* A common user error is to pass the address of a 4-byte
        int when the address of a pointer (or an address-sized int)
        should have been used.  We can test for this specific
-       case.  Note that this code assumes sizeof(MPI_Aint) is 
-       a power of 2. */
-     if (MPI_VOID_PTR_CAST_TO_MPI_AINT attribute_val & 
(sizeof(MPI_Aint)-1)) {
+       case.  Note that this code assumes sizeof(long) is 
+       a power of 2. Note that this formerly used MPI_Aint for the
+               address sized int, but since this is configurable and 
could
+               be larger than a pointer, we use long for the check, since
+               long is expected to be the size of a pointer. */
+     if (MPI_VOID_PTR_CAST_TO_MPI_AINT attribute_val & (sizeof(long)-1)) 
{
  MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
      }
 #           endif
-- 
1.5.3.7


William Gropp
Paul and Cynthia Saylor Professor of Computer Science
University of Illinois Urbana-Champaign


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mcs.anl.gov/mailman/private/mpich2-dev/attachments/20080324/54d20fd9/attachment.htm>


More information about the mpich2-dev mailing list