0

I can send the row of a matrix, and the column of another matrix in a single MPI_SEND, how can I do this procedure?

MPI_SEND (row and column of the matrix ...)
Max
  • 135
  • 1
  • 1
  • 8
  • Sending a column of matrix with MPI in C/C++ is described in these questions/answers: [1](http://stackoverflow.com/questions/10788180/sending-columns-of-a-matrix-using-mpi-scatter/10788351#10788351), [2](http://stackoverflow.com/questions/5371733/how-to-mpi-gatherv-columns-from-processor-where-each-process-may-send-different/5373104#5373104), [3](http://stackoverflow.com/questions/5512245/mpi-scatter-sending-columns-of-2d-array), [4](http://stackoverflow.com/questions/16151973/mpi-sending-and-recieving-a-column) – Jonathan Dursi Apr 29 '13 at 02:00

1 Answers1

1

Since C/C++ works in row major order, you can either declare your 2D matrix in a 1D vector and access its entries by using a simple convention. Assuming A is of size mxn and B is a vector;

A[i][j] = B[i*n+j];

But if you are coding in C++, I would suggest defining a matrix object and try sending these objects in MPI. You would have to create your own MPI_Data_Type.

brkorkut
  • 46
  • 3
  • You mean the object? It depends on your knowledge on Object Oriented Programming (OOP). Try looking at "C++ matrix objects". If you are in a hurry, maybe you should not follow this path. Reading your response once again, may be you are referring to MPI_Data_Type. You can create you own data type by mpi type commit. You may want to look at PETSc [link](http://www.mcs.anl.gov/petsc/) which can help you hide all this details regarding the communication. – brkorkut Apr 29 '13 at 00:43
  • I'm not in a hurry, i'm not derail you? – Max Apr 29 '13 at 00:46
  • If you are not in a hurry, try looking at PETSc. – brkorkut Apr 29 '13 at 00:48
  • you have any examples implemented? – Max Apr 29 '13 at 00:49
  • PETSc website has nice examples [link](http://www.mcs.anl.gov/petsc/documentation/tutorials/index.html). As it is said in the website, you rarely call MPI functions, most of the legwork is done by PETSc. – brkorkut Apr 29 '13 at 00:53