Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] MPI_ERR_TRUNCATE: On Broadcast
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2012-11-09 08:20:00


Offhand, your code looks fine.

Can you send a small, self-contained example?

On Nov 8, 2012, at 9:42 AM, Lim Jiew Meng wrote:

> I have an int I intend to broadcast from root (rank==(FIELD=0)).
>
> int
> winner
>
>
> if (rank == FIELD) {
>
> winner
> = something;
> }
>
>
> MPI_Barrier
> (MPI_COMM_WORLD);
>
> MPI_Bcast
> (&winner, 1, MPI_INT, FIELD, MPI_COMM_WORLD);
>
> MPI_Barrier
> (MPI_COMM_WORLD);
> if (rank != FIELD) {
>
> cout
> << rank << " informed that winner is " << winner << endl;
> }
> But it appears I get
>
> [JM:6892] *** An
> error occurred in MPI_Bcast
>
> [JM:6892] ***
> on communicator MPI_COMM_WORLD
>
> [JM:6892] *** MPI_ERR_TRUNCATE:
> message truncated
>
> [JM:6892] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
> Found that I can increase the buffer size in Bcast
>
> MPI_Bcast(&winner, NUMPROCS, MPI_INT, FIELD, MPI_COMM_WORLD);
> Where NUMPROCS is number of running processes. (actually seems like I just need it to be 2). Then it runs, but gives unexpected output ...
>
> 1 informed that winner is 103
> 2 informed that winner is 103
> 3 informed that winner is 103
> 5 informed that winner is 103
> 4 informed that winner is 103
> When I cout the winner, it should be -1
>
> Whats wrong? In a simple try, it appears to work:
>
>
> MPI_Init(NULL, NULL);
>
> MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
>
> MPI_Comm_rank(MPI_COMM_WORLD, &rank);
>
>
>
> if (rank == 0) {
>
> srand(time(NULL));
>
> tmp = (rand() % 100) + 1;
>
> cout << "generated " << tmp << endl;
>
> }
>
>
>
> MPI_Barrier(MPI_COMM_WORLD);
>
> MPI_Bcast(&tmp, 1, MPI_INT, 0, MPI_COMM_WORLD);
>
> MPI_Barrier(MPI_COMM_WORLD);
>
>
>
> if (rank != 0) {
>
> cout << rank << " received " << tmp << endl;
>
> }
>
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users

-- 
Jeff Squyres
jsquyres_at_[hidden]
For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/