Blame view

fvn_sparse/UMFPACK/Source/cholmod_blas.h 13.9 KB
422234dc3   daniau   git-svn-id: https...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  /* ========================================================================== */
  /* === Include/cholmod_blas.h =============================================== */
  /* ========================================================================== */
  
  /* -----------------------------------------------------------------------------
   * CHOLMOD/Include/cholmod_blas.h.
   * Copyright (C) Univ. of Florida.  Author: Timothy A. Davis
   * CHOLMOD/Include/cholmod_blas.h is licensed under Version 2.1 of the GNU
   * Lesser General Public License.  See lesser.txt for a text of the license.
   * CHOLMOD is also available under other licenses; contact authors for details.
   * http://www.cise.ufl.edu/research/sparse
   * -------------------------------------------------------------------------- */
  
  /* This does not need to be included in the user's program. */
  
  #ifndef CHOLMOD_BLAS_H
  #define CHOLMOD_BLAS_H
  
  /* ========================================================================== */
  /* === Architecture ========================================================= */
  /* ========================================================================== */
  
  #if defined (__sun) || defined (MSOL2) || defined (ARCH_SOL2)
  #define CHOLMOD_SOL2
  #define CHOLMOD_ARCHITECTURE "Sun Solaris"
  
  #elif defined (__sgi) || defined (MSGI) || defined (ARCH_SGI)
  #define CHOLMOD_SGI
  #define CHOLMOD_ARCHITECTURE "SGI Irix"
  
  #elif defined (__linux) || defined (MGLNX86) || defined (ARCH_GLNX86)
  #define CHOLMOD_LINUX
  #define CHOLMOD_ARCHITECTURE "Linux"
  
  #elif defined (_AIX) || defined (MIBM_RS) || defined (ARCH_IBM_RS)
  #define CHOLMOD_AIX
  #define CHOLMOD_ARCHITECTURE "IBM AIX"
  #define BLAS_NO_UNDERSCORE
  
  #elif defined (__alpha) || defined (MALPHA) || defined (ARCH_ALPHA)
  #define CHOLMOD_ALPHA
  #define CHOLMOD_ARCHITECTURE "Compaq Alpha"
  
  #elif defined (_WIN32) || defined (WIN32) || defined (_WIN64) || defined (WIN64)
  #if defined (__MINGW32__) || defined (__MINGW32__)
  #define CHOLMOD_MINGW
  #elif defined (__CYGWIN32__) || defined (__CYGWIN32__)
  #define CHOLMOD_CYGWIN
  #else
  #define CHOLMOD_WINDOWS
  #define BLAS_NO_UNDERSCORE
  #endif
  #define CHOLMOD_ARCHITECTURE "Microsoft Windows"
  
  #elif defined (__hppa) || defined (__hpux) || defined (MHPUX) || defined (ARCH_HPUX)
  #define CHOLMOD_HP
  #define CHOLMOD_ARCHITECTURE "HP Unix"
  #define BLAS_NO_UNDERSCORE
  
  #elif defined (__hp700) || defined (MHP700) || defined (ARCH_HP700)
  #define CHOLMOD_HP
  #define CHOLMOD_ARCHITECTURE "HP 700 Unix"
  #define BLAS_NO_UNDERSCORE
  
  #else
  /* If the architecture is unknown, and you call the BLAS, you may need to */
  /* define BLAS_BY_VALUE, BLAS_NO_UNDERSCORE, and/or BLAS_CHAR_ARG yourself. */
  #define CHOLMOD_ARCHITECTURE "unknown"
  #endif
  
  
  /* ========================================================================== */
  /* === BLAS and LAPACK names ================================================ */
  /* ========================================================================== */
  
  /* Prototypes for the various versions of the BLAS.  */
  
  /* Determine if the 64-bit Sun Performance BLAS is to be used */
  #if defined(CHOLMOD_SOL2) && !defined(NSUNPERF) && defined(LONG) && defined(LONGBLAS)
  #define SUN64
  #endif
  
  #ifdef SUN64
  
  #define BLAS_DTRSV dtrsv_64_
  #define BLAS_DGEMV dgemv_64_
  #define BLAS_DTRSM dtrsm_64_
  #define BLAS_DGEMM dgemm_64_
  #define BLAS_DSYRK dsyrk_64_
  #define BLAS_DGER  dger_64_
  #define BLAS_DSCAL dscal_64_
  #define LAPACK_DPOTRF dpotrf_64_
  
  #define BLAS_ZTRSV ztrsv_64_
  #define BLAS_ZGEMV zgemv_64_
  #define BLAS_ZTRSM ztrsm_64_
  #define BLAS_ZGEMM zgemm_64_
  #define BLAS_ZHERK zherk_64_
  #define BLAS_ZGER  zgeru_64_
  #define BLAS_ZSCAL zscal_64_
  #define LAPACK_ZPOTRF zpotrf_64_
  
  #elif defined (BLAS_NO_UNDERSCORE)
  
  #define BLAS_DTRSV dtrsv
  #define BLAS_DGEMV dgemv
  #define BLAS_DTRSM dtrsm
  #define BLAS_DGEMM dgemm
  #define BLAS_DSYRK dsyrk
  #define BLAS_DGER  dger
  #define BLAS_DSCAL dscal
  #define LAPACK_DPOTRF dpotrf
  
  #define BLAS_ZTRSV ztrsv
  #define BLAS_ZGEMV zgemv
  #define BLAS_ZTRSM ztrsm
  #define BLAS_ZGEMM zgemm
  #define BLAS_ZHERK zherk
  #define BLAS_ZGER  zgeru
  #define BLAS_ZSCAL zscal
  #define LAPACK_ZPOTRF zpotrf
  
  #else
  
  #define BLAS_DTRSV dtrsv_
  #define BLAS_DGEMV dgemv_
  #define BLAS_DTRSM dtrsm_
  #define BLAS_DGEMM dgemm_
  #define BLAS_DSYRK dsyrk_
  #define BLAS_DGER  dger_
  #define BLAS_DSCAL dscal_
  #define LAPACK_DPOTRF dpotrf_
  
  #define BLAS_ZTRSV ztrsv_
  #define BLAS_ZGEMV zgemv_
  #define BLAS_ZTRSM ztrsm_
  #define BLAS_ZGEMM zgemm_
  #define BLAS_ZHERK zherk_
  #define BLAS_ZGER  zgeru_
  #define BLAS_ZSCAL zscal_
  #define LAPACK_ZPOTRF zpotrf_
  
  #endif
