Sending submatrices



Hi all,
I'm trying to split up a matrix stored in P0 into 2 parts and send
each part to P1 and P2 column by column. Each processor has the table
structure named "cell" with the appropriate dimensions to store the
matrix/submatrices. Each cell has an extra first row and first column
with values not useful for computation but are there for other
purposes.

For example, in P0, I have the matrix and I want to split it up in
this way:

1 | 2 3 | 4 5 6 <-- 1st row of "non-useful" values
-----------------------------
7 | 8 9 | 10 11 12
13 | 14 15 | 16 17 18
19 | 20 21 | 22 23 24
^
1st column of "non-useful" values.

P1 and P2 will then store the transpose of the submatrix, i.e.

P1:
0 0 0 0
0 8 14 20
0 9 15 21

P2:
0 0 0 0
0 10 16 22
0 11 17 23
0 12 18 24

I tried this exact example and I got the correct results. However,
when I tried to execute this idea on my program, I was only able to
get the first column correct, the other values are incorrect. For
example, in this example, I would only get the {8,9} column in P1 and
{10,11,12} column in P2 correct.

Here is part of my program that sends/receives the matrices. P0 stores
the original (size[0]+1)-by-(size[k]+1) matrix; P1 and P2 stores the
respective (length+1)-by-(size[0]+1) submatrix after taking the
transpose, p is the number of processors (3, in this case), stable is
the derived datatype for TABLE.

typedef struct
{
int previ;
int prevj;
int prevrank;
double value;
}TABLE;

MPI_Type_vector(size[0], 1, size[k]+1, stable, &stype);
MPI_Type_commit(&stype);

mlength = size[k]/(p-1);
if (rank == (p-1))
length = mlength + size[k]%(p-1);
else
if (rank >= 1)
length = mlength;
else
if (rank == 0)
length = size[k];

if (rank == 0)
{
/* Send blocks of columns to p-2 processors */
for (dest = 1 ; dest < (p-1) ; dest++)
for (i = 1 ; i <= mlength ; i++)
MPI_Send(&(cell[1][i+(dest-1)*mlength]), 1, stype, dest,
dest, MPI_COMM_WORLD);

/* Send blocks of columns to last processor */
for (i = (p-2)*mlength+1 ; i <= size[k] ; i++)
MPI_Send(&(cell[1][i]), 1, stype, p-1, p-1,
MPI_COMM_WORLD);
}
if (rank != 0)
{
for (i = 1 ; i <= length ; i++)
MPI_Recv(&(cell[i][1]), size[0], stable, 0, rank,
MPI_COMM_WORLD, &status);
}

I can't figure out what is wrong with my program. Please help.

Thank you.

Regards,
Rayne

.



Relevant Pages

  • can this code be improved
    ... // the new array containing unique numbers only ... int number = 0; ... boolean dupLocated=false; ... Rank 1 number is 43 ...
    (comp.lang.java.programmer)
  • RE: Ranking group report with thresholds HELP umm sorry
    ... start a different store layout differently. ... Or you could just keep the rank ... [Other Qualifier] ... tblStoreDisplayLayout ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Compiler-extension small int type promotion
    ... second one states "If an int can represent all values of the original ... rank of any signed integer type with less precision." ... Since an int can hold any value a longshort can, ...
    (comp.lang.c)
  • Sending/receiving column vectors
    ... processors, so each processor has a 18x18 square matrix, ... void exchange(int **grid, int rank, int rows, int columns, int size) ... int srofsize, left, right; ...
    (comp.parallel.mpi)
  • Non-blocking Irecv and Isend
    ... The master process (rank 0) ... then send the integers back to the master. ... there are 2 slave processors and the integers to be ... void quicksort(int a, int lo, int hi) ...
    (comp.parallel.mpi)