Skip to content

Commit

Permalink
Merge pull request #3099 from mhoemmen/Anasazi-purge-DefaultPlatform
Browse files Browse the repository at this point in the history
Anasazi: Purge use of Tpetra::DefaultPlatform from tests & examples
  • Loading branch information
mhoemmen authored Jul 13, 2018
2 parents 8e9d4ba + 9b6a0f9 commit 2fb1016
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "AnasaziTypes.hpp"

#include "Teuchos_GlobalMPISession.hpp"
#include "Tpetra_DefaultPlatform.hpp"
#include "Tpetra_Core.hpp"
#include "MatrixMarket_Tpetra.hpp"

// These tell the compiler which namespace contains RCP, cout, etc
Expand Down Expand Up @@ -250,21 +250,15 @@ main (int argc, char* argv[])
typedef Anasazi::BasicEigenproblem<Scalar,TMV,TOP> Problem;
typedef Anasazi::MultiVecTraits<Scalar, TMV> TMVT;
typedef Anasazi::OperatorTraits<Scalar, TMV, TOP> TOPT;
typedef Tpetra::Map<>::node_type Node;
typedef Tpetra::CrsMatrix<> CrsMatrix;
typedef Tpetra::MatrixMarket::Reader<CrsMatrix> Reader;

//
// Initialize the MPI session
//
Teuchos::oblackholestream blackhole;
Teuchos::GlobalMPISession mpiSession (&argc, &argv, &blackhole);
Tpetra::ScopeGuard tpetraScope (&argc, &argv);

//
// Get the default communicator
//
RCP<const Teuchos::Comm<int> > comm = Tpetra::DefaultPlatform::getDefaultPlatform ().getComm ();
RCP<Node> node = Tpetra::DefaultPlatform::getDefaultPlatform ().getNode ();
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();
const int myRank = comm->getRank();

// Read the command line arguments
Expand All @@ -276,6 +270,7 @@ main (int argc, char* argv[])
}

// Get the matrix
Teuchos::RCP<Tpetra::Map<>::node_type> node; // for type deduction
RCP<const CrsMatrix> A = Reader::readSparseFile (fileA, comm, node);

// Create the folded operator, K = A^2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

