Преглед на файлове

Pardiso on kingspeak

master
Trevor Irons преди 6 години
родител
ревизия
418bf0d226
променени са 4 файла, в които са добавени 67 реда и са изтрити 2 реда
  1. 6
    0
      CMakeLists.txt
  2. 4
    1
      examples/EMSchur3D-vtk.cpp
  3. 4
    1
      examples/EMSchur3D.cpp
  4. 53
    0
      include/EMSchur3D.h

+ 6
- 0
CMakeLists.txt Целия файл

@@ -48,6 +48,12 @@ if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT OR LEMMA_VTK8_SUPPORT AND LEMMA_MO
48 48
     	CXX_STANDARD_REQUIRED_ON
49 49
 	)
50 50
 
51
+        # No OpenMP
52
+	#set (MKLLINK  "-L$MKLROOT/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -Wl,-rpath=$MKLROOT/lib/intel64")
53
+        # OpenMP 
54
+        set (MKLLINK  "-L$MKLROOT/lib/intel64 -Wl,-rpath=$MKLROOT/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread")
55
+	target_link_libraries(emschur3d "lemmacore" ${MKLLINK})
56
+
51 57
 	# Linking
52 58
 	target_link_libraries(emschur3d "lemmacore" "fdem1d" )
53 59
 

+ 4
- 1
examples/EMSchur3D-vtk.cpp Целия файл

@@ -115,7 +115,10 @@ int main( int argc, char** argv ) {
115 115
 
116 116
     // Use BiCGSTAB Diagonal preconditioner
117 117
     //auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::IncompleteLUT<Complex> > >::NewSP();
118
-    auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
118
+    //auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
119
+    
120
+    auto EM3D = EMSchur3D< Eigen::PardisoLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
121
+    //auto EM3D = EMSchur3D< Eigen::PardisoLDLT<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower > >::NewSP();
119 122
 
120 123
     // LS CG
121 124
     //auto EM3D = EMSchur3D< Eigen::LeastSquaresConjugateGradient<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();

+ 4
- 1
examples/EMSchur3D.cpp Целия файл

@@ -33,7 +33,10 @@ int main( int argc, char** argv ) {
33 33
     //auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
34 34
 
35 35
     // SUPERLU
36
-    auto EM3D = EMSchur3D< Eigen::SuperLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
36
+    //auto EM3D = EMSchur3D< Eigen::SuperLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
37
+    
38
+    //auto EM3D = EMSchur3D< Eigen::PardisoLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
39
+    auto EM3D = EMSchur3D< Eigen::PardisoLDLT<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower > >::NewSP();
37 40
 
38 41
     // Eigen built-in
39 42
     //auto EM3D = EMSchur3D< Eigen::SparseLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();

+ 53
- 0
include/EMSchur3D.h Целия файл

@@ -37,6 +37,8 @@
37 37
 #include <Eigen/PaStiXSupport>
38 38
 #endif
39 39
 
40
+#include <Eigen/PardisoSupport>
41
+
40 42
 //#include "CSymSimplicialCholesky.h"
41 43
 
42 44
 namespace Lemma {
@@ -437,6 +439,57 @@ namespace Lemma {
437 439
             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
438 440
         }
439 441
     }
442
+    
443
+// Pardiso 
444
+    template<>
445
+    void EMSchur3D< Eigen::PardisoLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::BuildCDirectSolver() {
446
+        CSolver = new Eigen::PardisoLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > [Omegas.size()];
447
+        for (int iw=0; iw<Omegas.size(); ++iw) {
448
+            jsw_timer timer;
449
+            timer.begin();
450
+        
451
+            //CSolver[iw].pardisoParameterArray()[2] = 28; // OMP_NUM_THREADS?
452
+            
453
+            /*  Complex system */
454
+            std::cout << "PardisoLU pattern analyzing C_" << iw << ",";
455
+            std::cout.flush();
456
+            CSolver[iw].analyzePattern( Cvec[iw].selfadjointView< Eigen::Lower>() );
457
+            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
458
+
459
+            // factorize
460
+            timer.begin();
461
+            std::cout << "PardisoLU factorising C_" << iw << ", ";
462
+            std::cout.flush();
463
+            CSolver[iw].factorize( Cvec[iw].selfadjointView< Eigen::Lower>() );
464
+            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
465
+        }
466
+    }
467
+
468
+    template<>
469
+    void EMSchur3D< Eigen::PardisoLDLT<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower > >::BuildCDirectSolver() {
470
+        CSolver = new Eigen::PardisoLDLT<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower > [Omegas.size()];
471
+        for (int iw=0; iw<Omegas.size(); ++iw) {
472
+            jsw_timer timer;
473
+            timer.begin();
474
+        
475
+            //CSolver[iw].pardisoParameterArray()[2] = 28; // OMP_NUM_THREADS?
476
+            
477
+            /*  Complex system */
478
+            std::cout << "PardisoLDLT pattern analyzing C_" << iw << ",";
479
+            std::cout.flush();
480
+            //CSolver[iw].analyzePattern( Cvec[iw].selfadjointView< Eigen::Lower>() );
481
+            CSolver[iw].analyzePattern( Cvec[iw] );
482
+            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
483
+
484
+            // factorize
485
+            timer.begin();
486
+            std::cout << "PardisoLDLT factorising C_" << iw << ", ";
487
+            std::cout.flush();
488
+            //CSolver[iw].factorize( Cvec[iw].selfadjointView< Eigen::Lower>() );
489
+            CSolver[iw].factorize( Cvec[iw] );
490
+            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
491
+        }
492
+    }
440 493
 
441 494
 #ifdef HAVE_UMFPACK
442 495
     // Umfpack only seems to work when LOWER and UPPER are set to 1. Workarounds this have not been found.

Loading…
Отказ
Запис