Procházet zdrojové kódy

PaStiX support added, but not working

master
Trevor Irons před 6 roky
rodič
revize
bb782b5551
4 změnil soubory, kde provedl 127 přidání a 47 odebrání
  1. 23
    0
      CMakeLists.txt
  2. 10
    0
      examples/EMSchur3D.cpp
  3. 74
    27
      include/EMSchur3D.h
  4. 20
    20
      include/EMSchur3DBase.h

+ 23
- 0
CMakeLists.txt Zobrazit soubor

@@ -14,6 +14,20 @@ if (SUPERLU_FOUND)
14 14
 	INCLUDE_DIRECTORIES(${SUPERLU_INCLUDES})
15 15
 endif()
16 16
 
17
+find_package( PaSTiX )
18
+if ( PASTIX_FOUND )
19
+	message( STATUS "PaSTiX was found" )
20
+	add_compile_options(-DHAVE_PASTIX)
21
+	INCLUDE_DIRECTORIES(${PASTIX_INCLUDES})
22
+endif()
23
+
24
+find_package( Umfpack )
25
+if ( UMFPACK_FOUND )
26
+	message( STATUS "Umfpack was found" )
27
+	add_compile_options(-DHAVE_UMFPACK)
28
+	INCLUDE_DIRECTORIES(${UMFPACK_INCLUDES})
29
+endif()
30
+
17 31
 if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT OR LEMMA_VTK8_SUPPORT AND LEMMA_MODULE_EMSCHUR3D ) 
18 32
 
