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  * Portability and fallback layer for BLAS functions
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 #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  * Public function prototypes or wrapper macros
52  *============================================================================*/
53 
54 /*----------------------------------------------------------------------------
55  * Constant times a vector plus a vector: y <-- ax + y
56  *
57  * parameters:
58  * n <-- size of arrays x and y
59  * a <-- multiplier for x
60  * x <-- array of floating-point values
61  * y <-- array of floating-point values
62  *----------------------------------------------------------------------------*/
63 
64 void
66  double a,
67  const cs_real_t *x,
68  cs_real_t *restrict y);
69 
70 /*----------------------------------------------------------------------------
71  * Return the dot product of 2 vectors: x.y
72  *
73  * For better precision, a superblock algorithm is used.
74  *
75  * parameters:
76  * n <-- size of arrays x and y
77  * x <-- array of floating-point values
78  * y<-- array of floating-point values
79  *
80  * returns:
81  * dot product
82  *----------------------------------------------------------------------------*/
83 
84 double
86  const cs_real_t *x,
87  const cs_real_t *y);
88 
89 /*----------------------------------------------------------------------------
90  * Return the global residual of 2 extensive vectors:
91  * 1/sum(vol) . sum(X.Y/vol)
92  *
93  * For better precision, a superblock algorithm is used.
94  *
95  * parameters:
96  * n <-- size of arrays x and y
97  * vol <-- array of floating-point values
98  * x <-- array of floating-point values
99  * y <-- array of floating-point values
100  *
101  * returns:
102  * global residual
103  *----------------------------------------------------------------------------*/
104 
105 double
107  const cs_real_t *vol,
108  const cs_real_t *x,
109  const cs_real_t *y);
110 
111 /*----------------------------------------------------------------------------
112  * Return dot products of a vector with itself: x.x
113  *
114  * For better precision, a superblock algorithm is used.
115  *
116  * parameters:
117  * n <-- size of arrays x and y
118  * x <-- array of floating-point values
119  *
120  * returns:
121  * dot product
122  *----------------------------------------------------------------------------*/
123 
124 double
126  const cs_real_t *x);
127 
128 /*----------------------------------------------------------------------------
129  * Return the double dot product of 2 vectors: x.x, and x.y
130  *
131  * The products could be computed separately, but computing them
132  * simultaneously adds more optimization opportunities and possibly better
133  * cache behavior.
134  *
135  * For better precision, a superblock algorithm is used.
136  *
137  * parameters:
138  * n <-- size of arrays x and y
139  * x <-- array of floating-point values
140  * y <-- array of floating-point values
141  * xx --> x.x dot product
142  * xy --> x.y dot product
143  *----------------------------------------------------------------------------*/
144 
145 void
147  const cs_real_t *restrict x,
148  const cs_real_t *restrict y,
149  double *xx,
150  double *xy);
151 
152 /*----------------------------------------------------------------------------
153  * Return the double dot product of 3 vectors: x.y, and y.z
154  *
155  * The products could be computed separately, but computing them
156  * simultaneously adds more optimization opportunities and possibly better
157  * cache behavior.
158  *
159  * For better precision, a superblock algorithm is used.
160  *
161  * parameters:
162  * n <-- size of arrays x and y
163  * x <-- array of floating-point values
164  * y <-- array of floating-point values
165  * z <-- array of floating-point values
166  * xy --> x.y dot product
167  * yz --> x.z dot product
168  *----------------------------------------------------------------------------*/
169 
170 void
172  const cs_real_t *restrict x,
173  const cs_real_t *restrict y,
174  const cs_real_t *restrict z,
175  double *xx,
176  double *xy);
177 
178 /*----------------------------------------------------------------------------
179  * Return 3 dot products of 3 vectors: x.y, x.y, and y.z
180  *
181  * The products could be computed separately, but computing them
182  * simultaneously adds more optimization opportunities and possibly better
183  * cache behavior.
184  *
185  * For better precision, a superblock algorithm is used.
186  *
187  * parameters:
188  * n <-- size of arrays x and y
189  * x <-- array of floating-point values
190  * y <-- array of floating-point values
191  * z <-- array of floating-point values
192  * xx --> x.y dot product
193  * xy --> x.y dot product
194  * yz --> y.z dot product
195  *----------------------------------------------------------------------------*/
196 
197 void
199  const cs_real_t *restrict x,
200  const cs_real_t *restrict y,
201  const cs_real_t *restrict z,
202  double *xx,
203  double *xy,
204  double *yz);
205 
206 /*----------------------------------------------------------------------------
207  * Return 5 dot products of 3 vectors: x.x, y.y, x.y, x.z, and y.z
208  *
209  * The products could be computed separately, but computing them
210  * simultaneously adds more optimization opportunities and possibly better
211  * cache behavior.
212  *
213  * For better precision, a superblock algorithm is used.
214  *
215  * parameters:
216  * n <-- size of arrays x and y
217  * x <-- array of floating-point values
218  * y <-- array of floating-point values
219  * z <-- array of floating-point values
220  * xx --> x.y dot product
221  * yy --> y.y dot product
222  * xy --> x.y dot product
223  * xz --> x.z dot product
224  * yz --> y.z dot product
225  *----------------------------------------------------------------------------*/
226 
227 void
229  const cs_real_t *restrict x,
230  const cs_real_t *restrict y,
231  const cs_real_t *restrict z,
232  double *xx,
233  double *yy,
234  double *xy,
235  double *xz,
236  double *yz);
237 
238 /*----------------------------------------------------------------------------
239  * Return the global dot product of 2 vectors: x.y
240  *
241  * In parallel mode, the local results are summed on the default
242  * global communicator.
243  *
244  * For better precision, a superblock algorithm is used.
245  *
246  * parameters:
247  * n <-- size of arrays x and y
248  * x <-- array of floating-point values
249  * y <-- array of floating-point values
250  *
251  * returns:
252  * dot product
253  *----------------------------------------------------------------------------*/
254 
255 double
257  const cs_real_t *x,
258  const cs_real_t *y);
259 
260 /*----------------------------------------------------------------------------*/
261 
263 
264 #endif /* __CS_BLAS_H__ */
#define restrict
Definition: cs_defs.h:122
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
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:680
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:91
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:119
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:322
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:264
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:480
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
#define END_C_DECLS
Definition: cs_defs.h:430
double cs_real_t
Definition: cs_defs.h:296
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:573
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:185
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.x, and y.z.
Definition: cs_blas.c:400