9.1
general documentation
cs_sles_cudss.h
Go to the documentation of this file.
1#ifndef CS_SLES_CUDSS_H
2#define CS_SLES_CUDSS_H
3
4/*============================================================================
5 * Sparse Linear Equation Solvers using cuDSS
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2025 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 "base/cs_base.h"
35#include "alge/cs_matrix.h"
36#include "alge/cs_sles.h"
37
38/*----------------------------------------------------------------------------*/
39
41
42/*============================================================================
43 * Macro definitions
44 *============================================================================*/
45
50/*============================================================================
51 * Type definitions
52 *============================================================================*/
53
54/* cuDSS linear solver context (opaque) */
55
56typedef struct _cs_sles_cudss_t cs_sles_cudss_t;
57
58/*============================================================================
59 * Global variables
60 *============================================================================*/
61
62/*=============================================================================
63 * Public function prototypes
64 *============================================================================*/
65
66/*----------------------------------------------------------------------------
67 * Define and associate an cuDSS linear system solver
68 * for a given field or equation name.
69 *
70 * If this system did not previously exist, it is added to the list of
71 * "known" systems. Otherwise, its definition is replaced by the one
72 * defined here.
73 *
74 * This is a utility function: if finer control is needed, see
75 * cs_sles_define() and cs_sles_cudss_create().
76 *
77 * Note that this function returns a pointer directly to the cuDSS solver
78 * management structure. This may be used to set further options.
79 * If needed, cs_sles_find() may be used to obtain a pointer to the matching
80 * cs_sles_t container.
81 *
82 * parameters:
83 * f_id <-- associated field id, or < 0
84 * name <-- associated name if f_id < 0, or NULL
85 *
86 * returns:
87 * pointer to newly created cuDSS solver info object.
88 *----------------------------------------------------------------------------*/
89
92 const char *name);
93
94/*----------------------------------------------------------------------------
95 * Create cuDSS linear system solver info and context.
96 *
97 * In case of rotational periodicity for a block (non-scalar) matrix,
98 * the matrix type will be forced to MATSHELL ("shell") regardless
99 * of the option used.
100 *
101 * returns:
102 * pointer to newly created solver info object.
103 *----------------------------------------------------------------------------*/
104
107
108/*----------------------------------------------------------------------------
109 * Create cuDSS linear system solver info and context
110 * based on existing info and context.
111 *
112 * Most configuration parameters will be copied from the existing context,
113 * though not all, since cuDSS does not provide a comprehensive way to
114 * do this.
115 *
116 * parameters:
117 * context <-- pointer to reference info and context
118 * (actual type: cs_sles_cudss_t *)
119 *
120 * returns:
121 * pointer to newly created solver info object
122 * (actual type: cs_sles_cudss_t *)
123 *----------------------------------------------------------------------------*/
124
125void *
126cs_sles_cudss_copy(const void *context);
127
128/*----------------------------------------------------------------------------
129 * Destroy cuDSS linear system solver info and context.
130 *
131 * parameters:
132 * context <-> pointer to cuDSS linear solver info
133 * (actual type: cs_sles_cudss_t **)
134 *----------------------------------------------------------------------------*/
135
136void
137cs_sles_cudss_destroy(void **context);
138
139/*----------------------------------------------------------------------------*/
149/*----------------------------------------------------------------------------*/
150
151void
153 int flags);
154
155/*----------------------------------------------------------------------------*/
163/*----------------------------------------------------------------------------*/
164
165int
167
168/*----------------------------------------------------------------------------
169 * Setup cuDSS linear equation solver.
170 *
171 * parameters:
172 * context <-> pointer to cuDSS linear solver info
173 * (actual type: cs_sles_cudss_t *)
174 * name <-- pointer to system name
175 * a <-- associated matrix
176 * verbosity <-- verbosity level
177 *----------------------------------------------------------------------------*/
178
179void
180cs_sles_cudss_setup(void *context,
181 const char *name,
182 const cs_matrix_t *a,
183 int verbosity);
184
185/*----------------------------------------------------------------------------
186 * Call cuDSS linear equation solver.
187 *
188 * \warn The precision, r_norm, and n_iter parameters are ignored here.
189 * the matching configuration options should be set earlier, using
190 * the \ref cs_sles_cudss_set_config function
191 *
192 *
193 * parameters:
194 * context <-> pointer to cuDSS linear solver info
195 * (actual type: cs_sles_cudss_t *)
196 * name <-- pointer to system name
197 * a <-- matrix
198 * verbosity <-- verbosity level
199 * precision <-- solver precision
200 * r_norm <-- residual normalization
201 * n_iter --> number of iterations
202 * residual --> residual
203 * rhs <-- right hand side
204 * vx_ini <-- initial system solution
205 * (vx if nonzero, nullptr if zero)
206 * vx <-> system solution
207 * aux_size <-- number of elements in aux_vectors (in bytes)
208 * aux_vectors --- optional working area (internal allocation if NULL)
209 *
210 * returns:
211 * convergence state
212 *----------------------------------------------------------------------------*/
213
215cs_sles_cudss_solve(void *context,
216 const char *name,
217 const cs_matrix_t *a,
218 int verbosity,
219 double precision,
220 double r_norm,
221 int *n_iter,
222 double *residual,
223 const cs_real_t *rhs,
224 cs_real_t *vx_ini,
225 cs_real_t *vx,
226 size_t aux_size,
227 void *aux_vectors);
228
229/*----------------------------------------------------------------------------
230 * Free cuDSS linear equation solver setup context.
231 *
232 * This function frees resolution-related data, such as
233 * buffers and preconditioning but does not free the whole context,
234 * as info used for logging (especially performance data) is maintained.
235
236 * parameters:
237 * context <-> pointer to cuDSS linear solver info
238 * (actual type: cs_sles_cudss_t *)
239 *----------------------------------------------------------------------------*/
240
241void
242cs_sles_cudss_free(void *context);
243
244/*----------------------------------------------------------------------------
245 * Log sparse linear equation solver info.
246 *
247 * parameters:
248 * context <-> pointer to cuDSS linear solver info
249 * (actual type: cs_sles_cudss_t *)
250 * log_type <-- log type
251 *----------------------------------------------------------------------------*/
252
253void
254cs_sles_cudss_log(const void *context,
255 cs_log_t log_type);
256
257/*----------------------------------------------------------------------------*/
263/*----------------------------------------------------------------------------*/
264
265void
267
268#if defined(HAVE_MPI)
269
270/*----------------------------------------------------------------------------*/
280/*----------------------------------------------------------------------------*/
281
282void
283cs_sles_cudss_set_mpi_comm(cs_sles_cudss_t *context,
284 MPI_Comm comm);
285
286#endif /* defined(HAVE_MPI) */
287
288/*----------------------------------------------------------------------------*/
289
291
292#endif /* CS_SLES_CUDSS_H */
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
#define END_C_DECLS
Definition: cs_defs.h:555
cs_log_t
Definition: cs_log.h:48
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:114
cs_sles_convergence_state_t
Definition: cs_sles.h:56
void cs_sles_cudss_free(void *context)
Free cuDSS linear equation solver setup context.
Definition: cs_sles_cudss.cpp:946
struct _cs_sles_cudss_t cs_sles_cudss_t
Definition: cs_sles_cudss.h:56
void cs_sles_cudss_log(const void *context, cs_log_t log_type)
Log sparse linear equation solver info.
Definition: cs_sles_cudss.cpp:1006
cs_sles_cudss_t * cs_sles_cudss_create(void)
Create cuDSS linear system solver info and context.
Definition: cs_sles_cudss.cpp:397
cs_sles_convergence_state_t cs_sles_cudss_solve(void *context, const char *name, const cs_matrix_t *a, int verbosity, double precision, double r_norm, int *n_iter, double *residual, const cs_real_t *rhs, cs_real_t *vx_ini, cs_real_t *vx, size_t aux_size, void *aux_vectors)
Call cuDSS linear equation solver.
Definition: cs_sles_cudss.cpp:762
cs_sles_cudss_t * cs_sles_cudss_define(int f_id, const char *name)
Define and associate an cuDSS linear system solver for a given field or equation name.
Definition: cs_sles_cudss.cpp:363
void * cs_sles_cudss_copy(const void *context)
Create cuDSS linear system solver info and context based on existing info and context.
Definition: cs_sles_cudss.cpp:511
int cs_sles_cudss_get_flags(void *context)
Query additional cuDSS solver usage flags.
void cs_sles_cudss_setup(void *context, const char *name, const cs_matrix_t *a, int verbosity)
Setup cuDSS linear equation solver.
Definition: cs_sles_cudss.cpp:622
void cs_sles_cudss_destroy(void **context)
Destroy cuDSS linear system solver info and context.
Definition: cs_sles_cudss.cpp:585
void cs_sles_cudss_library_info(cs_log_t log_type)
Print information on cuDSS library.
Definition: cs_sles_cudss.cpp:1057
void cs_sles_cudss_set_flags(void *context, int flags)
Define additional cuDSS solver usage flags.