Skip to content

Commit

Permalink
Merge pull request #9862 from brian-kelley/MueLuDeprecated
Browse files Browse the repository at this point in the history
MueLu: remove some Tpetra deprecated
  • Loading branch information
jhux2 authored Oct 27, 2021
2 parents b607078 + 4d9a4f0 commit 1d02e11
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 52 deletions.
47 changes: 22 additions & 25 deletions packages/muelu/test/scaling/MMKernelDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,17 @@ void Multiply_ViennaCL(const Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,No
RCP<const crs_matrix_type> Cu = Utilities::Op2TpetraCrs(rcp(&C,false));
RCP<crs_matrix_type> Cnc = Teuchos::rcp_const_cast<crs_matrix_type>(Cu);

const KCRS & Amat = Au->getLocalMatrix();
const KCRS & Bmat = Bu->getLocalMatrix();
KCRS Cmat = Cu->getLocalMatrix();
const KCRS & Amat = Au->getLocalMatrixDevice();
const KCRS & Bmat = Bu->getLocalMatrixDevice();

using no_init_view=Kokkos::ViewAllocateWithoutInitializing;

c_lno_view_t Arowptr = Amat.graph.row_map, Browptr = Bmat.graph.row_map;
lno_view_t Crowptr(no_init_view("Crowptr"),C.getNodeNumRows()+1);
c_lno_nnz_view_t Acolind = Amat.graph.entries, Bcolind = Bmat.graph.entries;
lno_nnz_view_t Ccolind = Cmat.graph.entries;
lno_nnz_view_t Ccolind;
const scalar_view_t Avals = Amat.values, Bvals = Bmat.values;
scalar_view_t Cvals = Cmat.values;
scalar_view_t Cvals;

// **********************************
// Copy in the data for ViennaCL
Expand Down Expand Up @@ -335,8 +334,8 @@ void Multiply_ViennaCL(const Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,No
{
Teuchos::TimeMonitor tm_copy (*TimeMonitor::getNewTimer("MM ViennaCL: Copy Out"));
size_t cnnz = (size_t)CVCL.nnz();
Kokkos::resize(Ccolind,cnnz);
Kokkos::resize(Cvals,cnnz);
Ccolind = lno_nnz_view_t(Kokkos::ViewAllocateWithoutInitializing("Ccolind"), cnnz);
Cvals = scalar_view_t(Kokkos::ViewAllocateWithoutInitializing("Cvals"), cnnz);
#ifdef VIENNACL_WITH_CUDA
const unsigned int * CrowptrVCL = viennacl::cuda_arg<unsigned int>(CVCL.handle1());
const unsigned int * CcolindVCL = viennacl::cuda_arg<unsigned int>(CVCL.handle2());
Expand Down Expand Up @@ -446,17 +445,14 @@ void Multiply_MKL_SPMM(const Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,No
RCP<const crs_matrix_type> Cu = Utilities::Op2TpetraCrs(rcp(&C,false));
RCP<crs_matrix_type> Cnc = Teuchos::rcp_const_cast<crs_matrix_type>(Cu);

const KCRS & Amat = Au->getLocalMatrix();
const KCRS & Bmat = Bu->getLocalMatrix();
KCRS Cmat = Cu->getLocalMatrix();
const KCRS & Amat = Au->getLocalMatrixDevice();
const KCRS & Bmat = Bu->getLocalMatrixDevice();
if(A.getNodeNumRows()!=C.getNodeNumRows()) throw std::runtime_error("C is not sized correctly");

c_lno_view_t Arowptr = Amat.graph.row_map, Browptr = Bmat.graph.row_map;
lno_view_t Crowptr(no_init_view("Crowptr"),C.getNodeNumRows()+1);
c_lno_nnz_view_t Acolind = Amat.graph.entries, Bcolind = Bmat.graph.entries;
lno_nnz_view_t Ccolind = Cmat.graph.entries;
const scalar_view_t Avals = Amat.values, Bvals = Bmat.values;
scalar_view_t Cvals = Cmat.values;

sparse_matrix_t AMKL;
sparse_matrix_t BMKL;
Expand Down Expand Up @@ -536,6 +532,8 @@ void Multiply_MKL_SPMM(const Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,No
mkl_rc = mkl_sparse_d_export_csr(CMKL,&c_indexing, &c_rows, &c_cols, &rows_start, &rows_end, &columns, &values);
MMKD_MKL_ERROR_CHECK(mkl_rc);
size_t cnnz = rows_end[c_rows-1];
lno_nnz_view_t Ccolind = lno_nnz_view_t(Kokkos::ViewAllocateWithoutInitializing("Ccolind"), cnnz);
scalar_view_t Cvals = scalar_view_t(Kokkos::ViewAllocateWithoutInitializing("Cvals"), cnnz);
Kokkos::resize(Ccolind,cnnz);
Kokkos::resize(Cvals,cnnz);
if((size_t) c_rows != A.getNodeNumRows() || (size_t) c_rows+1 != Crowptr.extent(0)) throw std::runtime_error("C row size mismatch");
Expand Down Expand Up @@ -622,30 +620,29 @@ void Multiply_KokkosKernels(const Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdin
if (lib == Xpetra::UseTpetra) {
#if defined(HAVE_MUELU_TPETRA)
typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> crs_matrix_type;
typedef typename crs_matrix_type::local_matrix_type KCRS;
typedef typename KCRS::StaticCrsGraphType graph_t;
typedef typename graph_t::row_map_type::non_const_type lno_view_t;
typedef typename graph_t::row_map_type::const_type c_lno_view_t;
typedef typename graph_t::entries_type::non_const_type lno_nnz_view_t;
typedef typename graph_t::entries_type::const_type c_lno_nnz_view_t;
typedef typename KCRS::values_type::non_const_type scalar_view_t;
typedef typename KCRS::device_type device_t;
typedef typename crs_matrix_type::local_matrix_device_type KCRS;
typedef typename KCRS::StaticCrsGraphType graph_t;
typedef typename graph_t::row_map_type::non_const_type lno_view_t;
typedef typename graph_t::row_map_type::const_type c_lno_view_t;
typedef typename graph_t::entries_type::non_const_type lno_nnz_view_t;
typedef typename graph_t::entries_type::const_type c_lno_nnz_view_t;
typedef typename KCRS::values_type::non_const_type scalar_view_t;
typedef typename KCRS::device_type device_t;

RCP<const crs_matrix_type> Au = Utilities::Op2TpetraCrs(rcp(&A,false));
RCP<const crs_matrix_type> Bu = Utilities::Op2TpetraCrs(rcp(&B,false));
RCP<const crs_matrix_type> Cu = Utilities::Op2TpetraCrs(rcp(&C,false));
RCP<crs_matrix_type> Cnc = Teuchos::rcp_const_cast<crs_matrix_type>(Cu);

const KCRS & Amat = Au->getLocalMatrix();
const KCRS & Bmat = Bu->getLocalMatrix();
KCRS Cmat = Cu->getLocalMatrix();
const KCRS & Amat = Au->getLocalMatrixDevice();
const KCRS & Bmat = Bu->getLocalMatrixDevice();

c_lno_view_t Arowptr = Amat.graph.row_map, Browptr = Bmat.graph.row_map;
lno_view_t Crowptr("Crowptr",A.getNodeNumRows()+1);
c_lno_nnz_view_t Acolind = Amat.graph.entries, Bcolind = Bmat.graph.entries;
lno_nnz_view_t Ccolind = Cmat.graph.entries;
const scalar_view_t Avals = Amat.values, Bvals = Bmat.values;
scalar_view_t Cvals = Cmat.values;
lno_nnz_view_t Ccolind;
scalar_view_t Cvals;

// KokkosKernelsHandle
typedef KokkosKernels::Experimental::KokkosKernelsHandle<
Expand Down
54 changes: 27 additions & 27 deletions packages/muelu/test/unit_tests/RegionMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,18 @@ void test_matrix(RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
using entries_type = typename local_graph_type::entries_type;
using values_type = typename local_matrix_type::values_type;

local_matrix_type orignalA = A->getLocalMatrix(); // Local matrix
entries_type refEntries = orignalA.graph.entries; // view of local column indices
values_type refValues = orignalA.values; // view of local values
local_matrix_type orignalA = A->getLocalMatrixDevice(); // Local matrix
entries_type refEntries = orignalA.graph.entries; // view of local column indices
values_type refValues = orignalA.values; // view of local values

typename entries_type::HostMirror refEntries_h = Kokkos::create_mirror_view(refEntries);
Kokkos::deep_copy(refEntries_h, refEntries);
typename values_type::HostMirror refValues_h = Kokkos::create_mirror_view(refValues);
Kokkos::deep_copy(refValues_h, refValues);

local_matrix_type compositeA = compositeMatrix->getLocalMatrix(); // Local matrix
entries_type compositeEntries = compositeA.graph.entries; // view of local column indices
values_type compositeValues = compositeA.values; // view of local values
local_matrix_type compositeA = compositeMatrix->getLocalMatrixDevice(); // Local matrix
entries_type compositeEntries = compositeA.graph.entries; // view of local column indices
values_type compositeValues = compositeA.values; // view of local values

typename entries_type::HostMirror compositeEntries_h = Kokkos::create_mirror_view(compositeEntries);
Kokkos::deep_copy(compositeEntries_h, compositeEntries);
Expand Down Expand Up @@ -429,9 +429,9 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(RegionMatrix, CompositeToRegionMatrix, Scalar,
using entries_type = typename local_graph_type::entries_type;
using values_type = typename local_matrix_type::values_type;

local_matrix_type myLocalA = regionMats->getLocalMatrix(); // Local matrix
entries_type myEntries = myLocalA.graph.entries; // view of local column indices
values_type myValues = myLocalA.values; // view of local values
local_matrix_type myLocalA = regionMats->getLocalMatrixDevice(); // Local matrix
entries_type myEntries = myLocalA.graph.entries; // view of local column indices
values_type myValues = myLocalA.values; // view of local values

typename entries_type::HostMirror myEntries_h = Kokkos::create_mirror_view(myEntries);
Kokkos::deep_copy(myEntries_h, myEntries);
Expand All @@ -447,8 +447,8 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(RegionMatrix, CompositeToRegionMatrix, Scalar,
TEST_EQUALITY(regionMats->getNodeNumEntries(), 105);

// In the serial case we can just compare to the values in A
entries_type refEntries = A->getLocalMatrix().graph.entries;
values_type refValues = A->getLocalMatrix().values;
entries_type refEntries = A->getLocalMatrixDevice().graph.entries;
values_type refValues = A->getLocalMatrixDevice().values;
typename entries_type::HostMirror refEntries_h = Kokkos::create_mirror_view(refEntries);
Kokkos::deep_copy(refEntries_h, refEntries);
typename values_type::HostMirror refValues_h = Kokkos::create_mirror_view(refValues);
Expand Down Expand Up @@ -619,18 +619,18 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(RegionMatrix, RegionToCompositeMatrix, Scalar,
using entries_type = typename local_graph_type::entries_type;
using values_type = typename local_matrix_type::values_type;

local_matrix_type orignalA = A->getLocalMatrix(); // Local matrix
entries_type refEntries = orignalA.graph.entries; // view of local column indices
values_type refValues = orignalA.values; // view of local values
local_matrix_type orignalA = A->getLocalMatrixDevice(); // Local matrix
entries_type refEntries = orignalA.graph.entries; // view of local column indices
values_type refValues = orignalA.values; // view of local values

typename entries_type::HostMirror refEntries_h = Kokkos::create_mirror_view(refEntries);
Kokkos::deep_copy(refEntries_h, refEntries);
typename values_type::HostMirror refValues_h = Kokkos::create_mirror_view(refValues);
Kokkos::deep_copy(refValues_h, refValues);

local_matrix_type compositeA = compositeMatrix->getLocalMatrix(); // Local matrix
entries_type compositeEntries = compositeA.graph.entries; // view of local column indices
values_type compositeValues = compositeA.values; // view of local values
local_matrix_type compositeA = compositeMatrix->getLocalMatrixDevice(); // Local matrix
entries_type compositeEntries = compositeA.graph.entries; // view of local column indices
values_type compositeValues = compositeA.values; // view of local values

typename entries_type::HostMirror compositeEntries_h = Kokkos::create_mirror_view(compositeEntries);
Kokkos::deep_copy(compositeEntries_h, compositeEntries);
Expand Down Expand Up @@ -1120,9 +1120,9 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(RegionMatrix, Laplace2D, Scalar, LocalOrdinal,
using entries_type = typename local_graph_type::entries_type;
using values_type = typename local_matrix_type::values_type;

local_matrix_type myLocalA = regionMats->getLocalMatrix(); // Local matrix
entries_type myEntries = myLocalA.graph.entries; // view of local column indices
values_type myValues = myLocalA.values; // view of local values
local_matrix_type myLocalA = regionMats->getLocalMatrixDevice(); // Local matrix
entries_type myEntries = myLocalA.graph.entries; // view of local column indices
values_type myValues = myLocalA.values; // view of local values

typename entries_type::HostMirror myEntries_h = Kokkos::create_mirror_view(myEntries);
Kokkos::deep_copy(myEntries_h, myEntries);
Expand All @@ -1139,8 +1139,8 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(RegionMatrix, Laplace2D, Scalar, LocalOrdinal,
TEST_EQUALITY(regionMats->getNodeNumEntries(), 128);

// In the serial case we can just compare to the values in A
entries_type refEntries = A->getLocalMatrix().graph.entries;
values_type refValues = A->getLocalMatrix().values;
entries_type refEntries = A->getLocalMatrixDevice().graph.entries;
values_type refValues = A->getLocalMatrixDevice().values;
typename entries_type::HostMirror refEntries_h = Kokkos::create_mirror_view(refEntries);
Kokkos::deep_copy(refEntries_h, refEntries);
typename values_type::HostMirror refValues_h = Kokkos::create_mirror_view(refValues);
Expand Down Expand Up @@ -1298,9 +1298,9 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(RegionMatrix, Laplace3D, Scalar, LocalOrdinal,
using entries_type = typename local_graph_type::entries_type;
using values_type = typename local_matrix_type::values_type;

local_matrix_type myLocalA = regionMats->getLocalMatrix(); // Local matrix
entries_type myEntries = myLocalA.graph.entries; // view of local column indices
values_type myValues = myLocalA.values; // view of local values
local_matrix_type myLocalA = regionMats->getLocalMatrixDevice(); // Local matrix
entries_type myEntries = myLocalA.graph.entries; // view of local column indices
values_type myValues = myLocalA.values; // view of local values

typename entries_type::HostMirror myEntries_h = Kokkos::create_mirror_view(myEntries);
Kokkos::deep_copy(myEntries_h, myEntries);
Expand All @@ -1317,8 +1317,8 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(RegionMatrix, Laplace3D, Scalar, LocalOrdinal,
TEST_EQUALITY(regionMats->getNodeNumEntries(), 692);

// In the serial case we can just compare to the values in A
entries_type refEntries = A->getLocalMatrix().graph.entries;
values_type refValues = A->getLocalMatrix().values;
entries_type refEntries = A->getLocalMatrixDevice().graph.entries;
values_type refValues = A->getLocalMatrixDevice().values;
typename entries_type::HostMirror refEntries_h = Kokkos::create_mirror_view(refEntries);
Kokkos::deep_copy(refEntries_h, refEntries);
typename values_type::HostMirror refValues_h = Kokkos::create_mirror_view(refValues);
Expand Down

0 comments on commit 1d02e11

Please sign in to comment.