// Include header for Tpetra compressed-row storage matrix
#include "Tpetra_CrsMatrix.hpp"
#include "Tpetra_DefaultPlatform.hpp"
#include "Tpetra_Core.hpp"
#include "Tpetra_Version.hpp"
#include "Tpetra_Map.hpp"
#include "Tpetra_MultiVector.hpp"
Expand Down Expand Up @@ -86,8 +86,6 @@ int main(int argc, char *argv[]) {
// Specify types used in this example
//
typedef double Scalar;
typedef Tpetra::DefaultPlatform::DefaultPlatformType Platform;
typedef Tpetra::Map<>::node_type Node;
typedef Tpetra::CrsMatrix<Scalar> CrsMatrix;
typedef Tpetra::MultiVector<Scalar> MV;
typedef Tpetra::Operator<Scalar> OP;
Expand All @@ -98,15 +96,12 @@ int main(int argc, char *argv[]) {
//
// Initialize the MPI session
//
Teuchos::oblackholestream blackhole;
Teuchos::GlobalMPISession mpiSession(&argc,&argv,&blackhole);
Tpetra::ScopeGuard tpetraScope(&argc,&argv);

//
// Get the default communicator and node
// Get the default communicator
//
Platform& platform = Tpetra::DefaultPlatform::getDefaultPlatform ();
RCP<const Teuchos::Comm<int> > comm = platform.getComm ();
RCP<Node> node = platform.getNode ();
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();
const int myRank = comm->getRank ();

//
Expand Down Expand Up @@ -138,6 +133,7 @@ int main(int argc, char *argv[]) {
//
// Read the matrices from a file
//
RCP<Tpetra::Map<>::node_type> node; // can be null
RCP<const CrsMatrix> K = Reader::readSparseFile(filenameA, comm, node);
RCP<const CrsMatrix> M = Reader::readSparseFile(filenameB, comm, node);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

// Include header for Tpetra compressed-row storage matrix
#include "Tpetra_CrsMatrix.hpp"
#include "Tpetra_DefaultPlatform.hpp"
#include "Tpetra_Core.hpp"
#include "Tpetra_Version.hpp"
#include "Tpetra_Map.hpp"
#include "Tpetra_MultiVector.hpp"
Expand Down Expand Up @@ -88,32 +88,27 @@
//
// Specify types used in this example
//
typedef double Scalar;
typedef int Ordinal;
typedef Tpetra::DefaultPlatform::DefaultPlatformType Platform;
typedef Tpetra::DefaultPlatform::DefaultPlatformType::NodeType Node;
typedef Tpetra::CrsMatrix<Scalar,Ordinal,Ordinal,Node> CrsMatrix;
typedef Tpetra::Vector<Scalar,Ordinal,Ordinal,Node> Vector;
typedef Tpetra::MultiVector<Scalar,Ordinal,Ordinal,Node> TMV;
typedef Tpetra::Operator<Scalar,Ordinal,Ordinal,Node> TOP;
typedef Anasazi::MultiVecTraits<Scalar, TMV> TMVT;
typedef Anasazi::OperatorTraits<Scalar, TMV, TOP> TOPT;
typedef double Scalar;
typedef int Ordinal;
typedef Tpetra::CrsMatrix<Scalar,Ordinal,Ordinal> CrsMatrix;
typedef Tpetra::Vector<Scalar,Ordinal,Ordinal> Vector;
typedef Tpetra::MultiVector<Scalar,Ordinal,Ordinal> TMV;
typedef Tpetra::Operator<Scalar,Ordinal,Ordinal> TOP;
typedef Anasazi::MultiVecTraits<Scalar, TMV> TMVT;
typedef Anasazi::OperatorTraits<Scalar, TMV, TOP> TOPT;

void formLaplacian(const RCP<const CrsMatrix>& A, const bool weighted, const bool normalized, RCP<CrsMatrix>& L, RCP<Vector>& auxVec);

int main(int argc, char *argv[]) {
//
// Initialize the MPI session
//
Teuchos::oblackholestream blackhole;
Teuchos::GlobalMPISession mpiSession(&argc,&argv,&blackhole);
Tpetra::ScopeGuard tpetraScope(&argc, &argv);

//
// Get the default communicator and node
// Get the default communicator
//
Platform &platform = Tpetra::DefaultPlatform::getDefaultPlatform();
RCP<const Teuchos::Comm<int> > comm = platform.getComm();
RCP<Node> node = platform.getNode();
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
const int myRank = comm->getRank();

//
Expand Down Expand Up @@ -147,6 +142,7 @@ int main(int argc, char *argv[]) {
//
// Read the matrix from a file
//
RCP<Tpetra::Map<>::node_type> node; // can be null
RCP<const CrsMatrix> fileMat = Tpetra::MatrixMarket::Reader<CrsMatrix>::readSparseFile(inputFilename, comm, node);

//
Expand Down Expand Up @@ -377,7 +373,7 @@ void formLaplacian(const RCP<const CrsMatrix>& A, const bool weighted, const boo
// L = A + A'
//
L = Tpetra::MatrixMatrix::add(ONE,false,*A,ONE,true,*A);
RCP<const Tpetra::Map<Ordinal,Ordinal,Node> > rowMap = L->getRowMap();
RCP<const Tpetra::Map<Ordinal,Ordinal> > rowMap = L->getRowMap();

// This line tells L that we are going to modify its entries
L->resumeFill();
Expand Down Expand Up @@ -522,7 +518,7 @@ void formLaplacian(const RCP<const CrsMatrix>& A, const bool weighted, const boo
L->fillComplete();

// Create the auxiliary vector and set its values
auxVec = Teuchos::rcp( new Tpetra::Vector<Scalar,Ordinal,Ordinal,Node>(rowMap,false) );
auxVec = Teuchos::rcp( new Tpetra::Vector<Scalar,Ordinal,Ordinal>(rowMap,false) );
if(normalized)
{
// Computes the degree of each vertex of the graph
Expand Down Expand Up @@ -561,7 +557,7 @@ void formLaplacian(const RCP<const CrsMatrix>& A, const bool weighted, const boo
{
// Compute the degree of each node so we can normalize the Laplacian
// normalizedL = D^{-1/2} L D^{-1/2}
Tpetra::Vector<Scalar,Ordinal,Ordinal,Node> scalars(rowMap,false);
Tpetra::Vector<Scalar,Ordinal,Ordinal> scalars(rowMap,false);
for(Ordinal i=0; i<n; i++)
{
// If this process does not own that row of the matrix, do nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

// Include header for Tpetra compressed-row storage matrix
#include "Tpetra_CrsMatrix.hpp"
#include "Tpetra_DefaultPlatform.hpp"
#include "Tpetra_Core.hpp"
#include "Tpetra_Version.hpp"
#include "Tpetra_Map.hpp"
#include "Tpetra_MultiVector.hpp"
Expand Down Expand Up @@ -87,8 +87,6 @@ main (int argc, char *argv[])
// Specify types used in this example
//
typedef Tpetra::CrsMatrix<>::scalar_type Scalar;
typedef Tpetra::DefaultPlatform::DefaultPlatformType Platform;
typedef Tpetra::Map<>::node_type Node;
typedef Tpetra::CrsMatrix<Scalar> CrsMatrix;
typedef Tpetra::MultiVector<Scalar> MV;
typedef Tpetra::Operator<Scalar> OP;
Expand All @@ -98,15 +96,12 @@ main (int argc, char *argv[])
//
// Initialize the MPI session
//
Teuchos::oblackholestream blackhole;
Teuchos::GlobalMPISession mpiSession(&argc,&argv,&blackhole);
Tpetra::ScopeGuard tpetraScope(&argc,&argv);

//
// Get the default communicator and node
// Get the default communicator
//
Platform &platform = Tpetra::DefaultPlatform::getDefaultPlatform();
RCP<const Teuchos::Comm<int> > comm = platform.getComm();
RCP<Node> node = platform.getNode();
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
const int myRank = comm->getRank();

//
Expand All @@ -132,6 +127,7 @@ main (int argc, char *argv[])
//
// Read the matrices from a file
//
RCP<Tpetra::Map<>::node_type> node; // can be null
RCP<const CrsMatrix> K = Tpetra::MatrixMarket::Reader<CrsMatrix>::readSparseFile(filenameA, comm, node);

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#include "AnasaziOperator.hpp"

// Include headers for Tpetra
#include "Tpetra_DefaultPlatform.hpp"
#include "Tpetra_Core.hpp"
#include "Tpetra_Version.hpp"
#include "Tpetra_Map.hpp"
#include "Tpetra_MultiVector.hpp"
Expand Down Expand Up @@ -95,7 +95,6 @@ typedef Teuchos::ScalarTraits<Scalar>::magnitudeType Magnitude;
typedef TMV::local_ordinal_type LocalOrdinal;
typedef TMV::global_ordinal_type GlobalOrdinal;
typedef TMV::node_type Node;
typedef Tpetra::DefaultPlatform::DefaultPlatformType Platform;

//
// Define a class for our user-defined operator.
Expand Down Expand Up @@ -314,14 +313,12 @@ main (int argc, char *argv[])
//
// Initialize MPI.
//
Teuchos::oblackholestream blackhole;
Teuchos::GlobalMPISession mpiSession (&argc, &argv, &blackhole);
Tpetra::ScopeGuard tpetraScope (&argc, &argv);

//
// Get the default communicator and node
// Get the default communicator
//
RCP<const Teuchos::Comm<int> > comm =
Tpetra::DefaultPlatform::getDefaultPlatform ().getComm ();
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();
const int myRank = comm->getRank ();

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
#include "AnasaziBlockDavidsonSolMgr.hpp"
#include <Teuchos_CommandLineProcessor.hpp>

#include <Teuchos_GlobalMPISession.hpp>
#include <Tpetra_DefaultPlatform.hpp>
#include <Tpetra_Core.hpp>
#include <Tpetra_CrsMatrix.hpp>

// I/O for Harwell-Boeing files
Expand Down Expand Up @@ -91,14 +90,13 @@ int main(int argc, char *argv[])
typedef Anasazi::MultiVecTraits<ST,MV> MVT;
typedef Anasazi::OperatorTraits<ST,MV,OP> OPT;

Teuchos::GlobalMPISession mpisess (&argc, &argv, &std::cout);
Tpetra::ScopeGuard tpetraScope (&argc, &argv);

const ST ONE = SCT::one();
int info = 0;
int MyPID = 0;

RCP<const Teuchos::Comm<int> > comm =
Tpetra::DefaultPlatform::getDefaultPlatform ().getComm ();
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();

MyPID = rank(*comm);

Expand Down
9 changes: 3 additions & 6 deletions packages/anasazi/tpetra/test/BlockDavidson/cxx_main_lap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
#include "AnasaziBlockDavidsonSolMgr.hpp"
#include <Teuchos_CommandLineProcessor.hpp>

#include <Teuchos_GlobalMPISession.hpp>
#include <Tpetra_DefaultPlatform.hpp>
#include <Tpetra_Core.hpp>
#include <Tpetra_CrsMatrix.hpp>

using Tpetra::CrsMatrix;
Expand All @@ -76,10 +75,8 @@ int main(int argc, char *argv[])
typedef Anasazi::OperatorTraits<ST,MV,OP> OPT;
const ST ONE = SCT::one();

Teuchos::GlobalMPISession mpisess (&argc,&argv,&std::cout);

RCP<const Teuchos::Comm<int> > comm =
Tpetra::DefaultPlatform::getDefaultPlatform ().getComm ();
Tpetra::ScopeGuard tpetraScope (&argc,&argv);
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();

const int MyPID = comm->getRank ();
const int NumImages = comm->getSize ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
#include "AnasaziBlockKrylovSchurSolMgr.hpp"
#include <Teuchos_CommandLineProcessor.hpp>

#include <Teuchos_GlobalMPISession.hpp>
#include <Tpetra_DefaultPlatform.hpp>
#include <Tpetra_Core.hpp>
#include <Tpetra_CrsMatrix.hpp>

// I/O for Harwell-Boeing files
Expand Down Expand Up @@ -89,16 +88,15 @@ int main(int argc, char *argv[])
typedef Anasazi::MultiVecTraits<ST,MV> MVT;
typedef Anasazi::OperatorTraits<ST,MV,OP> OPT;

Teuchos::GlobalMPISession mpisess (&argc, &argv, &std::cout);
Tpetra::ScopeGuard tpetraScope (&argc, &argv);

bool success = false;

const ST ONE = SCT::one ();

int info = 0;

RCP<const Teuchos::Comm<int> > comm =
Tpetra::DefaultPlatform::getDefaultPlatform ().getComm ();
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();

const int MyPID = comm->getRank ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
#include "AnasaziBlockKrylovSchurSolMgr.hpp"
#include <Teuchos_CommandLineProcessor.hpp>

#include <Teuchos_GlobalMPISession.hpp>
#include <Tpetra_DefaultPlatform.hpp>
#include <Tpetra_Core.hpp>
#include <Tpetra_CrsMatrix.hpp>

using Tpetra::CrsMatrix;
Expand All @@ -76,10 +75,8 @@ int main(int argc, char *argv[])
typedef Anasazi::OperatorTraits<ST,MV,OP> OPT;
const ST ONE = SCT::one();

Teuchos::GlobalMPISession mpisess (&argc,&argv,&std::cout);

RCP<const Teuchos::Comm<int> > comm =
Tpetra::DefaultPlatform::getDefaultPlatform ().getComm ();
Tpetra::ScopeGuard tpetraScope (&argc, &argv);
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();

const int MyPID = comm->getRank ();
const int NumImages = comm->getSize ();
Expand Down
8 changes: 3 additions & 5 deletions packages/anasazi/tpetra/test/IRTR/cxx_main_complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
#include "AnasaziRTRSolMgr.hpp"
#include <Teuchos_CommandLineProcessor.hpp>

#include <Teuchos_GlobalMPISession.hpp>
#include <Tpetra_DefaultPlatform.hpp>
#include <Tpetra_Core.hpp>
#include <Tpetra_CrsMatrix.hpp>

// I/O for Harwell-Boeing files
Expand All @@ -85,16 +84,15 @@ int main(int argc, char *argv[])
typedef Operator<ST> OP;
typedef Anasazi::MultiVecTraits<ST,MV> MVT;
typedef Anasazi::OperatorTraits<ST,MV,OP> OPT;
GlobalMPISession mpisess(&argc,&argv,&std::cout);
Tpetra::ScopeGuard tpetraScope (&argc, &argv);

bool success = false;
ST ONE = SCT::one();

int info = 0;
int MyPID = 0;

RCP<const Teuchos::Comm<int> > comm =
Tpetra::DefaultPlatform::getDefaultPlatform ().getComm ();
RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();

MyPID = rank(*comm);

Expand Down
Loading

0 comments on commit 2fb1016

Please sign in to comment.