66 #ifdef HAVE_SYS_UTSNAME_WORKS_H
78 #elif defined HAVE_IOMANIP_H
84 #define setprecision(a) ("")
105 #include "BridgeMPI.h"
112 int main(
int argc,
char **argv)
115 MPI_Init(&argc,&argv);
120 int MyPID = Comm.
MyPID();
121 int NumMpiProcs = Comm.
NumProc();
122 bool summary = MyPID == 0 ;
128 std::ofstream summary_file;
136 std::vector <double> BBval;
138 Epetra_Object::SetTracebackMode( 2 );
147 const int MAX_TOLERANCE_RATIO = 10000 ;
148 const int MAXNAMELENGTH = 800;
150 #ifdef HAVE_SYS_UTSNAME_WORKS_H
153 char timebuffer[MAXNAMELENGTH];
155 std::string Sprogram ;
156 if ( argc >1 ) Sprogram = argv[1] ;
157 const int NUM_PARAMS = 9 ;
158 const int NUM_SUPERLU_PARAMS = NUM_PARAMS + 1 ;
159 const int NUM_SPOOLES_PARAMS = NUM_PARAMS + 6 ;
160 bool argc_ok = ( argc == NUM_PARAMS ) ;
161 if ( argc == NUM_SPOOLES_PARAMS && Sprogram ==
"SPOOLES" ) argc_ok = true ;
162 if ( argc == NUM_SPOOLES_PARAMS && Sprogram ==
"SPOOLESSERIAL" )
165 if ( argc == NUM_SUPERLU_PARAMS && Sprogram ==
"SuperLU" )
174 std::cerr <<
" argc = " << argc <<
" Sprogam= " << Sprogram <<
175 " SPOOLES? " << (int) (Sprogram==
"SPOOLES") << std::endl ;
176 std::cerr <<
"Usage: " << argv[0] <<
" SolverName InputMatrix special numsolves transpose maxerror maxresid" << std::endl ;
177 std::cerr <<
" Solvername = UMFPACK, SUPERLUDIST, TAUCS, PARDISO, CSS, PARAKLETE, MUMPS, KLU, SUPERLU" << std::endl;
178 std::cerr <<
" InputMatrix must be a file in Harwell Boeing format"<< std::endl;
179 std::cerr <<
" special = number of repeats (0 means run just once) " << std::endl ;
180 std::cerr <<
" numsolves = number of right hand sidess (<0 means MRHS, >1 means BRHS) " << std::endl ;
181 std::cerr <<
" transpose = 1 means test A^T x = b instead of Ax = b" << std::endl ;
182 std::cerr <<
" maxerror = maximum allowed error < 0 == no check " << std::endl ;
183 std::cerr <<
" maxresid = maximum allowed residual < 0 == no check" << std::endl ;
184 std::cerr <<
" if maxerror == -2 and maxresid == -2, failure (hang or abort) is expected" << std::endl ;
185 std::cerr <<
" if maxerror == 1e30 and maxresid == 1e30, the solver is expected to finish but produce incorrect results" << std::endl ;
194 #ifdef HAVE_SYS_UTSNAME_WORKS_H
195 int uname_stat = uname( &uname_buf ) ;
199 time_t now = time( NULL ) ;
200 tm *localnow = localtime( &now ) ;
201 (void) strftime( timebuffer, MAXNAMELENGTH,
"20%g%b%d@%H:%M:%S", localnow ) ;
203 strcpy( timebuffer,
"unknown date" ) ;
210 char *ShortOutputFileName = (
char *)
"SST.summary" ;
211 char *LongOutputFileName = (
char *)
"SST.log" ;
213 #ifdef AMESOS_TEST_VERBOSE
214 bool verbose = ( MyPID == 0 ) &&
true ;
216 bool verbose = ( MyPID == 0 ) &&
false ;
218 bool log = MyPID == 0 ;
223 if ( ( MyPID == 0 ) ) {
224 matrix_fd = fopen( argv[2],
"r" ) ;
225 if ( matrix_fd == NULL ) {
226 std::cerr <<
"Unable to open " << argv[2] <<
" for reading" << std::endl ;
229 fclose( matrix_fd ) ;
235 std::cerr <<
"Unable to open " << LongOutputFileName <<
" for writing" << std::endl ;
241 summary_file.open( ShortOutputFileName, std::ios::app ) ;
242 if ( summary_file.fail() ) {
243 std::cerr <<
"Unable to open " << ShortOutputFileName <<
" for writing" << std::endl ;
254 int MatType = atoi( argv[3] ) ;
255 int special = atoi( argv[4] ) ;
256 int numsolves = atoi( argv[5] ) ;
257 int transpose = atoi( argv[6] ) ;
258 double maxerror = atof( argv[7] ) ;
259 double maxresid = atof( argv[8] ) ;
261 if ( Sprogram ==
"LAPACK" )
263 else if ( Sprogram ==
"KLU" )
265 else if ( Sprogram ==
"UMFPACK" )
267 else if ( Sprogram ==
"SUPERLU" )
269 else if ( Sprogram ==
"SUPERLUDIST" )
271 else if ( Sprogram ==
"DSCPACK" )
273 else if ( Sprogram ==
"TAUCS" )
274 SparseSolver =
TAUCS ;
275 else if ( Sprogram ==
"PARDISO" )
277 else if ( Sprogram ==
"CSS" )
279 else if ( Sprogram ==
"PARAKLETE" )
281 else if ( Sprogram ==
"MUMPS" )
282 SparseSolver =
MUMPS ;
283 else if ( Sprogram ==
"SCALAPACK" )
286 if (( MyPID == 0 ) ) std::cerr <<
"Unknown program: " << Sprogram << std::endl ;
292 #ifndef HAVE_AMESOS_KLU
293 if (SparseSolver ==
KLU) {
294 std::cerr <<
"KLU is not installed..." << std::endl;
298 #ifndef HAVE_AMESOS_UMFPACK
300 std::cerr <<
"UMFPACK is not installed..." << std::endl;
304 #ifndef HAVE_AMESOS_SUPERLU
306 std::cerr <<
"SUPERLU is not installed..." << std::endl;
310 #ifndef HAVE_AMESOS_SUPERLUDIST
312 std::cerr <<
"SUPERLUDIST is not installed..." << std::endl;
316 #ifndef HAVE_AMESOS_TAUCS
317 if (SparseSolver ==
TAUCS) {
318 std::cerr <<
"TAUCS is not installed..." << std::endl;
322 #if !defined(HAVE_AMESOS_PARDISO) && !defined(HAVE_AMESOS_PARDISO_MKL)
324 std::cerr <<
"PARDISO is not installed..." << std::endl;
328 #if !defined(HAVE_AMESOS_PARDISO_MKL) || !defined(HAVE_MPI)
329 if (SparseSolver ==
CSS) {
330 std::cerr <<
"CSS is not installed..." << std::endl;
334 #ifndef HAVE_AMESOS_PARAKLETE
336 std::cerr <<
"PARAKLETE is not installed..." << std::endl;
340 #ifndef HAVE_AMESOS_MUMPS
341 if (SparseSolver ==
MUMPS) {
342 std::cerr <<
"MUMPS is not installed..." << std::endl;
346 #ifndef HAVE_AMESOS_SCALAPACK
348 std::cerr <<
"SCALAPACK is not installed..." << std::endl;
352 #ifndef HAVE_AMESOS_DSCPACK
354 std::cerr <<
"DSCPACK is not installed..." << std::endl;
360 if ( argc == NUM_SUPERLU_PARAMS &&
361 ( Sprogram ==
"SuperLU" || Sprogram ==
"SuperLUdist" ) ) {
366 const int MaxNumSolves = 3200 ;
367 if ( MatType < 0 || MatType > 1 ) {
368 if ( ( MyPID == 0 ) )
369 std::cerr <<
" MatType must be 0 or 1, is: "
370 << MatType << std::endl ;
373 if ( special < 0 || special > 10000 ) {
374 if ( ( MyPID == 0 ) )
375 std::cerr <<
" No more than 10000 repeats allowed"
376 << special << std::endl ;
379 if ( numsolves< -MaxNumSolves || numsolves > MaxNumSolves ) {
380 if ( ( MyPID == 0 ) )
381 std::cerr <<
"The number of solves must be between 0 and " << MaxNumSolves
383 << numsolves << std::endl ;
386 if ( transpose< 0 || transpose > 1) {
387 if ( ( MyPID == 0 ) )
388 std::cerr <<
"transpose must be 0 (no trans) or 1"
390 << transpose << std::endl ;
393 if ( transpose != 0 && SparseSolver ==
SUPERLUDIST ) {
394 if ( ( MyPID == 0 ) )
395 std::cerr <<
"Our use of SUPERLUDIST does not support transpose yet" << std::endl ;
398 if ( numsolves != 1 &&
403 SparseSolver !=
KLU &&
404 SparseSolver !=
TAUCS &&
406 SparseSolver !=
CSS &&
408 SparseSolver !=
MUMPS &&
411 if ( ( MyPID == 0 ) )
412 std::cerr <<
"Only LAPACK, SUPERLUDIST, UMFPACK, TAUCS, PARDISO, CSS, PARAKLETE, MUMPS, SCALAPACK, KLU and DSCPACK support MRHS and BRHS" << std::endl ;
417 #ifdef HAVE_SYS_UTSNAME_WORKS_H
418 char *hostname = uname_buf.nodename ;
419 char *releasenum = uname_buf.release;
421 char *hostname = (
char *)
"";
428 if ( exit_value == 0 ) {
439 << argv[1] <<
" " << timebuffer
440 <<
" BEGIN RUN" << std::endl ;
441 #ifdef HAVE_SYS_UTSNAME_WORKS_H
443 hostname << releasenum << uname_buf.version <<
444 uname_buf.machine << std::endl ;
448 summary_file << std::endl <<
setw(12) << hostname <<
" "
449 <<
setw(12) << argv[1]
450 <<
" " <<
setw(-1) << timebuffer <<
" "
451 <<
setw(15) << argv[2] <<
setw(6) <<
" "
454 << NumMpiProcs <<
setw(6) <<
" "
456 if ( maxresid == -2 && maxerror == -2 ) summary_file <<
"Failure OK" ;
457 flush( summary_file ) ;
461 std::cerr << std::endl <<
setw(12) << hostname
462 <<
setw(12) << argv[1]
463 <<
" " <<
setw(-1) << timebuffer
467 << NumMpiProcs <<
setw(6) <<
" "
469 if ( maxresid == -2 && maxerror == -2 ) std::cerr <<
"Failure OK" ;
480 if ( numsolves < 0 ) {
481 Amesos_TestMrhsSolver( Comm, argv[2], - numsolves, SparseSolver, (transpose==1), special, MatrixType ) ;
483 if ( numsolves > 1 ) {
486 Amesos_TestSolver( Comm, argv[2], SparseSolver, (transpose==1), special, MatrixType ) ;
501 << argv[1] << timebuffer
502 <<
" END RUN" << std::endl ;
505 <<
setw(12) << hostname <<
setw(9) << argv[1]
506 <<
" " <<
setw(-1) << timebuffer
507 <<
setw(15) << argv[2] <<
setw(6) << NumMpiProcs <<
setw(6)
509 << numsolves <<
setw(6)
521 bool ErrorOK = maxerror <= -1 ||
523 bool ResidualOK = maxresid <= -1 ||
525 if ( ErrorOK && ResidualOK ) summary_file <<
" OK" ;
526 if ( ErrorOK && ResidualOK && verbose ) std::cerr <<
" OK" ;
528 summary_file <<
" Error too large is: " <<
530 " should be < " << maxerror ;
531 std::cerr <<
" Error too large is: " <<
533 " should be < " << maxerror ;
544 if (maxerror == 1e30 ) maxerror = 10 ;
546 maxerror > 1.1e-14 ) {
547 summary_file <<
" Error TOLERANCE is too large: " <<
549 " is allowed to be " << maxerror ;
551 std::cerr <<
" Error TOLERANCE is too large: " <<
553 " is allowed to be " << maxerror ;
556 if ( ! ResidualOK ) {
557 summary_file <<
" Residual too large is:" <<
559 " should be < " << maxresid ;
560 std::cerr <<
" Residual too large is:" <<
562 " should be < " << maxresid ;
565 if (maxresid == 1e30 ) maxresid = 10 ;
567 maxresid > 1.1e-14 ) {
568 summary_file <<
" Residual TOLERANCE is too large: " <<
570 " is allowed to be " << maxresid ;
572 std::cerr <<
" Residual TOLERANCE is too large: " <<
574 " is allowed to be " << maxresid ;
578 flush( summary_file ) ;
580 std::cerr << std::endl ;
585 catch(
const std::string &errormsg)
587 if ( summary ) { summary_file << errormsg ; }
589 if ( ( verbose ) || summary ) std::cerr << errormsg << std::endl;
604 auto comm =
Teuchos::rcp(
new Teuchos::MpiComm<int>(Comm.Comm()));
608 stackedTimer->
report(std::cout, comm, options);
610 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)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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[])
static void setStackedTimer(const Teuchos::RCP< Teuchos::StackedTimer > &t)
int Amesos_TestMultiSolver(Epetra_Comm &Comm, char *matrix_file, int numsolves, SparseSolverType SparseSolver, bool transpose, int special, AMESOS_MatrixType matrix_type)
void report(std::ostream &os)
static std::ofstream log_file
int Broadcast(double *MyVals, int Count, int Root) const
static SparseSolverResult SS_Result