59ae88e06   daniau   git-svn-id: https...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
  #ifdef PGIW32
  
  #undef BLAS_DTRSV
  #undef BLAS_DGEMV
  #undef BLAS_DTRSM
  #undef BLAS_DGEMM
  #undef BLAS_DSYRK
  #undef BLAS_DGER
  #undef BLAS_DSCAL
  #undef LAPACK_DPOTRF
  
  #undef BLAS_ZTRSV
  #undef BLAS_ZGEMV
  #undef BLAS_ZTRSM
  #undef BLAS_ZGEMM
  #undef BLAS_ZHERK
  #undef BLAS_ZGER
  #undef BLAS_ZSCAL
  #undef LAPACK_ZPOTRF
  
  
  
  #define BLAS_DTRSV dtrsv_
  #define BLAS_DGEMV dgemv_
  #define BLAS_DTRSM dtrsm_
  #define BLAS_DGEMM dgemm_
  #define BLAS_DSYRK dsyrk_
  #define BLAS_DGER  dger_
  #define BLAS_DSCAL dscal_
  #define LAPACK_DPOTRF dpotrf_
  
  #define BLAS_ZTRSV ztrsv_
  #define BLAS_ZGEMV zgemv_
  #define BLAS_ZTRSM ztrsm_
  #define BLAS_ZGEMM zgemm_
  #define BLAS_ZHERK zherk_
  #define BLAS_ZGER  zgeru_
  #define BLAS_ZSCAL zscal_
  #define LAPACK_ZPOTRF zpotrf_
  
  #endif
