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-2015 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 for Fortran API
59  *============================================================================*/
60 
61 void CS_PROCF(promav, PROMAV)
62 (
63  const cs_int_t *isym, /* <-- Symmetry indicator:
64  1: symmetric; 2: not symmetric */
65  const cs_int_t *ibsize, /* <-- Block size of diagonal element */
66  const cs_int_t *iesize, /* <-- Block size of element ij */
67  const cs_int_t *iinvpe, /* <-- Indicator to cancel increments
68  in rotational periodicty (2) or
69  to exchange them as scalars (1) */
70  const cs_real_t *dam, /* <-- Matrix diagonal */
71  const cs_real_t *xam, /* <-- Matrix extra-diagonal terms */
72  cs_real_t *vx, /* <-- A*vx */
73  cs_real_t *vy /* <-> vy = A*vx */
74  );
75 
76 /*=============================================================================
77  * Public function prototypes
78  *============================================================================*/
79 
80 /*----------------------------------------------------------------------------
81  * Initialize sparse matrix API.
82  *----------------------------------------------------------------------------*/
83 
84 void
86 
87 /*----------------------------------------------------------------------------
88  * Finalize sparse matrix API.
89  *----------------------------------------------------------------------------*/
90 
91 void
92 cs_matrix_finalize(void);
93 
94 /*----------------------------------------------------------------------------
95  * Update sparse matrix API in case of mesh modification.
96  *----------------------------------------------------------------------------*/
97 
98 void
100 
101 /*----------------------------------------------------------------------------
102  * Return default matrix for a given fill type
103  *
104  * parameters:
105  * symmetric <-- Indicates if matrix coefficients are symmetric
106  * diag_block_size <-- Block sizes for diagonal, or NULL
107  * extra_diag_block_size <-- Block sizes for extra diagonal, or NULL
108  *
109  * returns:
110  * pointer to default matrix structure adapted to fill type
111  *----------------------------------------------------------------------------*/
112 
113 cs_matrix_t *
114 cs_matrix_default(bool symmetric,
115  const int *diag_block_size,
116  const int *extra_diag_block_size);
117 
118 /*----------------------------------------------------------------------------
119  * Return MSR matrix for a given fill type
120  *
121  * parameters:
122  * symmetric <-- Indicates if matrix coefficients are symmetric
123  * diag_block_size <-- Block sizes for diagonal, or NULL
124  * extra_diag_block_size <-- Block sizes for extra diagonal, or NULL
125  *
126  * returns:
127  * pointer to MSR matrix adapted to fill type
128  *----------------------------------------------------------------------------*/
129 
130 cs_matrix_t *
131 cs_matrix_msr(bool symmetric,
132  const int *diag_block_size,
133  const int *extra_diag_block_size);
134 
135 /*----------------------------------------------------------------------------
136  * Force matrix variant for a given fill type
137  *
138  * Information from the variant used fo this definition is copied,
139  * so it may be freed after calling this function.
140  *
141  * parameters:
142  * fill type <-- Fill type for which tuning behavior is set
143  * mv <-- Matrix variant to use for this type
144  *----------------------------------------------------------------------------*/
145 
146 void
148  const cs_matrix_variant_t *mv);
149 
150 /*----------------------------------------------------------------------------
151  * Set matrix tuning behavior for a given fill type
152  *
153  * parameters:
154  * fill type <-- Fill type for which tuning behavior is set
155  * tune <-- 1 to activate tuning, 0 to deactivate
156  *----------------------------------------------------------------------------*/
157 
158 void
160  int tune);
161 
162 /*----------------------------------------------------------------------------
163  * Return matrix tuning behavior for a given fill type.
164  *
165  * parameters:
166  * fill type <-- Fill type for which tuning behavior is set
167  *
168  * returns:
169  * 1 if tuning is active, 0 otherwise
170  *----------------------------------------------------------------------------*/
171 
172 int
174 
175 /*----------------------------------------------------------------------------
176  * Set number of matrix computation runs for tuning.
177  *
178  * If this function is not called, defaults are:
179  * - minimum of 10 runs
180  * - minimum of 0.5 seconds of running
181  *
182  * parameters:
183  * n_min_products <-- minimum number of expected SpM.V products for
184  * coefficients assign amortization.
185  * t_measure <-- minimum running time per measure
186  *----------------------------------------------------------------------------*/
187 
188 void
189 cs_matrix_set_tuning_runs(int n_min_products,
190  double t_measure);
191 
192 /*----------------------------------------------------------------------------
193  * Get number of matrix computation runs for tuning.
194  *
195  * parameters:
196  * n_min_products --> minimum number of expected SpM.V products for
197  * coefficients assign amortization.
198  * t_measure --> minimum running time per measure, or NULL
199  *----------------------------------------------------------------------------*/
200 
201 void
202 cs_matrix_get_tuning_runs(int *n_min_products,
203  double *t_measure);
204 
205 /*----------------------------------------------------------------------------
206  * Return a global block row numbering.
207  *
208  * The numbering is built if not previously present, and returned otherwise.
209  *
210  * Currently, the function only handles one n_rows/halo combination, and does
211  * not check for consistency.
212  *
213  * parameters:
214  * n_rows <-- associated number of local rows
215  * halo <-- associated halo, or NULL
216  *
217  * returns:
218  * pointer to requested global numbering
219  *----------------------------------------------------------------------------*/
220 
221 const cs_gnum_t *
223  const cs_halo_t *halo);
224 
225 /*----------------------------------------------------------------------------*/
226 
228 
229 #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:635
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:825
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:795
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:295
Definition: cs_halo.h:70
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:89
int cs_matrix_get_tuning(cs_matrix_fill_type_t fill_type)
Definition: cs_matrix_default.c:748
void cs_matrix_initialize(void)
Definition: cs_matrix_default.c:354
void cs_matrix_finalize(void)
Definition: cs_matrix_default.c:474
void promav(const cs_int_t *isym, const cs_int_t *ibsize, const cs_int_t *iesize, const cs_int_t *iinvpe, const cs_real_t *dam, const cs_real_t *xam, cs_real_t *vx, cs_real_t *vy)
Definition: cs_matrix_default.c:273
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:606
#define END_C_DECLS
Definition: cs_defs.h:430
double cs_real_t
Definition: cs_defs.h:296
#define CS_PROCF(x, y)
Definition: cs_defs.h:453
void cs_matrix_update_mesh(void)
Definition: cs_matrix_default.c:510
void cs_matrix_set_variant(cs_matrix_fill_type_t fill_type, const cs_matrix_variant_t *mv)
Definition: cs_matrix_default.c:696
void cs_matrix_set_tuning_runs(int n_min_products, double t_measure)
Definition: cs_matrix_default.c:775
void cs_matrix_set_tuning(cs_matrix_fill_type_t fill_type, int tune)
Definition: cs_matrix_default.c:723
cs_matrix_fill_type_t
Definition: cs_matrix.h:66