Newsgroups: comp.parallel.mpi
From: phsamuel@uxmail.ust.hk (Samuel)
Subject: How to use MPI_BSEND?
Organization: Hong Kong University of Science and Technology
Date: 10 Feb 1998 07:31:00 GMT
Message-ID: <6bovnk$3tf@ustsu10.ust.hk>

Dear all,

	Does anybody know how to use MPI_BSEND? Is that just
same format as MPI_SEND? I've write a test program as follows,
it just send block to itself for many many times. I find that
memory leakage occur. But if I use MPI_SEND instead of MPI_BSEND,
it works fine. The program is running under a SGI2000 machine with
IRIX6.4.

	Reply through email is appreciated. 

	phsamuel@usthk.ust.hk

Samuel

c--------------------------------------------------------
        include "mpif.h"

C       test whether MPI_BSEND and MPI_RECV work correctly
C
C       m0 will store a list of integer and transfer to m1
C        in the same node, m0 and m1 is compared to check
C        whether error exist

        character*20 msg
        INTEGER myrank, ierr, size,status(MPI_STATUS_SIZE)
        integer i,k1,k2,k3
        integer error_found
        integer  m0(100),m1(100)

        integer tag
        integer node,mtype,tsize
        mtype=0

        call MPI_INIT(ierr)
        call MPI_COMM_RANK(MPI_COMM_WORLD,myrank,ierr)

        do 10 i=1,100
        m0(i)=i
10      continue

        do 100 k1=1,10000
        do 100 k2=1,10000
        do 100 k3=1,10000
c send to his own
        call MPI_BSEND(m0,100,MPI_INTEGER,myrank,0,MPI_COMM_WORLD,ierr)

c receive from his own
        call MPI_RECV(m1,100,MPI_INTEGER,myrank,0,MPI_COMM_WORLD,
     +     status,ierr)

        error_found=0
        do 20 i=1,100
        if (m0(i).ne.m1(i)) then
          error_found=1
        endif
20      continue

        if (error_found.eq.1) then
           print*, 'wrong!'
        else
           print*, 'ok'
        endif
100     continue

        call MPI_FINALIZE(ierr)

        end
c-------------------------------------------------------------


