Browse Source

Pardiso on kingspeak

master
Trevor Irons 6 years ago
parent
commit
418bf0d226
4 changed files with 67 additions and 2 deletions
  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 View File

48
     	CXX_STANDARD_REQUIRED_ON
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
 	# Linking
57
 	# Linking
52
 	target_link_libraries(emschur3d "lemmacore" "fdem1d" )
58
 	target_link_libraries(emschur3d "lemmacore" "fdem1d" )
53
 
59
 

+ 4
- 1
examples/EMSchur3D-vtk.cpp View File

115
 
115
 
116
     // Use BiCGSTAB Diagonal preconditioner
116
     // Use BiCGSTAB Diagonal preconditioner
117
     //auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::IncompleteLUT<Complex> > >::NewSP();
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
     // LS CG
123
     // LS CG
121
     //auto EM3D = EMSchur3D< Eigen::LeastSquaresConjugateGradient<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
124
     //auto EM3D = EMSchur3D< Eigen::LeastSquaresConjugateGradient<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();

+ 4
- 1
examples/EMSchur3D.cpp View File

33
     //auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
33
     //auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
34
 
34
 
35
     // SUPERLU
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
     // Eigen built-in
41
     // Eigen built-in
39
     //auto EM3D = EMSchur3D< Eigen::SparseLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
42
     //auto EM3D = EMSchur3D< Eigen::SparseLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();

+ 53
- 0
include/EMSchur3D.h View File

37
 #include <Eigen/PaStiXSupport>
37
 #include <Eigen/PaStiXSupport>
38
 #endif
38
 #endif
39
 
39
 
40
+#include <Eigen/PardisoSupport>
41
+
40
 //#include "CSymSimplicialCholesky.h"
42
 //#include "CSymSimplicialCholesky.h"
41
 
43
 
42
 namespace Lemma {
44
 namespace Lemma {
437
             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
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
 #ifdef HAVE_UMFPACK
494
 #ifdef HAVE_UMFPACK
442
     // Umfpack only seems to work when LOWER and UPPER are set to 1. Workarounds this have not been found.
495
     // Umfpack only seems to work when LOWER and UPPER are set to 1. Workarounds this have not been found.

Loading…
Cancel
Save