Skip to content

Commit

Permalink
Double complex version added
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyangzhuan committed Feb 14, 2018
1 parent 4fe9531 commit 173c260
Show file tree
Hide file tree
Showing 36 changed files with 8,760 additions and 4,527 deletions.
27 changes: 13 additions & 14 deletions EXAMPLE/dcreate_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ at the top-level directory.
* </pre>
*/


int dcreate_matrix(SuperMatrix *A, int nrhs, double **rhs,
int dcreate_matrix(SuperMatrix *A, int nrhs, double **rhs,
int *ldb, double **x, int *ldx,
FILE *fp, gridinfo_t *grid)
{
Expand All @@ -90,14 +89,14 @@ at the top-level directory.
#endif

if ( !iam ) {
double t = SuperLU_timer_();
double t = SuperLU_timer_();

/* Read the matrix stored on disk in Harwell-Boeing format. */
dreadhb_dist(iam, fp, &m, &n, &nnz, &nzval, &rowind, &colptr);

/* Read the matrix stored on disk in Harwell-Boeing format. */
dreadhb_dist(iam, fp, &m, &n, &nnz, &nzval, &rowind, &colptr);

printf("Time to read and distribute matrix %.2f\n",
SuperLU_timer_() - t); fflush(stdout);
SuperLU_timer_() - t); fflush(stdout);

/* Broadcast matrix A to the other PEs. */
MPI_Bcast( &m, 1, mpi_int_t, 0, grid->comm );
MPI_Bcast( &n, 1, mpi_int_t, 0, grid->comm );
Expand Down Expand Up @@ -235,9 +234,8 @@ at the top-level directory.
return 0;
}






int dcreate_matrix_postfix(SuperMatrix *A, int nrhs, double **rhs,
int *ldb, double **x, int *ldx,
FILE *fp, char * postfix, gridinfo_t *grid)
Expand All @@ -264,8 +262,9 @@ int dcreate_matrix_postfix(SuperMatrix *A, int nrhs, double **rhs,
#endif

if ( !iam ) {
double t = SuperLU_timer_();
if(!strcmp(postfix,"rua")){
double t = SuperLU_timer_();

if(!strcmp(postfix,"rua")){
/* Read the matrix stored on disk in Harwell-Boeing format. */
dreadhb_dist(iam, fp, &m, &n, &nnz, &nzval, &rowind, &colptr);
}else if(!strcmp(postfix,"mtx")){
Expand All @@ -286,7 +285,7 @@ int dcreate_matrix_postfix(SuperMatrix *A, int nrhs, double **rhs,

printf("Time to read and distribute matrix %.2f\n",
SuperLU_timer_() - t); fflush(stdout);

/* Broadcast matrix A to the other PEs. */
MPI_Bcast( &m, 1, mpi_int_t, 0, grid->comm );
MPI_Bcast( &n, 1, mpi_int_t, 0, grid->comm );
Expand Down
6 changes: 3 additions & 3 deletions EXAMPLE/dcreate_matrix_perturbed.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ int dcreate_matrix_perturbed_postfix(SuperMatrix *A, int nrhs, double **rhs,

if ( !iam ) {
double t = SuperLU_timer_();
if(!strcmp(postfix,"rua")){
if(!strcmp(postfix,"rua")){
/* Read the matrix stored on disk in Harwell-Boeing format. */
dreadhb_dist(iam, fp, &m, &n, &nnz, &nzval, &rowind, &colptr);
}else if(!strcmp(postfix,"mtx")){
Expand All @@ -279,7 +279,7 @@ int dcreate_matrix_perturbed_postfix(SuperMatrix *A, int nrhs, double **rhs,

printf("Time to read and distribute matrix %.2f\n",
SuperLU_timer_() - t); fflush(stdout);

/* Broadcast matrix A to the other PEs. */
MPI_Bcast( &m, 1, mpi_int_t, 0, grid->comm );
MPI_Bcast( &n, 1, mpi_int_t, 0, grid->comm );
Expand Down Expand Up @@ -416,4 +416,4 @@ int dcreate_matrix_perturbed_postfix(SuperMatrix *A, int nrhs, double **rhs,
CHECK_MALLOC(iam, "Exit dcreate_matrix()");
#endif
return 0;
}
}
32 changes: 13 additions & 19 deletions EXAMPLE/pddrive.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ at the top-level directory.
*/

#include <math.h>
#include <superlu_dist_config.h>
#include "superlu_ddefs.h"

/*! \brief
Expand Down Expand Up @@ -62,16 +61,16 @@ int main(int argc, char *argv[])
int m, n;
int nprow, npcol;
int iam, info, ldb, ldx, nrhs;
char **cpp, c, *postfix;
char **cpp, c, *postfix;;
FILE *fp, *fopen();
int cpp_defs();
int ii;
int omp_mpi_level;

nprow = 1; /* Default process rows. */
npcol = 1; /* Default process columns. */
nrhs =1; /* Number of right-hand side. */
nrhs = 1; /* Number of right-hand side. */

/* ------------------------------------------------------------
INITIALIZE MPI ENVIRONMENT.
------------------------------------------------------------*/
Expand All @@ -86,7 +85,7 @@ int main(int argc, char *argv[])
#if ( VTUNE>=1 )
__itt_pause();
#endif

/* Parse command line argv[]. */
for (cpp = argv+1; *cpp; ++cpp) {
if ( **cpp == '-' ) {
Expand Down Expand Up @@ -116,7 +115,7 @@ int main(int argc, char *argv[])
INITIALIZE THE SUPERLU PROCESS GRID.
------------------------------------------------------------*/
superlu_gridinit(MPI_COMM_WORLD, nprow, npcol, &grid);

if(grid.iam==0){
MPI_Query_thread(&omp_mpi_level);
switch (omp_mpi_level) {
Expand All @@ -138,7 +137,7 @@ int main(int argc, char *argv[])
break;
}
}

/* Bail out if I do not belong in the grid. */
iam = grid.iam;
if ( iam >= nprow * npcol ) goto out;
Expand Down Expand Up @@ -167,7 +166,6 @@ int main(int argc, char *argv[])
}
// printf("%s\n", postfix);


/* ------------------------------------------------------------
GET THE MATRIX FROM FILE AND SETUP THE RIGHT HAND SIDE.
------------------------------------------------------------*/
Expand All @@ -192,24 +190,19 @@ int main(int argc, char *argv[])
options.SolveInitialized = NO;
options.RefineInitialized = NO;
options.PrintStat = YES;
options.DiagInv = NO;
*/
set_default_options_dist(&options);
// options.DiagInv = YES;

#if 0
options.ColPerm = PARMETIS;
options.ParSymbFact = YES;
options.RowPerm = NOROWPERM;
options.IterRefine = NOREFINE;
options.ColPerm = NATURAL;
options.Equil = NO;
options.ReplaceTinyPivot = YES;
#endif

// // options.ParSymbFact = YES;
// // options.ColPerm = PARMETIS;
// // options.RowPerm = NOROWPERM;
// options.IterRefine = 0;
// // options.DiagInv = YES;
// options.ReplaceTinyPivot = NO;
// options.SymPattern = YES;

if (!iam) {
print_sp_ienv_dist(&options);
print_options_dist(&options);
Expand Down Expand Up @@ -244,7 +237,8 @@ int main(int argc, char *argv[])
PStatFree(&stat);
Destroy_CompRowLoc_Matrix_dist(&A);
ScalePermstructFree(&ScalePermstruct);
Destroy_LU(n, &grid, &LUstruct);
dDestroy_Tree(n, &grid, &LUstruct);
Destroy_LU(n, &grid, &LUstruct);
LUstructFree(&LUstruct);
if ( options.SolveInitialized ) {
dSolveFinalize(&options, &SOLVEstruct);
Expand Down
10 changes: 4 additions & 6 deletions EXAMPLE/pddrive1.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ at the top-level directory.
*/

#include <math.h>
#include <superlu_dist_config.h>
#include "superlu_ddefs.h"

/*! \brief
Expand Down Expand Up @@ -129,13 +128,12 @@ int main(int argc, char *argv[])
}
}
// printf("%s\n", postfix);

/* ------------------------------------------------------------
GET THE MATRIX FROM FILE AND SETUP THE RIGHT HAND SIDE.
------------------------------------------------------------*/
dcreate_matrix_postfix(&A, nrhs, &b, &ldb, &xtrue, &ldx, fp, postfix, &grid);

if ( !(b1 = doubleMalloc_dist(ldb * nrhs)) )
if ( !(b1 = doubleMalloc_dist(ldb * nrhs)) )
ABORT("Malloc fails for b1[]");
for (j = 0; j < nrhs; ++j)
for (i = 0; i < ldb; ++i) b1[i+j*ldb] = b[i+j*ldb];
Expand All @@ -160,7 +158,6 @@ int main(int argc, char *argv[])
options.PrintStat = YES;
*/
set_default_options_dist(&options);
printf("options.ColPerm = %d\n", options.ColPerm);

if (!iam) {
print_sp_ienv_dist(&options);
Expand Down Expand Up @@ -216,7 +213,8 @@ int main(int argc, char *argv[])
PStatFree(&stat);
Destroy_CompRowLoc_Matrix_dist(&A);
ScalePermstructFree(&ScalePermstruct);
Destroy_LU(n, &grid, &LUstruct);
dDestroy_Tree(n, &grid, &LUstruct);
Destroy_LU(n, &grid, &LUstruct);
LUstructFree(&LUstruct);
if ( options.SolveInitialized ) {
dSolveFinalize(&options, &SOLVEstruct);
Expand Down
15 changes: 8 additions & 7 deletions EXAMPLE/pddrive2.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ at the top-level directory.
*/

#include <math.h>
#include <superlu_dist_config.h>
#include "superlu_ddefs.h"

/*! \brief
Expand Down Expand Up @@ -70,8 +69,8 @@ int main(int argc, char *argv[])
/* prototypes */
extern int dcreate_matrix_perturbed
(SuperMatrix *, int, double **, int *, double **, int *,
FILE *, gridinfo_t *);
extern int dcreate_matrix_perturbed_postfix
FILE *, gridinfo_t *);
extern int dcreate_matrix_perturbed_postfix
(SuperMatrix *, int, double **, int *, double **, int *,
FILE *, char *, gridinfo_t *);

Expand Down Expand Up @@ -137,9 +136,9 @@ int main(int argc, char *argv[])
}
}
// printf("%s\n", postfix);

/* ------------------------------------------------------------
GET THE MATRIX FROM FILE AND SETUP THE RIGHT HAND SIDE.
GET THE MATRIX FROM FILE AND SETUP THE RIGHT-HAND SIDE.
------------------------------------------------------------*/
dcreate_matrix_postfix(&A, nrhs, &b, &ldb, &xtrue, &ldx, fp, postfix, &grid);

Expand Down Expand Up @@ -191,7 +190,8 @@ int main(int argc, char *argv[])
PStatPrint(&options, &stat, &grid); /* Print the statistics. */
PStatFree(&stat);
Destroy_CompRowLoc_Matrix_dist(&A); /* Deallocate storage of matrix A. */
Destroy_LU(n, &grid, &LUstruct); /* Deallocate storage associated with
dDestroy_Tree(n, &grid, &LUstruct);
Destroy_LU(n, &grid, &LUstruct); /* Deallocate storage associated with
the L and U matrices. */
SUPERLU_FREE(b); /* Free storage of right-hand side. */
SUPERLU_FREE(xtrue); /* Free storage of the exact solution. */
Expand Down Expand Up @@ -239,7 +239,8 @@ int main(int argc, char *argv[])
------------------------------------------------------------*/
PStatFree(&stat);
Destroy_CompRowLoc_Matrix_dist(&A); /* Deallocate storage of matrix A. */
Destroy_LU(n, &grid, &LUstruct); /* Deallocate storage associated with
dDestroy_Tree(n, &grid, &LUstruct);
Destroy_LU(n, &grid, &LUstruct); /* Deallocate storage associated with
the L and U matrices. */
ScalePermstructFree(&ScalePermstruct);
LUstructFree(&LUstruct); /* Deallocate the structure of L and U.*/
Expand Down
8 changes: 4 additions & 4 deletions EXAMPLE/pddrive3.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ at the top-level directory.
*/

#include <math.h>
#include <superlu_dist_config.h>
#include "superlu_ddefs.h"

/*! \brief
Expand Down Expand Up @@ -68,7 +67,7 @@ int main(int argc, char *argv[])
int_t i, j, ii, m, n, nnz_loc, m_loc, fst_row;
int nprow, npcol;
int iam, info, ldb, ldx, nrhs;
char **cpp, c, *postfix;;
char **cpp, c, *postfix;
FILE *fp, *fopen();
int cpp_defs();

Expand Down Expand Up @@ -134,7 +133,7 @@ int main(int argc, char *argv[])
}
}
// printf("%s\n", postfix);

/* ------------------------------------------------------------
GET THE MATRIX FROM FILE AND SETUP THE RIGHT HAND SIDE.
------------------------------------------------------------*/
Expand Down Expand Up @@ -240,7 +239,8 @@ int main(int argc, char *argv[])
------------------------------------------------------------*/
PStatFree(&stat);
Destroy_CompRowLoc_Matrix_dist(&A); /* Deallocate storage of matrix A. */
Destroy_LU(n, &grid, &LUstruct); /* Deallocate storage associated with
dDestroy_Tree(n, &grid, &LUstruct);
Destroy_LU(n, &grid, &LUstruct); /* Deallocate storage associated with
the L and U matrices. */
ScalePermstructFree(&ScalePermstruct);
LUstructFree(&LUstruct); /* Deallocate the structure of L and U.*/
Expand Down
13 changes: 6 additions & 7 deletions EXAMPLE/pddrive4.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main(int argc, char *argv[])
int_t usermap[6];
int iam, info, ldb, ldx, nprocs;
int nrhs = 1; /* Number of right-hand side. */
char **cpp, c, *postfix;;
char **cpp, c, *postfix;
FILE *fp, *fopen();
int cpp_defs();

Expand Down Expand Up @@ -134,24 +134,21 @@ int main(int argc, char *argv[])
CHECK_MALLOC(iam, "Enter main()");
#endif


for(ii = 0;ii<strlen(*cpp);ii++){
if((*cpp)[ii]=='.'){
postfix = &((*cpp)[ii+1]);
}
}
// printf("%s\n", postfix);


if ( iam >= 0 && iam < 6 ) { /* I am in grid 1. */
iam = grid1.iam; /* Get the logical number in the new grid. */

/* ------------------------------------------------------------
GET THE MATRIX FROM FILE AND SETUP THE RIGHT HAND SIDE.
------------------------------------------------------------*/
dcreate_matrix_postfix(&A, nrhs, &b, &ldb, &xtrue, &ldx, fp, postfix, &grid1);


dcreate_matrix_postfix(&A, nrhs, &b, &ldb, &xtrue, &ldx, fp, postfix, &grid1);

if ( !(berr = doubleMalloc_dist(nrhs)) )
ABORT("Malloc fails for berr[].");

Expand Down Expand Up @@ -205,6 +202,7 @@ int main(int argc, char *argv[])
PStatFree(&stat);
Destroy_CompRowLoc_Matrix_dist(&A);
ScalePermstructFree(&ScalePermstruct);
dDestroy_Tree(n, &grid1, &LUstruct);
Destroy_LU(n, &grid1, &LUstruct);
LUstructFree(&LUstruct);
if ( options.SolveInitialized ) {
Expand All @@ -220,7 +218,7 @@ int main(int argc, char *argv[])
/* ------------------------------------------------------------
GET THE MATRIX FROM FILE AND SETUP THE RIGHT HAND SIDE.
------------------------------------------------------------*/
dcreate_matrix_postfix(&A, nrhs, &b, &ldb, &xtrue, &ldx, fp, postfix, &grid2);
dcreate_matrix_postfix(&A, nrhs, &b, &ldb, &xtrue, &ldx, fp, postfix, &grid2);

if ( !(berr = doubleMalloc_dist(nrhs)) )
ABORT("Malloc fails for berr[].");
Expand Down Expand Up @@ -270,6 +268,7 @@ int main(int argc, char *argv[])
PStatFree(&stat);
Destroy_CompRowLoc_Matrix_dist(&A);
ScalePermstructFree(&ScalePermstruct);
dDestroy_Tree(n, &grid2, &LUstruct);
Destroy_LU(n, &grid2, &LUstruct);
LUstructFree(&LUstruct);
if ( options.SolveInitialized ) {
Expand Down
Loading

1 comment on commit 173c260

@prj-
Copy link
Contributor

@prj- prj- commented on 173c260 Apr 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you import make.inc_good_static, make.inc_good_dynamic, and make.inc_tmp? Shouldn't you delete those files?

Please sign in to comment.