Revision | 6bc79af3000f755882f238f2f4ea6567b93bccca (tree) |
---|---|
Time | 2013-01-24 20:53:10 |
Author | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Use only cblas routines in BLAS wrapper. #30566
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1249 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -79,12 +79,8 @@ void Blas::Dcopy(molds_blas_int n, | ||
79 | 79 | void Blas::Dcopy(molds_blas_int n, |
80 | 80 | double const* vectorX, molds_blas_int incrementX, |
81 | 81 | double* vectorY, molds_blas_int incrementY) const{ |
82 | -#ifdef __INTEL_COMPILER | |
83 | - dcopy(&n, vectorX, &incrementX, vectorY, &incrementY); | |
84 | -#else | |
85 | 82 | double* x = const_cast<double*>(&vectorX[0]); |
86 | 83 | cblas_dcopy(n, x, incrementX, vectorY, incrementY); |
87 | -#endif | |
88 | 84 | } |
89 | 85 | |
90 | 86 | // vectorY = alpha*vectorX + vectorY |
@@ -104,12 +100,8 @@ void Blas::Daxpy(molds_blas_int n, double alpha, | ||
104 | 100 | void Blas::Daxpy(molds_blas_int n, double alpha, |
105 | 101 | double const* vectorX, molds_blas_int incrementX, |
106 | 102 | double* vectorY, molds_blas_int incrementY) const{ |
107 | -#ifdef __INTEL_COMPILER | |
108 | - daxpy(&n, &alpha, vectorX, &incrementX, vectorY, &incrementY); | |
109 | -#else | |
110 | 103 | double* x = const_cast<double*>(&vectorX[0]); |
111 | 104 | cblas_daxpy(n, alpha, x, incrementX, vectorY, incrementY); |
112 | -#endif | |
113 | 105 | } |
114 | 106 | |
115 | 107 | // returns vectorX^T*vectorY |
@@ -129,13 +121,9 @@ double Blas::Ddot(molds_blas_int n, | ||
129 | 121 | double Blas::Ddot(molds_blas_int n, |
130 | 122 | double const* vectorX, molds_blas_int incrementX, |
131 | 123 | double const* vectorY, molds_blas_int incrementY)const{ |
132 | -#ifdef __INTEL_COMPILER | |
133 | - return ddot(&n, vectorX, &incrementX, vectorY, &incrementY); | |
134 | -#else | |
135 | 124 | double* x=const_cast<double*>(vectorX), |
136 | 125 | * y=const_cast<double*>(vectorY); |
137 | 126 | return cblas_ddot(n, x, incrementX, y, incrementY); |
138 | -#endif | |
139 | 127 | } |
140 | 128 | |
141 | 129 | // vectorY = matrixA*vectorX |
@@ -167,19 +155,6 @@ void Blas::Dgemv(bool isColumnMajorMatrixA, | ||
167 | 155 | double beta, |
168 | 156 | double* vectorY, |
169 | 157 | molds_blas_int incrementY) const{ |
170 | -#ifdef __INTEL_COMPILER | |
171 | - double const* a = &matrixA[0][0]; | |
172 | - char transA; | |
173 | - if(isColumnMajorMatrixA){ | |
174 | - transA = 'N'; | |
175 | - } | |
176 | - else{ | |
177 | - transA = 'T'; | |
178 | - swap(m,n); | |
179 | - } | |
180 | - molds_blas_int lda = m; | |
181 | - dgemv(&transA, &m, &n, &alpha, a, &lda, vectorX, &incrementX, &beta, vectorY, &incrementY); | |
182 | -#else | |
183 | 158 | double* a = const_cast<double*>(&matrixA[0][0]); |
184 | 159 | double* x = const_cast<double*>(&vectorX[0]); |
185 | 160 | CBLAS_TRANSPOSE transA; |
@@ -192,7 +167,6 @@ void Blas::Dgemv(bool isColumnMajorMatrixA, | ||
192 | 167 | } |
193 | 168 | int lda = m; |
194 | 169 | cblas_dgemv(CblasColMajor, transA, m, n, alpha, a, lda, x, incrementX, beta, vectorY, incrementY); |
195 | -#endif | |
196 | 170 | } |
197 | 171 | |
198 | 172 | // vectorY = matrixA*vectorX |
@@ -218,18 +192,11 @@ void Blas::Dsymv(molds_blas_int n, double alpha, | ||
218 | 192 | double const* vectorX, molds_blas_int incrementX, |
219 | 193 | double beta, |
220 | 194 | double* vectorY, molds_blas_int incrementY) const{ |
221 | -#ifdef __INTEL_COMPILER | |
222 | - double const* a = &matrixA[0][0]; | |
223 | - char uploA='L'; | |
224 | - molds_blas_int lda = n; | |
225 | - dsymv(&uploA, &n, &alpha, a, &lda, vectorX, &incrementX, &beta, vectorY, &incrementY); | |
226 | -#else | |
227 | 195 | double* a = const_cast<double*>(&matrixA[0][0]); |
228 | 196 | double* x = const_cast<double*>(&vectorX[0]); |
229 | 197 | CBLAS_UPLO uploA=CblasUpper; |
230 | 198 | int lda = n; |
231 | 199 | cblas_dsymv(CblasRowMajor, uploA, n, alpha, a, lda, x, incrementX, beta, vectorY, incrementY); |
232 | -#endif | |
233 | 200 | } |
234 | 201 | |
235 | 202 | // matrixA = alpha*vectorX*vectorX^T + matrixA |
@@ -246,16 +213,10 @@ void Blas::Dsyr(molds_blas_int n, double alpha, | ||
246 | 213 | double const* vectorX, molds_blas_int incrementX, |
247 | 214 | double ** matrixA)const{ |
248 | 215 | double* a = &matrixA[0][0]; |
249 | -#ifdef __INTEL_COMPILER | |
250 | - char uploA='L'; | |
251 | - molds_blas_int lda = n; | |
252 | - dsyr(&uploA, &n, &alpha, vectorX, &incrementX, a, &lda); | |
253 | -#else | |
254 | 216 | double* x = const_cast<double*>(&vectorX[0]); |
255 | 217 | CBLAS_UPLO uploA=CblasUpper; |
256 | 218 | int lda = n; |
257 | 219 | cblas_dsyr(CblasRowMajor, uploA, n, alpha, x, incrementX, a, lda); |
258 | -#endif | |
259 | 220 | #pragma omp parallel for schedule(auto) |
260 | 221 | for(molds_blas_int i=0;i<n;i++){ |
261 | 222 | for(molds_blas_int j=i+1;j<n;j++){ |
@@ -291,33 +252,6 @@ void Blas::Dgemm(bool isColumnMajorMatrixA, | ||
291 | 252 | double const* const* matrixB, |
292 | 253 | double beta, |
293 | 254 | double** matrixC) const{ |
294 | -#ifdef __INTEL_COMPILER | |
295 | - double const* a = &matrixA[0][0]; | |
296 | - double const* b = &matrixB[0][0]; | |
297 | - double* c = &matrixC[0][0]; | |
298 | - | |
299 | - char transA; | |
300 | - molds_blas_int lda; | |
301 | - if(isColumnMajorMatrixA){ | |
302 | - transA = 'N'; //ka=k | |
303 | - lda = m; | |
304 | - } | |
305 | - else{ | |
306 | - transA = 'T'; //ka=m | |
307 | - lda = k; | |
308 | - } | |
309 | - | |
310 | - char transB; | |
311 | - molds_blas_int ldb; | |
312 | - if(isColumnMajorMatrixB){ | |
313 | - transB = 'N'; //kb=n | |
314 | - ldb = k; | |
315 | - } | |
316 | - else{ | |
317 | - transB = 'T'; //kb=k | |
318 | - ldb = n; | |
319 | - } | |
320 | -#else | |
321 | 255 | double* a = const_cast<double*>(&matrixA[0][0]); |
322 | 256 | double* b = const_cast<double*>(&matrixB[0][0]); |
323 | 257 | double* c = &matrixC[0][0]; |
@@ -343,7 +277,6 @@ void Blas::Dgemm(bool isColumnMajorMatrixA, | ||
343 | 277 | transB = CblasTrans; |
344 | 278 | ldb = n; |
345 | 279 | } |
346 | -#endif | |
347 | 280 | |
348 | 281 | double* tmpC; |
349 | 282 | #ifdef __INTEL_COMPILER |
@@ -358,11 +291,7 @@ void Blas::Dgemm(bool isColumnMajorMatrixA, | ||
358 | 291 | } |
359 | 292 | molds_blas_int ldc = m; |
360 | 293 | //call blas |
361 | -#ifdef __INTEL_COMPILER | |
362 | - dgemm(&transA, &transB, &m, &n, &k, &alpha, a, &lda, b, &ldb, &beta, tmpC, &ldc); | |
363 | -#else | |
364 | 294 | cblas_dgemm(CblasColMajor, transA, transB, m, n, k, alpha, a, lda, b, ldb, beta, tmpC, ldc); |
365 | -#endif | |
366 | 295 | for(molds_blas_int i=0; i<m; i++){ |
367 | 296 | for(molds_blas_int j=0; j<n; j++){ |
368 | 297 | matrixC[i][j] = tmpC[i+j*m]; |