[mpich-discuss] MPI_Bsend
Pavan Balaji
balaji at mcs.anl.gov
Thu Nov 10 13:36:03 CST 2011
You need to allocate MPI_BSEND_OVERHEAD bytes more. See pg. 274 of the
MPI-2.2 standard.
-- Pavan
On 11/10/2011 01:30 PM, Wei-keng Liao wrote:
> My program using MPI_Bsend failed due to insufficient space,
> even though it did allocate exact size required, but not one byte more.
> I wonder if this is an mpich bug, or MPI requires more space than needed.
> If it is later, how much more is needed?
>
> Wei-keng
>
> error message:
> $ mpiexec -machinefile=machinefile -l -n 4 a.out
> [2] Fatal error in MPI_Bsend: Invalid buffer pointer, error stack:
> [2] MPI_Bsend(182).......: MPI_Bsend(buf=0x7fff81048a50, count=1024, MPI_BYTE, dest=0, tag=2, MPI_COMM_WORLD) failed
> [2] MPIR_Bsend_isend(318): Insufficient space in Bsend buffer; requested 1024; total buffer size is 4096
>
> ---- bsend.c -----------------------------
> #include<stdio.h>
> #include<stdlib.h>
> #include<mpi.h>
>
> int main(int argc, char **argv)
> {
> int i, rank, nprocs, src, bufsize;
> char buf[1024];
> void *bsend_buf = NULL;
> MPI_Status status;
>
> MPI_Init(&argc,&argv);
> MPI_Comm_rank(MPI_COMM_WORLD,&rank);
> MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
>
> bufsize = 1024*4;
> // bufsize += 512; // if uncommented, the program runs successfully
> MPI_Buffer_attach(malloc(bufsize), bufsize);
>
> for (i=0; i<4; i++) {
> if (rank> 0)
> MPI_Bsend(buf, 1024, MPI_BYTE, 0, rank, MPI_COMM_WORLD);
> else {
> for (src=1; src<nprocs; src++)
> MPI_Recv(buf, 1024, MPI_BYTE, src, src, MPI_COMM_WORLD,&status);
> }
> }
>
> MPI_Buffer_detach(&bsend_buf,&bufsize);
> free(bsend_buf);
> MPI_Finalize();
> return 0;
> }
>
>
>
> _______________________________________________
> mpich-discuss mailing list mpich-discuss at mcs.anl.gov
> To manage subscription options or unsubscribe:
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss
--
Pavan Balaji
http://www.mcs.anl.gov/~balaji
More information about the mpich-discuss
mailing list