422234dc3   daniau   git-svn-id: https...
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
  /* ========================================================================== */
  /* === BLAS and LAPACK integer arguments ==================================== */
  /* ========================================================================== */
  
  /* CHOLMOD can be compiled with -D'LONGBLAS=long' for the Sun Performance
   * Library, or -D'LONGBLAS=long long' for SGI's SCSL BLAS.  This defines the
   * integer used in the BLAS for the cholmod_l_* routines.
   *
   * The "int" version of CHOLMOD always uses the "int" version of the BLAS.
   */
  
  #if defined (LONGBLAS) && defined (LONG)
  #define BLAS_INT LONGBLAS
  #else
  #define BLAS_INT int
  #endif
  
  /* If the BLAS integer is smaller than the basic CHOLMOD integer, then we need
   * to check for integer overflow when converting from one to the other.  If
   * any integer overflows, the externally-defined blas_ok variable is set to
   * FALSE.  blas_ok should be set to TRUE before calling any BLAS_* macro.
   */
  
  #define CHECK_BLAS_INT (sizeof (BLAS_INT) < sizeof (Int))
  #define EQ(K,k) (((BLAS_INT) K) == ((Int) k))
  
  /* ========================================================================== */
  /* === BLAS and LAPACK prototypes and macros ================================ */
  /* ========================================================================== */
  
  void BLAS_DGEMV (char *trans, BLAS_INT *m, BLAS_INT *n, double *alpha,
  	double *A, BLAS_INT *lda, double *X, BLAS_INT *incx, double *beta,
  	double *Y, BLAS_INT *incy) ;
  
  #define BLAS_dgemv(trans,m,n,alpha,A,lda,X,incx,beta,Y,incy) \
  { \
      BLAS_INT M = m, N = n, LDA = lda, INCX = incx, INCY = incy ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) \
  		&& EQ (INCY,incy) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_DGEMV (trans, &M, &N, alpha, A, &LDA, X, &INCX, beta, Y, &INCY) ; \
      } \
  }
  
  void BLAS_ZGEMV (char *trans, BLAS_INT *m, BLAS_INT *n, double *alpha,
  	double *A, BLAS_INT *lda, double *X, BLAS_INT *incx, double *beta,
  	double *Y, BLAS_INT *incy) ;
  
  #define BLAS_zgemv(trans,m,n,alpha,A,lda,X,incx,beta,Y,incy) \
  { \
      BLAS_INT M = m, N = n, LDA = lda, INCX = incx, INCY = incy ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) \
  		&& EQ (INCY,incy) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_ZGEMV (trans, &M, &N, alpha, A, &LDA, X, &INCX, beta, Y, &INCY) ; \
      } \
  }
  
  void BLAS_DTRSV (char *uplo, char *trans, char *diag, BLAS_INT *n, double *A,
  	BLAS_INT *lda, double *X, BLAS_INT *incx) ;
  
  #define BLAS_dtrsv(uplo,trans,diag,n,A,lda,X,incx) \
  { \
      BLAS_INT N = n, LDA = lda, INCX = incx ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_DTRSV (uplo, trans, diag, &N, A, &LDA, X, &INCX) ; \
      } \
  }
  
  void BLAS_ZTRSV (char *uplo, char *trans, char *diag, BLAS_INT *n, double *A,
  	BLAS_INT *lda, double *X, BLAS_INT *incx) ;
  
  #define BLAS_ztrsv(uplo,trans,diag,n,A,lda,X,incx) \
  { \
      BLAS_INT N = n, LDA = lda, INCX = incx ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_ZTRSV (uplo, trans, diag, &N, A, &LDA, X, &INCX) ; \
      } \
  }
  
  void BLAS_DTRSM (char *side, char *uplo, char *transa, char *diag, BLAS_INT *m,
  	BLAS_INT *n, double *alpha, double *A, BLAS_INT *lda, double *B,
  	BLAS_INT *ldb) ;
  
  #define BLAS_dtrsm(side,uplo,transa,diag,m,n,alpha,A,lda,B,ldb) \
  { \
      BLAS_INT M = m, N = n, LDA = lda, LDB = ldb ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (LDB,ldb) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_DTRSM (side, uplo, transa, diag, &M, &N, alpha, A, &LDA, B, &LDB);\
      } \
  }
  
  void BLAS_ZTRSM (char *side, char *uplo, char *transa, char *diag, BLAS_INT *m,
  	BLAS_INT *n, double *alpha, double *A, BLAS_INT *lda, double *B,
  	BLAS_INT *ldb) ;
  
  #define BLAS_ztrsm(side,uplo,transa,diag,m,n,alpha,A,lda,B,ldb) \
  { \
      BLAS_INT M = m, N = n, LDA = lda, LDB = ldb ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (LDB,ldb) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_ZTRSM (side, uplo, transa, diag, &M, &N, alpha, A, &LDA, B, &LDB);\
      } \
  }
  
  void BLAS_DGEMM (char *transa, char *transb, BLAS_INT *m, BLAS_INT *n,
  	BLAS_INT *k, double *alpha, double *A, BLAS_INT *lda, double *B,
  	BLAS_INT *ldb, double *beta, double *C, BLAS_INT *ldc) ;
  
  #define BLAS_dgemm(transa,transb,m,n,k,alpha,A,lda,B,ldb,beta,C,ldc) \
  { \
      BLAS_INT M = m, N = n, K = k, LDA = lda, LDB = ldb, LDC = ldc ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (M,m) && EQ (N,n) && EQ (K,k) && EQ (LDA,lda) \
  		&& EQ (LDB,ldb) && EQ (LDC,ldc) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_DGEMM (transa, transb, &M, &N, &K, alpha, A, &LDA, B, &LDB, beta, \
  	    C, &LDC) ; \
      } \
  }
  
  void BLAS_ZGEMM (char *transa, char *transb, BLAS_INT *m, BLAS_INT *n,
  	BLAS_INT *k, double *alpha, double *A, BLAS_INT *lda, double *B,
  	BLAS_INT *ldb, double *beta, double *C, BLAS_INT *ldc) ;
  
  #define BLAS_zgemm(transa,transb,m,n,k,alpha,A,lda,B,ldb,beta,C,ldc) \
  { \
      BLAS_INT M = m, N = n, K = k, LDA = lda, LDB = ldb, LDC = ldc ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (M,m) && EQ (N,n) && EQ (K,k) && EQ (LDA,lda) \
  		&& EQ (LDB,ldb) && EQ (LDC,ldc) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_ZGEMM (transa, transb, &M, &N, &K, alpha, A, &LDA, B, &LDB, beta, \
  	    C, &LDC) ; \
      } \
  }
  
  void BLAS_DSYRK (char *uplo, char *trans, BLAS_INT *n, BLAS_INT *k,
  	double *alpha, double *A, BLAS_INT *lda, double *beta, double *C,
  	BLAS_INT *ldc) ;
  
  #define BLAS_dsyrk(uplo,trans,n,k,alpha,A,lda,beta,C,ldc) \
  { \
      BLAS_INT N = n, K = k, LDA = lda, LDC = ldc ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (N,n) && EQ (K,k) && EQ (LDA,lda) && EQ (LDC,ldc) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_DSYRK (uplo, trans, &N, &K, alpha, A, &LDA, beta, C, &LDC) ; \
      } \
  } \
  
  void BLAS_ZHERK (char *uplo, char *trans, BLAS_INT *n, BLAS_INT *k,
  	double *alpha, double *A, BLAS_INT *lda, double *beta, double *C,
  	BLAS_INT *ldc) ;
  
  #define BLAS_zherk(uplo,trans,n,k,alpha,A,lda,beta,C,ldc) \
  { \
      BLAS_INT N = n, K = k, LDA = lda, LDC = ldc ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (N,n) && EQ (K,k) && EQ (LDA,lda) && EQ (LDC,ldc) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_ZHERK (uplo, trans, &N, &K, alpha, A, &LDA, beta, C, &LDC) ; \
      } \
  } \
  
  void LAPACK_DPOTRF (char *uplo, BLAS_INT *n, double *A, BLAS_INT *lda,
  	BLAS_INT *info) ;
  
  #define LAPACK_dpotrf(uplo,n,A,lda,info) \
  { \
      BLAS_INT N = n, LDA = lda, INFO = 1 ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (N,n) && EQ (LDA,lda) ; \
      } \
      if (blas_ok) \
      { \
  	LAPACK_DPOTRF (uplo, &N, A, &LDA, &INFO) ; \
      } \
      info = INFO ; \
  }
  
  void LAPACK_ZPOTRF (char *uplo, BLAS_INT *n, double *A, BLAS_INT *lda,
  	BLAS_INT *info) ;
  
  #define LAPACK_zpotrf(uplo,n,A,lda,info) \
  { \
      BLAS_INT N = n, LDA = lda, INFO = 1 ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (N,n) && EQ (LDA,lda) ; \
      } \
      if (blas_ok) \
      { \
  	LAPACK_ZPOTRF (uplo, &N, A, &LDA, &INFO) ; \
      } \
      info = INFO ; \
  }
  
  /* ========================================================================== */
  
  void BLAS_DSCAL (BLAS_INT *n, double *alpha, double *Y, BLAS_INT *incy) ;
  
  #define BLAS_dscal(n,alpha,Y,incy) \
  { \
      BLAS_INT N = n, INCY = incy ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (N,n) && EQ (INCY,incy) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_DSCAL (&N, alpha, Y, &INCY) ; \
      } \
  }
  
  void BLAS_ZSCAL (BLAS_INT *n, double *alpha, double *Y, BLAS_INT *incy) ;
  
  #define BLAS_zscal(n,alpha,Y,incy) \
  { \
      BLAS_INT N = n, INCY = incy ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (N,n) && EQ (INCY,incy) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_ZSCAL (&N, alpha, Y, &INCY) ; \
      } \
  }
  
  void BLAS_DGER (BLAS_INT *m, BLAS_INT *n, double *alpha,
  	double *X, BLAS_INT *incx, double *Y, BLAS_INT *incy,
  	double *A, BLAS_INT *lda) ;
  
  #define BLAS_dger(m,n,alpha,X,incx,Y,incy,A,lda) \
  { \
      BLAS_INT M = m, N = n, LDA = lda, INCX = incx, INCY = incy ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) \
  		&& EQ (INCY,incy) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_DGER (&M, &N, alpha, X, &INCX, Y, &INCY, A, &LDA) ; \
      } \
  }
  
  void BLAS_ZGERU (BLAS_INT *m, BLAS_INT *n, double *alpha,
  	double *X, BLAS_INT *incx, double *Y, BLAS_INT *incy,
  	double *A, BLAS_INT *lda) ;
  
  #define BLAS_zgeru(m,n,alpha,X,incx,Y,incy,A,lda) \
  { \
      BLAS_INT M = m, N = n, LDA = lda, INCX = incx, INCY = incy ; \
      if (CHECK_BLAS_INT) \
      { \
  	blas_ok &= EQ (M,m) && EQ (N,n) && EQ (LDA,lda) && EQ (INCX,incx) \
  		&& EQ (INCY,incy) ; \
      } \
      if (blas_ok) \
      { \
  	BLAS_ZGER (&M, &N, alpha, X, &INCX, Y, &INCY, A, &LDA) ; \
      } \
  }
  
  #endif