Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Amesos_Performance.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Amesos: Direct Sparse Solver Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25 //
26 // ***********************************************************************
27 // @HEADER
28 
29 //
30 // Amesos_TestDriver
31 //
32 // usage:
33 // Amesos_TestDriver.exe Solver InputMatrix Transpose MaxTimeIncr MaxErrorIncr MaxError MaxResid
34 // Where solver is: SuperLU, SuperLUdist, SuperLUdist2,
35 // UMFPACK, SPOOLES, DSCPACK, DSCPACKOLD, KLU,
36 // SPOOLESERIAL, MUMPS, SUPERLU, SCALAPACK or AZTEC
37 // special is, at present, only used in SuperLU, where 0 means dgssv
38 // and 1 means dgssvx
39 // examples:
40 // Solver - Amesos class name
41 // InputMatrix - matrix_market file name
42 // Transpose - "Trans" or "No Trans"
43 // Maximum increase in execution time (typically 0.10 to 0.20)
44 // Maximum increase in error (typically 2 to 10)
45 // MaxSymFactTime - Time for one symbolic factorization
46 // MaxNumFacttime - Time for one numeric factorization
47 // MaxSolveTime - Time for a single solve
48 // MaxBlockSolveTime - Per vector time for 16 blocked right hand sides
49 // MaxRefactTime - Time for a refactorization
50 // MaxMemory - Maximum memory used
51 // MaxError - Maximum scaled error
52 // MaxResid - Maximum scaled residual
53 //
54 // output:
55 // AmesosPerf.log (append)
56 // standard out
57 //
58 // exits with 0 if test completed (does not imply that the test passed)
59 // exits with -1 if command line options or file permissions are wrong
60 //
61 #include "Amesos_ConfigDefs.h"
62 
64 #include "Teuchos_Version.hpp"
65 
66 #ifdef HAVE_MPI
67 #include "mpi.h"
68 #endif
69 
70 // Enum for the speed option
72 
73 int main(int argc, char* argv[])
74 {
75 #ifdef HAVE_MPI
76  /* initialize MPI if we are running in parallel */
77  MPI_Init(&argc, &argv);
78  int procRank = -1;
79  MPI_Comm_rank( MPI_COMM_WORLD, &procRank );
80  if ( procRank == 0 )
81  std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
82 #else
83  std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
84 #endif
85 
86  // Creating an empty command line processor looks like:
88 
89  /* To set and option, it must be given a name and default value. Additionally,
90  each option can be given a help string. Although it is not necessary, a help
91  string aids a users comprehension of the acceptable command line arguments.
92  Some examples of setting command line options are:
93  */
94  // Set an integer command line option.
95  int NumIters = 1550;
96  My_CLP.setOption("iterations", &NumIters, "Number of iterations");
97  // Set a double-precision command line option.
98  double Tolerance = 1e-10;
99  My_CLP.setOption("tolerance", &Tolerance, "Tolerance");
100  // Set a string command line option.
101  std::string Solver = "GMRES";
102  My_CLP.setOption("solver", &Solver, "Linear solver");
103  // Set a boolean command line option.
104  bool Precondition;
105  My_CLP.setOption("precondition","no-precondition",
106  &Precondition,"Preconditioning flag");
107  // Set an enumeration command line option
108  const int num_speed_values = 3;
109  const ESpeed speed_opt_values[] = { SPEED_SLOW, SPEED_MEDIUM, SPEED_FAST };
110  const char* speed_opt_names[] = { "slow", "medium", "fast" };
111  ESpeed Speed = SPEED_MEDIUM;
112  My_CLP.setOption(
113  "speed", &Speed,
114  num_speed_values, speed_opt_values, speed_opt_names,
115  "Speed of our solver"
116  );
117 
118  /* There are also two methods that control the behavior of the
119  command line processor. First, for the command line processor to
120  allow an unrecognized a command line option to be ignored (and
121  only have a warning printed), use:
122  */
123  My_CLP.recogniseAllOptions(true);
124 
125  /* Second, by default, if the parser finds a command line option it
126  doesn't recognize or finds the --help option, it will throw an
127  exception. If you want prevent a command line processor from
128  throwing an exception (which is important in this program since
129  we don't have an try/catch around this) when it encounters a
130  unrecognized option or help is printed, use:
131  */
132  My_CLP.throwExceptions(false);
133 
134  /* We now parse the command line where argc and argv are passed to
135  the parse method. Note that since we have turned off exception
136  throwing above we had better grab the return argument so that
137  we can see what happened and act accordingly.
138  */
140  parseReturn= My_CLP.parse( argc, argv );
142 #ifdef HAVE_MPI
143  MPI_Finalize();
144 #endif
145  return 0;
146  }
148 #ifdef HAVE_MPI
149  MPI_Finalize();
150 #endif
151  return 1; // Error!
152  }
153  // Here is where you would use these command line arguments but for this example program
154  // we will just print the help message with the new values of the command-line arguments.
155 #ifdef HAVE_MPI
156  if (procRank == 0)
157 #endif
158  std::cout << "\nPrinting help message with new values of command-line arguments ...\n\n";
159  My_CLP.printHelpMessage(argv[0],std::cout);
160 
161  // Now we will print the option values
162 #ifdef HAVE_MPI
163  if (procRank == 0) {
164 #endif
165  std::cout << "\nPrinting user options after parsing ...\n\n";
166  std::cout << "NumIters = " << NumIters << std::endl;
167  std::cout << "Tolerance = " << Tolerance << std::endl;
168  std::cout << "Solver = \"" << Solver << "\"\n";
169  std::cout << "Precondition = " << Precondition << std::endl;
170  std::cout << "Speed = " << Speed << std::endl;
171 #ifdef HAVE_MPI
172  }
173  /* finalize MPI if we are running in parallel */
174  MPI_Finalize();
175 #endif
176 
177  return 0;
178 }
void recogniseAllOptions(const bool &recogniseAllOptions)
void printHelpMessage(const char program_name[], std::ostream &out) const
ESpeed
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
int main(int argc, char *argv[])
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
void throwExceptions(const bool &throwExceptions)
std::string Teuchos_Version()