Tpetra Matrix/Vector Services Version of the Day
RTIInlineCG_qd.cpp
00001 #include "RTIInlineCG.hpp"
00002 #include <qd/qd_real.h>
00003 
00004 int main(int argc, char *argv[])
00005 {
00006   using Tpetra::global_size_t;
00007   using Teuchos::RCP;
00008   using Teuchos::rcp;
00009   using Teuchos::Comm;
00010   using Teuchos::ParameterList;
00011 
00012   // 
00013   // Get the communicator
00014   //
00015   Teuchos::oblackholestream blackhole;
00016   Teuchos::GlobalMPISession mpiSession(&argc,&argv,&blackhole);
00017   auto comm = Tpetra::DefaultPlatform::getDefaultPlatform().getComm();
00018   const int myImageID = comm->getRank();
00019 
00020   //
00021   // Get example parameters from command-line processor
00022   //  
00023   bool verbose = (myImageID==0);
00024   std::string xmlfile;
00025   std::string machineFile;
00026 
00027   Teuchos::CommandLineProcessor cmdp(false,true);
00028   cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
00029   cmdp.setOption("param-file", &xmlfile,"XML file for solver parameters");
00030   cmdp.setOption("machine-file",&machineFile,"Filename for XML machine description file.");
00031   if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
00032     return -1;
00033   }
00034 
00035   // 
00036   // read machine file and initialize platform
00037   // 
00038   RCP<Teuchos::ParameterList> machinePL = Teuchos::parameterList();
00039   std::string defaultMachine(
00040     " <ParameterList>                                                               "
00041     "   <ParameterList name='%1=0'>                                                 "
00042     "     <Parameter name='NodeType'     type='string' value='Kokkos::SerialNode'/> "
00043     "   </ParameterList>                                                            "
00044     " </ParameterList>                                                              "
00045   );
00046   Teuchos::updateParametersFromXmlString(defaultMachine,machinePL.getRawPtr());
00047   if (machineFile != "") Teuchos::updateParametersFromXmlFile(machineFile,machinePL.getRawPtr());
00048 
00049   // 
00050   // create the platform object
00051   // 
00052   Tpetra::HybridPlatform platform(comm,*machinePL);
00053 
00054   //
00055   // instantiate a driver on the scalar stack
00056   //
00057   CGDriver<qd_real> driver;
00058   // hand output stream to driver
00059   if (verbose) driver.out = Teuchos::getFancyOStream(Teuchos::rcp(&std::cout,false));
00060   else         driver.out = Teuchos::getFancyOStream(Teuchos::rcp(new Teuchos::oblackholestream()));
00061 
00062   //
00063   // get the solver parameters
00064   // 
00065   RCP<Teuchos::ParameterList> params = Teuchos::parameterList();
00066   // default solver stack parameters
00067   std::string xmlString(
00068     " <ParameterList>                                                  \n"
00069     "   <Parameter name='tolerance' value='5e-15' type='double'/>      \n"
00070     "   <Parameter name='verbose' value='1' type='int'/>               \n"
00071     "   <Parameter name='kappa' value='100' type='double'/>            \n"
00072     "   <Parameter name='size'  value='100' type='int'/>               \n"
00073     "   <Parameter name='numIters' value='100' type='int'/>            \n"
00074     " </ParameterList>                                                 \n"
00075   );
00076   Teuchos::updateParametersFromXmlString(xmlString,params.getRawPtr());
00077   if (xmlfile != "") Teuchos::updateParametersFromXmlFile(xmlfile,params.getRawPtr());
00078   // hand solver parameters to driver
00079   driver.params = params;
00080 
00081   // 
00082   // run the driver
00083   // 
00084   unsigned int old_cw;
00085   fpu_fix_start(&old_cw);
00086   platform.runUserCode(driver);
00087   fpu_fix_end(&old_cw);
00088 
00089   //
00090   // Print result
00091   if (driver.testPassed) {
00092     *driver.out << "End Result: TEST PASSED" << std::endl;
00093   }
00094 
00095   return 0;
00096 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines