What is the MPI code to extract a 2D sub-matrix from a larger 2D matrix?
I am looking for the best way of extracting a 2D sub-matrix from a larger 2-D submatrix. That is. If I have a matrix with 1 ghost point on each edge, I want to extract t开发者_如何学运维he interior matrix. So if the matrix is defined as matrix[NX+2][NY+2] how do I extract out the submatrix starting at matrix[1][1] going to matrix[NX+1][NY+1]
I want to do this with an MPI_Type_vector I think, but I am not exactly sure how to define it with the proper stride, blocklength, etc. I want to send that new MPI_Datatype to another processor using MPI_Send and MPI_Recv. The buffer on the receiving procssor will be size [NX][NY] Thanks
In Fortran this would be
call mpi_type_vector(ny,nx,nx+2,mpi_double_precision,my_new_type,ierr)
call mpi_type_commit(my_new_type,ierr)
I'd make more mistakes translating this to C than you will. Don't forget that Fortran stores arrays in row-major order.
精彩评论