programmer's documentation
cs_matrix_default.h
Go to the documentation of this file.
1 #ifndef __CS_MATRIX_DEFAULT_H__
2 #define __CS_MATRIX_DEFAULT_H__
3 
4 /*============================================================================
5  * Default Sparse Matrix structure and Tuning.
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2016 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_defs.h"
35 
36 #include "cs_halo.h"
37 #include "cs_matrix.h"
38 #include "cs_numbering.h"
39 #include "cs_halo_perio.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /*============================================================================
50  * Type definitions
51  *============================================================================*/
52 
53 /*============================================================================
54  * Global variables
55  *============================================================================*/
56 
57 /*=============================================================================
58  * Public function prototypes
59  *============================================================================*/
60 
61 /*----------------------------------------------------------------------------
62  * Matrix (native format) vector product
63  *
64  * parameters:
65  * isym <-- Symmetry indicator:
66  * 1: symmetric; 2: not symmetric
67  * ibsize <-- Block size of element ii
68  * iesize <-- Block size of element ij
69  * iinvpe <-- Indicator to cancel increments
70  * in rotational periodicty (2) or
71  * to exchange them as scalars (1)
72  * dam <-- Matrix diagonal
73  * xam <-- Matrix extra-diagonal terms
74  * vx <-- A*vx
75  * vy <-> vy = A*vx
76  *----------------------------------------------------------------------------*/
77 
78 void
80  int ibsize,
81  int iesize,
82  int iinvpe,
83  const cs_real_t *dam,
84  const cs_real_t *xam,
85  cs_real_t *vx,
86  cs_real_t *vy);
87 
88 /*----------------------------------------------------------------------------
89  * Initialize sparse matrix API.
90  *----------------------------------------------------------------------------*/
91 
92 void
94 
95 /*----------------------------------------------------------------------------
96  * Finalize sparse matrix API.
97  *----------------------------------------------------------------------------*/
98 
99 void
100 cs_matrix_finalize(void);
101 
102 /*----------------------------------------------------------------------------
103  * Update sparse matrix API in case of mesh modification.
104  *----------------------------------------------------------------------------*/
105 
106 void
108 
109 /*----------------------------------------------------------------------------
110  * Return default matrix for a given fill type
111  *
112  * parameters:
113  * symmetric <-- Indicates if matrix coefficients are symmetric
114  * diag_block_size <-- Block sizes for diagonal, or NULL
115  * extra_diag_block_size <-- Block sizes for extra diagonal, or NULL
116  *
117  * returns:
118  * pointer to default matrix structure adapted to fill type
119  *----------------------------------------------------------------------------*/
120 
121 cs_matrix_t *
122 cs_matrix_default(bool symmetric,
123  const int *diag_block_size,
124  const int *extra_diag_block_size);
125 
126 /*----------------------------------------------------------------------------
127  * Return MSR matrix for a given fill type
128  *
129  * parameters:
130  * symmetric <-- Indicates if matrix coefficients are symmetric
131  * diag_block_size <-- Block sizes for diagonal, or NULL
132  * extra_diag_block_size <-- Block sizes for extra diagonal, or NULL
133  *
134  * returns:
135  * pointer to MSR matrix adapted to fill type
136  *----------------------------------------------------------------------------*/
137 
138 cs_matrix_t *
139 cs_matrix_msr(bool symmetric,
140  const int *diag_block_size,
141  const int *extra_diag_block_size);
142 
143 /*----------------------------------------------------------------------------
144  * Return native matrix for a given fill type
145  *
146  * parameters:
147  * symmetric <-- Indicates if matrix coefficients are symmetric
148  * diag_block_size <-- Block sizes for diagonal, or NULL
149  * extra_diag_block_size <-- Block sizes for extra diagonal, or NULL
150  *
151  * returns:
152  * pointer to native matrix adapted to fill type
153  *----------------------------------------------------------------------------*/
154 
155 cs_matrix_t *
156 cs_matrix_native(bool symmetric,
157  const int *diag_block_size,
158  const int *extra_diag_block_size);
159 
160 /*----------------------------------------------------------------------------
161  * Force matrix variant for a given fill type
162  *
163  * Information from the variant used fo this definition is copied,
164  * so it may be freed after calling this function.
165  *
166  * parameters:
167  * fill type <-- Fill type for which tuning behavior is set
168  * mv <-- Matrix variant to use for this type
169  *----------------------------------------------------------------------------*/
170 
171 void
173  const cs_matrix_variant_t *mv);
174 
175 /*----------------------------------------------------------------------------
176  * Set matrix tuning behavior for a given fill type
177  *
178  * parameters:
179  * fill type <-- Fill type for which tuning behavior is set
180  * tune <-- 1 to activate tuning, 0 to deactivate
181  *----------------------------------------------------------------------------*/
182 
183 void
185  int tune);
186 
187 /*----------------------------------------------------------------------------
188  * Return matrix tuning behavior for a given fill type.
189  *
190  * parameters:
191  * fill type <-- Fill type for which tuning behavior is set
192  *
193  * returns:
194  * 1 if tuning is active, 0 otherwise
195  *----------------------------------------------------------------------------*/
196 
197 int
199 
200 /*----------------------------------------------------------------------------
201  * Set number of matrix computation runs for tuning.
202  *
203  * If this function is not called, defaults are:
204  * - minimum of 10 runs
205  * - minimum of 0.5 seconds of running
206  *
207  * parameters:
208  * n_min_products <-- minimum number of expected SpM.V products for
209  * coefficients assign amortization.
210  * t_measure <-- minimum running time per measure
211  *----------------------------------------------------------------------------*/
212 
213 void
214 cs_matrix_set_tuning_runs(int n_min_products,
215  double t_measure);
216 
217 /*----------------------------------------------------------------------------
218  * Get number of matrix computation runs for tuning.
219  *
220  * parameters:
221  * n_min_products --> minimum number of expected SpM.V products for
222  * coefficients assign amortization.
223  * t_measure --> minimum running time per measure, or NULL
224  *----------------------------------------------------------------------------*/
225 
226 void
227 cs_matrix_get_tuning_runs(int *n_min_products,
228  double *t_measure);
229 
230 /*----------------------------------------------------------------------------
231  * Return a global block row numbering.
232  *
233  * The numbering is built if not previously present, and returned otherwise.
234  *
235  * Currently, the function only handles one n_rows/halo combination, and does
236  * not check for consistency.
237  *
238  * parameters:
239  * n_rows <-- associated number of local rows
240  * halo <-- associated halo, or NULL
241  *
242  * returns:
243  * pointer to requested global numbering
244  *----------------------------------------------------------------------------*/
245 
246 const cs_gnum_t *
248  const cs_halo_t *halo);
249 
250 /*----------------------------------------------------------------------------*/
251 
253 
254 #endif /* __CS_MATRIX_DEFAULT_H__ */
cs_matrix_t * cs_matrix_msr(bool symmetric, const int *diag_block_size, const int *extra_diag_block_size)
Definition: cs_matrix_default.c:622
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:280
const cs_gnum_t * cs_matrix_get_block_row_gnum(cs_lnum_t n_rows, const cs_halo_t *halo)
Definition: cs_matrix_default.c:887
struct _cs_matrix_variant_t cs_matrix_variant_t
Definition: cs_matrix.h:93
void cs_matrix_get_tuning_runs(int *n_min_products, double *t_measure)
Definition: cs_matrix_default.c:857
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
Definition: cs_halo.h:70
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:89
void cs_matrix_vector_native_multiply(int isym, int ibsize, int iesize, int iinvpe, const cs_real_t *dam, const cs_real_t *xam, cs_real_t *vx, cs_real_t *vy)
Definition: cs_matrix_default.c:229
int cs_matrix_get_tuning(cs_matrix_fill_type_t fill_type)
Definition: cs_matrix_default.c:810
void cs_matrix_initialize(void)
Definition: cs_matrix_default.c:301
void cs_matrix_finalize(void)
Definition: cs_matrix_default.c:435
cs_matrix_t * cs_matrix_native(bool symmetric, const int *diag_block_size, const int *extra_diag_block_size)
Definition: cs_matrix_default.c:697
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
cs_matrix_t * cs_matrix_default(bool symmetric, const int *diag_block_size, const int *extra_diag_block_size)
Definition: cs_matrix_default.c:593
#define END_C_DECLS
Definition: cs_defs.h:449
void cs_matrix_update_mesh(void)
Definition: cs_matrix_default.c:471
void cs_matrix_set_variant(cs_matrix_fill_type_t fill_type, const cs_matrix_variant_t *mv)
Definition: cs_matrix_default.c:758
void cs_matrix_set_tuning_runs(int n_min_products, double t_measure)
Definition: cs_matrix_default.c:837
void cs_matrix_set_tuning(cs_matrix_fill_type_t fill_type, int tune)
Definition: cs_matrix_default.c:785
cs_matrix_fill_type_t
Definition: cs_matrix.h:66