-1

So i need to solve the problem of multiple producer and consumers using open mpi. The compiler says that there are an error in MPI_Ssend, but where? (id_buffer == 4)

Error description

void funcion_productor(int productor_i)
{ 
  int b = 4;
  for ( unsigned int i= 0 ; i < num_items ; i++ )
  {
    // producir valor
    int valor_prod = producir(productor_i);
    // enviar valor
    cout << "Productor " << productor_i << " va a enviar valor " << 
    valor_prod << endl << flush;
    MPI_Ssend( &valor_prod, 1, MPI_INT, id_buffer, 0, MPI_COMM_WORLD );
    }
}
Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
Yunhao
  • 23
  • 6

1 Answers1

0

This is a very basic error, and obvious from the error message and the documentation (https://www.mpich.org/static/docs/v3.2/www3/MPI_Ssend.html).

You have 3 processes, but your are sending to rank 4 (id_buffer) (so you should have at least 5 processes). Obviously a failure in your logic of receiver selection.

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
  • thank you, sorry, it is my first time using mpi, once changed the rank, it throw me a new error: There are not enough slots available in the system to satisfy the 10 slots that were requested by the application: ./prodcons2-mu_exe Either request fewer slots for your application, or make more slots available for use. – Yunhao Dec 02 '18 at 13:14
  • In that case, start by using simple send/receive calls. Try simple, and then go more complex. – Matthieu Brucher Dec 02 '18 at 13:22
  • it is an assignment, 0 to 3 is producer ids, 4 is buffer , 5 to 9 consumers – Yunhao Dec 02 '18 at 13:25
  • With the code you gave, that's the only thing I can say. But definitely start with the basics. – Matthieu Brucher Dec 02 '18 at 13:26
  • here is the full code: https://correougres-my.sharepoint.com/:u:/g/personal/yunhaolin_correo_ugr_es/EYuSTjdd1DtMsrjfj8JXUDIBGev0haMM0_JHlw5IE9nlzw?e=qALP03 – Yunhao Dec 02 '18 at 13:32
  • Start with something simpler, not with the assignment, you don't have the skill to complete it at this time. – Matthieu Brucher Dec 02 '18 at 14:05