For hours im trying to send 2D array over MPI to diffrent thread. Code looks like this (i'll leave comments to show tricks that i have already tryed):
Type definition:
// Define datatype
//MPI_Type_contiguous(N, MPI_INT, &mpi_vector);
//MPI_Type_vector(N, N, N, mpi_vector, &mpi_matrix);
//MPI_Type_vector(N, N, N, MPI_INT, &mpi_matrix);
//MPI_Type_contiguous(N, MPI_INTEGER, &mpi_vector);
//MPI_Type_contiguous(N, mpi_vector, &mpi_matrix);
MPI_Type_vector(N, N, 0, MPI_INTEGER, &mpi_matrix);
//MPI_Type_commit(&mpi_vector);
MPI_Type_commit(&mpi_matrix);
Sending and recieving:
int** tmp = new int*[N];
switch(r) {
case T1:
inputMatrix(tmp, 2);
MPI_Send(tmp, 1, mpi_matrix, T2, 0, MPI_COMM_WORLD);
//task_T1();
break;
case T2:
//task_T2();
inputMatrix(tmp, -1);
MPI_Recv(tmp, 1, mpi_matrix, T1, 0, MPI_COMM_WORLD, &s);
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++) {
cout << " " << tmp[i][j];
}
cout << endl;
}
break;
}
I need to have this done till morning (in 7 hours), i hope smb is able to help me.