Using indxl2g in C/C++

Open discussion regarding features, bugs, issues, vendors, etc.

Using indxl2g in C/C++

Postby Henrici » Tue Nov 01, 2011 3:45 pm

Hello,

I am trying to use the indxl2g function in C/C++ program and I cannot seem to replicate the results from Fortran examples.

Below is a simple program I am using just to understand indxl2g usage. It is a 5x5 global matrix
with 2x2 blocks and a 2x2 process grid. When I run the program, I do not get local indices mapping to the expected global indices.

My understanding is that process (0,0) local indices should map to the global indices as follows:

a11 a12 a15
a21 a22 a25
a51 a52 a55

Specifically, shouldn't local indices (0,0) (0,1) (0,2) in process (0,0) map to global indices (1,1) (1,2) (1,5) - assuming the global indices are indexed starting at 1? I am not seeing this result at all using indxl2g. In the code below, (0,0) (0,1) (0,2) in process (0,0) is instead mapping to (1,1) (2,1) (3,1).

I have given the output of the program for the entire map for a complete reference.

Could someone please help?

OUTPUT
-----------------------------------------------------
myrow = 0, mycol = 0 : np = 3, nq = 3
(0,0) : (1,1)
(1,0) : (2,1)
(2,0) : (3,1)
(0,1) : (1,2)
(1,1) : (2,2)
(2,1) : (3,2)
(0,2) : (1,3)
(1,2) : (2,3)
(2,2) : (3,3)
myrow = 0, mycol = 1 : np = 3, nq = 2
(0,0) : (1,3)
(1,0) : (2,3)
(2,0) : (3,3)
(0,1) : (1,4)
(1,1) : (2,4)
(2,1) : (3,4)
myrow = 1, mycol = 0 : np = 2, nq = 3
(0,0) : (3,1)
(1,0) : (4,1)
(0,1) : (3,2)
(1,1) : (4,2)
(0,2) : (3,3)
(1,2) : (4,3)
myrow = 1, mycol = 1 : np = 2, nq = 2
(0,0) : (3,3)
(1,0) : (4,3)
(0,1) : (3,4)
(1,1) : (4,4)

C PROGRAM
--------------------------------------------------------
int main(int argc, char **argv)
{
int myrank_mpi, nprocs_mpi;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank_mpi);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs_mpi);

int descA[9], descB[9], descC[9];
int ictxt, myrow, mycol;
int info, itemp;
int ZERO = 0, ONE = 1;
int iLRow, jLCol, iGRow, jGCol;
int llda, lldb, lldc;

int nprow = 2, npcol = 2;

Cblacs_pinfo(&myrank_mpi, &nprocs_mpi);
Cblacs_get(-1, 0, &ictxt);
Cblacs_gridinit(&ictxt, "Row", nprow, npcol);
Cblacs_gridinfo(ictxt, &nprow, &npcol, &myrow, &mycol);

int m = 5, n = 5;
int mb = 2, nb = 2;
int rsrc = 0, csrc = 0;
double alpha = 1.0, beta = 0.0;

// Determine local dimensions : np-by-nq.
int np = numroc_(&m, &mb, &myrow, &ZERO, &nprow);
int nq = numroc_(&n, &nb, &mycol, &ZERO, &npcol);

printf("myrow = %d, mycol = %d : np = %d, nq = %d\n", myrow, mycol, np, nq);

for (jLCol = 0; jLCol < nq; jLCol++)
for (iLRow = 0; iLRow < np; iLRow++)
{
iGRow = indxl2g_(&iLRow, &mb, &myrow, &ZERO, &nprow);
jGCol = indxl2g_(&jLCol, &nb, &mycol, &ZERO, &npcol);

printf("(%d,%d) : (%d,%d)\n", iLRow, jLCol, iGRow + 1, jGCol + 1);
}

Cblacs_gridexit(0);

MPI_Finalize();

return 0;
}
Henrici
 
Posts: 1
Joined: Tue Nov 01, 2011 3:23 pm

Return to User Discussion

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 2 guests