19 33
 	configure_file (
@@ -39,7 +53,16 @@ if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT OR LEMMA_VTK8_SUPPORT AND LEMMA_MO
39 53
 
40 54
 	# Linking
41 55
 	target_link_libraries(emschur3d ${VTK_LIBRARIES})
56
+if ( SUPERLU_FOUND )
42 57
 	target_link_libraries(emschur3d ${SUPERLU_LIBRARIES})
58
+endif()
59
+if ( PASTIX_FOUND )
60
+	target_link_libraries(emschur3d ${PASTIX_LIBRARIES})
61
+	target_link_libraries(emschur3d "blas" "metis" "scotch" "scotchmetis" "scotcherr" "scotcherrexit" "hwloc")
62
+endif()
63
+if ( UMFPACK_FOUND )
64
+	target_link_libraries(emschur3d ${UMFPACK_LIBRARIES})
65
+endif()
43 66
 
44 67
 	# Testing
45 68
 	if (LEMMA_ENABLE_TESTING)

+ 10
- 0
examples/EMSchur3D.cpp Zobrazit soubor

@@ -35,6 +35,16 @@ int main( int argc, char** argv ) {
35 35
     // SUPERLU
36 36
     auto EM3D = EMSchur3D< Eigen::SuperLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
37 37
 
38
+    // Eigen built-in
39
+    //auto EM3D = EMSchur3D< Eigen::SparseLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
40
+
41
+    // UmfPack
42
+    //auto EM3D = EMSchur3D< Eigen::UmfPackLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
43
+
44
+    // PaStiX
45
+    //auto EM3D = EMSchur3D< Eigen::PastixLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, true > >::NewSP();
46
+
47
+
38 48
     if (argc < 3) {
39 49
         std::cout << "EMSchur3D  <rgrid>  <1dmod> <3dmod>  <aemsurvey> " << std::endl;
40 50
         exit( EXIT_SUCCESS );

+ 74
- 27
include/EMSchur3D.h Zobrazit soubor

@@ -28,6 +28,15 @@
28 28
 #ifdef HAVE_SUPERLU
29 29
 #include "Eigen/SuperLUSupport"
30 30
 #endif
31
+
32
+#ifdef HAVE_UMFPACK
33
+#include <Eigen/UmfPackSupport>
34
+#endif
35
+
36
+#ifdef HAVE_PASTIX
37
+#include <Eigen/PaStiXSupport>
38
+#endif
39
+
31 40
 //#include "CSymSimplicialCholesky.h"
32 41
 
33 42
 namespace Lemma {
@@ -361,10 +370,9 @@ namespace Lemma {
361 370
         }
362 371
     }
363 372
 
364
-    #ifdef HAVE_SUPERLU
373
+#ifdef HAVE_SUPERLU
365 374
     template<>
366 375
     void EMSchur3D< Eigen::SuperLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::BuildCDirectSolver() {
367
-
368 376
         CSolver = new Eigen::SuperLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > [Omegas.size()];
369 377
 
370 378
         for (int iw=0; iw<Omegas.size(); ++iw) {
@@ -372,9 +380,10 @@ namespace Lemma {
372 380
             timer.begin();
373 381
 
374 382
             /* SuperLU */
375
-            CSolver[iw].options().DiagPivotThresh = 0.0;
383
+            // Recommended values for symmetric mode
384
+            CSolver[iw].options().DiagPivotThresh = 0.01;
376 385
             CSolver[iw].options().SymmetricMode = YES;
377
-            //CSolver[iw].options().ColPerm = MMD_AT_PLUS_A;
386
+            CSolver[iw].options().ColPerm = MMD_AT_PLUS_A;
378 387
             //CSolver[iw].options().Trans = NOTRANS;
379 388
             //CSolver[iw].options().ConditionNumber = NO;
380 389
             //std::cout << "SuperLU options:\n";
@@ -400,7 +409,7 @@ namespace Lemma {
400 409
 
401 410
         }
402 411
     }
403
-    #endif
412
+#endif
404 413
 
405 414
     template<>
406 415
     void EMSchur3D< Eigen::SparseLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::COLAMDOrdering<int> > >::BuildCDirectSolver() {
@@ -429,6 +438,39 @@ namespace Lemma {
429 438
         }
430 439
     }
431 440
 
441
+#ifdef HAVE_UMFPACK
442
+    // Umfpack only seems to work when LOWER and UPPER are set to 1. Workarounds this have not been found.
443
+    template<>
444
+    void EMSchur3D< Eigen::UmfPackLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::BuildCDirectSolver() {
445
+        CSolver = new Eigen::UmfPackLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > [Omegas.size()];
446
+        for (int iw=0; iw<Omegas.size(); ++iw) {
447
+            jsw_timer timer;
448
+            timer.begin();
449
+            /*  Complex system */
450
+            std::cout << "UmfPackLU pattern analyzing C_" << iw << ",";
451
+            std::cout.flush();
452
+
453
+            // Doesn't work, seg faults in solve
454
+            //Eigen::SparseMatrix<Complex> Csym = Cvec[iw].selfadjointView< Eigen::Lower >();
455
+
456
+            // Compiler errors get thrown with the view setting, good performance if LOWER and UPPER are set
457
+            // CSolver[iw].analyzePattern( Cvec[iw].selfadjointView< Eigen::Lower>() ); // Compiler error
458
+            CSolver[iw].analyzePattern( Cvec[iw] ); // requires LOWER=1 UPPER=1, double memory
459
+            // CSolver[iw].analyzePattern( Csym );     // seg faults
460
+            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
461
+
462
+            // factorize
463
+            timer.begin();
464
+            std::cout << "UmfPackLU factorising C_" << iw << ", ";
465
+            std::cout.flush();
466
+            // CSolver[iw].factorize( Cvec[iw].selfadjointView< Eigen::Lower>() );
467
+            CSolver[iw].factorize( Cvec[iw] );
468
+            // CSolver[iw].factorize( Csym );
469
+            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
470
+        }
471
+    }
472
+#endif
473
+
432 474
 //     template<>
433 475
 //     void EMSchur3D< Eigen::CholmodSupernodalLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower > > ::BuildCDirectSolver() {
434 476
 //         CSolver = new Eigen::CholmodSupernodalLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower > [Omegas.size()];
@@ -668,28 +710,33 @@ namespace Lemma {
668 710
 //         }
669 711
 //     }
670 712
 //
671
-//     template<>
672
-//     void EMSchur3D<   Eigen::PastixLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, true > > ::BuildCDirectSolver() {
673
-//         CSolver = new Eigen::PastixLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, true > [Omegas.size()];
674
-//         //MPI_Init(NULL, NULL);
675
-//         for (int iw=0; iw<Omegas.size(); ++iw) {
676
-//             Csym = Cvec[iw].selfadjointView<Eigen::Lower>();
677
-//             jsw_timer timer;
678
-//             timer.begin();
679
-//             /*  Complex system */
680
-//             std::cout << "PaStiX LU pattern analyzing C_" << iw << ",";
681
-//             std::cout.flush();
682
-//             CSolver[iw].compute( Csym );
683
-//             std::cout << "PaStiX LU Done C_" << iw << std::endl;;
684
-// //             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
685
-// //             // factorize
686
-// //             timer.begin();
687
-// //             std::cout << "PaStiX LU factorising C_" << iw << ", ";
688
-// //             std::cout.flush();
689
-// //             CSolver[iw].factorize( Csym );
690
-// //             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
691
-//         }
692
-//     }
713
+
714
+#ifdef HAVE_PASTIX
715
+    template<>
716
+    void EMSchur3D<   Eigen::PastixLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, true > > ::BuildCDirectSolver() {
717
+        CSolver = new Eigen::PastixLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, true > [Omegas.size()];
718
+
719
+        for (int iw=0; iw<Omegas.size(); ++iw) {
720
+            jsw_timer timer;
721
+            timer.begin();
722
+            /*  Complex system */
723
+            std::cout << "PastixLU pattern analyzing C_" << iw << ",";
724
+            std::cout.flush();
725
+            CSolver[iw].analyzePattern( Cvec[iw].selfadjointView< Eigen::Lower>() );
726
+            //CSolver[iw].analyzePattern( Cvec[iw] );
727
+            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
728
+
729
+            // factorize
730
+            timer.begin();
731
+            std::cout << "PastixLU factorising C_" << iw << ", ";
732
+            std::cout.flush();
733
+            CSolver[iw].factorize( Cvec[iw].selfadjointView< Eigen::Lower>() );
734
+            //CSolver[iw].factorize( Cvec[iw] );
735
+            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
736
+        }
737
+    }
738
+#endif
739
+
693 740
 
694 741
 }		// -----  end of Lemma  name  -----
695 742
 

+ 20
- 20
include/EMSchur3DBase.h Zobrazit soubor

@@ -44,26 +44,26 @@
44 44
 #include <Eigen/Sparse>
45 45
 //#include "bicgstab.h"
46 46
 
47
-// Solvers
48
-#ifdef HAVE_PASTIX
49
-#include <Eigen/PaStiXSupport>
50
-#endif
51
-
52
-#ifdef HAVE_METIS
53
-#include <Eigen/MetisSupport>
54
-#endif
55
-
56
-#ifdef HAVE_SUPERLU
57
-#include <Eigen/SuperLUSupport>
58
-#endif
59
-
60
-#ifdef HAVE_SUPERLUMT
61
-#include <Eigen/SuperLUMTSupport>
62
-#endif
63
-
64
-#ifdef HAVE_SPQR
65
-#include <Eigen/SPQRSupport>
66
-#endif
47
+// // Solvers
48
+// #ifdef HAVE_PASTIX
49
+// #include <Eigen/PaStiXSupport>
50
+// #endif
51
+//
52
+// #ifdef HAVE_METIS
53
+// #include <Eigen/MetisSupport>
54
+// #endif
55
+//
56
+// #ifdef HAVE_SUPERLU
57
+// #include <Eigen/SuperLUSupport>
58
+// #endif
59
+//
60
+// #ifdef HAVE_SUPERLUMT
61
+// #include <Eigen/SuperLUMTSupport>
62
+// #endif
63
+//
64
+// #ifdef HAVE_SPQR
65
+// #include <Eigen/SPQRSupport>
66
+// #endif
67 67
 
68 68
 // Cholmod Support won't compile typedef issue
69 69
 // #ifdef HAVE_CHOLMOD

Načítá se…
Zrušit
Uložit