Newsgroups: comp.parallel.mpi
From: mspieg@linus.ldgo.columbia.edu (marc spiegelman)
Subject: Possible bug in IBM MPI
Keywords: behaviour of MPI_TYPE_HVECTOR
Organization: LDEO
Date: Thu, 26 Oct 1995 01:52:56 GMT
Message-ID: <u4xn3aphuyv.fsf@linus.ldgo.columbia.edu>

Hello,

	I'm trying to do some simple cartesian domain decomposition of
a 3-D array and seem to have found a bug in IBM's version of MPI
running under their parallel environment on an SP2 running AIX4.1.3. 
The code works fine using mpich v1.0.10 on a solaris machine.  

Here's the problem:  I'd like to define 3 derived datatypes for the
3 kinds of planes of a 3-D array A(ni,nj,nk) (call them
iplane,jplane,kplane)

the jplane and kplane types are easily constructed using
MPI_TYPE_VECTOR as

      call mpi_type_vector( nk, ni , ni*nj ,MPI_DOUBLE_PRECISION ,jplane
     &     ,ierr)
      call mpi_type_vector( nj , ni , ni  , MPI_DOUBLE_PRECISION
     &     ,kplane ,ierr)

the iplanes (which are non-contiguous memory) I've constructed in 2
steps.  First define a row then make an hvector of rows with stride
ni*nj*sizeof(datatype) i.e

      stride=ni*nj*8
      call mpi_type_vector( nj ,1,ni  ,MPI_DOUBLE_PRECISION,
     &        row,ierr)
      call mpi_type_hvector( nk , 1 , stride , row, iplane ,ierr)

if I calculate the size and extent of row,iplane,jplane,kplane using
mpich (using p4 on solaris) I get the correct answers

 Process   0 of   1 is up
 blocksize is ni,nj,nk   10  20  30
 row: size, extent=        160  1528
 iplane: size, extent=   4800  47928
 jplane: size, extent=   2400  46480
 kplane: size, extent=  1600  1600

on the sp2 using poe under AIX4.1.3 I get

 Process  0  of  1  is up
 blocksize is ni,nj,nk  10 20 30
 row: size, extent=  160 1528
 iplane: size, extent=   4800 -1610520612  <<< That's some extent !
 jplane: size, extent=   2400 46480
 kplane: size, extent=  1600 1600

Any clues?  Who should I report this to?  Is this the most sensible
way to define these datatypes?

let me know
marc
----------------------------------------
Marc Spiegelman
Lamont-Doherty Earth Observatory
Columbia University
Palisades, NY 10964
tel: (914) 365 8425
fax: (914) 365 8150
----------------------------------------

p.s.  FYI the full working code is
----------------------------------------------
c       ****************************************************************
c      program typetest 
c     quicky test program to sort out extents and sizes of planar datatypes
 
c       ****************************************************************
         
      INCLUDE "mpif.h"
      implicit none
      integer ierr,numprocs,myid
      integer iplane,jplane,kplane,row
      integer size,extent,stride
      integer ni,nj,nk
      data ni,nj,nk/ 10,20,30/

c       ****************************************************************
c
c       Initialize MPI  
c
c       ****************************************************************
      call mpi_init( ierr )
      call mpi_comm_rank( MPI_COMM_WORLD, myid, ierr )
      call mpi_comm_size( MPI_COMM_WORLD, numprocs, ierr )
      print *, 'Process ', myid, ' of ', numprocs, ' is up'
      print *, 'blocksize is ni,nj,nk ' , ni,nj,nk
      
      stride=ni*nj*8
      call mpi_type_vector( nj ,1,ni  ,MPI_DOUBLE_PRECISION,
     &        row,ierr)
      call mpi_type_hvector( nk , 1 , stride , row, iplane ,ierr)
      call mpi_type_vector( nk, ni , ni*nj ,MPI_DOUBLE_PRECISION ,jplane
     &     ,ierr)
      call mpi_type_vector( nj , ni , ni  , MPI_DOUBLE_PRECISION
     &     ,kplane ,ierr)
      call mpi_type_size(row,size,ierr)
      call mpi_type_extent(row,extent,ierr)
      print *, 'row: size, extent=',row,size,extent
      call mpi_type_size(iplane,size,ierr)
      call mpi_type_extent(iplane,extent,ierr)
      print *, 'iplane: size, extent=',iplane,size,extent
      call mpi_type_size(jplane,size,ierr)
      call mpi_type_extent(jplane,extent,ierr)
      print *, 'jplane: size, extent=',jplane,size,extent
      call mpi_type_size(kplane,size,ierr)
      call mpi_type_extent(kplane,extent,ierr)
      print *, 'kplane: size, extent=',kplane,size,extent
      call mpi_finalize(ierr)
      end
 

