Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_BLAS_wrappers.h
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef EPETRA_BLAS_WRAPPERS_H
45 #define EPETRA_BLAS_WRAPPERS_H
46 
47 #include "Epetra_ConfigDefs.h"
48 /* #include <stdio.h> */
49 /* #include <string.h> */
50 
51 
52 /* Define fcd (Fortran Epetra_fcd descriptor) for non-standard situations */
53 
54 #if defined(CRAY_T3X) || defined(INTEL_CXML) || defined(INTEL_MKL)
55 
56 
57 #if defined(CRAY_T3X)
58 
59 #include <fortran.h>
60 #define PREFIX
61 #define Epetra_fcd fcd
62 
63 #define DASUM_F77 SASUM
64 #define DAXPY_F77 SAXPY
65 #define DCOPY_F77 SCOPY
66 #define DDOT_F77 SDOT
67 #define DNRM2_F77 SNRM2
68 #define DSCAL_F77 SSCAL
69 #define IDAMAX_F77 ISAMAX
70 #define DGEMV_F77 SGEMV
71 #define DGER_F77 SGER
72 #define DTRMV_F77 STRMV
73 #define DGEMM_F77 SGEMM
74 #define DSYMM_F77 SSYMM
75 #define DTRMM_F77 STRMM
76 #define DTRSM_F77 STRSM
77 #define DSYRK_F77 SSYRK
78 #define EPETRA_DCRSMV_F77 EPETRA_DCRSMV
79 #define EPETRA_DCRSMM_F77 EPETRA_DCRSMM
80 #define EPETRA_DCRSSV_F77 EPETRA_DCRSSV
81 #define EPETRA_DCRSSM_F77 EPETRA_DCRSSM
82 
83 #elif defined(INTEL_CXML)
84 
85 #define PREFIX __stdcall
86 #define Epetra_fcd const char *, const unsigned int
87 
88 #elif defined(INTEL_MKL)
89 
90 #define PREFIX
91 #define Epetra_fcd const char *
92 
93 #endif
94 
95 /* All three of these machines use a simple uppercase mangling of Fortran names */
96 
97 /* if F77_BLAS_MANGLE is defined undefine it because we want to redefine */
98 
99 #ifdef F77_BLAS_MANGLE
100 #undef F77_BLAS_MANGLE
101 #endif
102 
103 #ifdef F77_FUNC
104 #undef F77_FUNC
105 #endif
106 
107 #ifdef F77_FUNC_
108 #undef F77_FUNC_
109 #endif
110 
111 #define F77_BLAS_MANGLE(lcase,UCASE) UCASE
112 #define F77_FUNC(lcase,UCASE) UCASE
113 #define F77_FUNC_(lcase,UCASE) UCASE
114 
115 #else /* Define Epetra_fcd for all other machines */
116 
117 #define PREFIX
118 #define Epetra_fcd const char *
119 
120 /* Use autoconf's definition of F77_BLAS_MANGLE
121  unless using old make system */
122 
123 #ifdef TRILINOS_NO_CONFIG_H
124 
125 #ifdef F77_BLAS_MANGLE
126 #undef F77_BLAS_MANGLE
127 #endif
128 #ifdef F77_FUNC
129 #undef F77_FUNC
130 #endif
131 #ifdef F77_FUNC_
132 #undef F77_FUNC_
133 #endif
134 
135 #ifdef TRILINOS_HAVE_NO_FORTRAN_UNDERSCORE
136 #define F77_BLAS_MANGLE(lcase,UCASE) lcase
137 #define F77_FUNC(lcase,UCASE) lcase
138 #define F77_FUNC_(lcase,UCASE) lcase
139 #else /* TRILINOS_HAVE_NO_FORTRAN_UNDERSCORE not defined*/
140 #define F77_BLAS_MANGLE(lcase,UCASE) lcase ## _
141 #define F77_FUNC(lcase,UCASE) lcase ## _
142 #define F77_FUNC_(lcase,UCASE) lcase ## __
143 #endif /* TRILINOS_HAVE_NO_FORTRAN_UNDERSCORE */
144 
145 #endif /* TRILINOS_NO_CONFIG_H */
146 
147 #endif /* defined(CRAY_T3X) || defined(INTEL_CXML) || defined(INTEL_MKL) */
148 
149 #ifndef CRAY_T3X /* Double declarations already done for the Cray */
150 
151 #define DASUM_F77 F77_BLAS_MANGLE(dasum,DASUM)
152 #define DAXPY_F77 F77_BLAS_MANGLE(daxpy,DAXPY)
153 #define DCOPY_F77 F77_BLAS_MANGLE(dcopy,DCOPY)
154 #define DDOT_F77 F77_BLAS_MANGLE(ddot,DDOT)
155 #define DNRM2_F77 F77_BLAS_MANGLE(dnrm2,DNRM2)
156 #define DSCAL_F77 F77_BLAS_MANGLE(dscal,DSCAL)
157 #define IDAMAX_F77 F77_BLAS_MANGLE(idamax,IDAMAX)
158 #define DGEMV_F77 F77_BLAS_MANGLE(dgemv,DGEMV)
159 #define DGER_F77 F77_BLAS_MANGLE(dger,DGER)
160 #define DTRMV_F77 F77_BLAS_MANGLE(dtrmv,DTRMV)
161 #define DGEMM_F77 F77_BLAS_MANGLE(dgemm,DGEMM)
162 #define DSYMM_F77 F77_BLAS_MANGLE(dsymm,DSYMM)
163 #define DTRMM_F77 F77_BLAS_MANGLE(dtrmm,DTRMM)
164 #define DTRSM_F77 F77_BLAS_MANGLE(dtrsm,DTRSM)
165 #define DSYRK_F77 F77_BLAS_MANGLE(dsyrk,DSYRK)
166 
167 #ifndef FORTRAN_DISABLED
168 
169 #if ( defined(__GNUC__) || defined(_WIN32) ) && ! defined(FORTRAN_NO_UNDERSCORE)
170 /* standard Epetra implementation */
171 
172 #define EPETRA_DCRSMV_F77 F77_FUNC_(epetra_dcrsmv,EPETRA_DCRSMV)
173 #define EPETRA_DCRSMM_F77 F77_FUNC_(epetra_dcrsmm,EPETRA_DCRSMM)
174 #define EPETRA_DCRSSV_F77 F77_FUNC_(epetra_dcrssv,EPETRA_DCRSSV)
175 #define EPETRA_DCRSSM_F77 F77_FUNC_(epetra_dcrssm,EPETRA_DCRSSM)
176 
177 #else /* MSE: 3/17/05 - patch for Solaris/OSF/IRIX */
178 
179 #define EPETRA_DCRSMV_F77 F77_FUNC(epetra_dcrsmv,EPETRA_DCRSMV)
180 #define EPETRA_DCRSMM_F77 F77_FUNC(epetra_dcrsmm,EPETRA_DCRSMM)
181 #define EPETRA_DCRSSV_F77 F77_FUNC(epetra_dcrssv,EPETRA_DCRSSV)
182 #define EPETRA_DCRSSM_F77 F77_FUNC(epetra_dcrssm,EPETRA_DCRSSM)
183 #endif /* __GNUC__ */
184 
185 #endif /* FORTRAN_DISABLED */
186 
187 /* End of defines for double precision when not on a T3X */
188 
189 #endif
190 
191 /* The following defines are good for all platforms */
192 
193 
194 #define SSCAL_F77 F77_BLAS_MANGLE(sscal,SSCAL)
195 #define SCOPY_F77 F77_BLAS_MANGLE(scopy,SCOPY)
196 #define SAXPY_F77 F77_BLAS_MANGLE(saxpy,SAXPY)
197 #define SDOT_F77 F77_BLAS_MANGLE(sdot,SDOT)
198 #define SNRM2_F77 F77_BLAS_MANGLE(snrm2,SNRM2)
199 #define SASUM_F77 F77_BLAS_MANGLE(sasum,SASUM)
200 #define ISAMAX_F77 F77_BLAS_MANGLE(isamax,ISAMAX)
201 
202 #define SGEMV_F77 F77_BLAS_MANGLE(sgemv,SGEMV)
203 #define SGER_F77 F77_BLAS_MANGLE(sger,SGER)
204 #define STRMV_F77 F77_BLAS_MANGLE(strmv,STRMV)
205 #define SGEMM_F77 F77_BLAS_MANGLE(sgemm,SGEMM)
206 #define SSYMM_F77 F77_BLAS_MANGLE(ssymm,SSYMM)
207 #define STRMM_F77 F77_BLAS_MANGLE(strmm,STRMM)
208 #define STRSM_F77 F77_BLAS_MANGLE(strsm,STRSM)
209 #define SSYRK_F77 F77_BLAS_MANGLE(ssyrk,SSYRK)
210 
211 /* Explicitly define each F77 name for all BLAS kernels */
212 
213 #ifdef __cplusplus
214 extern "C" {
215 #endif
216 
217 /* Double precision BLAS 1 */
218 double PREFIX DASUM_F77(const int* n, const double x[], const int* incx);
219 void PREFIX DAXPY_F77(const int* n, const double* alpha, const double x[], const int* incx, double y[], const int* incy);
220 void PREFIX DCOPY_F77(const int* n, const double *x, const int* incx, double *y, const int* incy);
221 double PREFIX DDOT_F77(const int* n, const double x[], const int* incx, const double y[], const int* incy);
222 double PREFIX DNRM2_F77(const int* n, const double x[], const int* incx);
223 void PREFIX DSCAL_F77(const int* n, const double* alpha, double *x, const int* incx);
224 int PREFIX IDAMAX_F77(const int* n, const double *x, const int* incx);
225 
226 /* Single precision BLAS 1 */
227 float PREFIX SASUM_F77(const int* n, const float x[], const int* incx);
228 void PREFIX SAXPY_F77(const int* n, const float* alpha, const float x[], const int* incx, float y[], const int* incy);
229 void PREFIX SCOPY_F77(const int* n, const float *x, const int* incx, float *y, const int* incy);
230 float PREFIX SDOT_F77(const int* n, const float x[], const int* incx, const float y[], const int* incy);
231 float PREFIX SNRM2_F77(const int* n, const float x[], const int* incx);
232 void PREFIX SSCAL_F77(const int* n, const float* alpha, float *x, const int* incx);
233 int PREFIX ISAMAX_F77(const int* n, const float *x, const int* incx);
234 
235 /* Double precision BLAS 2 */
236 void PREFIX DGEMV_F77(Epetra_fcd, const int* m, const int* n, const double* alpha, const double A[], const int* lda,
237  const double x[], const int* incx, const double* beta, double y[], const int* incy);
238 void PREFIX DTRMV_F77(Epetra_fcd, Epetra_fcd, Epetra_fcd, const int *n,
239  const double *a, const int *lda, double *x, const int *incx);
240 void PREFIX DGER_F77(const int *m, const int *n, const double *alpha, const double *x, const int *incx, const double *y,
241  const int *incy, double *a, const int *lda);
242 
243 
244 /* Single precision BLAS 2 */
245 void PREFIX SGEMV_F77(Epetra_fcd, const int* m, const int* n, const float* alpha, const float A[], const int* lda,
246  const float x[], const int* incx, const float* beta, float y[], const int* incy);
247 void PREFIX STRMV_F77(Epetra_fcd, Epetra_fcd, Epetra_fcd, const int *n,
248  const float *a, const int *lda, float *x, const int *incx);
249 void PREFIX SGER_F77(const int *m, const int *n, const float *alpha, const float *x, const int *incx, const float *y,
250  const int *incy, float *a, const int *lda);
251 
252 /* Double precision BLAS 3 */
253 void PREFIX DGEMM_F77(Epetra_fcd, Epetra_fcd, const int *m, const int *
254  n, const int *k, const double *alpha, const double *a, const int *lda,
255  const double *b, const int *ldb, const double *beta, double *c, const int *ldc);
256 void PREFIX DSYMM_F77(Epetra_fcd, Epetra_fcd, const int *m, const int * n,
257  const double *alpha, const double *a, const int *lda,
258  const double *b, const int *ldb, const double *beta, double *c, const int *ldc);
260  const int *m, const int *n, const double *alpha, const double *a, const int * lda, double *b, const int *ldb);
262  const int *m, const int *n, const double *alpha, const double *a, const int *
263  lda, double *b, const int *ldb);
264 void PREFIX EPETRA_DCRSMV_F77(const int *, const int *, const int *, const double *, const int *,
265  const int *, double *, double *);
266 void PREFIX EPETRA_DCRSMM_F77(const int *, const int *, const int *, const double *, const int *,
267  const int *, double *, int *, double *, int *, int *);
268 void PREFIX EPETRA_DCRSSV_F77(const int *, const int *, const int *, const int *, const int *,
269  const int *, const double *, const int *, const int *, double *,
270  double *, const int *);
271 void PREFIX EPETRA_DCRSSM_F77(const int *, const int *, const int *, const int *, const int *,
272  const int *, const double *, const int *, const int *, double *,
273  const int *, double *, const int *, const int *, const int *);
274 void PREFIX DSYRK_F77(Epetra_fcd uplo, Epetra_fcd trans, const int *n, const int *k,
275  const double *alpha, const double *a, const int *lda, const double *beta,
276  double *c, const int *ldc);
277 
278 /* Single precision BLAS 3 */
279 void PREFIX SGEMM_F77(Epetra_fcd, Epetra_fcd, const int *m, const int *
280  n, const int *k, const float *alpha, const float *a, const int *lda,
281  const float *b, const int *ldb, const float *beta, float *c, const int *ldc);
282 void PREFIX SSYMM_F77(Epetra_fcd, Epetra_fcd, const int *m, const int * n,
283  const float *alpha, const float *a, const int *lda,
284  const float *b, const int *ldb, const float *beta, float *c, const int *ldc);
286  const int *m, const int *n, const float *alpha, const float *a, const int * lda, float *b, const int *ldb);
288  const int *m, const int *n, const float *alpha, const float *a, const int *
289  lda, float *b, const int *ldb);
290 
291 void PREFIX XERBLA_F77(Epetra_fcd, int *info);
292 
293 void PREFIX SSYRK_F77(Epetra_fcd uplo, Epetra_fcd trans, const int *n, const int *k,
294  const float *alpha, const float *a, const int *lda, const float *beta,
295  float *c, const int *ldc);
296 
297 #ifdef __cplusplus
298 }
299 #endif
300 
301 #endif /* EPETRA_BLAS_WRAPPERS_H */
#define SGEMM_F77
#define DCOPY_F77
#define PREFIX
#define SSYRK_F77
#define ISAMAX_F77
#define STRSM_F77
#define STRMM_F77
#define DAXPY_F77
#define SSYMM_F77
#define DDOT_F77
#define SCOPY_F77
#define DTRMV_F77
#define DTRMM_F77
void PREFIX EPETRA_DCRSSM_F77(const int *, const int *, const int *, const int *, const int *, const int *, const double *, const int *, const int *, double *, const int *, double *, const int *, const int *, const int *)
#define DASUM_F77
#define DNRM2_F77
#define SSCAL_F77
#define SDOT_F77
void PREFIX EPETRA_DCRSSV_F77(const int *, const int *, const int *, const int *, const int *, const int *, const double *, const int *, const int *, double *, double *, const int *)
#define DGEMV_F77
#define DSCAL_F77
#define DGEMM_F77
#define Epetra_fcd
void PREFIX EPETRA_DCRSMM_F77(const int *, const int *, const int *, const double *, const int *, const int *, double *, int *, double *, int *, int *)
#define STRMV_F77
#define DTRSM_F77
#define SGER_F77
#define DGER_F77
#define IDAMAX_F77
#define SGEMV_F77
void PREFIX EPETRA_DCRSMV_F77(const int *, const int *, const int *, const double *, const int *, const int *, double *, double *)
#define SASUM_F77
int n
#define SNRM2_F77
#define DSYRK_F77
#define DSYMM_F77
void PREFIX XERBLA_F77(Epetra_fcd, int *info)
#define SAXPY_F77