• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision6bc79af3000f755882f238f2f4ea6567b93bccca (tree)
Time2013-01-24 20:53:10
AuthorKatsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Log Message

Use only cblas routines in BLAS wrapper. #30566

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1249 1136aad2-a195-0410-b898-f5ea1d11b9d8

Change Summary

Incremental Difference

--- a/src/wrappers/Blas.cpp
+++ b/src/wrappers/Blas.cpp
@@ -79,12 +79,8 @@ void Blas::Dcopy(molds_blas_int n,
7979 void Blas::Dcopy(molds_blas_int n,
8080 double const* vectorX, molds_blas_int incrementX,
8181 double* vectorY, molds_blas_int incrementY) const{
82-#ifdef __INTEL_COMPILER
83- dcopy(&n, vectorX, &incrementX, vectorY, &incrementY);
84-#else
8582 double* x = const_cast<double*>(&vectorX[0]);
8683 cblas_dcopy(n, x, incrementX, vectorY, incrementY);
87-#endif
8884 }
8985
9086 // vectorY = alpha*vectorX + vectorY
@@ -104,12 +100,8 @@ void Blas::Daxpy(molds_blas_int n, double alpha,
104100 void Blas::Daxpy(molds_blas_int n, double alpha,
105101 double const* vectorX, molds_blas_int incrementX,
106102 double* vectorY, molds_blas_int incrementY) const{
107-#ifdef __INTEL_COMPILER
108- daxpy(&n, &alpha, vectorX, &incrementX, vectorY, &incrementY);
109-#else
110103 double* x = const_cast<double*>(&vectorX[0]);
111104 cblas_daxpy(n, alpha, x, incrementX, vectorY, incrementY);
112-#endif
113105 }
114106
115107 // returns vectorX^T*vectorY
@@ -129,13 +121,9 @@ double Blas::Ddot(molds_blas_int n,
129121 double Blas::Ddot(molds_blas_int n,
130122 double const* vectorX, molds_blas_int incrementX,
131123 double const* vectorY, molds_blas_int incrementY)const{
132-#ifdef __INTEL_COMPILER
133- return ddot(&n, vectorX, &incrementX, vectorY, &incrementY);
134-#else
135124 double* x=const_cast<double*>(vectorX),
136125 * y=const_cast<double*>(vectorY);
137126 return cblas_ddot(n, x, incrementX, y, incrementY);
138-#endif
139127 }
140128
141129 // vectorY = matrixA*vectorX
@@ -167,19 +155,6 @@ void Blas::Dgemv(bool isColumnMajorMatrixA,
167155 double beta,
168156 double* vectorY,
169157 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
183158 double* a = const_cast<double*>(&matrixA[0][0]);
184159 double* x = const_cast<double*>(&vectorX[0]);
185160 CBLAS_TRANSPOSE transA;
@@ -192,7 +167,6 @@ void Blas::Dgemv(bool isColumnMajorMatrixA,
192167 }
193168 int lda = m;
194169 cblas_dgemv(CblasColMajor, transA, m, n, alpha, a, lda, x, incrementX, beta, vectorY, incrementY);
195-#endif
196170 }
197171
198172 // vectorY = matrixA*vectorX
@@ -218,18 +192,11 @@ void Blas::Dsymv(molds_blas_int n, double alpha,
218192 double const* vectorX, molds_blas_int incrementX,
219193 double beta,
220194 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
227195 double* a = const_cast<double*>(&matrixA[0][0]);
228196 double* x = const_cast<double*>(&vectorX[0]);
229197 CBLAS_UPLO uploA=CblasUpper;
230198 int lda = n;
231199 cblas_dsymv(CblasRowMajor, uploA, n, alpha, a, lda, x, incrementX, beta, vectorY, incrementY);
232-#endif
233200 }
234201
235202 // matrixA = alpha*vectorX*vectorX^T + matrixA
@@ -246,16 +213,10 @@ void Blas::Dsyr(molds_blas_int n, double alpha,
246213 double const* vectorX, molds_blas_int incrementX,
247214 double ** matrixA)const{
248215 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
254216 double* x = const_cast<double*>(&vectorX[0]);
255217 CBLAS_UPLO uploA=CblasUpper;
256218 int lda = n;
257219 cblas_dsyr(CblasRowMajor, uploA, n, alpha, x, incrementX, a, lda);
258-#endif
259220 #pragma omp parallel for schedule(auto)
260221 for(molds_blas_int i=0;i<n;i++){
261222 for(molds_blas_int j=i+1;j<n;j++){
@@ -291,33 +252,6 @@ void Blas::Dgemm(bool isColumnMajorMatrixA,
291252 double const* const* matrixB,
292253 double beta,
293254 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
321255 double* a = const_cast<double*>(&matrixA[0][0]);
322256 double* b = const_cast<double*>(&matrixB[0][0]);
323257 double* c = &matrixC[0][0];
@@ -343,7 +277,6 @@ void Blas::Dgemm(bool isColumnMajorMatrixA,
343277 transB = CblasTrans;
344278 ldb = n;
345279 }
346-#endif
347280
348281 double* tmpC;
349282 #ifdef __INTEL_COMPILER
@@ -358,11 +291,7 @@ void Blas::Dgemm(bool isColumnMajorMatrixA,
358291 }
359292 molds_blas_int ldc = m;
360293 //call blas
361-#ifdef __INTEL_COMPILER
362- dgemm(&transA, &transB, &m, &n, &k, &alpha, a, &lda, b, &ldb, &beta, tmpC, &ldc);
363-#else
364294 cblas_dgemm(CblasColMajor, transA, transB, m, n, k, alpha, a, lda, b, ldb, beta, tmpC, ldc);
365-#endif
366295 for(molds_blas_int i=0; i<m; i++){
367296 for(molds_blas_int j=0; j<n; j++){
368297 matrixC[i][j] = tmpC[i+j*m];