IFPACK Development
Loading...
Searching...
No Matches
Mat_dh.h
1/*@HEADER
2// ***********************************************************************
3//
4// Ifpack: Object-Oriented Algebraic Preconditioner Package
5// Copyright (2002) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40//@HEADER
41*/
42
43#ifndef MAT_DH_DH
44#define MAT_DH_DH
45
46#if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47#ifdef __GNUC__
48#warning "The Ifpack package is deprecated"
49#endif
50#endif
51
52#include "euclid_common.h"
53
54 /* this stuff for experimental internal timing */
55#define MAT_DH_BINS 10
56#define MATVEC_TIME 0 /* time to actually perform matvec */
57#define MATVEC_MPI_TIME 1 /* time for comms + vector copying needed */
58#define MATVEC_MPI_TIME2 5 /* time for comms, + vector copying needed */
59#define MATVEC_TOTAL_TIME 2 /* MATVEC_TIME+MATVEC_MPI_TIME */
60#define MATVEC_RATIO 3 /* computation/communication ratio */
61#define MATVEC_WORDS 4 /* total words sent to other procs. */
62
63#ifdef __cplusplus
64extern "C"
65{
66#endif
67
68 struct _mat_dh
69 {
70 int m, n; /* dimensions of local rectangular submatrix;
71 * the global matrix is n by n.
72 */
73 int beg_row; /* global number of 1st locally owned row */
74 int bs; /* block size */
75
76 /* sparse row-oriented storage for locally owned submatrix */
77 int *rp;
78 int *len; /* length of each row; only used for MPI triangular solves */
79 int *cval;
80 int *fill;
81 int *diag;
82 double *aval;
83 bool owner; /* for MPI triangular solves */
84
85 /* working space for getRow */
86 int len_private;
87 int rowCheckedOut;
88 int *cval_private;
89 double *aval_private;
90
91 /* row permutations to increase positive definiteness */
92 int *row_perm;
93
94 /* for timing matvecs in experimental studies */
95 double time[MAT_DH_BINS];
96 double time_max[MAT_DH_BINS];
97 double time_min[MAT_DH_BINS];
98 bool matvec_timing;
99
100 /* used for MatVecs */
101 int num_recv;
102 int num_send; /* used in destructor */
103 MPI_Request *recv_req;
104 MPI_Request *send_req;
105 double *recvbuf, *sendbuf;
106 int *sendind;
107 int sendlen;
108 int recvlen;
109 bool matvecIsSetup;
110 Numbering_dh numb;
111 MPI_Status *status;
112
113 bool debug;
114 };
115
116 extern void Mat_dhCreate (Mat_dh * mat);
117 extern void Mat_dhDestroy (Mat_dh mat);
118
119 extern void Mat_dhTranspose (Mat_dh matIN, Mat_dh * matOUT);
120 extern void Mat_dhMakeStructurallySymmetric (Mat_dh A);
121
122 /* adopted from ParaSails, by Edmond Chow */
123 extern void Mat_dhMatVecSetup (Mat_dh mat);
124 extern void Mat_dhMatVecSetdown (Mat_dh mat);
125
126/*========================================================================*/
127/* notes: if not compiled with OpenMP, Mat_dhMatVec() and Mat_dhMatVec_omp()
128 perform identically; similarly for Mat_dhMatVec_uni()
129 and Mat_dhMatVec_uni_omp()
130*/
131
132 extern void Mat_dhMatVec (Mat_dh mat, double *lhs, double *rhs);
133 /* unthreaded MPI version */
134
135 extern void Mat_dhMatVec_omp (Mat_dh mat, double *lhs, double *rhs);
136 /* OpenMP/MPI version */
137
138 extern void Mat_dhMatVec_uni (Mat_dh mat, double *lhs, double *rhs);
139 /* unthreaded, single-task version */
140
141 extern void Mat_dhMatVec_uni_omp (Mat_dh mat, double *lhs, double *rhs);
142 /* OpenMP/single primary task version */
143
144
145 extern int Mat_dhReadNz (Mat_dh mat);
146
147 /* for next five, SubdomainGraph_dh() may be NULL; if not null,
148 caller must ensure it has been properly initialized;
149 if not null, matrix is permuted before printing.
150
151 note: use "-matlab" when calling Mat_dhPrintTriples, to
152 insert small value in place of 0.
153
154 Mat_dhPrintCSR only implemented for single cpu, no reordering.
155 */
156 extern void Mat_dhPrintGraph (Mat_dh mat, SubdomainGraph_dh sg, FILE * fp);
157 extern void Mat_dhPrintRows (Mat_dh mat, SubdomainGraph_dh sg, FILE * fp);
158
159 extern void Mat_dhPrintCSR (Mat_dh mat, SubdomainGraph_dh sg,
160 char *filename);
161 extern void Mat_dhPrintTriples (Mat_dh mat, SubdomainGraph_dh sg,
162 char *filename);
163 extern void Mat_dhPrintBIN (Mat_dh mat, SubdomainGraph_dh sg,
164 char *filename);
165
166 extern void Mat_dhReadCSR (Mat_dh * mat, char *filename);
167 extern void Mat_dhReadTriples (Mat_dh * mat, int ignore, char *filename);
168 extern void Mat_dhReadBIN (Mat_dh * mat, char *filename);
169
170
171 extern void Mat_dhPermute (Mat_dh Ain, int *pIN, Mat_dh * Bout);
172 /* for single cpu only! */
173
174 extern void Mat_dhFixDiags (Mat_dh A);
175 /* inserts diagonal if not explicitly present;
176 sets diagonal value in row i to sum of absolute
177 values of all elts in row i.
178 */
179
180 extern void Mat_dhPrintDiags (Mat_dh A, FILE * fp);
181
182 extern void Mat_dhGetRow (Mat_dh B, int globalRow, int *len, int **ind,
183 double **val);
184 extern void Mat_dhRestoreRow (Mat_dh B, int row, int *len, int **ind,
185 double **val);
186
187 /* partition matrix into "k" blocks. User must free storage. */
188 extern void Mat_dhPartition (Mat_dh mat, int k, int **beg_rowOUT,
189 int **row_countOUT, int **n2oOUT,
190 int **o2nOUT);
191
192
193
194
195 extern void Mat_dhZeroTiming (Mat_dh mat);
196 extern void Mat_dhReduceTiming (Mat_dh mat);
197
198
199 extern void Mat_dhRowPermute (Mat_dh);
200
201 extern void dldperm (int job, int n, int nnz, int colptr[], int adjncy[],
202 double nzval[], int *perm, double u[], double v[]);
203
204
205#ifdef __cplusplus
206}
207#endif
208#endif