#include <Teuchos_CommandLineProcessor.hpp>
#include <Teuchos_GlobalMPISession.hpp>
#include <Teuchos_oblackholestream.hpp>
#include <Teuchos_XMLParameterListHelpers.hpp>
#include <Tpetra_DefaultPlatform.hpp>
#undef HAVE_KOKKOSCLASSIC_THRUST
#include <Tpetra_HybridPlatform.hpp>
#include <TpetraExt_TypeStack.hpp>
#include <iostream>
#include "MultiPrecDriver.hpp"
int main(int argc, char *argv[])
{
using Teuchos::RCP;
using Teuchos::rcp;
using Teuchos::Comm;
using Teuchos::ParameterList;
Teuchos::oblackholestream blackhole;
Teuchos::GlobalMPISession mpiSession(&argc,&argv,&blackhole);
const int myImageID = comm->getRank();
bool verbose = (myImageID==0);
bool unfused = false;
std::string matfile;
std::string xmlfile;
std::string machineFile;
Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("matrix-file",&matfile,"Filename for matrix");
cmdp.setOption("param-file", &xmlfile,"XML file for solver parameters");
cmdp.setOption("machine-file",&machineFile,"Filename for XML machine description file.");
cmdp.setOption("unfused","no-unfused",&unfused,"Test unfused iteration.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
RCP<Teuchos::ParameterList> machinePL = Teuchos::parameterList();
std::string defaultMachine(
" <ParameterList> "
" <ParameterList name='%1=0'> "
" <Parameter name='NodeType' type='string' value='Kokkos::SerialNode'/> "
" </ParameterList> "
" </ParameterList> "
);
Teuchos::updateParametersFromXmlString(defaultMachine,machinePL.ptr());
if (machineFile != "") Teuchos::updateParametersFromXmlFile(machineFile,machinePL.ptr());
TPETRAEXT_TYPESTACK2(MPStack, double, float)
MultiPrecDriver<MPStack> driver;
if (verbose) driver.out = Teuchos::getFancyOStream(Teuchos::rcp(&std::cout,false));
else driver.out = Teuchos::getFancyOStream(Teuchos::rcp(new Teuchos::oblackholestream()));
driver.matrixFile = matfile;
driver.unfusedTest = unfused;
RCP<Teuchos::ParameterList> params = Teuchos::parameterList();
std::string xmlString(
" <ParameterList> \n"
" <Parameter name='tolerance' value='1e-15' type='double'/> \n"
" <Parameter name='verbose' value='2' type='int'/> \n"
" <ParameterList name='child'> \n"
" <Parameter name='tolerance' value='1e-7' type='double'/> \n"
" <Parameter name='verbose' value='1' type='int'/> \n"
" <Parameter name='Extract Diagonal' value='true' type='bool'/> \n"
" </ParameterList> \n"
" </ParameterList> \n"
);
Teuchos::updateParametersFromXmlString(xmlString,params.ptr());
if (xmlfile != "") Teuchos::updateParametersFromXmlFile(xmlfile,params.ptr());
driver.params = params;
platform.runUserCode(driver);
if (driver.testPassed) {
*driver.out << "End Result: TEST PASSED" << std::endl;
}
return 0;
}