Write a program working only with 2 MPI processes.
For each process, define a square matrix A (nXn). Rank 0 fills the matrix with 0, while rank 1 fills it with 1. Define a datatype that handles a column (if C) or a row (If Fortran) of A.
Extract size and extent of this type: is the result what you expect?
Now begin the communication: rank 0 sends the first column/row of A to rank 1, overwriting its own first column/row. Check the results by printing the matrix on the screen.Modify the code by sending the first nb columns/rows of A: do you have to change the type? Can you send two items of the new type?
C |
|
MPI_TYPE_VECTOR |
|
MPI_TYPE_COMMIT |
|
MPI_TYPE_FREE |
|
MPI_TYPE_SIZE |
|
MPI_TYPE_GET_EXTENT |
int MPI_Type_get_extent(MPI_Datatype *datatype, MPI_Aint *lb, MPI_Aint *extent) |
MPI_SEND |
int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) |
MPI_RECV |
|
MPI_INIT |
|
MPI_COMM_SIZE | |
MPI_COMM_RANK |
|
MPI_FINALIZE |
|
|
|
MPI_TYPE_VECTOR |
|
MPI_TYPE_COMMIT |
|
MPI_TYPE_FREE |
|
MPI_TYPE_SIZE |
MPI_TYPE_SIZE(DATATYPE, SIZE, IERROR) |
MPI_TYPE_GET_EXTENT |
|
MPI_SEND |
|
MPI_RECV |
|
MPI_INIT |
|
MPI_COMM_SIZE |
MPI_COMM_SIZE(COMM, SIZE, IERROR) |
MPI_COMM_RANK |
MPI_COMM_RANK(COMM, RANK, IERROR) |
MPI_FINALIZE |