programmer's documentation
cs_blas.h
Go to the documentation of this file.
1 #ifndef __CS_BLAS_H__
2 #define __CS_BLAS_H__
3 
4 /*============================================================================
5  * BLAS (Basic Linear Algebra Subroutine) functions
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 #include "cs_defs.h"
31 
32 /*----------------------------------------------------------------------------
33  * External library headers
34  *----------------------------------------------------------------------------*/
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *----------------------------------------------------------------------------*/
39 
40 #include "cs_base.h"
41 
42 /*----------------------------------------------------------------------------*/
43 
45 
46 /*============================================================================
47  * Macro definitions
48  *============================================================================*/
49 
50 /*============================================================================
51  * Type definitions
52  *============================================================================*/
53 
54 /* BLAS reduction algorithm families */
55 
56 typedef enum {
57 
60 
62 
63 /*============================================================================
64  * Public function prototypes
65  *============================================================================*/
66 
67 /*----------------------------------------------------------------------------*/
76 /*----------------------------------------------------------------------------*/
77 
78 void
80 
81 /*----------------------------------------------------------------------------
82  * Constant times a vector plus a vector: y <-- ax + y
83  *
84  * parameters:
85  * n <-- size of arrays x and y
86  * a <-- multiplier for x
87  * x <-- array of floating-point values
88  * y <-- array of floating-point values
89  *----------------------------------------------------------------------------*/
90 
91 void
93  double a,
94  const cs_real_t *x,
95  cs_real_t *restrict y);
96 
97 /*----------------------------------------------------------------------------
98  * Return the dot product of 2 vectors: x.y
99  *
100  * parameters:
101  * n <-- size of arrays x and y
102  * x <-- array of floating-point values
103  * y<-- array of floating-point values
104  *
105  * returns:
106  * dot product
107  *----------------------------------------------------------------------------*/
108 
109 double
110 cs_dot(cs_lnum_t n,
111  const cs_real_t *x,
112  const cs_real_t *y);
113 
114 /*----------------------------------------------------------------------------
115  * Return dot products of a vector with itself: x.x
116  *
117  * parameters:
118  * n <-- size of arrays x and y
119  * x <-- array of floating-point values
120  *
121  * returns:
122  * dot product
123  *----------------------------------------------------------------------------*/
124 
125 double
127  const cs_real_t *x);
128 
129 /*----------------------------------------------------------------------------
130  * Return the double dot product of 2 vectors: x.x, and x.y
131  *
132  * The products could be computed separately, but computing them
133  * simultaneously adds more optimization opportunities and possibly better
134  * cache behavior.
135  *
136  * parameters:
137  * n <-- size of arrays x and y
138  * x <-- array of floating-point values
139  * y <-- array of floating-point values
140  * xx --> x.x dot product
141  * xy --> x.y dot product
142  *----------------------------------------------------------------------------*/
143 
144 void
146  const cs_real_t *restrict x,
147  const cs_real_t *restrict y,
148  double *xx,
149  double *xy);
150 
151 /*----------------------------------------------------------------------------
152  * Return the double dot product of 3 vectors: x.y, and y.z
153  *
154  * The products could be computed separately, but computing them
155  * simultaneously adds more optimization opportunities and possibly better
156  * cache behavior.
157  *
158  * parameters:
159  * n <-- size of arrays x and y
160  * x <-- array of floating-point values
161  * y <-- array of floating-point values
162  * z <-- array of floating-point values
163  * xy --> x.y dot product
164  * yz --> x.z dot product
165  *----------------------------------------------------------------------------*/
166 
167 void
169  const cs_real_t *restrict x,
170  const cs_real_t *restrict y,
171  const cs_real_t *restrict z,
172  double *xx,
173  double *xy);
174 
175 /*----------------------------------------------------------------------------
176  * Return 3 dot products of 3 vectors: x.x, x.y, and y.z
177  *
178  * The products could be computed separately, but computing them
179  * simultaneously adds more optimization opportunities and possibly better
180  * cache behavior.
181  *
182  * parameters:
183  * n <-- size of arrays x and y
184  * x <-- array of floating-point values
185  * y <-- array of floating-point values
186  * z <-- array of floating-point values
187  * xx --> x.y dot product
188  * xy --> x.y dot product
189  * yz --> y.z dot product
190  *----------------------------------------------------------------------------*/
191 
192 void
194  const cs_real_t *restrict x,
195  const cs_real_t *restrict y,
196  const cs_real_t *restrict z,
197  double *xx,
198  double *xy,
199  double *yz);
200 
201 /*----------------------------------------------------------------------------
202  * Return 5 dot products of 3 vectors: x.x, y.y, x.y, x.z, and y.z
203  *
204  * The products could be computed separately, but computing them
205  * simultaneously adds more optimization opportunities and possibly better
206  * cache behavior.
207  *
208  * parameters:
209  * n <-- size of arrays x and y
210  * x <-- array of floating-point values
211  * y <-- array of floating-point values
212  * z <-- array of floating-point values
213  * xx --> x.y dot product
214  * yy --> y.y dot product
215  * xy --> x.y dot product
216  * xz --> x.z dot product
217  * yz --> y.z dot product
218  *----------------------------------------------------------------------------*/
219 
220 void
222  const cs_real_t *restrict x,
223  const cs_real_t *restrict y,
224  const cs_real_t *restrict z,
225  double *xx,
226  double *yy,
227  double *xy,
228  double *xz,
229  double *yz);
230 
231 /*----------------------------------------------------------------------------
232  * Return the global dot product of 2 vectors: x.y
233  *
234  * In parallel mode, the local results are summed on the default
235  * global communicator.
236  *
237  * parameters:
238  * n <-- size of arrays x and y
239  * x <-- array of floating-point values
240  * y <-- array of floating-point values
241  *
242  * returns:
243  * dot product
244  *----------------------------------------------------------------------------*/
245 
246 double
248  const cs_real_t *x,
249  const cs_real_t *y);
250 
251 /*----------------------------------------------------------------------------
252  * Return the global residual of 2 extensive vectors:
253  * 1/sum(vol) . sum(X.Y/vol)
254  *
255  * parameters:
256  * n <-- size of arrays x and y
257  * vol <-- array of floating-point values
258  * x <-- array of floating-point values
259  * y <-- array of floating-point values
260  *
261  * returns:
262  * global residual
263  *----------------------------------------------------------------------------*/
264 
265 double
267  const cs_real_t *vol,
268  const cs_real_t *x,
269  const cs_real_t *y);
270 
271 /*----------------------------------------------------------------------------*/
272 
274 
275 #endif /* __CS_BLAS_H__ */
#define restrict
Definition: cs_defs.h:122
cs_blas_reduce_t
Reduction algorithm type.
Definition: cs_blas.h:56
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
double cs_gdot(cs_lnum_t n, const cs_real_t *x, const cs_real_t *y)
Return the global dot product of 2 vectors: x.y.
Definition: cs_blas.c:1478
void cs_axpy(cs_lnum_t n, double a, const cs_real_t *x, cs_real_t *restrict y)
Constant times a vector plus a vector: y <– ax + y.
Definition: cs_blas.c:1280
double cs_dot(cs_lnum_t n, const cs_real_t *x, const cs_real_t *y)
Return the dot product of 2 vectors: x.y.
Definition: cs_blas.c:1315
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
Definition: cs_blas.h:59
void cs_dot_xx_xy(cs_lnum_t n, const cs_real_t *restrict x, const cs_real_t *restrict y, double *xx, double *xy)
Return 2 dot products of 2 vectors: x.x, and x.y.
Definition: cs_blas.c:1359
double precision, save a
Definition: cs_fuel_incl.f90:146
double cs_dot_xx(cs_lnum_t n, const cs_real_t *x)
Return dot products of a vector with itself: x.x.
Definition: cs_blas.c:1336
void cs_blas_set_reduce_algorithm(cs_blas_reduce_t mode)
Set the preferred BLAS reduction algorithm family.
Definition: cs_blas.c:1241
void cs_dot_xx_xy_yz(cs_lnum_t n, const cs_real_t *restrict x, const cs_real_t *restrict y, const cs_real_t *restrict z, double *xx, double *xy, double *yz)
Return 3 dot products of 3 vectors: x.x, x.y, and y.z.
Definition: cs_blas.c:1415
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
#define END_C_DECLS
Definition: cs_defs.h:449
void cs_dot_xx_yy_xy_xz_yz(cs_lnum_t n, const cs_real_t *restrict x, const cs_real_t *restrict y, const cs_real_t *restrict z, double *xx, double *yy, double *xy, double *xz, double *yz)
Return 5 dot products of 3 vectors: x.x, y.y, x.y, x.z, and y.z.
Definition: cs_blas.c:1447
double cs_gres(cs_lnum_t n, const cs_real_t *vol, const cs_real_t *x, const cs_real_t *y)
Return the global residual of 2 extensive vectors: 1/sum(vol) . sum(X.Y/vol)
Definition: cs_blas.c:1507
Definition: cs_blas.h:58
void cs_dot_xy_yz(cs_lnum_t n, const cs_real_t *restrict x, const cs_real_t *restrict y, const cs_real_t *restrict z, double *xx, double *xy)
Return 2 dot products of 3 vectors: x.y, and y.z.
Definition: cs_blas.c:1386