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-2018 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  * symmetric <-- Symmetry indicator:
66  * db_size <-- block sizes for diagonal
67  * eb_size <-- block sizes for extra diagonal
68  * rotation_mode <-- halo update option for rotational periodicity
69  * dam <-- Matrix diagonal
70  * xam <-- Matrix extra-diagonal terms
71  * vx <-- A*vx
72  * vy <-> vy = A*vx
73  *----------------------------------------------------------------------------*/
74 
75 void
77  int db_size[4],
78  int eb_size[4],
79  cs_halo_rotation_t rotation_mode,
80  int f_id,
81  const cs_real_t *dam,
82  const cs_real_t *xam,
83  cs_real_t *vx,
84  cs_real_t *vy);
85 
86 /*----------------------------------------------------------------------------
87  * Initialize sparse matrix API.
88  *----------------------------------------------------------------------------*/
89 
90 void
92 
93 /*----------------------------------------------------------------------------
94  * Finalize sparse matrix API.
95  *----------------------------------------------------------------------------*/
96 
97 void
98 cs_matrix_finalize(void);
99 
100 /*----------------------------------------------------------------------------
101  * Update sparse matrix API in case of mesh modification.
102  *----------------------------------------------------------------------------*/
103 
104 void
106 
107 /*----------------------------------------------------------------------------
108  * Return default matrix for a given fill type
109  *
110  * parameters:
111  * symmetric <-- Indicates if matrix coefficients are symmetric
112  * diag_block_size <-- Block sizes for diagonal, or NULL
113  * extra_diag_block_size <-- Block sizes for extra diagonal, or NULL
114  *
115  * returns:
116  * pointer to default matrix structure adapted to fill type
117  *----------------------------------------------------------------------------*/
118 
119 cs_matrix_t *
120 cs_matrix_default(bool symmetric,
121  const int *diag_block_size,
122  const int *extra_diag_block_size);
123 
124 /*----------------------------------------------------------------------------
125  * Return MSR matrix for a given fill type
126  *
127  * parameters:
128  * symmetric <-- Indicates if matrix coefficients are symmetric
129  * diag_block_size <-- Block sizes for diagonal, or NULL
130  * extra_diag_block_size <-- Block sizes for extra diagonal, or NULL
131  *
132  * returns:
133  * pointer to MSR matrix adapted to fill type
134  *----------------------------------------------------------------------------*/
135 
136 cs_matrix_t *
137 cs_matrix_msr(bool symmetric,
138  const int *diag_block_size,
139  const int *extra_diag_block_size);
140 
141 /*----------------------------------------------------------------------------
142  * Return native matrix for a given fill type
143  *
144  * parameters:
145  * symmetric <-- Indicates if matrix coefficients are symmetric
146  * diag_block_size <-- Block sizes for diagonal, or NULL
147  * extra_diag_block_size <-- Block sizes for extra diagonal, or NULL
148  *
149  * returns:
150  * pointer to native matrix adapted to fill type
151  *----------------------------------------------------------------------------*/
152 
153 cs_matrix_t *
154 cs_matrix_native(bool symmetric,
155  const int *diag_block_size,
156  const int *extra_diag_block_size);
157 
158 /*----------------------------------------------------------------------------
159  * Force matrix variant for a given fill type
160  *
161  * Information from the variant used fo this definition is copied,
162  * so it may be freed after calling this function.
163  *
164  * parameters:
165  * fill type <-- Fill type for which tuning behavior is set
166  * mv <-- Matrix variant to use for this type
167  *----------------------------------------------------------------------------*/
168 
169 void
171  const cs_matrix_variant_t *mv);
172 
173 /*----------------------------------------------------------------------------
174  * Set matrix tuning behavior for a given fill type
175  *
176  * parameters:
177  * fill type <-- Fill type for which tuning behavior is set
178  * tune <-- 1 to activate tuning, 0 to deactivate
179  *----------------------------------------------------------------------------*/
180 
181 void
183  int tune);
184 
185 /*----------------------------------------------------------------------------
186  * Return matrix tuning behavior for a given fill type.
187  *
188  * parameters:
189  * fill type <-- Fill type for which tuning behavior is set
190  *
191  * returns:
192  * 1 if tuning is active, 0 otherwise
193  *----------------------------------------------------------------------------*/
194 
195 int
197 
198 /*----------------------------------------------------------------------------
199  * Set number of matrix computation runs for tuning.
200  *
201  * If this function is not called, defaults are:
202  * - minimum of 10 runs
203  * - minimum of 0.5 seconds of running
204  *
205  * parameters:
206  * n_min_products <-- minimum number of expected SpM.V products for
207  * coefficients assign amortization.
208  * t_measure <-- minimum running time per measure
209  *----------------------------------------------------------------------------*/
210 
211 void
212 cs_matrix_set_tuning_runs(int n_min_products,
213  double t_measure);
214 
215 /*----------------------------------------------------------------------------
216  * Get number of matrix computation runs for tuning.
217  *
218  * parameters:
219  * n_min_products --> minimum number of expected SpM.V products for
220  * coefficients assign amortization.
221  * t_measure --> minimum running time per measure, or NULL
222  *----------------------------------------------------------------------------*/
223 
224 void
225 cs_matrix_get_tuning_runs(int *n_min_products,
226  double *t_measure);
227 
228 /*----------------------------------------------------------------------------
229  * Return a (0-based) global block row numbering.
230  *
231  * The numbering is built if not previously present, and returned otherwise.
232  *
233  * Currently, the function only handles one n_rows/halo combination, and does
234  * not check for consistency.
235  *
236  * parameters:
237  * n_rows <-- associated number of local rows
238  * halo <-- associated halo, or NULL
239  *
240  * returns:
241  * pointer to requested global numbering
242  *----------------------------------------------------------------------------*/
243 
244 const cs_gnum_t *
246  const cs_halo_t *halo);
247 
248 /*----------------------------------------------------------------------------*/
249 
251 
252 #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:584
const cs_gnum_t * cs_matrix_get_block_row_g_id(cs_lnum_t n_rows, const cs_halo_t *halo)
Definition: cs_matrix_default.c:846
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:281
cs_halo_rotation_t
Definition: cs_halo.h:60
struct _cs_matrix_variant_t cs_matrix_variant_t
Definition: cs_matrix.h:94
void cs_matrix_get_tuning_runs(int *n_min_products, double *t_measure)
Definition: cs_matrix_default.c:816
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
Definition: cs_halo.h:71
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:90
int cs_matrix_get_tuning(cs_matrix_fill_type_t fill_type)
Definition: cs_matrix_default.c:769
void cs_matrix_initialize(void)
Definition: cs_matrix_default.c:271
void cs_matrix_vector_native_multiply(bool symmetric, int db_size[4], int eb_size[4], cs_halo_rotation_t rotation_mode, int f_id, const cs_real_t *dam, const cs_real_t *xam, cs_real_t *vx, cs_real_t *vy)
Definition: cs_matrix_default.c:219
void cs_matrix_finalize(void)
Definition: cs_matrix_default.c:402
cs_matrix_t * cs_matrix_native(bool symmetric, const int *diag_block_size, const int *extra_diag_block_size)
Definition: cs_matrix_default.c:657
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
cs_matrix_t * cs_matrix_default(bool symmetric, const int *diag_block_size, const int *extra_diag_block_size)
Definition: cs_matrix_default.c:555
#define END_C_DECLS
Definition: cs_defs.h:454
void cs_matrix_update_mesh(void)
Definition: cs_matrix_default.c:438
void cs_matrix_set_variant(cs_matrix_fill_type_t fill_type, const cs_matrix_variant_t *mv)
Definition: cs_matrix_default.c:717
void cs_matrix_set_tuning_runs(int n_min_products, double t_measure)
Definition: cs_matrix_default.c:796
void cs_matrix_set_tuning(cs_matrix_fill_type_t fill_type, int tune)
Definition: cs_matrix_default.c:744
cs_matrix_fill_type_t
Definition: cs_matrix.h:67