HP MLIB User's Guide Vol. 2 7th Ed.
Chapter 11 Introduction to Distributed SuperLU 757
Sample programs
/* ------------------------------------------------------------
Initialize MPI environment and SuperLU_DIST process grid.
------------------------------------------------------------*/
MPI_Init( &argc, &argv );
/* void superlu_gridinit(MPI_Comm Bcomm, int_t nprow, int_t npcol,
* gridinfo_t *grid)
* initializes the SuperLU_DIST 2D process grid.
*
* MPI_COMM_WORLD is the base communicator upon which the new
* grid is formed.
* nprow is the number of process rows.
* npcol is the number of process columns.
* grid points to the storage of the SuperLU_DIST
* 2D process grid.
*/
superlu_gridinit(MPI_COMM_WORLD, nprow, npcol, &grid);
/* Bail out if I do not belong in the grid. */
iam = grid.iam;
if ( iam >= nprow * npcol )
goto out;
/* ------------------------------------------------------------
Set up the input matrix and the right-hand side.
------------------------------------------------------------*/
m=5; n=5; nnz=14;
if (!(nzval = (double *) malloc(nnz * sizeof(double)))) {
printf("malloc fails for a[]\n");
exit (-1);
}
if (!(rowind = (int_t *) malloc(nnz * sizeof(int_t)))) {
printf("malloc fails for rowind[]\n");
exit (-1);
}
if (!(colptr = (int_t *) malloc((n+1) * sizeof(int_t)))) {
printf("malloc fails for colptr[]\n");
exit (-1);
}
nzval[0]=1.1; nzval[1]=3.1; nzval[2]=5.1; nzval[3]=3.2;
nzval[4]=4.2; nzval[5]=5.2; nzval[6]=1.3;
nzval[7]=2.3; nzval[8]=3.3; nzval[9]=1.4; nzval[10]=2.4;
nzval[11]=3.4; nzval[12]=4.4; nzval[13]=5.5;
rowind[0]=0; rowind[1]=2; rowind[2]=4; rowind[3]=2; rowind[4]=3;
rowind[5]=4; rowind[6]=0; rowind[7]=1; rowind[8]=2; rowind[9]=0;
rowind[10]=1; rowind[11]=2; rowind[12]=3; rowind[13]=4;