Witam, mam problem z programem, ktory uruchamia n procesów. Proces zerowy (i==0) ma pobrać wartość typu int i wysłać ją do pierwszego procesu (i==1).
Niestety wyskakuje mi error moglby ktos mnie naprowadzic co robie zle ?
Na wyjsciu:
Liczba procesor: 1
Indetyfikator procesora: 0
Fatal error in MPI_Send: Invalid rank, error stack:
MPI_Send(173): MPI_Send(buf=006AFEE4, count=1, MPI_INT, dest=1, tag=1, MPI_COMM_WORLD) failed
MPI_Send(98).: Invalid rank has value 1 but must be nonnegative and less than 1
#include <iostream>
#include <mpi.h>
using namespace std;
int main(int argc, char *argv[])
{
MPI_Init(&argc,&argv);
int size=4;
int rank=4;
MPI_Comm_size(MPI_COMM_WORLD,&size);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
cout << "Liczba procesow: " <<size <<endl;
cout <<"Indetyfikator danego procesu: "<<rank << endl;
int bufor= 0;
if(rank==0)
{
MPI_Send(&bufor,1,MPI_INT, 1, size,MPI_COMM_WORLD);
cout<<cos<<endl;
}
else if(rank==1)
{
MPI_Recv(&bufor,1,MPI_INT,size-1,9,MPI_COMM_WORLD,0);
cout << cos <<endl;
}
cout << "rank: " << rank << "size: " << size <<endl;
}