-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstatic.h
119 lines (100 loc) · 3.1 KB
/
static.h
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
/*
vecLibFort
https://github.com/mcg1969/vecLibFort
Run-time F2C/GFORTRAN translation for Apple's vecLib BLAS/LAPACK
Copyright (c) 2014 Michael C. Grant
See README.md for full background and usage details.
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. See the accompanying file LICENSE or
http://www.booost.org/LICENSE_1_0.txt
*/
#if defined(ADD_UNDERSCORE)
#define FNAME(x) x ## _
#define STATIC
#elif defined(ADD_PREFIX)
#define FNAME(x) my_ ## x
#define STATIC static
#else
#define FNAME(x) x
#define STATIC
#endif
STATIC float FNAME(sdsdot)( const int* N, const float* alpha, const float* X, const int* incX, const float* Y, const int* incY )
{
DEBUG_S( "sdsdot" )
return cblas_sdsdot( *N, *alpha, X, *incX, Y, *incY );
}
STATIC float FNAME(sdot)( const int* N, const float* X, const int* incX, const float* Y, const int* incY )
{
DEBUG_S( "sdot" )
return cblas_sdot( *N, X, *incX, Y, *incY );
}
STATIC float FNAME(snrm2)( const int* N, const float* X, const int* incX )
{
DEBUG_S( "snrm2" )
return cblas_snrm2( *N, X, *incX );
}
STATIC float FNAME(sasum)( const int* N, const float *X, const int* incX )
{
DEBUG_S( "sasum" )
return cblas_sasum( *N, X, *incX );
}
STATIC c_float FNAME(cdotu)( const int* N, const void* X, const int* incX, const void* Y, const int* incY )
{
DEBUG_S( "cdotu" )
c_float ans;
cblas_cdotu_sub( *N, X, *incX, Y, *incY, &ans );
return ans;
}
STATIC c_float FNAME(cdotc)( const int* N, const void* X, const int* incX, const void* Y, const int* incY )
{
DEBUG_S( "cdotc" )
c_float ans;
cblas_cdotc_sub( *N, X, *incX, Y, *incY, &ans );
return ans;
}
STATIC float FNAME(scnrm2)( const int* N, const void* X, const int* incX )
{
DEBUG_S( "scnrm2" )
return cblas_scnrm2( *N, X, *incX );
}
STATIC float FNAME(scasum)( const int* N, const void *X, const int* incX )
{
DEBUG_S( "scasum" )
return cblas_scasum( *N, X, *incX );
}
STATIC c_double FNAME(zdotu)( const int* N, const void* X, const int* incX, const void* Y, const int* incY )
{
DEBUG_S( "zdotu" )
c_double ans;
cblas_zdotu_sub( *N, X, *incX, Y, *incY, &ans );
return ans;
}
STATIC c_double FNAME(zdotc)( const int* N, const void* X, const int* incX, const void* Y, const int* incY )
{
DEBUG_S( "zdotc" )
c_double ans;
cblas_zdotc_sub( *N, X, *incX, Y, *incY, &ans );
return ans;
}
#ifdef VECLIBFORT_SGEMV
STATIC void FNAME(sgemv)( const char* trans, const int* m, const int* n,
const float* alpha, const float* A, const int* ldA,
const float* X, const int* incX,
const float* beta, float* Y, const int* incY )
{
DEBUG_S( "sgemv" )
enum CBLAS_TRANSPOSE T;
switch ( trans[0] ) {
case 'T': case 't':
if ( ((intptr_t)X|(intptr_t)A|(intptr_t)Y)%32 == 0 ) { T = CblasTrans; break; }
/* Implement as alpha * X^T * A + beta * Y^T */
cblas_sgemm( CblasColMajor, CblasNoTrans, CblasNoTrans, 1, *n, *m, *alpha, X, *incX, A, *ldA, *beta, Y, *incY );
return;
default:
T = CblasNoTrans;
}
cblas_sgemv( CblasColMajor, T, *m, *n, *alpha, A, *ldA, X, *incX, *beta, Y, *incY );
}
#endif
#undef FNAME
#undef STATIC