src/alge/cs_blas.h Source File

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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-2013 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
44 BEGIN_C_DECLS
45
46 /*============================================================================
47 * Macro definitions
48 *============================================================================*/
49
50 /*============================================================================
51 * Public function prototypes for Fortran API
52 *============================================================================*/
53
54 /* Return the dot product of 2 vectors: x.y */
55
56 double CS_PROCF(csdot, CSDOT)(const cs_int_t *n,
57 const cs_real_t *x,
58 const cs_real_t *y);
59
60 /* Return the global residual of 2 extensiv vectors: x.y */
61
62 double CS_PROCF(csres, CSRES)(const cs_int_t *n,
63 const cs_real_t *vol,
64 const cs_real_t *x,
65 const cs_real_t *y);
66
67 /*============================================================================
68 * Public function prototypes or wrapper macros
69 *============================================================================*/
70
71 /*----------------------------------------------------------------------------
72 * Constant times a vector plus a vector: y <-- ax + y
73 *
74 * parameters:
75 * n <-- size of arrays x and y
76 * a <-- multiplier for x
77 * x <-- array of floating-point values
78 * y <-- array of floating-point values
79 *----------------------------------------------------------------------------*/
80
81 void
82 cs_axpy(cs_lnum_t n,
83 double a,
84 const cs_real_t *x,
85 cs_real_t *restrict y);
86
87 /*----------------------------------------------------------------------------
88 * Return the dot product of 2 vectors: x.y
89 *
90 * For better precision, a superblock algorithm is used.
91 *
92 * parameters:
93 * n <-- size of arrays x and y
94 * x <-- array of floating-point values
95 * y<-- array of floating-point values
96 *
97 * returns:
98 * dot product
99 *----------------------------------------------------------------------------*/
100
101 double
102 cs_dot(cs_lnum_t n,
103 const cs_real_t *x,
104 const cs_real_t *y);
105
106 /*----------------------------------------------------------------------------
107 * Return the global resildual of 2 extensive vectors:
108 * 1/sum(vol) . sum(X.Y/vol)
109 *
110 * For better precision, a superblock algorithm is used.
111 *
112 * parameters:
113 * n <-- size of arrays x and y
114 * vol <-- array of floating-point values
115 * x <-- array of floating-point values
116 * y <-- array of floating-point values
117 *
118 * returns:
119 * dot product
120 *----------------------------------------------------------------------------*/
121
122 double
123 cs_gres(cs_lnum_t n,
124 const cs_real_t *vol,
125 const cs_real_t *x,
126 const cs_real_t *y);
127
128 /*----------------------------------------------------------------------------
129 * Return dot products of a vector with itself: x.x
130 *
131 * For better precision, a superblock algorithm is used.
132 *
133 * parameters:
134 * n <-- size of arrays x and y
135 * x <-- array of floating-point values
136 *
137 * returns:
138 * dot product
139 *----------------------------------------------------------------------------*/
140
141 double
142 cs_dot_xx(cs_lnum_t n,
143 const cs_real_t *x);
144
145 /*----------------------------------------------------------------------------
146 * Return the double dot product of 2 vectors: x.x, and x.y
147 *
148 * The products could be computed separately, but computing them
149 * simultaneously adds more optimization opportunities and possibly better
150 * cache behavior.
151 *
152 * For better precision, a superblock algorithm is used.
153 *
154 * parameters:
155 * n <-- size of arrays x and y
156 * x <-- array of floating-point values
157 * y <-- array of floating-point values
158 * xx --> x.x dot product
159 * xy --> x.y dot product
160 *----------------------------------------------------------------------------*/
161
162 void
163 cs_dot_xx_xy(cs_lnum_t n,
164 const cs_real_t *restrict x,
165 const cs_real_t *restrict y,
166 double *xx,
167 double *xy);
168
169 /*----------------------------------------------------------------------------
170 * Return the double dot product of 3 vectors: x.y, and y.z
171 *
172 * The products could be computed separately, but computing them
173 * simultaneously adds more optimization opportunities and possibly better
174 * cache behavior.
175 *
176 * For better precision, a superblock algorithm is used.
177 *
178 * parameters:
179 * n <-- size of arrays x and y
180 * x <-- array of floating-point values
181 * y <-- array of floating-point values
182 * z <-- array of floating-point values
183 * xy --> x.y dot product
184 * yz --> x.z dot product
185 *----------------------------------------------------------------------------*/
186
187 void
188 cs_dot_xy_yz(cs_lnum_t n,
189 const cs_real_t *restrict x,
190 const cs_real_t *restrict y,
191 const cs_real_t *restrict z,
192 double *xx,
193 double *xy);
194
195 /*----------------------------------------------------------------------------
196 * Return 3 dot products of 3 vectors: x.y, x.y, and y.z
197 *
198 * The products could be computed separately, but computing them
199 * simultaneously adds more optimization opportunities and possibly better
200 * cache behavior.
201 *
202 * For better precision, a superblock algorithm is used.
203 *
204 * parameters:
205 * n <-- size of arrays x and y
206 * x <-- array of floating-point values
207 * y <-- array of floating-point values
208 * z <-- array of floating-point values
209 * xx --> x.y dot product
210 * xy --> x.y dot product
211 * yz --> y.z dot product
212 *----------------------------------------------------------------------------*/
213
214 void
215 cs_dot_xx_xy_yz(cs_lnum_t n,
216 const cs_real_t *restrict x,
217 const cs_real_t *restrict y,
218 const cs_real_t *restrict z,
219 double *xx,
220 double *xy,
221 double *yz);
222
223 /*----------------------------------------------------------------------------
224 * Return the global dot product of 2 vectors: x.y
225 *
226 * In parallel mode, the local results are summed on the default
227 * global communicator.
228 *
229 * For better precision, a superblock algorithm is used.
230 *
231 * parameters:
232 * n <-- size of arrays x and y
233 * x <-- array of floating-point values
234 * y <-- array of floating-point values
235 *
236 * returns:
237 * dot product
238 *----------------------------------------------------------------------------*/
239
240 double
241 cs_gdot(cs_lnum_t n,
242 const cs_real_t *x,
243 const cs_real_t *y);
244
245 /*----------------------------------------------------------------------------*/
246
247 END_C_DECLS
248
249 #endif /* __CS_BLAS_H__ */