Skip to content

Commit

Permalink
#26: finalize all tests (Tpetra[Row/Crs]MatrixInput, MatrixAdapterInput)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Jul 31, 2023
1 parent dc71f6f commit e07bd54
Show file tree
Hide file tree
Showing 6 changed files with 681 additions and 579 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ template <typename User, typename UserCoord = User>

this->rowWeightsDevice_.resize(this->nWeightsPerRow_);

this->numNzWeight_ = Kokkos::View<bool *, host_t>(
"numNzWeight_", this->nWeightsPerRow_);

for (int i = 0; i < this->nWeightsPerRow_; ++i) {
this->numNzWeight_(i) = false;
}
Expand All @@ -182,7 +185,7 @@ template <typename User, typename UserCoord>
Z2_FORWARD_EXCEPTIONS;

// Move the rows, creating a new matrix.
RCP<User> outPtr = doMigration(in, numNewRows,importList.getRawPtr());
RCP<User> outPtr = this->doMigration(in, numNewRows,importList.getRawPtr());
out = const_cast<User *>(outPtr.get());
outPtr.release();
}
Expand All @@ -205,7 +208,7 @@ template <typename User, typename UserCoord>
Z2_FORWARD_EXCEPTIONS;

// Move the rows, creating a new matrix.
out = doMigration(in, numNewRows, importList.getRawPtr());
out = this->doMigration(in, numNewRows, importList.getRawPtr());
}

} //namespace Zoltan2
Expand Down
18 changes: 4 additions & 14 deletions packages/zoltan2/core/src/input/Zoltan2_TpetraRowMatrixAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,6 @@ class TpetraRowMatrixAdapter : public MatrixAdapter<User, UserCoord> {

RCP<const User> matrix_;

RCP<const Tpetra::Map<lno_t, gno_t, node_t>> rowMap_;
RCP<const Tpetra::Map<lno_t, gno_t, node_t>> colMap_;

ArrayRCP<offset_t> offset_;
ArrayRCP<gno_t> columnIds_;
ArrayRCP<scalar_t> values_;
Expand Down Expand Up @@ -309,15 +306,13 @@ class TpetraRowMatrixAdapter : public MatrixAdapter<User, UserCoord> {
template <typename User, typename UserCoord>
TpetraRowMatrixAdapter<User, UserCoord>::TpetraRowMatrixAdapter(
const RCP<const User> &inmatrix, int nWeightsPerRow):
matrix_(inmatrix), rowMap_(), colMap_(), offset_(), columnIds_(),
matrix_(inmatrix), offset_(), columnIds_(),
nWeightsPerRow_(nWeightsPerRow), rowWeights_(),
mayHaveDiagonalEntries(true) {
using strided_t = StridedData<lno_t, scalar_t>;
using localInds_t = typename User::nonconst_local_inds_host_view_type;
using localVals_t = typename User::nonconst_values_host_view_type;

std::cout << "beginning TpetraRowMatrixAdapter constructor" << std::endl;

const auto nrows = matrix_->getLocalNumRows();
const auto nnz = matrix_->getLocalNumEntries();
auto maxNumEntries = matrix_->getLocalMaxNumRowEntries();
Expand All @@ -331,7 +326,7 @@ TpetraRowMatrixAdapter<User, UserCoord>::TpetraRowMatrixAdapter(

localInds_t localColInds("localColInds", maxNumEntries);
localVals_t localVals("localVals", maxNumEntries);
std::cout << "before for loop" << std::endl;

for (size_t r = 0; r < nrows; r++) {
size_t numEntries = 0;
matrix_->getLocalRowCopy(r, localColInds, localVals, numEntries); // Diff from CrsGraph
Expand All @@ -344,8 +339,6 @@ TpetraRowMatrixAdapter<User, UserCoord>::TpetraRowMatrixAdapter(
valuesHost_(r) = localVals[j];
}
}
std::cout << "after for loop" << std::endl;

offsDevice_ = Kokkos::create_mirror_view_and_copy(
typename Base::device_t(), offsHost_);
colIdsDevice_ = Kokkos::create_mirror_view_and_copy(
Expand All @@ -365,7 +358,6 @@ TpetraRowMatrixAdapter<User, UserCoord>::TpetraRowMatrixAdapter(
for (int i = 0; i < nWeightsPerRow_; ++i) {
numNzWeight_(i) = false;
}
std::cout << "after weights for loop" << std::endl;
}
}

Expand Down Expand Up @@ -421,6 +413,7 @@ void TpetraRowMatrixAdapter<User, UserCoord>::setWeightsHost(
template <typename User, typename UserCoord>
void TpetraRowMatrixAdapter<User, UserCoord>::setRowWeights(
const scalar_t *weightVal, int stride, int idx) {
typedef StridedData<lno_t, scalar_t> input_t;
AssertCondition((idx >= 0) and (idx < nWeightsPerRow_),
"Invalid row weight index: " + std::to_string(idx));

Expand Down Expand Up @@ -506,7 +499,7 @@ bool TpetraRowMatrixAdapter<User, UserCoord>::CRSViewAvailable() const { return
////////////////////////////////////////////////////////////////////////////
template <typename User, typename UserCoord>
void TpetraRowMatrixAdapter<User, UserCoord>::getRowIDsView(const gno_t *&rowIds) const {
ArrayView<const gno_t> rowView = rowMap_->getLocalElementList();
ArrayView<const gno_t> rowView = matrix_->getRowMap()->getLocalElementList();
rowIds = rowView.getRawPtr();
}

Expand Down Expand Up @@ -659,19 +652,16 @@ void TpetraRowMatrixAdapter<User, UserCoord>::applyPartitioningSolution(
size_t numNewRows;
ArrayRCP<gno_t> importList;
try {
std::cout << " test 1 " << std::endl;
numNewRows =
Zoltan2::getImportList<Adapter, TpetraRowMatrixAdapter<User, UserCoord>>(
solution, this, importList);
}
Z2_FORWARD_EXCEPTIONS;
std::cout << "test 3" << std::endl;

// Move the rows, creating a new matrix.
RCP<User> outPtr = doMigration(in, numNewRows, importList.getRawPtr());
out = outPtr.get();
outPtr.release();
std::cout << "end of partitioning soln" << std::endl;
}

////////////////////////////////////////////////////////////////////////////
Expand Down
18 changes: 18 additions & 0 deletions packages/zoltan2/test/core/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ TRIBITS_COPY_FILES_TO_BINARY_DIR(copy_files_for_scorec_unit_tests

ENDIF()

TRIBITS_ADD_EXECUTABLE_AND_TEST(
TpetraCrsMatrixInput
SOURCES input/TpetraCrsMatrixInput.cpp
NUM_MPI_PROCS 4
COMM serial mpi
PASS_REGULAR_EXPRESSION "PASS"
FAIL_REGULAR_EXPRESSION "FAIL"
)

TRIBITS_ADD_EXECUTABLE_AND_TEST(
TpetraRowMatrixInput
SOURCES input/TpetraRowMatrixInput.cpp
Expand Down Expand Up @@ -309,6 +318,15 @@ TRIBITS_ADD_EXECUTABLE_AND_TEST(
FAIL_REGULAR_EXPRESSION "FAIL"
)

TRIBITS_ADD_EXECUTABLE_AND_TEST(
MatrixAdapter
SOURCES input/MatrixAdapter.cpp
NUM_MPI_PROCS 4
COMM serial mpi
PASS_REGULAR_EXPRESSION "PASS"
FAIL_REGULAR_EXPRESSION "FAIL"
)

#
# Tests for src/problems
#
Expand Down
Loading

0 comments on commit e07bd54

Please sign in to comment.