Gentoo Archives: gentoo-commits

From: Andrea Arteaga <andyspiros@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/auto-numerical-bench:newinterfaces commit in: NumericInterface/NI_internal/
Date: Fri, 28 Sep 2012 15:53:07
Message-Id: 1348847555.8fb800d2817e2087b4d2e04e30877c42a8b6cb50.spiros@gentoo
1 commit: 8fb800d2817e2087b4d2e04e30877c42a8b6cb50
2 Author: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
3 AuthorDate: Fri Sep 28 15:52:35 2012 +0000
4 Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
5 CommitDate: Fri Sep 28 15:52:35 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=8fb800d2
7
8 Compelete the Fortran BLAS interface as requested by the current BLAS
9 operations.
10
11 ---
12 .../NI_internal/FortranDeclarations.hpp | 30 ++++++++-
13 NumericInterface/NI_internal/FortranInterface.hpp | 65 +++++++++++++++++++-
14 2 files changed, 89 insertions(+), 6 deletions(-)
15
16 diff --git a/NumericInterface/NI_internal/FortranDeclarations.hpp b/NumericInterface/NI_internal/FortranDeclarations.hpp
17 index fce99d2..9fe0b04 100644
18 --- a/NumericInterface/NI_internal/FortranDeclarations.hpp
19 +++ b/NumericInterface/NI_internal/FortranDeclarations.hpp
20 @@ -45,14 +45,36 @@ extern "C" {
21 * LEVEL 2 BLAS *
22 ****************/
23
24 - void sgemv_(const char*, const int*, const int*, const float*, const float*, const int*, const float*, const int*, const float*, const float*, const int*);
25 - void dgemv_(const char*, const int*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, const double*, const int*);
26 + void sgemv_(const char*, const int*, const int*, const float*, const float*, const int*, const float*, const int*, const float*, float*, const int*);
27 + void dgemv_(const char*, const int*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, double*, const int*);
28 +
29 + void ssymv_(const char*, const int*, const float*, const float*, const int*, const float*, const int*, const float*, float*, const int*);
30 + void dsymv_(const char*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, double*, const int*);
31
32 void strsv_(const char*, const char*, const char*, const int*, const float*, const int*, float*, const int*);
33 void dtrsv_(const char*, const char*, const char*, const int*, const double*, const int*, double*, const int*);
34
35 - void sger_(const int*, const int*, const float*, const float*, const int*, const float*, const int*, const float*, const int*);
36 - void dger_(const int*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, const int*);
37 + void sger_(const int*, const int*, const float*, const float*, const int*, const float*, const int*, float*, const int*);
38 + void dger_(const int*, const int*, const double*, const double*, const int*, const double*, const int*, double*, const int*);
39 +
40 + void ssyr2_(const char*, const int*, const float*, const float*, const int*, const float*, const int*, float*, const int*);
41 + void dsyr2_(const char*, const int*, const double*, const double*, const int*, const double*, const int*, double*, const int*);
42 +
43 +
44 +
45 +
46 + /****************
47 + * LEVEL 3 BLAS *
48 + ****************/
49 +
50 + void sgemm_(const char*, const char*, const int*, const int*, const int*, const float*, const float*, const int*, const float*, const int*, const float*, float*, const int*);
51 + void dgemm_(const char*, const char*, const int*, const int*, const int*, const double*, const double*, const int*, const double*, const int*, const double*, double*, const int*);
52 +
53 + void strmm_(const char*, const char*, const char*, const char*, const int*, const int*, const float*, const float*, const int*, float*, const int*);
54 + void dtrmm_(const char*, const char*, const char*, const char*, const int*, const int*, const double*, const double*, const int*, double*, const int*);
55 +
56 + void strsm_(const char*, const char*, const char*, const char*, const int*, const int*, const float*, const float*, const int*, float*, const int*);
57 + void dtrsm_(const char*, const char*, const char*, const char*, const int*, const int*, const double*, const double*, const int*, double*, const int*);
58 }
59
60
61
62 diff --git a/NumericInterface/NI_internal/FortranInterface.hpp b/NumericInterface/NI_internal/FortranInterface.hpp
63 index 0bdcf89..39dfa84 100644
64 --- a/NumericInterface/NI_internal/FortranInterface.hpp
65 +++ b/NumericInterface/NI_internal/FortranInterface.hpp
66 @@ -33,6 +33,9 @@ public:
67
68 static const int ZERO;
69 static const int ONE;
70 + static const Scalar fONE;
71 + static const char NoTrans;
72 + static const char Trans;
73
74 public:
75 static std::string name()
76 @@ -78,11 +81,20 @@ public:
77 * LEVEL 2 BLAS *
78 ****************/
79
80 - static void matrixVector(const char& trans, const int& M, const int& N,
81 + static void matrixVector(const bool& trans, const int& M, const int& N,
82 const Scalar& alpha, const Scalar* A, const Scalar* x,
83 const Scalar& beta, Scalar* y)
84 {
85 - FORTFUNC(gemv)(&trans, &M, &N, &alpha, A, &M, x, &ONE, &beta, y, &ONE);
86 + const int LDA = trans ? N : M;
87 + const char tA = trans ? Trans : NoTrans;
88 + FORTFUNC(gemv)(&tA, &M, &N, &alpha, A, &LDA, x, &ONE, &beta, y, &ONE);
89 + }
90 +
91 + static void symmetricMatrixVector(const char& uplo, const int& N,
92 + const Scalar& alpha, const Scalar* A, const Scalar* x,
93 + const Scalar& beta, Scalar* y)
94 + {
95 + FORTFUNC(symv)(&uplo, &N, &alpha, A, &N, x, &ONE, &beta, y, &ONE);
96 }
97
98 static void triangularSolveVector(const char& uplo, const char& diag,
99 @@ -96,10 +108,59 @@ public:
100 {
101 FORTFUNC(ger)(&M, &N, &alpha, x, &ONE, y, &ONE, A, &M);
102 }
103 +
104 + static void rank2update(const char& uplo, const int& N, const Scalar& alpha,
105 + const Scalar* x, const Scalar* y, Scalar* A)
106 + {
107 + FORTFUNC(syr2)(&uplo, &N, &alpha, x, &ONE, y, &ONE, A, &N);
108 + }
109 +
110 +
111 +
112 + /****************
113 + * LEVEL 3 BLAS *
114 + ****************/
115 +
116 + static void matrixMatrix(const bool& transA, const bool& transB,
117 + const int& M, const int& N, const int& K,
118 + const Scalar& alpha, const Scalar* A, const Scalar* B,
119 + const Scalar& beta, Scalar* C)
120 + {
121 + int LDA = M, LDB = K;
122 + char tA = NoTrans, tB = NoTrans;
123 +
124 + if (transA) {
125 + LDA = K;
126 + tA = Trans;
127 + }
128 + if (transB) {
129 + LDB = N;
130 + tB = Trans;
131 + }
132 +
133 + const int LDB = transB ? N : K;
134 + FORTFUNC(gemm)(&tA, &tB, &M, &N, &K, &alpha, A, &LDA, B, &LDB,
135 + &beta, C, &M);
136 + }
137 +
138 + static void triangularMatrixMatrix(const char& uplo,
139 + const int& M, const int& N, const Scalar* A, Scalar* B)
140 + {
141 + FORTFUNC(trmm)("L", &uplo, "N", "N", &M, &N, &fONE, A, &M, B, &M);
142 + }
143 +
144 + static void triangularSolveMatrix(const char& uplo,
145 + const int& M, const int& N, const Scalar* A, Scalar *B)
146 + {
147 + FORTFUNC(trsm)("L", &uplo, "N", "N", &M, &N, &fONE, A, &M, B, &M);
148 + }
149 };
150
151 const int NumericInterface<NI_SCALAR>::ZERO = 0;
152 const int NumericInterface<NI_SCALAR>::ONE = 1;
153 +const NI_SCALAR NumericInterface<NI_SCALAR>::fONE = 1.;
154 +const char NumericInterface<NI_SCALAR>::NoTrans = 'N';
155 +const char NumericInterface<NI_SCALAR>::Trans = 'T';