Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TestScalapack.cpp
Go to the documentation of this file.
1 //
2 // Knonw Bugs:
3 // Fails in test #6
4 // Tested only on SuperLU.rua
5 // Monstrously too many prints
6 // Fails on an assert when teseint glarger matrix
7 // Also in test #6 - try without test #6
8 //
9 // Epetra_CHK_ERRs look like negative values on return - and hence
10 // look like Amesos_Scalapack is not built in.
11 // PROPOSED SOLUTION: Set a BUILT flag for each AmesosClass
12 // verbose is not controlling print outs from Amesos_Scalapack -
13 // they are always on -DONE
14 // Failue in PDGETRS - FIXED
15 // debug is not being turned off in Amesos_ScaLAPACK - FIXED
16 //
17 //
18 //
19 
20 
21 
22 
23 
24 
25 
26 
27 #include "Epetra_Comm.h"
29 #include "Amesos.h"
30 #include "Epetra_CrsMatrix.h"
31 #include "Epetra_Map.h"
32 #include "Epetra_Vector.h"
33 #include "Epetra_LinearProblem.h"
34 #include "PerformOneSolveAndTest.h"
35 #include "TestScalapack.h"
36 
37 //
38 // Tests:
39 // 1) MaxProcs==100000
40 // 2) ComputeVectorNorms==true, MaxProcs==2
41 // 3) ComputeVectorNorms==true, MaxProcs==2, grid_mb_ =2, grid_nb_=2
42 // 4) ComputeTrueResidual==true, MaxProcs==1000 grid_mb_ =3, grid_nb_=3
43 // 5) "2D distribution"=false, ComputeTrueResidual=true, ComputeVectorNorms=true
44 // 6) no parameters
45 //
47  int EpetraMatrixType,
48  bool transpose,
49  bool verbose,
50  int Levels,
51  const double Rcond,
52  double &maxrelerror,
53  double &maxrelresidual,
54  int &NumTests ) {
55 
56  int NumErrors = 0 ;
57  maxrelerror = 0.0;
58  maxrelresidual = 0.0;
59  const Epetra_Comm& Comm = Amat->Comm();
60 
61 #if 1
62  //
63  // 1) MaxProcs==100000
64 
65  {
66  Teuchos::ParameterList ParamList ;
67  ParamList.set( "MaxProcs", 100000 );
68  // ParamList.print( std::cerr, 10 ) ;
69 
70  double relerror;
71  double relresidual;
72 
73  int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
74  EpetraMatrixType,
75  Comm,
76  transpose,
77  verbose,
78  ParamList,
79  Amat,
80  Levels,
81  Rcond,
82  relerror,
83  relresidual );
84 
85 
86  if (Errors < 0 ) {
87  NumErrors++;
88  NumTests++ ;
89  if ( verbose ) {
90  std::cout << "Amesos_Scalapack failed with error code " << Errors<< std::endl ;
91  }
92  } else {
93  NumErrors += Errors ;
94 
95  maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ;
96  maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ;
97  NumTests++ ;
98 
99  }
100  if (verbose) std::cout << " TestScalapack NumErrors = " << NumErrors
101  << __FILE__ << "::" << __LINE__
102  << std::endl ;
103  if ( verbose && Errors > 0 ) {
104  std::cout << "Amesos_Scalapack" << " failed with transpose = " <<
105  (transpose?"true":"false") << std::endl ;
106  }
107  }
108 
109  //
110  // 2) ComputeVectorNorms==true, MaxProcs==2
111  {
112  Teuchos::ParameterList ParamList ;
113  ParamList.set( "MaxProcs", 2 );
114  ParamList.set( "ComputeTrueResidual", true );
115  ParamList.set( "OutputLevel", 0 );
116  // ParamList.print( std::cerr, 10 ) ;
117 
118  double relerror;
119  double relresidual;
120 
121  int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
122  EpetraMatrixType,
123  Comm,
124  transpose,
125  verbose,
126  ParamList,
127  Amat,
128  Levels,
129  Rcond,
130  relerror,
131  relresidual ) ;
132 
133  if (Errors < 0 ) {
134  if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ;
135  return 0 ;
136  } else {
137  NumErrors += Errors ;
138 
139  maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ;
140  maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ;
141  NumTests++ ;
142 
143  }
144  if (verbose) std::cout << " TestScalapack NumErrors = " << NumErrors
145  << __FILE__ << "::" << __LINE__
146  << std::endl ;
147  if ( verbose && Errors > 0 ) {
148  std::cout << "Amesos_Scalapack" << " failed with transpose = " <<
149  (transpose?"true":"false") << std::endl ;
150  }
151  }
152 
153  //
154  // 3) ComputeVectorNorms==true, MaxProcs==2, grid_mb_ =2, grid_nb_=2
155  //
156  // These tests are disabled on atlantis - see bug #1888
157  //
158 #ifndef IRIX64
159  {
160  Teuchos::ParameterList ParamList ;
161  ParamList.set( "MaxProcs", 2 );
162  ParamList.set( "ComputeTrueResidual", true );
163  ParamList.set( "OutputLevel", 0 );
164  // ParamList.print( std::cerr, 10 ) ;
165  Teuchos::ParameterList& ScalapackParams = ParamList.sublist("Scalapack") ;
166 // ScalapackParams.set( "grid_mb", 2 );
167  ScalapackParams.set( "grid_nb", 2 );
168 
169  double relerror;
170  double relresidual;
171 
172  int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
173  EpetraMatrixType,
174  Comm,
175  transpose,
176  verbose,
177  ParamList,
178  Amat,
179  Levels,
180  Rcond,
181  relerror,
182  relresidual ) ;
183 
184  if (Errors < 0 ) {
185  if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ;
186  return 0 ;
187  } else {
188  NumErrors += Errors ;
189 
190  maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ;
191  maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ;
192  NumTests++ ;
193 
194  }
195  if (verbose) std::cout << " TestScalapack NumErrors = " << NumErrors << " "
196  << __FILE__ << "::" << __LINE__
197  << std::endl ;
198  if ( verbose && Errors > 0 ) {
199  std::cout << "Amesos_Scalapack" << " failed with transpose = " <<
200  (transpose?"true":"false") << std::endl ;
201  }
202  }
203  //
204  // 4) ComputeTrueResidual==true, MaxProcs==1000 grid_mb_ =3, grid_nb_=3
205  {
206  Teuchos::ParameterList ParamList ;
207  ParamList.set( "MaxProcs", 1000 );
208  ParamList.set( "ComputeTrueResidual", true );
209  ParamList.set( "OutputLevel", 0 );
210  Teuchos::ParameterList& ScalapackParams = ParamList.sublist("Scalapack") ;
211 // ScalapackParams.set( "grid_mb", 3 );
212  ScalapackParams.set( "grid_nb", 3 );
213 
214  double relerror;
215  double relresidual;
216 
217  int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
218  EpetraMatrixType,
219  Comm,
220  transpose,
221  verbose,
222  ParamList,
223  Amat,
224  Levels,
225  Rcond,
226  relerror,
227  relresidual ) ;
228 
229  if (Errors < 0 ) {
230  if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ;
231  return 0 ;
232  } else {
233  NumErrors += Errors ;
234 
235  maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ;
236  maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ;
237  NumTests++ ;
238 
239  }
240  if (verbose) std::cout
241  << __FILE__ << "::" << __LINE__
242  << " TestScalapack NumErrors = " << NumErrors << std::endl ;
243  if ( verbose && Errors > 0 ) {
244  std::cout << "Amesos_Scalapack" << " failed with transpose = " <<
245  (transpose?"true":"false") << std::endl ;
246  }
247  }
248 
249  //
250  // 5) "2D distribution"=false, ComputeTrueResidual=true, ComputeVectorNorms=true
251  {
252  Teuchos::ParameterList ParamList ;
253  ParamList.set( "MaxProcs", 1000 );
254  ParamList.set( "ComputeTrueResidual", true );
255  ParamList.set( "OutputLevel", 0 );
256  Teuchos::ParameterList& ScalapackParams = ParamList.sublist("Scalapack") ;
257  ScalapackParams.set( "2D distribution", false );
258 
259 
260  double relerror;
261  double relresidual;
262 
263  int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
264  EpetraMatrixType,
265  Comm,
266  transpose,
267  verbose,
268  ParamList,
269  Amat,
270  Levels,
271  Rcond,
272  relerror,
273  relresidual ) ;
274 
275  if (Errors < 0 ) {
276  if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ;
277  return 0 ;
278  } else {
279  NumErrors += Errors ;
280 
281  maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ;
282  maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ;
283  NumTests++ ;
284 
285  }
286  if (verbose) std::cout
287  << __FILE__ << "::" << __LINE__
288  << " TestScalapack NumErrors = " << NumErrors << std::endl ;
289  if ( verbose && Errors > 0 ) {
290  std::cout << "Amesos_Scalapack" << " failed with transpose = " <<
291  (transpose?"true":"false") << std::endl ;
292  }
293  }
294 #endif
295 
296 #endif
297 #if 1
298  //
299  // 6) no parameters
300  {
301  Teuchos::ParameterList ParamList ;
302  double relerror;
303  double relresidual;
304 
305  int Errors = PerformOneSolveAndTest("Amesos_Scalapack",
306  EpetraMatrixType,
307  Comm,
308  transpose,
309  verbose,
310  ParamList,
311  Amat,
312  Levels,
313  Rcond,
314  relerror,
315  relresidual ) ;
316 
317  if (Errors < 0 ) {
318  if (verbose ) std::cout << "Amesos_Scalapack" << " not built in this executable " << std::endl ;
319  return 0 ;
320  } else {
321  NumErrors += Errors ;
322 
323  maxrelerror = EPETRA_MAX( relerror, maxrelerror ) ;
324  maxrelresidual = EPETRA_MAX( relresidual, maxrelresidual ) ;
325  NumTests++ ;
326 
327  }
328  if (verbose) std::cout
329  << __FILE__ << "::" << __LINE__
330  << " TestScalapack NumErrors = " << NumErrors << std::endl ;
331  if ( verbose && Errors > 0 ) {
332  std::cout << "Amesos_Scalapack" << " failed with transpose = " <<
333  (transpose?"true":"false") << std::endl ;
334  }
335  }
336 #endif
337 
338 
339  return NumErrors;
340 }
341 
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static bool verbose
Definition: Amesos.cpp:67
RCP< ParameterList > sublist(const RCP< ParameterList > &paramList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
int TestScalapack(Epetra_CrsMatrix *&Amat, int EpetraMatrixType, bool transpose, bool verbose, int Levels, const double Rcond, double &maxrelerror, double &maxrelresidual, int &NumTests)
const Epetra_Comm & Comm() const
int PerformOneSolveAndTest(const char *AmesosClass, int EpetraMatrixType, const Epetra_Comm &Comm, bool transpose, bool verbose, Teuchos::ParameterList ParamList, Epetra_CrsMatrix *&InMat, int Levels, const double Rcond, double &relerror, double &relresidual, int ExpectedError)
#define EPETRA_MAX(x, y)