Amesos Package Browser (Single Doxygen Collection) Development
TestScalapack.cpp
Go to the documentation of this file.
00001 //
00002 //  Knonw Bugs: 
00003 //     Fails in test #6 
00004 //     Tested only on SuperLU.rua
00005 //     Monstrously too many prints
00006 //     Fails on an assert when teseint glarger matrix
00007 //        Also in test #6 - try without test #6 
00008 //
00009 //     Epetra_CHK_ERRs look like negative values on return - and hence
00010 //     look like Amesos_Scalapack is not built in. 
00011 //        PROPOSED SOLUTION:  Set a BUILT  flag for each AmesosClass 
00012 //     verbose is not controlling print outs from Amesos_Scalapack -
00013 //       they are always on  -DONE
00014 //     Failue in PDGETRS - FIXED 
00015 //     debug is not being turned off in Amesos_ScaLAPACK - FIXED
00016 //
00017 //
00018 //
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 #include "Epetra_Comm.h"
00028 #include "Teuchos_ParameterList.hpp"
00029 #include "Amesos.h"
00030 #include "Epetra_CrsMatrix.h"
00031 #include "Epetra_Map.h"
00032 #include "Epetra_Vector.h"
00033 #include "Epetra_LinearProblem.h"
00034 #include "PerformOneSolveAndTest.h"
00035 #include "TestScalapack.h"
00036 
00037 //
00038 //  Tests:
00039 //     1)  MaxProcs==100000
00040 //     2)  ComputeVectorNorms==true,  MaxProcs==2
00041 //     3)  ComputeVectorNorms==true,  MaxProcs==2, grid_mb_ =2, grid_nb_=2
00042 //     4)  ComputeTrueResidual==true,  MaxProcs==1000 grid_mb_ =3, grid_nb_=3
00043 //     5)  "2D distribution"=false, ComputeTrueResidual=true, ComputeVectorNorms=true
00044 //     6)  no parameters
00045 //
00046 int TestScalapack( Epetra_CrsMatrix *& Amat, 
00047         int EpetraMatrixType,
00048           bool transpose, 
00049           bool verbose, 
00050           int Levels,
00051           const double Rcond,
00052           double &maxrelerror, 
00053           double &maxrelresidual,
00054           int &NumTests ) {
00055   
00056   int NumErrors = 0 ;
00057   maxrelerror = 0.0;
00058   maxrelresidual = 0.0;
00059   const Epetra_Comm& Comm = Amat->Comm();
00060 
00061 #if 1
00062   //
00063   //     1)  MaxProcs==100000
00064 
00065   {
00066     Teuchos::ParameterList ParamList ;
00067     ParamList.set( "MaxProcs", 100000 );
00068     //  ParamList.print( std::cerr, 10 ) ; 
00069       
00070     double relerror;
00071     double relresidual;
00072       
00073     int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
00074           EpetraMatrixType,
00075           Comm, 
00076           transpose, 
00077           verbose,
00078           ParamList, 
00079           Amat, 
00080           Levels,
00081           Rcond, 
00082           relerror, 
00083           relresidual );
00084 
00085       
00086     if (Errors < 0 ) {
00087       NumErrors++;
00088       NumTests++ ; 
00089       if ( verbose ) {
00090   std::cout << "Amesos_Scalapack failed with error code " << Errors<< std::endl ; 
00091       }
00092     } else { 
00093       NumErrors += Errors ; 
00094   
00095       maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ; 
00096       maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ; 
00097       NumTests++ ; 
00098 
00099     }
00100     if (verbose)  std::cout << " TestScalapack NumErrors = " << NumErrors 
00101            << __FILE__ << "::" << __LINE__ 
00102            << std::endl ; 
00103     if ( verbose && Errors > 0 ) {
00104       std::cout << "Amesos_Scalapack" << " failed with transpose = " << 
00105   (transpose?"true":"false") << std::endl ;  
00106     }
00107   }
00108 
00109   //
00110   //     2)  ComputeVectorNorms==true,  MaxProcs==2
00111   {
00112     Teuchos::ParameterList ParamList ;
00113     ParamList.set( "MaxProcs", 2 );
00114     ParamList.set( "ComputeTrueResidual", true );
00115     ParamList.set( "OutputLevel", 0 );
00116     //  ParamList.print( std::cerr, 10 ) ; 
00117       
00118     double relerror;
00119     double relresidual;
00120       
00121     int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
00122           EpetraMatrixType,
00123           Comm, 
00124           transpose, 
00125           verbose,
00126           ParamList, 
00127           Amat, 
00128           Levels,
00129           Rcond, 
00130           relerror, 
00131           relresidual ) ; 
00132       
00133     if (Errors < 0 ) {
00134       if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ; 
00135       return 0 ; 
00136     } else { 
00137       NumErrors += Errors ; 
00138   
00139       maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ; 
00140       maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ; 
00141       NumTests++ ; 
00142 
00143     }
00144     if (verbose)  std::cout << " TestScalapack NumErrors = " << NumErrors 
00145            << __FILE__ << "::" << __LINE__ 
00146            << std::endl ; 
00147     if ( verbose && Errors > 0 ) {
00148       std::cout << "Amesos_Scalapack" << " failed with transpose = " << 
00149   (transpose?"true":"false") << std::endl ;  
00150     }
00151   }
00152 
00153   //
00154   //     3)  ComputeVectorNorms==true,  MaxProcs==2, grid_mb_ =2, grid_nb_=2
00155   //
00156   //     These tests are disabled on atlantis - see bug #1888
00157   //
00158 #ifndef IRIX64
00159   {
00160     Teuchos::ParameterList ParamList ;
00161     ParamList.set( "MaxProcs", 2 );
00162     ParamList.set( "ComputeTrueResidual", true );
00163     ParamList.set( "OutputLevel", 0 );
00164     //  ParamList.print( std::cerr, 10 ) ; 
00165     Teuchos::ParameterList& ScalapackParams = ParamList.sublist("Scalapack") ;
00166 //    ScalapackParams.set( "grid_mb", 2 );
00167     ScalapackParams.set( "grid_nb", 2 );
00168       
00169     double relerror;
00170     double relresidual;
00171       
00172     int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
00173           EpetraMatrixType,
00174           Comm, 
00175           transpose, 
00176           verbose,
00177           ParamList, 
00178           Amat, 
00179           Levels,
00180           Rcond, 
00181           relerror, 
00182           relresidual ) ; 
00183       
00184     if (Errors < 0 ) {
00185       if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ; 
00186       return 0 ; 
00187     } else { 
00188       NumErrors += Errors ; 
00189   
00190       maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ; 
00191       maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ; 
00192       NumTests++ ; 
00193 
00194     }
00195     if (verbose)  std::cout << " TestScalapack NumErrors = " << NumErrors << " "
00196            << __FILE__ << "::" << __LINE__ 
00197            << std::endl ; 
00198     if ( verbose && Errors > 0 ) {
00199       std::cout << "Amesos_Scalapack" << " failed with transpose = " << 
00200   (transpose?"true":"false") << std::endl ;  
00201     }
00202   }
00203   //
00204   //     4)  ComputeTrueResidual==true,  MaxProcs==1000 grid_mb_ =3, grid_nb_=3
00205   {
00206     Teuchos::ParameterList ParamList ;
00207     ParamList.set( "MaxProcs", 1000 );
00208     ParamList.set( "ComputeTrueResidual", true );
00209     ParamList.set( "OutputLevel", 0 );
00210     Teuchos::ParameterList& ScalapackParams = ParamList.sublist("Scalapack") ;
00211 //    ScalapackParams.set( "grid_mb", 3 );
00212     ScalapackParams.set( "grid_nb", 3 );
00213 
00214     double relerror;
00215     double relresidual;
00216       
00217     int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
00218           EpetraMatrixType,
00219           Comm, 
00220           transpose, 
00221           verbose,
00222           ParamList, 
00223           Amat, 
00224           Levels,
00225           Rcond, 
00226           relerror, 
00227           relresidual ) ; 
00228       
00229     if (Errors < 0 ) {
00230       if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ; 
00231       return 0 ; 
00232     } else { 
00233       NumErrors += Errors ; 
00234   
00235       maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ; 
00236       maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ; 
00237       NumTests++ ; 
00238 
00239     }
00240     if (verbose)  std::cout 
00241       << __FILE__ << "::" << __LINE__ 
00242       << " TestScalapack NumErrors = " << NumErrors << std::endl ; 
00243     if ( verbose && Errors > 0 ) {
00244       std::cout << "Amesos_Scalapack" << " failed with transpose = " << 
00245   (transpose?"true":"false") << std::endl ;  
00246     }
00247   }
00248 
00249   //
00250   //     5)  "2D distribution"=false, ComputeTrueResidual=true, ComputeVectorNorms=true
00251   {
00252     Teuchos::ParameterList ParamList ;
00253     ParamList.set( "MaxProcs", 1000 );
00254     ParamList.set( "ComputeTrueResidual", true );
00255     ParamList.set( "OutputLevel", 0 );
00256     Teuchos::ParameterList& ScalapackParams = ParamList.sublist("Scalapack") ;
00257     ScalapackParams.set( "2D distribution", false );
00258 
00259       
00260     double relerror;
00261     double relresidual;
00262       
00263     int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
00264           EpetraMatrixType,
00265           Comm, 
00266           transpose, 
00267           verbose,
00268           ParamList, 
00269           Amat, 
00270           Levels,
00271           Rcond, 
00272           relerror, 
00273           relresidual ) ; 
00274       
00275     if (Errors < 0 ) {
00276       if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ; 
00277       return 0 ; 
00278     } else { 
00279       NumErrors += Errors ; 
00280   
00281       maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ; 
00282       maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ; 
00283       NumTests++ ; 
00284 
00285     }
00286     if (verbose)  std::cout 
00287       << __FILE__ << "::" << __LINE__ 
00288       << " TestScalapack NumErrors = " << NumErrors << std::endl ; 
00289     if ( verbose && Errors > 0 ) {
00290       std::cout << "Amesos_Scalapack" << " failed with transpose = " << 
00291   (transpose?"true":"false") << std::endl ;  
00292     }
00293   }
00294 #endif
00295 
00296 #endif
00297 #if 1
00298   //
00299   //     6)  no parameters
00300   {
00301     Teuchos::ParameterList ParamList ;
00302     double relerror;
00303     double relresidual;
00304       
00305     int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
00306           EpetraMatrixType,
00307           Comm, 
00308           transpose, 
00309           verbose,
00310           ParamList, 
00311           Amat, 
00312           Levels,
00313           Rcond, 
00314           relerror, 
00315           relresidual ) ; 
00316       
00317     if (Errors < 0 ) {
00318       if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ; 
00319       return 0 ; 
00320     } else { 
00321       NumErrors += Errors ; 
00322   
00323       maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ; 
00324       maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ; 
00325       NumTests++ ; 
00326 
00327     }
00328     if (verbose)  std::cout 
00329       << __FILE__ << "::" << __LINE__ 
00330       << " TestScalapack NumErrors = " << NumErrors << std::endl ; 
00331     if ( verbose && Errors > 0 ) {
00332       std::cout << "Amesos_Scalapack" << " failed with transpose = " << 
00333   (transpose?"true":"false") << std::endl ;  
00334     }
00335   }
00336 #endif
00337 
00338 
00339     return NumErrors; 
00340 }
00341 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines