|
IFPACK Development
|
00001 /*@HEADER 00002 // *********************************************************************** 00003 // 00004 // Ifpack: Object-Oriented Algebraic Preconditioner Package 00005 // Copyright (2009) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 */ 00029 00030 #ifndef MAT_DH_DH 00031 #define MAT_DH_DH 00032 00033 #include "euclid_common.h" 00034 00035 /* this stuff for experimental internal timing */ 00036 #define MAT_DH_BINS 10 00037 #define MATVEC_TIME 0 /* time to actually perform matvec */ 00038 #define MATVEC_MPI_TIME 1 /* time for comms + vector copying needed */ 00039 #define MATVEC_MPI_TIME2 5 /* time for comms, + vector copying needed */ 00040 #define MATVEC_TOTAL_TIME 2 /* MATVEC_TIME+MATVEC_MPI_TIME */ 00041 #define MATVEC_RATIO 3 /* computation/communication ratio */ 00042 #define MATVEC_WORDS 4 /* total words sent to other procs. */ 00043 00044 #ifdef __cplusplus 00045 extern "C" 00046 { 00047 #endif 00048 00049 struct _mat_dh 00050 { 00051 int m, n; /* dimensions of local rectangular submatrix; 00052 * the global matrix is n by n. 00053 */ 00054 int beg_row; /* global number of 1st locally owned row */ 00055 int bs; /* block size */ 00056 00057 /* sparse row-oriented storage for locally owned submatrix */ 00058 int *rp; 00059 int *len; /* length of each row; only used for MPI triangular solves */ 00060 int *cval; 00061 int *fill; 00062 int *diag; 00063 double *aval; 00064 bool owner; /* for MPI triangular solves */ 00065 00066 /* working space for getRow */ 00067 int len_private; 00068 int rowCheckedOut; 00069 int *cval_private; 00070 double *aval_private; 00071 00072 /* row permutations to increase positive definiteness */ 00073 int *row_perm; 00074 00075 /* for timing matvecs in experimental studies */ 00076 double time[MAT_DH_BINS]; 00077 double time_max[MAT_DH_BINS]; 00078 double time_min[MAT_DH_BINS]; 00079 bool matvec_timing; 00080 00081 /* used for MatVecs */ 00082 int num_recv; 00083 int num_send; /* used in destructor */ 00084 MPI_Request *recv_req; 00085 MPI_Request *send_req; 00086 double *recvbuf, *sendbuf; 00087 int *sendind; 00088 int sendlen; 00089 int recvlen; 00090 bool matvecIsSetup; 00091 Numbering_dh numb; 00092 MPI_Status *status; 00093 00094 bool debug; 00095 }; 00096 00097 extern void Mat_dhCreate (Mat_dh * mat); 00098 extern void Mat_dhDestroy (Mat_dh mat); 00099 00100 extern void Mat_dhTranspose (Mat_dh matIN, Mat_dh * matOUT); 00101 extern void Mat_dhMakeStructurallySymmetric (Mat_dh A); 00102 00103 /* adopted from ParaSails, by Edmond Chow */ 00104 extern void Mat_dhMatVecSetup (Mat_dh mat); 00105 extern void Mat_dhMatVecSetdown (Mat_dh mat); 00106 00107 /*========================================================================*/ 00108 /* notes: if not compiled with OpenMP, Mat_dhMatVec() and Mat_dhMatVec_omp() 00109 perform identically; similarly for Mat_dhMatVec_uni() 00110 and Mat_dhMatVec_uni_omp() 00111 */ 00112 00113 extern void Mat_dhMatVec (Mat_dh mat, double *lhs, double *rhs); 00114 /* unthreaded MPI version */ 00115 00116 extern void Mat_dhMatVec_omp (Mat_dh mat, double *lhs, double *rhs); 00117 /* OpenMP/MPI version */ 00118 00119 extern void Mat_dhMatVec_uni (Mat_dh mat, double *lhs, double *rhs); 00120 /* unthreaded, single-task version */ 00121 00122 extern void Mat_dhMatVec_uni_omp (Mat_dh mat, double *lhs, double *rhs); 00123 /* OpenMP/single primary task version */ 00124 00125 00126 extern int Mat_dhReadNz (Mat_dh mat); 00127 00128 /* for next five, SubdomainGraph_dh() may be NULL; if not null, 00129 caller must ensure it has been properly initialized; 00130 if not null, matrix is permuted before printing. 00131 00132 note: use "-matlab" when calling Mat_dhPrintTriples, to 00133 insert small value in place of 0. 00134 00135 Mat_dhPrintCSR only implemented for single cpu, no reordering. 00136 */ 00137 extern void Mat_dhPrintGraph (Mat_dh mat, SubdomainGraph_dh sg, FILE * fp); 00138 extern void Mat_dhPrintRows (Mat_dh mat, SubdomainGraph_dh sg, FILE * fp); 00139 00140 extern void Mat_dhPrintCSR (Mat_dh mat, SubdomainGraph_dh sg, 00141 char *filename); 00142 extern void Mat_dhPrintTriples (Mat_dh mat, SubdomainGraph_dh sg, 00143 char *filename); 00144 extern void Mat_dhPrintBIN (Mat_dh mat, SubdomainGraph_dh sg, 00145 char *filename); 00146 00147 extern void Mat_dhReadCSR (Mat_dh * mat, char *filename); 00148 extern void Mat_dhReadTriples (Mat_dh * mat, int ignore, char *filename); 00149 extern void Mat_dhReadBIN (Mat_dh * mat, char *filename); 00150 00151 00152 extern void Mat_dhPermute (Mat_dh Ain, int *pIN, Mat_dh * Bout); 00153 /* for single cpu only! */ 00154 00155 extern void Mat_dhFixDiags (Mat_dh A); 00156 /* inserts diagonal if not explicitly present; 00157 sets diagonal value in row i to sum of absolute 00158 values of all elts in row i. 00159 */ 00160 00161 extern void Mat_dhPrintDiags (Mat_dh A, FILE * fp); 00162 00163 extern void Mat_dhGetRow (Mat_dh B, int globalRow, int *len, int **ind, 00164 double **val); 00165 extern void Mat_dhRestoreRow (Mat_dh B, int row, int *len, int **ind, 00166 double **val); 00167 00168 /* partition matrix into "k" blocks. User must free storage. */ 00169 extern void Mat_dhPartition (Mat_dh mat, int k, int **beg_rowOUT, 00170 int **row_countOUT, int **n2oOUT, 00171 int **o2nOUT); 00172 00173 00174 00175 00176 extern void Mat_dhZeroTiming (Mat_dh mat); 00177 extern void Mat_dhReduceTiming (Mat_dh mat); 00178 00179 00180 extern void Mat_dhRowPermute (Mat_dh); 00181 00182 extern void dldperm (int job, int n, int nnz, int colptr[], int adjncy[], 00183 double nzval[], int *perm, double u[], double v[]); 00184 00185 00186 #ifdef __cplusplus 00187 } 00188 #endif 00189 #endif
1.7.4