-1

How would I go about gathering a partitioned MPI matrix?

Initially I have a matrix which I break down into several row and column-wise sub-matrices, used for the floyd warshall algorithm.

When I gather the sub-matrices they come unordered.

Instead of getting values that would fit in my original matrix

M[ij] 00, 01, 02, 03, 10, 11... 

I get them in the order of the sub matrix, (imagine sub-matrix is 2x2)

00,01,10,11,02,03,12,13

How can I reorder the unsorted floyd matrix?

jwpfox
  • 5,124
  • 11
  • 45
  • 42
  • C or C++? They're very distinct. – MD XF Dec 05 '16 at 05:14
  • 2
    Possible duplicate of [sending blocks of 2D array in C using MPI](http://stackoverflow.com/questions/9269399/sending-blocks-of-2d-array-in-c-using-mpi) – Zulan Dec 05 '16 at 07:44

1 Answers1

-1

you could use this code to do that

i = 0;
    j = 0;
    k = 0;
    bump = 0;
    for (written = 0; written < matrix_dimensions * matrix_dimensions; written += 1) {
      matrix[written] = out_of_order_subblocks[k * matrix_dimensions * subblock_dimensions + j * subblock_dimensions * subblock_dimensions + i + bump];
      i += 1;
      if (i % subblock_dimensions == 0) {
        i = 0;
        j += 1;
        if (j % grid_dimensions == 0) {
          j = 0;
          bump += subblock_dimensions;
          if (bump == subblock_dimensions * subblock_dimensions) {
            bump = 0;
            k += 1;
          }
        }
      }
    }