Skip to content

Commit

Permalink
Tpetra: Test virtual vs. nonvirtual Epetra methods in view benchmark
Browse files Browse the repository at this point in the history
@trilinos/tpetra See #118 for discussion.

Build/Test Cases Summary
Enabled Packages: TpetraCore
Disabled Packages: FEI,STK,PyTrilinos,NOX,Teko,Piro
0) MPI_DEBUG => Test case MPI_DEBUG was not run! => Does not affect push readiness! (-1.00 min)
1) SERIAL_RELEASE => Test case SERIAL_RELEASE was not run! => Does not affect push readiness! (-1.00 min)
2) MPI_DEBUG_COMPLEX => passed: passed=86,notpassed=0 (5.43 min)
3) SERIAL_RELEASE => passed: passed=66,notpassed=0 (3.02 min)
Other local commits for this build/test group: 194974a
  • Loading branch information
Mark Hoemmen committed Feb 6, 2016
1 parent 194974a commit 6c572f5
Showing 1 changed file with 56 additions and 6 deletions.
62 changes: 56 additions & 6 deletions packages/tpetra/core/example/advanced/Benchmarks/localView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,18 @@ main (int argc, char* argv[])
typedef int LO;

auto timer = TimeMonitor::getNewCounter ("Epetra NumMyEntries");
RCP<const Epetra_CrsMatrix> A = getEpetraMatrix (comm, opts);
RCP<const Epetra_CrsMatrix> A_ptr = getEpetraMatrix (comm, opts);
TEUCHOS_TEST_FOR_EXCEPTION
(A_ptr.is_null (), std::logic_error, "getEpetraMatrix returned null! "
"This should never happen.");
const Epetra_CrsMatrix& A = *A_ptr;
{ // Start timing after matrix creation
TimeMonitor timeMon (*timer);

const LO lclNumRows = opts.lclNumRows;
for (int trial = 0; trial < opts.numTrials; ++trial) {
for (LO lclRow = 0; lclRow < lclNumRows; ++lclRow) {
const size_t len = static_cast<size_t> (A->NumMyEntries (lclRow));
const size_t len = static_cast<size_t> (A.NumMyEntries (lclRow));
totalLclNumEnt += len;
}
}
Expand All @@ -586,13 +590,55 @@ main (int argc, char* argv[])
<< expectedTotalLclNumEnt << "." << endl;
}

totalLclNumEnt = 0;
if (opts.testEpetraLen) {
#ifdef HAVE_TPETRACORE_EPETRA
typedef int LO;

auto timer = TimeMonitor::getNewCounter ("Epetra NumMyRowEntries");
RCP<const Epetra_CrsMatrix> A_ptr = getEpetraMatrix (comm, opts);
TEUCHOS_TEST_FOR_EXCEPTION
(A_ptr.is_null (), std::logic_error, "getEpetraMatrix returned null! "
"This should never happen.");
const Epetra_CrsMatrix& A = *A_ptr;
{ // Start timing after matrix creation
TimeMonitor timeMon (*timer);

const LO lclNumRows = opts.lclNumRows;
for (int trial = 0; trial < opts.numTrials; ++trial) {
for (LO lclRow = 0; lclRow < lclNumRows; ++lclRow) {
int numEnt;
(void) A.NumMyRowEntries (lclRow, numEnt); // ignore error code
totalLclNumEnt += static_cast<size_t> (numEnt);
}
}
}
#else
// We've already checked this case when checking the command-line arguments.
TEUCHOS_TEST_FOR_EXCEPTION
(true, std::logic_error, "Epetra not enabled; should never get here!");
#endif // HAVE_TPETRACORE_EPETRA
}
lclSuccess = (totalLclNumEnt == expectedTotalLclNumEnt) ? 1 : 0;
gblSuccess = 0;
reduceAll<int, int> (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
if (gblSuccess != 1) {
out << "Epetra NumMyRowEntries validation FAILED. On my process, "
"totalLclNumEnt = " << totalLclNumEnt << " != expectedTotalLclNumEnt = "
<< expectedTotalLclNumEnt << "." << endl;
}

totalLclNumEnt = 0;
if (opts.testTpetra) {
typedef Tpetra::CrsMatrix<>::scalar_type SC;
typedef Tpetra::CrsMatrix<>::local_ordinal_type LO;

auto timer = TimeMonitor::getNewCounter ("Tpetra getLocalRowView");
RCP<const Tpetra::CrsMatrix<> > A = getTpetraMatrix (comm, opts);
RCP<const Tpetra::CrsMatrix<> > A_ptr = getTpetraMatrix (comm, opts);
TEUCHOS_TEST_FOR_EXCEPTION
(A_ptr.is_null (), std::logic_error, "getTpetraMatrix returned null! "
"This should never happen.");
const Tpetra::CrsMatrix<>& A = *A_ptr;
{ // Start timing after matrix creation
TimeMonitor timeMon (*timer);

Expand All @@ -601,7 +647,7 @@ main (int argc, char* argv[])
for (LO lclRow = 0; lclRow < lclNumRows; ++lclRow) {
Teuchos::ArrayView<const LO> ind;
Teuchos::ArrayView<const SC> val;
A->getLocalRowView (lclRow, ind, val);
A.getLocalRowView (lclRow, ind, val);
const size_t len = static_cast<size_t> (ind.size ());
totalLclNumEnt += len;
}
Expand All @@ -622,14 +668,18 @@ main (int argc, char* argv[])
typedef Tpetra::CrsMatrix<>::local_ordinal_type LO;

auto timer = TimeMonitor::getNewCounter ("Tpetra getNumEntriesInLocalRow");
RCP<const Tpetra::CrsMatrix<> > A = getTpetraMatrix (comm, opts);
RCP<const Tpetra::CrsMatrix<> > A_ptr = getTpetraMatrix (comm, opts);
TEUCHOS_TEST_FOR_EXCEPTION
(A_ptr.is_null (), std::logic_error, "getTpetraMatrix returned null! "
"This should never happen.");
const Tpetra::CrsMatrix<>& A = *A_ptr;
{ // Start timing after matrix creation
TimeMonitor timeMon (*timer);

for (int trial = 0; trial < opts.numTrials; ++trial) {
const LO lclNumRows = opts.lclNumRows;
for (LO lclRow = 0; lclRow < lclNumRows; ++lclRow) {
const size_t len = A->getNumEntriesInLocalRow (lclRow);
const size_t len = A.getNumEntriesInLocalRow (lclRow);
totalLclNumEnt += len;
}
}
Expand Down

0 comments on commit 6c572f5

Please sign in to comment.