• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

修订版a151270c4cbebcc9ddea54b99445edfa16260f85 (tree)
时间2012-12-29 14:23:50
作者Katsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Log Message

Integrate Blas/Lapack_GNU.cpp into Blas/Lapack.cpp. #30409

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

更改概述

差异

--- a/src/Makefile_GNU
+++ b/src/Makefile_GNU
@@ -28,9 +28,9 @@ OPENBLAS_LIBS = -lopenblas
2828 EXENAME = MolDS.out
2929 DEPFILE = obj/objfile.dep
3030
31-ALL_CPP_FILES = Main.cpp base/MolDSException.cpp wrappers/Blas_GNU.cpp wrappers/Lapack_GNU.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/MallocerFreer.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp
31+ALL_CPP_FILES = Main.cpp base/MolDSException.cpp wrappers/Blas.cpp wrappers/Lapack.cpp base/Utilities.cpp base/Enums.cpp base/MathUtilities.cpp base/MallocerFreer.cpp base/EularAngle.cpp base/Parameters.cpp base/atoms/Atom.cpp base/atoms/Hatom.cpp base/atoms/Liatom.cpp base/atoms/Catom.cpp base/atoms/Natom.cpp base/atoms/Oatom.cpp base/atoms/Satom.cpp base/factories/AtomFactory.cpp base/Molecule.cpp base/InputParser.cpp base/GTOExpansionSTO.cpp base/RealSphericalHarmonicsIndex.cpp base/loggers/MOLogger.cpp base/loggers/DensityLogger.cpp base/loggers/HoleDensityLogger.cpp base/loggers/ParticleDensityLogger.cpp cndo/Cndo2.cpp indo/Indo.cpp zindo/ZindoS.cpp mndo/Mndo.cpp am1/Am1.cpp am1/Am1D.cpp pm3/Pm3.cpp pm3/Pm3D.cpp pm3/Pm3Pddg.cpp base/factories/ElectronicStructureFactory.cpp md/MD.cpp mc/MC.cpp rpmd/RPMD.cpp nasco/NASCO.cpp optimization/Optimizer.cpp optimization/ConjugateGradient.cpp optimization/SteepestDescent.cpp optimization/BFGS.cpp base/factories/OptimizerFactory.cpp base/MolDS.cpp
3232 ALL_HEAD_FILES = base/PrintController.h base/MolDSException.h base/Uncopyable.h wrappers/Blas.h wrappers/Lapack.h base/Utilities.h base/Enums.h base/MathUtilities.h base/MallocerFreer.h base/EularAngle.h base/Parameters.h base/atoms/Atom.h base/atoms/Hatom.h base/atoms/Liatom.h base/atoms/Catom.h base/atoms/Natom.h base/atoms/Oatom.h base/atoms/Satom.h base/factories/AtomFactory.h base/Molecule.h base/InputParser.h base/GTOExpansionSTO.h base/RealSphericalHarmonicsIndex.h base/loggers/MOLogger.h base/loggers/DensityLogger.h base/loggers/HoleDensityLogger.h base/loggers/ParticleDensityLogger.h base/ElectronicStructure.h cndo/Cndo2.h cndo/ReducedOverlapAOsParameters.h indo/Indo.h zindo/ZindoS.h mndo/Mndo.h am1/Am1.h am1/Am1D.h pm3/Pm3.h pm3/Pm3D.h pm3/Pm3Pddg.h base/factories/ElectronicStructureFactory.h md/MD.h mc/MC.h rpmd/RPMD.h nasco/NASCO.h optimization/Optimizer.h optimization/ConjugateGradient.h optimization/SteepestDescent.h optimization/BFGS.h base/factories/OptimizerFactory.h base/MolDS.h
33-ALL_OBJ_FILES = obj/Main.o obj/MolDSException.o obj/Blas_GNU.o obj/Lapack_GNU.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/MallocerFreer.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o
33+ALL_OBJ_FILES = obj/Main.o obj/MolDSException.o obj/Blas.o obj/Lapack.o obj/Utilities.o obj/Enums.o obj/MathUtilities.o obj/MallocerFreer.o obj/EularAngle.o obj/Parameters.o obj/Atom.o obj/Hatom.o obj/Liatom.o obj/Catom.o obj/Natom.o obj/Oatom.o obj/Satom.o obj/AtomFactory.o obj/Molecule.o obj/InputParser.o obj/GTOExpansionSTO.o obj/RealSphericalHarmonicsIndex.o obj/MOLogger.o obj/DensityLogger.o obj/HoleDensityLogger.o obj/ParticleDensityLogger.o obj/Cndo2.o obj/Indo.o obj/ZindoS.o obj/Mndo.o obj/Am1.o obj/Am1D.o obj/Pm3.o obj/Pm3D.o obj/Pm3Pddg.o obj/ElectronicStructureFactory.o obj/MD.o obj/MC.o obj/RPMD.o obj/NASCO.o obj/Optimizer.o obj/ConjugateGradient.o obj/SteepestDescent.o obj/BFGS.o obj/OptimizerFactory.o obj/MolDS.o
3434
3535 $(EXENAME): $(DEPFILE) $(ALL_OBJ_FILES)
3636 $(CC) -o $@ -Wl,-rpath=$(OPENBLAS_LIB_DIR) $(ALL_OBJ_FILES) -L$(OPENBLAS_LIB_DIR) $(LIBS) $(OPENBLAS_LIBS)
--- a/src/wrappers/Blas.cpp
+++ b/src/wrappers/Blas.cpp
@@ -25,7 +25,11 @@
2525 #include<string>
2626 #include<stdexcept>
2727 #include<boost/format.hpp>
28+#ifdef __INTEL_COMPILER
2829 #include"mkl.h"
30+#else
31+#include"cblas.h"
32+#endif
2933 #include"../base/PrintController.h"
3034 #include"../base/MolDSException.h"
3135 #include"../base/Uncopyable.h"
@@ -75,7 +79,12 @@ void Blas::Dcopy(molds_blas_int n,
7579 void Blas::Dcopy(molds_blas_int n,
7680 double const* vectorX, molds_blas_int incrementX,
7781 double* vectorY, molds_blas_int incrementY) const{
82+#ifdef __INTEL_COMPILER
7883 dcopy(&n, vectorX, &incrementX, vectorY, &incrementY);
84+#else
85+ double* x = const_cast<double*>(&vectorX[0]);
86+ cblas_dcopy(n, x, incrementX, vectorY, incrementY);
87+#endif
7988 }
8089
8190 // vectorY = alpha*vectorX + vectorY
@@ -95,7 +104,12 @@ void Blas::Daxpy(molds_blas_int n, double alpha,
95104 void Blas::Daxpy(molds_blas_int n, double alpha,
96105 double const* vectorX, molds_blas_int incrementX,
97106 double* vectorY, molds_blas_int incrementY) const{
107+#ifdef __INTEL_COMPILER
98108 daxpy(&n, &alpha, vectorX, &incrementX, vectorY, &incrementY);
109+#else
110+ double* x = const_cast<double*>(&vectorX[0]);
111+ cblas_daxpy(n, alpha, x, incrementX, vectorY, incrementY);
112+#endif
99113 }
100114
101115 // returns vectorX^T*vectorY
@@ -115,7 +129,13 @@ double Blas::Ddot(molds_blas_int n,
115129 double Blas::Ddot(molds_blas_int n,
116130 double const* vectorX, molds_blas_int incrementX,
117131 double const* vectorY, molds_blas_int incrementY)const{
132+#ifdef __INTEL_COMPILER
118133 return ddot(&n, vectorX, &incrementX, vectorY, &incrementY);
134+#else
135+ double* x=const_cast<double*>(vectorX),
136+ * y=const_cast<double*>(vectorY);
137+ return cblas_ddot(n, x, incrementX, y, incrementY);
138+#endif
119139 }
120140
121141 // vectorY = matrixA*vectorX
@@ -147,6 +167,7 @@ void Blas::Dgemv(bool isColumnMajorMatrixA,
147167 double beta,
148168 double* vectorY,
149169 molds_blas_int incrementY) const{
170+#ifdef __INTEL_COMPILER
150171 double const* a = &matrixA[0][0];
151172 char transA;
152173 if(isColumnMajorMatrixA){
@@ -158,6 +179,20 @@ void Blas::Dgemv(bool isColumnMajorMatrixA,
158179 }
159180 molds_blas_int lda = m;
160181 dgemv(&transA, &m, &n, &alpha, a, &lda, vectorX, &incrementX, &beta, vectorY, &incrementY);
182+#else
183+ double* a = const_cast<double*>(&matrixA[0][0]);
184+ double* x = const_cast<double*>(&vectorX[0]);
185+ CBLAS_TRANSPOSE transA;
186+ if(isColumnMajorMatrixA){
187+ transA = CblasNoTrans;
188+ }
189+ else{
190+ transA = CblasTrans;
191+ swap(m,n);
192+ }
193+ int lda = m;
194+ cblas_dgemv(CblasColMajor, transA, m, n, alpha, a, lda, x, incrementX, beta, vectorY, incrementY);
195+#endif
161196 }
162197
163198 // vectorY = matrixA*vectorX
@@ -183,10 +218,18 @@ void Blas::Dsymv(molds_blas_int n, double alpha,
183218 double const* vectorX, molds_blas_int incrementX,
184219 double beta,
185220 double* vectorY, molds_blas_int incrementY) const{
221+#ifdef __INTEL_COMPILER
186222 double const* a = &matrixA[0][0];
187223 char uploA='L';
188224 molds_blas_int lda = n;
189225 dsymv(&uploA, &n, &alpha, a, &lda, vectorX, &incrementX, &beta, vectorY, &incrementY);
226+#else
227+ double* a = const_cast<double*>(&matrixA[0][0]);
228+ double* x = const_cast<double*>(&vectorX[0]);
229+ CBLAS_UPLO uploA=CblasUpper;
230+ int lda = n;
231+ cblas_dsymv(CblasRowMajor, uploA, n, alpha, a, lda, x, incrementX, beta, vectorY, incrementY);
232+#endif
190233 }
191234
192235 // matrixA = alpha*vectorX*vectorX^T + matrixA
@@ -203,9 +246,16 @@ void Blas::Dsyr(molds_blas_int n, double alpha,
203246 double const* vectorX, molds_blas_int incrementX,
204247 double ** matrixA)const{
205248 double* a = &matrixA[0][0];
249+#ifdef __INTEL_COMPILER
206250 char uploA='L';
207251 molds_blas_int lda = n;
208252 dsyr(&uploA, &n, &alpha, vectorX, &incrementX, a, &lda);
253+#else
254+ double* x = const_cast<double*>(&vectorX[0]);
255+ CBLAS_UPLO uploA=CblasUpper;
256+ int lda = n;
257+ cblas_dsyr(CblasRowMajor, uploA, n, alpha, x, incrementX, a, lda);
258+#endif
209259 #pragma omp parallel for schedule(auto)
210260 for(molds_blas_int i=0;i<n;i++){
211261 for(molds_blas_int j=i+1;j<n;j++){
@@ -241,6 +291,7 @@ void Blas::Dgemm(bool isColumnMajorMatrixA,
241291 double const* const* matrixB,
242292 double beta,
243293 double** matrixC) const{
294+#ifdef __INTEL_COMPILER
244295 double const* a = &matrixA[0][0];
245296 double const* b = &matrixB[0][0];
246297 double* c = &matrixC[0][0];
@@ -266,9 +317,40 @@ void Blas::Dgemm(bool isColumnMajorMatrixA,
266317 transB = 'T'; //kb=k
267318 ldb = n;
268319 }
320+#else
321+ double* a = const_cast<double*>(&matrixA[0][0]);
322+ double* b = const_cast<double*>(&matrixB[0][0]);
323+ double* c = &matrixC[0][0];
324+
325+ int lda;
326+ CBLAS_TRANSPOSE transA;
327+ if(isColumnMajorMatrixA){
328+ transA = CblasNoTrans;
329+ lda = m;
330+ }
331+ else{
332+ transA = CblasTrans;
333+ lda = k;
334+ }
335+
336+ int ldb;
337+ CBLAS_TRANSPOSE transB;
338+ if(isColumnMajorMatrixB){
339+ transB = CblasNoTrans;
340+ ldb = k;
341+ }
342+ else{
343+ transB = CblasTrans;
344+ ldb = n;
345+ }
346+#endif
269347
270348 double* tmpC;
349+#ifdef __INTEL_COMPILER
271350 tmpC = (double*)mkl_malloc( sizeof(double)*m*n, 16 );
351+#else
352+ tmpC = (double*)malloc( sizeof(double)*m*n);
353+#endif
272354 for(molds_blas_int i=0; i<m; i++){
273355 for(molds_blas_int j=0; j<n; j++){
274356 tmpC[i+j*m] = matrixC[i][j];
@@ -276,13 +358,21 @@ void Blas::Dgemm(bool isColumnMajorMatrixA,
276358 }
277359 molds_blas_int ldc = m;
278360 //call blas
361+#ifdef __INTEL_COMPILER
279362 dgemm(&transA, &transB, &m, &n, &k, &alpha, a, &lda, b, &ldb, &beta, tmpC, &ldc);
363+#else
364+ cblas_dgemm(CblasColMajor, transA, transB, m, n, k, alpha, a, lda, b, ldb, beta, tmpC, ldc);
365+#endif
280366 for(molds_blas_int i=0; i<m; i++){
281367 for(molds_blas_int j=0; j<n; j++){
282368 matrixC[i][j] = tmpC[i+j*m];
283369 }
284370 }
371+#ifdef __INTEL_COMPILER
285372 mkl_free(tmpC);
373+#else
374+ free(tmpC);
375+#endif
286376 }
287377
288378 }
--- a/src/wrappers/Lapack.cpp
+++ b/src/wrappers/Lapack.cpp
@@ -24,11 +24,30 @@
2424 #include<string>
2525 #include<stdexcept>
2626 #include<boost/format.hpp>
27+#ifdef __INTEL_COMPILER
2728 #include"mkl.h"
29+#else
30+#if ( __WORDSIZE == 32 )
31+#else
32+#define HAVE_LAPACK_CONFIG_H
33+#define LAPACK_ILP64
34+#endif
35+#include"lapacke.h"
36+#endif
2837 #include"../base/PrintController.h"
2938 #include"../base/MolDSException.h"
3039 #include"../base/Uncopyable.h"
3140 #include"Lapack.h"
41+
42+#ifdef __INTEL_COMPILER
43+#define MOLDS_LAPACK_malloc(a,b) mkl_malloc(a,b)
44+#define MOLDS_LAPACK_free(a) mkl_free(a)
45+#else
46+#define MOLDS_LAPACK_malloc(a,b) malloc(a)
47+#define MOLDS_LAPACK_free(a) free(a)
48+#endif
49+
50+
3251 using namespace std;
3352 using namespace MolDS_base;
3453
@@ -121,10 +140,10 @@ molds_lapack_int Lapack::Dsyevd(double** matrix, double* eigenValues, molds_lapa
121140 }
122141
123142 // malloc
124- work = (double*)mkl_malloc( sizeof(double)*lwork, 16 );
125- iwork = (molds_lapack_int*)mkl_malloc( sizeof(molds_lapack_int)*liwork, 16 );
126- convertedMatrix = (double*)mkl_malloc( sizeof(double)*size*size, 16 );
127- tempEigenValues = (double*)mkl_malloc( sizeof(double)*size, 16 );
143+ work = (double*)MOLDS_LAPACK_malloc( sizeof(double)*lwork, 16 );
144+ iwork = (molds_lapack_int*)MOLDS_LAPACK_malloc( sizeof(molds_lapack_int)*liwork, 16 );
145+ convertedMatrix = (double*)MOLDS_LAPACK_malloc( sizeof(double)*size*size, 16 );
146+ tempEigenValues = (double*)MOLDS_LAPACK_malloc( sizeof(double)*size, 16 );
128147
129148 for(molds_lapack_int i = 0; i < size; i++){
130149 for(molds_lapack_int j = i; j < size; j++){
@@ -133,7 +152,11 @@ molds_lapack_int Lapack::Dsyevd(double** matrix, double* eigenValues, molds_lapa
133152 }
134153
135154 // call Lapack
155+#ifdef __INTEL_COMPILER
136156 dsyevd(&job, &uplo, &size, convertedMatrix, &lda, tempEigenValues, work, &lwork, iwork, &liwork, &info);
157+#else
158+ info = LAPACKE_dsyevd_work(LAPACK_COL_MAJOR, job, uplo, size, convertedMatrix, lda, tempEigenValues, work, lwork, iwork, liwork);
159+#endif
137160
138161 for(molds_lapack_int i = 0; i < size; i++){
139162 for(molds_lapack_int j = 0; j < size; j++){
@@ -160,10 +183,10 @@ molds_lapack_int Lapack::Dsyevd(double** matrix, double* eigenValues, molds_lapa
160183 //this->OutputLog(boost::format("size=%d lwork=%d liwork=%d k=%d info=%d\n") % size % lwork % liwork % k % info);
161184
162185 // free
163- mkl_free(work);
164- mkl_free(iwork);
165- mkl_free(convertedMatrix);
166- mkl_free(tempEigenValues);
186+ MOLDS_LAPACK_free(work);
187+ MOLDS_LAPACK_free(iwork);
188+ MOLDS_LAPACK_free(convertedMatrix);
189+ MOLDS_LAPACK_free(tempEigenValues);
167190
168191 if(info != 0){
169192 stringstream ss;
@@ -199,9 +222,9 @@ molds_lapack_int Lapack::Dsysv(double const* const* matrix, double* b, molds_lap
199222 }
200223
201224 // malloc
202- ipiv = (molds_lapack_int*)mkl_malloc( sizeof(molds_lapack_int)*2*size, 16 );
203- convertedMatrix = (double*)mkl_malloc( sizeof(double)*size*size, 16 );
204- tempB = (double*)mkl_malloc( sizeof(double)*size, 16 );
225+ ipiv = (molds_lapack_int*)MOLDS_LAPACK_malloc( sizeof(molds_lapack_int)*2*size, 16 );
226+ convertedMatrix = (double*)MOLDS_LAPACK_malloc( sizeof(double)*size*size, 16 );
227+ tempB = (double*)MOLDS_LAPACK_malloc( sizeof(double)*size, 16 );
205228
206229 for(molds_lapack_int i = 0; i < size; i++){
207230 for(molds_lapack_int j = i; j < size; j++){
@@ -218,24 +241,32 @@ molds_lapack_int Lapack::Dsysv(double const* const* matrix, double* b, molds_lap
218241 {
219242 lwork = -1;
220243 double tempWork[3]={0.0, 0.0, 0.0};
221- dsysv(&uplo, &size, &nrhs, convertedMatrix, &lda, ipiv, tempB, &ldb, tempWork, &lwork, &info);
244+#ifdef __INTEL_COMPILER
245+ dsysv(&uplo, &size, &nrhs, convertedMatrix, &lda, ipiv, tempB, &ldb, tempWork, &lwork, &info);
246+#else
247+ info = LAPACKE_dsysv_work(LAPACK_COL_MAJOR, uplo, size, nrhs, convertedMatrix, lda, ipiv, tempB, ldb, tempWork, lwork);
248+#endif
222249 blockSize = tempWork[0]/size;
223250 }
224251 info = 0;
225252 lwork = blockSize*size;
226- work = (double*)mkl_malloc( sizeof(double)*lwork, 16 );
253+ work = (double*)MOLDS_LAPACK_malloc( sizeof(double)*lwork, 16 );
227254
228255 // call Lapack
256+#ifdef __INTEL_COMPILER
229257 dsysv(&uplo, &size, &nrhs, convertedMatrix, &lda, ipiv, tempB, &ldb, work, &lwork, &info);
258+#else
259+ info = LAPACKE_dsysv_work(LAPACK_COL_MAJOR, uplo, size, nrhs, convertedMatrix, lda, ipiv, tempB, ldb, work, lwork);
260+#endif
230261 for(molds_lapack_int i = 0; i < size; i++){
231262 b[i] = tempB[i];
232263 }
233264
234265 // free
235- mkl_free(convertedMatrix);
236- mkl_free(ipiv);
237- mkl_free(work);
238- mkl_free(tempB);
266+ MOLDS_LAPACK_free(convertedMatrix);
267+ MOLDS_LAPACK_free(ipiv);
268+ MOLDS_LAPACK_free(work);
269+ MOLDS_LAPACK_free(tempB);
239270
240271 if(info != 0){
241272 stringstream ss;
@@ -271,9 +302,9 @@ molds_lapack_int Lapack::Dgetrs(double const* const* matrix, double** b, molds_l
271302
272303 try{
273304 // malloc
274- ipiv = (molds_lapack_int*)mkl_malloc( sizeof(molds_lapack_int)*2*size, 16 );
275- convertedMatrix = (double*)mkl_malloc( sizeof(double)*size*size, 16 );
276- convertedB = (double*)mkl_malloc( sizeof(double)*nrhs*size, 16 );
305+ ipiv = (molds_lapack_int*)MOLDS_LAPACK_malloc( sizeof(molds_lapack_int)*2*size, 16 );
306+ convertedMatrix = (double*)MOLDS_LAPACK_malloc( sizeof(double)*size*size, 16 );
307+ convertedB = (double*)MOLDS_LAPACK_malloc( sizeof(double)*nrhs*size, 16 );
277308 for(molds_lapack_int i = 0; i < size; i++){
278309 for(molds_lapack_int j = 0; j < size; j++){
279310 convertedMatrix[i+j*size] = matrix[i][j];
@@ -285,7 +316,11 @@ molds_lapack_int Lapack::Dgetrs(double const* const* matrix, double** b, molds_l
285316 }
286317 }
287318 this->Dgetrf(convertedMatrix, ipiv, size, size);
319+#ifdef __INTEL_COMPILER
288320 dgetrs(&trans, &size, &nrhs, convertedMatrix, &lda, ipiv, convertedB, &ldb, &info);
321+#else
322+ info = LAPACKE_dgetrs_work(LAPACK_COL_MAJOR, trans, size, nrhs, convertedMatrix, lda, ipiv, convertedB, ldb);
323+#endif
289324 for(molds_lapack_int i = 0; i < nrhs; i++){
290325 for(molds_lapack_int j = 0; j < size; j++){
291326 b[i][j] = convertedB[j+i*size];
@@ -294,15 +329,15 @@ molds_lapack_int Lapack::Dgetrs(double const* const* matrix, double** b, molds_l
294329 }
295330 catch(MolDSException ex){
296331 // free
297- mkl_free(convertedMatrix);
298- mkl_free(convertedB);
299- mkl_free(ipiv);
332+ MOLDS_LAPACK_free(convertedMatrix);
333+ MOLDS_LAPACK_free(convertedB);
334+ MOLDS_LAPACK_free(ipiv);
300335 throw ex;
301336 }
302337 // free
303- mkl_free(convertedMatrix);
304- mkl_free(convertedB);
305- mkl_free(ipiv);
338+ MOLDS_LAPACK_free(convertedMatrix);
339+ MOLDS_LAPACK_free(convertedB);
340+ MOLDS_LAPACK_free(ipiv);
306341
307342 if(info != 0){
308343 stringstream ss;
@@ -316,9 +351,9 @@ molds_lapack_int Lapack::Dgetrs(double const* const* matrix, double** b, molds_l
316351 // Argument "matrix" is sizeM*sizeN matrix.
317352 // Argument "matrix" will be LU-decomposed.
318353 molds_lapack_int Lapack::Dgetrf(double** matrix, molds_lapack_int sizeM, molds_lapack_int sizeN) const{
319- molds_lapack_int* ipiv = (molds_lapack_int*)mkl_malloc( sizeof(molds_lapack_int)*2*sizeM, 16 );
354+ molds_lapack_int* ipiv = (molds_lapack_int*)MOLDS_LAPACK_malloc( sizeof(molds_lapack_int)*2*sizeM, 16 );
320355 this->Dgetrf(matrix, ipiv, sizeM, sizeN);
321- mkl_free(ipiv);
356+ MOLDS_LAPACK_free(ipiv);
322357 molds_lapack_int info = 0;
323358 return info;
324359 }
@@ -326,7 +361,7 @@ molds_lapack_int Lapack::Dgetrf(double** matrix, molds_lapack_int sizeM, molds_l
326361 // Argument "matrix" is sizeM*sizeN matrix.
327362 // Argument "matrix" will be LU-decomposed.
328363 molds_lapack_int Lapack::Dgetrf(double** matrix, molds_lapack_int* ipiv, molds_lapack_int sizeM, molds_lapack_int sizeN) const{
329- double* convertedMatrix = (double*)mkl_malloc( sizeof(double)*sizeM*sizeN, 16 );
364+ double* convertedMatrix = (double*)MOLDS_LAPACK_malloc( sizeof(double)*sizeM*sizeN, 16 );
330365 for(molds_lapack_int i=0; i<sizeM; i++){
331366 for(molds_lapack_int j=0; j<sizeN; j++){
332367 convertedMatrix[i+j*sizeM] = matrix[i][j];
@@ -338,7 +373,7 @@ molds_lapack_int Lapack::Dgetrf(double** matrix, molds_lapack_int* ipiv, molds_l
338373 matrix[i][j] = convertedMatrix[i+j*sizeM];
339374 }
340375 }
341- mkl_free(convertedMatrix);
376+ MOLDS_LAPACK_free(convertedMatrix);
342377 molds_lapack_int info = 0;
343378 return info;
344379 }
@@ -348,7 +383,11 @@ molds_lapack_int Lapack::Dgetrf(double** matrix, molds_lapack_int* ipiv, molds_l
348383 molds_lapack_int Lapack::Dgetrf(double* matrix, molds_lapack_int* ipiv, molds_lapack_int sizeM, molds_lapack_int sizeN) const{
349384 molds_lapack_int info = 0;
350385 molds_lapack_int lda = sizeM;
386+#ifdef __INTEL_COMPILER
351387 dgetrf(&sizeM, &sizeN, matrix, &lda, ipiv, &info);
388+#else
389+ info = LAPACKE_dgetrf_work(LAPACK_COL_MAJOR, sizeM, sizeN, matrix, lda, ipiv);
390+#endif
352391 if(info != 0){
353392 stringstream ss;
354393 ss << errorMessageDgetrfInfo;