Sending submatrices
- From: "lancer6238@xxxxxxxxx" <lancer6238@xxxxxxxxx>
- Date: Tue, 16 Oct 2007 03:26:58 -0700
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
.
- Prev by Date: Re: how to send very long vector
- Next by Date: Fault tolerance in MPI programs
- Previous by thread: buy access to the mpi cluster?
- Next by thread: Fault tolerance in MPI programs
- Index(es):
Relevant Pages
|