64 #ifdef HAVE_SYS_UTSNAME_WORKS_H
76 #elif defined HAVE_IOMANIP_H
82 #define setprecision(a) ("")
103 #include "BridgeMPI.h"
110 int main(
int argc,
char **argv)
113 std::vector <double> BBval ;
119 MPI_Init(&argc,&argv);
125 Epetra_Object::SetTracebackMode( 2 );
126 int MyPID = Comm.
MyPID();
127 int NumMpiProcs = Comm.
NumProc();
136 const int MAX_TOLERANCE_RATIO = 10000 ;
138 const int MAXNAMELENGTH = 800;
140 #ifdef HAVE_SYS_UTSNAME_WORKS_H
143 char timebuffer[MAXNAMELENGTH];
145 std::string Sprogram ;
146 if ( argc >1 ) Sprogram = argv[1] ;
147 const int NUM_PARAMS = 9 ;
148 const int NUM_SUPERLU_PARAMS = NUM_PARAMS + 1 ;
149 const int NUM_SPOOLES_PARAMS = NUM_PARAMS + 6 ;
150 bool argc_ok = ( argc == NUM_PARAMS ) ;
151 if ( argc == NUM_SPOOLES_PARAMS && Sprogram ==
"SPOOLES" ) argc_ok = true ;
152 if ( argc == NUM_SPOOLES_PARAMS && Sprogram ==
"SPOOLESSERIAL" )
155 if ( argc == NUM_SUPERLU_PARAMS && Sprogram ==
"SuperLU" )
164 std::cerr <<
" argc = " << argc <<
" Sprogam= " << Sprogram <<
165 " SPOOLES? " << (int) (Sprogram==
"SPOOLES") << std::endl ;
166 std::cerr <<
"Usage: " << argv[0] <<
" SolverName InputMatrix special numsolves transpose maxerror maxresid" << std::endl ;
167 std::cerr <<
" Solvername = UMFPACK, SUPERLUDIST, TAUCS, PARDISO, PARAKLETE, MUMPS, KLU, SUPERLU" << std::endl;
168 std::cerr <<
" InputMatrix must be a file in Harwell Boeing format"<< std::endl;
169 std::cerr <<
" special = number of repeats (0 means run just once) " << std::endl ;
170 std::cerr <<
" numsolves = number of right hand sidess (<0 means MRHS, >1 means BRHS) " << std::endl ;
171 std::cerr <<
" transpose = 1 means test A^T x = b instead of Ax = b" << std::endl ;
172 std::cerr <<
" maxerror = maximum allowed error < 0 == no check " << std::endl ;
173 std::cerr <<
" maxresid = maximum allowed residual < 0 == no check" << std::endl ;
174 std::cerr <<
" if maxerror == -2 and maxresid == -2, failure (hang or abort) is expected" << std::endl ;
175 std::cerr <<
" if maxerror == 1e30 and maxresid == 1e30, the solver is expected to finish but produce incorrect results" << std::endl ;
185 #ifdef HAVE_SYS_UTSNAME_WORKS_H
186 int uname_stat = uname( &uname_buf ) ;
190 time_t now = time( NULL ) ;
191 tm *localnow = localtime( &now ) ;
192 (void) strftime( timebuffer, MAXNAMELENGTH,
"20%g%b%d@%H:%M:%S", localnow ) ;
194 strcpy( timebuffer,
"unknown date" ) ;
201 char *ShortOutputFileName = (
char *)
"SST.summary" ;
202 char *LongOutputFileName = (
char *)
"SST.log" ;
204 bool summary = MyPID == 0 ;
205 #ifdef AMESOS_TEST_VERBOSE
206 bool verbose = ( MyPID == 0 ) &&
true ;
208 bool verbose = ( MyPID == 0 ) &&
false ;
210 bool log = MyPID == 0 ;
216 std::ofstream summary_file;
218 if ( ( MyPID == 0 ) ) {
219 matrix_fd = fopen( argv[2],
"r" ) ;
220 if ( matrix_fd == NULL ) {
221 std::cerr <<
"Unable to open " << argv[2] <<
" for reading" << std::endl ;
224 fclose( matrix_fd ) ;
230 std::cerr <<
"Unable to open " << LongOutputFileName <<
" for writing" << std::endl ;
236 summary_file.open( ShortOutputFileName, std::ios::app ) ;
237 if ( summary_file.fail() ) {
238 std::cerr <<
"Unable to open " << ShortOutputFileName <<
" for writing" << std::endl ;
249 int MatType = atoi( argv[3] ) ;
250 int special = atoi( argv[4] ) ;
251 int numsolves = atoi( argv[5] ) ;
252 int transpose = atoi( argv[6] ) ;
253 double maxerror = atof( argv[7] ) ;
254 double maxresid = atof( argv[8] ) ;
256 if ( Sprogram ==
"LAPACK" )
258 else if ( Sprogram ==
"KLU" )
260 else if ( Sprogram ==
"UMFPACK" )
262 else if ( Sprogram ==
"SUPERLU" )
264 else if ( Sprogram ==
"SUPERLUDIST" )
266 else if ( Sprogram ==
"DSCPACK" )
268 else if ( Sprogram ==
"TAUCS" )
269 SparseSolver =
TAUCS ;
270 else if ( Sprogram ==
"PARDISO" )
272 else if ( Sprogram ==
"PARAKLETE" )
274 else if ( Sprogram ==
"MUMPS" )
275 SparseSolver =
MUMPS ;
276 else if ( Sprogram ==
"SCALAPACK" )
279 if (( MyPID == 0 ) ) std::cerr <<
"Unknown program: " << Sprogram << std::endl ;
285 #ifndef HAVE_AMESOS_KLU
286 if (SparseSolver ==
KLU) {
287 std::cerr <<
"KLU is not installed..." << std::endl;
291 #ifndef HAVE_AMESOS_UMFPACK
293 std::cerr <<
"UMFPACK is not installed..." << std::endl;
297 #ifndef HAVE_AMESOS_SUPERLU
299 std::cerr <<
"SUPERLU is not installed..." << std::endl;
303 #ifndef HAVE_AMESOS_SUPERLUDIST
305 std::cerr <<
"SUPERLUDIST is not installed..." << std::endl;
309 #ifndef HAVE_AMESOS_TAUCS
310 if (SparseSolver ==
TAUCS) {
311 std::cerr <<
"TAUCS is not installed..." << std::endl;
315 #ifndef HAVE_AMESOS_PARDISO
317 std::cerr <<
"PARDISO is not installed..." << std::endl;
321 #ifndef HAVE_AMESOS_PARAKLETE
323 std::cerr <<
"PARAKLETE is not installed..." << std::endl;
327 #ifndef HAVE_AMESOS_MUMPS
328 if (SparseSolver ==
MUMPS) {
329 std::cerr <<
"MUMPS is not installed..." << std::endl;
333 #ifndef HAVE_AMESOS_SCALAPACK
335 std::cerr <<
"SCALAPACK is not installed..." << std::endl;
339 #ifndef HAVE_AMESOS_DSCPACK
341 std::cerr <<
"DSCPACK is not installed..." << std::endl;
347 if ( argc == NUM_SUPERLU_PARAMS &&
348 ( Sprogram ==
"SuperLU" || Sprogram ==
"SuperLUdist" ) ) {
353 const int MaxNumSolves = 3200 ;
354 if ( MatType < 0 || MatType > 1 ) {
355 if ( ( MyPID == 0 ) )
356 std::cerr <<
" MatType must be 0 or 1, is: "
357 << MatType << std::endl ;
360 if ( special < 0 || special > 10000 ) {
361 if ( ( MyPID == 0 ) )
362 std::cerr <<
" No more than 10000 repeats allowed"
363 << special << std::endl ;
366 if ( numsolves< -MaxNumSolves || numsolves > MaxNumSolves ) {
367 if ( ( MyPID == 0 ) )
368 std::cerr <<
"The number of solves must be between 0 and " << MaxNumSolves
370 << numsolves << std::endl ;
373 if ( transpose< 0 || transpose > 1) {
374 if ( ( MyPID == 0 ) )
375 std::cerr <<
"transpose must be 0 (no trans) or 1"
377 << transpose << std::endl ;
380 if ( transpose != 0 && SparseSolver ==
SUPERLUDIST ) {
381 if ( ( MyPID == 0 ) )
382 std::cerr <<
"Our use of SUPERLUDIST does not support transpose yet" << std::endl ;
385 if ( numsolves != 1 &&
390 SparseSolver !=
KLU &&
391 SparseSolver !=
TAUCS &&
394 SparseSolver !=
MUMPS &&
397 if ( ( MyPID == 0 ) )
398 std::cerr <<
"Only LAPACK, SUPERLUDIST, UMFPACK, TAUCS, PARDISO, PARAKLETE, MUMPS, SCALAPACK, KLU and DSCPACK support MRHS and BRHS" << std::endl ;
403 #ifdef HAVE_SYS_UTSNAME_WORKS_H
404 char *hostname = uname_buf.nodename ;
405 char *releasenum = uname_buf.release;
407 char *hostname = (
char *)
"";
414 if ( exit_value == 0 ) {
425 << argv[1] <<
" " << timebuffer
426 <<
" BEGIN RUN" << std::endl ;
427 #ifdef HAVE_SYS_UTSNAME_WORKS_H
429 hostname << releasenum << uname_buf.version <<
430 uname_buf.machine << std::endl ;
434 summary_file << std::endl <<
setw(12) << hostname <<
" "
435 <<
setw(12) << argv[1]
436 <<
" " <<
setw(-1) << timebuffer <<
" "
437 <<
setw(15) << argv[2] <<
setw(6) <<
" "
440 << NumMpiProcs <<
setw(6) <<
" "
442 if ( maxresid == -2 && maxerror == -2 ) summary_file <<
"Failure OK" ;
443 flush( summary_file ) ;
447 std::cerr << std::endl <<
setw(12) << hostname
448 <<
setw(12) << argv[1]
449 <<
" " <<
setw(-1) << timebuffer
453 << NumMpiProcs <<
setw(6) <<
" "
455 if ( maxresid == -2 && maxerror == -2 ) std::cerr <<
"Failure OK" ;
466 if ( numsolves < 0 ) {
467 Amesos_TestMrhsSolver( Comm, argv[2], - numsolves, SparseSolver, (transpose==1), special, MatrixType ) ;
469 if ( numsolves > 1 ) {
472 Amesos_TestSolver( Comm, argv[2], SparseSolver, (transpose==1), special, MatrixType ) ;
487 << argv[1] << timebuffer
488 <<
" END RUN" << std::endl ;
491 <<
setw(12) << hostname <<
setw(9) << argv[1]
492 <<
" " <<
setw(-1) << timebuffer
493 <<
setw(15) << argv[2] <<
setw(6) << NumMpiProcs <<
setw(6)
495 << numsolves <<
setw(6)
507 bool ErrorOK = maxerror <= -1 ||
509 bool ResidualOK = maxresid <= -1 ||
511 if ( ErrorOK && ResidualOK ) summary_file <<
" OK" ;
512 if ( ErrorOK && ResidualOK && verbose ) std::cerr <<
" OK" ;
514 summary_file <<
" Error too large is: " <<
516 " should be < " << maxerror ;
517 std::cerr <<
" Error too large is: " <<
519 " should be < " << maxerror ;
530 if (maxerror == 1e30 ) maxerror = 10 ;
532 maxerror > 1.1e-14 ) {
533 summary_file <<
" Error TOLERANCE is too large: " <<
535 " is allowed to be " << maxerror ;
537 std::cerr <<
" Error TOLERANCE is too large: " <<
539 " is allowed to be " << maxerror ;
542 if ( ! ResidualOK ) {
543 summary_file <<
" Residual too large is:" <<
545 " should be < " << maxresid ;
546 std::cerr <<
" Residual too large is:" <<
548 " should be < " << maxresid ;
551 if (maxresid == 1e30 ) maxresid = 10 ;
553 maxresid > 1.1e-14 ) {
554 summary_file <<
" Residual TOLERANCE is too large: " <<
556 " is allowed to be " << maxresid ;
558 std::cerr <<
" Residual TOLERANCE is too large: " <<
560 " is allowed to be " << maxresid ;
564 flush( summary_file ) ;
566 std::cerr << std::endl ;
571 catch(
const std::string &errormsg)
573 if ( summary ) { summary_file << errormsg ; }
575 if ( ( verbose ) || summary ) std::cerr << errormsg << std::endl;
580 if ( summary ) summary_file.close() ;
virtual void PrintSummary(std::ostream &os) const
int Amesos_TestMrhsSolver(Epetra_Comm &Comm, char *matrix_file, int numsolves, SparseSolverType SparseSolver, bool transpose, int special, AMESOS_MatrixType matrix_type)
int Amesos_TestSolver(Epetra_Comm &Comm, char *matrix_file, SparseSolverType SparseSolver, bool transpose, int special, AMESOS_MatrixType matrix_type)
int main(int argc, char *argv[])
int Amesos_TestMultiSolver(Epetra_Comm &Comm, char *matrix_file, int numsolves, SparseSolverType SparseSolver, bool transpose, int special, AMESOS_MatrixType matrix_type)
static std::ofstream log_file
int Broadcast(double *MyVals, int Count, int Root) const
static SparseSolverResult SS_Result