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

Douglas Miller dougmill at us.ibm.com
Fri Mar 21 14:01:54 CDT 2008


The (my) reasoning behind using "unsigned long" is that we are doing a
bitwise operation on something that is originally a pointer. So convention
for that would be treating it as unsigned for the purposes of the bitwise
AND. But it probably doesn't matter on all modern architectures.


_______________________________________________
Douglas Miller                  BlueGene Messaging Development
IBM Corp., Rochester, MN USA                     Bldg 030-2 C214
dougmill at us.ibm.com               Douglas Miller/Rochester/IBM


                                                                           
             Rob Ross                                                      
             <rross at mcs.anl.go                                             
             v>                                                         To 
             Sent by:                  mpich2-dev at mcs.anl.gov              
             owner-mpich2-dev@                                          cc 
             mcs.anl.gov               Jeff Parker/Rochester/IBM at IBMUS     
                                                                   Subject 
                                       Re: [mpich2-dev] [PATCH 1/1] Issue  
             03/21/08 12:44 PM         4120: Fix attr alignment check from 
                                       MPI_Aint to long alignment - again  
                                                                           
             Please respond to                                             
             mpich2-dev at mcs.an                                             
                   l.gov                                                   
                                                                           
                                                                           




I'm sort of coming in and out of the conversation, so maybe I'm
missing the point, but MPI_Aint has to be signed. Extents can be
negative. -- Rob

On Mar 21, 2008, at 11:23 AM, Jeff Parker wrote:

> One more time, Doug pointed out that the cast of the pointer to an
> MPI_Aint should be a
> cast to a long as well.  Also changed to unsigned long.
>
> Signed-off-by: Jeff Parker <jjparker at us.ibm.com>
> ---
> lib/mpi/mpich2/src/mpi/attr/attr_get.c      |    2 +-
> lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c |    2 +-
> lib/mpi/mpich2/src/mpi/attr/type_get_attr.c |    2 +-
> lib/mpi/mpich2/src/mpi/attr/win_get_attr.c  |    2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/mpi/mpich2/src/mpi/attr/attr_get.c b/lib/mpi/mpich2/
> src/mpi/attr/attr_get.c
> index cc39822..4527ba0 100644
> --- a/lib/mpi/mpich2/src/mpi/attr/attr_get.c
> +++ b/lib/mpi/mpich2/src/mpi/attr/attr_get.c
> @@ -97,7 +97,7 @@ int MPI_Attr_get(MPI_Comm comm, int keyval, void
> *attr_value, int *flag)
>                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)) {
> +              if ( (unsigned long) attr_value & (sizeof(unsigned
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 b243968..8e6a88d 100644
> --- a/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c
> +++ b/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c
> @@ -89,7 +89,7 @@ int MPI_Comm_get_attr(MPI_Comm comm, int
> comm_keyval, void *attribute_val, int *
>                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)) {
> +              if ( (unsigned long) attribute_val & (sizeof(unsigned
> 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 7a41051..fabfe6a 100644
> --- a/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c
> +++ b/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c
> @@ -91,7 +91,7 @@ int MPI_Type_get_attr(MPI_Datatype type, int
> type_keyval, void *attribute_val,
>                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)) {
> +              if ( (unsigned long) attribute_val & (sizeof(unsigned
> 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 921f018..958d193 100644
> --- a/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c
> +++ b/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c
> @@ -87,7 +87,7 @@ int MPI_Win_get_attr(MPI_Win win, int win_keyval,
> void *attribute_val,
>                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)) {
> +              if ( (unsigned long) attribute_val & (sizeof(unsigned
> long)-1)) {
>
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
>                }
> #           endif
> --
> 1.5.3.7
>






More information about the mpich2-dev mailing list