Code_Saturne
CFD tool
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros 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-2012 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 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 /*============================================================================
61  * Public function prototypes or wrapper macros
62  *============================================================================*/
63 
64 /*----------------------------------------------------------------------------
65  * Constant times a vector plus a vector: y <-- ax + y
66  *
67  * parameters:
68  * n <-- size of arrays x and y
69  * a <-- multiplier for x
70  * x <-- array of floating-point values
71  * y <-- array of floating-point values
72  *----------------------------------------------------------------------------*/
73 
74 void
76  double a,
77  const cs_real_t *x,
78  cs_real_t *restrict y);
79 
80 /*----------------------------------------------------------------------------
81  * Return the dot product of 2 vectors: x.y
82  *
83  * For better precision, a superblock algorithm is used.
84  *
85  * parameters:
86  * n <-- size of arrays x and y
87  * x <-- array of floating-point values
88  * y<-- array of floating-point values
89  *
90  * returns:
91  * dot product
92  *----------------------------------------------------------------------------*/
93 
94 double
96  const cs_real_t *x,
97  const cs_real_t *y);
98 
99 /*----------------------------------------------------------------------------
100  * Return the double dot product of 2 vectors: x.x, and x.y
101  *
102  * The products could be computed separately, but computing them
103  * simultaneously adds more optimization opportunities and possibly better
104  * cache behavior.
105  *
106  * For better precision, a superblock algorithm is used.
107  *
108  * parameters:
109  * n <-- size of arrays x and y
110  * x <-- array of floating-point values
111  * y <-- array of floating-point values
112  * xx --> x.x dot product
113  * xy --> x.y dot product
114  *----------------------------------------------------------------------------*/
115 
116 void
118  const cs_real_t *restrict x,
119  const cs_real_t *restrict y,
120  double *xx,
121  double *xy);
122 
123 /*----------------------------------------------------------------------------
124  * Return the double dot product of 3 vectors: x.y, and y.z
125  *
126  * The products could be computed separately, but computing them
127  * simultaneously adds more optimization opportunities and possibly better
128  * cache behavior.
129  *
130  * For better precision, a superblock algorithm is used.
131  *
132  * parameters:
133  * n <-- size of arrays x and y
134  * x <-- array of floating-point values
135  * y <-- array of floating-point values
136  * z <-- array of floating-point values
137  * xy --> x.y dot product
138  * yz --> x.z dot product
139  *----------------------------------------------------------------------------*/
140 
141 void
143  const cs_real_t *restrict x,
144  const cs_real_t *restrict y,
145  const cs_real_t *restrict z,
146  double *xx,
147  double *xy);
148 
149 /*----------------------------------------------------------------------------
150  * Return 3 dot products of 3 vectors: x.y, x.y, and y.z
151  *
152  * The products could be computed separately, but computing them
153  * simultaneously adds more optimization opportunities and possibly better
154  * cache behavior.
155  *
156  * For better precision, a superblock algorithm is used.
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  * xx --> x.y dot product
164  * xy --> x.y dot product
165  * yz --> y.z dot product
166  *----------------------------------------------------------------------------*/
167 
168 void
170  const cs_real_t *restrict x,
171  const cs_real_t *restrict y,
172  const cs_real_t *restrict z,
173  double *xx,
174  double *xy,
175  double *yz);
176 
177 /*----------------------------------------------------------------------------
178  * Return the global dot product of 2 vectors: x.y
179  *
180  * In parallel mode, the local results are summed on the default
181  * global communicator.
182  *
183  * For better precision, a superblock algorithm is used.
184  *
185  * parameters:
186  * n <-- size of arrays x and y
187  * x <-- array of floating-point values
188  * y <-- array of floating-point values
189  *
190  * returns:
191  * dot product
192  *----------------------------------------------------------------------------*/
193 
194 double
196  const cs_real_t *x,
197  const cs_real_t *y);
198 
199 /*----------------------------------------------------------------------------*/
200 
202 
203 #endif /* __CS_BLAS_H__ */
#define restrict
Definition: cs_defs.h:105
#define BEGIN_C_DECLS
Definition: cs_defs.h:365
double cs_gdot(cs_lnum_t n, const cs_real_t *x, const cs_real_t *y)
Definition: cs_blas.c:465
void cs_axpy(cs_lnum_t n, double a, const cs_real_t *x, cs_real_t *restrict y)
Definition: cs_blas.c:102
int cs_int_t
Definition: cs_defs.h:263
double cs_dot(cs_lnum_t n, const cs_real_t *x, const cs_real_t *y)
Definition: cs_blas.c:132
int cs_lnum_t
Definition: cs_defs.h:260
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)
Definition: cs_blas.c:203
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)
Definition: cs_blas.c:371
#define END_C_DECLS
Definition: cs_defs.h:366
double cs_real_t
Definition: cs_defs.h:264
#define CS_PROCF(x, y)
Definition: cs_defs.h:379
BEGIN_C_DECLS double csdot(const cs_int_t *n, const cs_real_t *x, const cs_real_t *y)
Definition: cs_blas.c:81
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)
Definition: cs_blas.c:286