9.2
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-2026 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 * Macro definitions
40 *============================================================================*/
41
46/*============================================================================
47 * Type definitions
48 *============================================================================*/
49
50/* cuDSS linear solver context (opaque) */
51
52typedef struct _cs_sles_cudss_t cs_sles_cudss_t;
53
54/*============================================================================
55 * Global variables
56 *============================================================================*/
57
58/*=============================================================================
59 * Public function prototypes
60 *============================================================================*/
61
62/*----------------------------------------------------------------------------
63 * Define and associate an cuDSS linear system solver
64 * for a given field or equation name.
65 *
66 * If this system did not previously exist, it is added to the list of
67 * "known" systems. Otherwise, its definition is replaced by the one
68 * defined here.
69 *
70 * This is a utility function: if finer control is needed, see
71 * cs_sles_define() and cs_sles_cudss_create().
72 *
73 * Note that this function returns a pointer directly to the cuDSS solver
74 * management structure. This may be used to set further options.
75 * If needed, cs_sles_find() may be used to obtain a pointer to the matching
76 * cs_sles_t container.
77 *
78 * parameters:
79 * f_id <-- associated field id, or < 0
80 * name <-- associated name if f_id < 0, or NULL
81 *
82 * returns:
83 * pointer to newly created cuDSS solver info object.
84 *----------------------------------------------------------------------------*/
85
88 const char *name);
89
90/*----------------------------------------------------------------------------
91 * Create cuDSS linear system solver info and context.
92 *
93 * In case of rotational periodicity for a block (non-scalar) matrix,
94 * the matrix type will be forced to MATSHELL ("shell") regardless
95 * of the option used.
96 *
97 * returns:
98 * pointer to newly created solver info object.
99 *----------------------------------------------------------------------------*/
100
103
104/*----------------------------------------------------------------------------
105 * Create cuDSS linear system solver info and context
106 * based on existing info and context.
107 *
108 * Most configuration parameters will be copied from the existing context,
109 * though not all, since cuDSS does not provide a comprehensive way to
110 * do this.
111 *
112 * parameters:
113 * context <-- pointer to reference info and context
114 * (actual type: cs_sles_cudss_t *)
115 *
116 * returns:
117 * pointer to newly created solver info object
118 * (actual type: cs_sles_cudss_t *)
119 *----------------------------------------------------------------------------*/
120
121void *
122cs_sles_cudss_copy(const void *context);
123
124/*----------------------------------------------------------------------------
125 * Destroy cuDSS linear system solver info and context.
126 *
127 * parameters:
128 * context <-> pointer to cuDSS linear solver info
129 * (actual type: cs_sles_cudss_t **)
130 *----------------------------------------------------------------------------*/
131
132void
133cs_sles_cudss_destroy(void **context);
134
135/*----------------------------------------------------------------------------*/
145/*----------------------------------------------------------------------------*/
146
147void
149 int flags);
150
151/*----------------------------------------------------------------------------*/
159/*----------------------------------------------------------------------------*/
160
161int
163
164/*----------------------------------------------------------------------------
165 * Setup cuDSS linear equation solver.
166 *
167 * parameters:
168 * context <-> pointer to cuDSS linear solver info
169 * (actual type: cs_sles_cudss_t *)
170 * name <-- pointer to system name
171 * a <-- associated matrix
172 * verbosity <-- verbosity level
173 *----------------------------------------------------------------------------*/
174
175void
176cs_sles_cudss_setup(void *context,
177 const char *name,
178 const cs_matrix_t *a,
179 int verbosity);
180
181/*----------------------------------------------------------------------------
182 * Call cuDSS linear equation solver.
183 *
184 * \warn The precision, r_norm, and n_iter parameters are ignored here.
185 * the matching configuration options should be set earlier, using
186 * the \ref cs_sles_cudss_set_config function
187 *
188 *
189 * parameters:
190 * context <-> pointer to cuDSS linear solver info
191 * (actual type: cs_sles_cudss_t *)
192 * name <-- pointer to system name
193 * a <-- matrix
194 * verbosity <-- verbosity level
195 * precision <-- solver precision
196 * r_norm <-- residual normalization
197 * n_iter --> number of iterations
198 * residual --> residual
199 * rhs <-- right hand side
200 * vx_ini <-- initial system solution
201 * (vx if nonzero, nullptr if zero)
202 * vx <-> system solution
203 * aux_size <-- number of elements in aux_vectors (in bytes)
204 * aux_vectors --- optional working area (internal allocation if NULL)
205 *
206 * returns:
207 * convergence state
208 *----------------------------------------------------------------------------*/
209
211cs_sles_cudss_solve(void *context,
212 const char *name,
213 const cs_matrix_t *a,
214 int verbosity,
215 double precision,
216 double r_norm,
217 int *n_iter,
218 double *residual,
219 const cs_real_t *rhs,
220 cs_real_t *vx_ini,
221 cs_real_t *vx,
222 size_t aux_size,
223 void *aux_vectors);
224
225/*----------------------------------------------------------------------------
226 * Free cuDSS linear equation solver setup context.
227 *
228 * This function frees resolution-related data, such as
229 * buffers and preconditioning but does not free the whole context,
230 * as info used for logging (especially performance data) is maintained.
231
232 * parameters:
233 * context <-> pointer to cuDSS linear solver info
234 * (actual type: cs_sles_cudss_t *)
235 *----------------------------------------------------------------------------*/
236
237void
238cs_sles_cudss_free(void *context);
239
240/*----------------------------------------------------------------------------
241 * Log sparse linear equation solver info.
242 *
243 * parameters:
244 * context <-> pointer to cuDSS linear solver info
245 * (actual type: cs_sles_cudss_t *)
246 * log_type <-- log type
247 *----------------------------------------------------------------------------*/
248
249void
250cs_sles_cudss_log(const void *context,
251 cs_log_t log_type);
252
253/*----------------------------------------------------------------------------*/
259/*----------------------------------------------------------------------------*/
260
261void
263
264#if defined(HAVE_MPI)
265
266/*----------------------------------------------------------------------------*/
276/*----------------------------------------------------------------------------*/
277
278void
280 MPI_Comm comm);
281
282#endif /* defined(HAVE_MPI) */
283
284/*----------------------------------------------------------------------------*/
285
286#endif /* CS_SLES_CUDSS_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_log_t
Definition: cs_log.h:44
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:108
cs_sles_convergence_state_t
Definition: cs_sles.h:57
void cs_sles_cudss_free(void *context)
Free cuDSS linear equation solver setup context.
Definition: cs_sles_cudss.cpp:942
struct _cs_sles_cudss_t cs_sles_cudss_t
Definition: cs_sles_cudss.h:52
void cs_sles_cudss_log(const void *context, cs_log_t log_type)
Log sparse linear equation solver info.
Definition: cs_sles_cudss.cpp:1002
cs_sles_cudss_t * cs_sles_cudss_create(void)
Create cuDSS linear system solver info and context.
Definition: cs_sles_cudss.cpp:393
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:758
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:359
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:507
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:618
void cs_sles_cudss_set_mpi_comm(cs_sles_cudss_t *context, MPI_Comm comm)
Set MPI communicator for cuDSS solver.
Definition: cs_sles_cudss.cpp:1080
void cs_sles_cudss_destroy(void **context)
Destroy cuDSS linear system solver info and context.
Definition: cs_sles_cudss.cpp:581
void cs_sles_cudss_library_info(cs_log_t log_type)
Print information on cuDSS library.
Definition: cs_sles_cudss.cpp:1053
void cs_sles_cudss_set_flags(void *context, int flags)
Define additional cuDSS solver usage flags.