From 8676d7addbd20c38c1f6b551f1256cc92c868da9 Mon Sep 17 00:00:00 2001 From: Mark Hoemmen Date: Tue, 5 Mar 2019 21:10:42 -0700 Subject: [PATCH 1/2] Tpetra: Fix build warning in CrsMatrix ReplaceDiagonal test --- .../CrsMatrix/CrsMatrix_ReplaceDiagonal.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/tpetra/core/test/CrsMatrix/CrsMatrix_ReplaceDiagonal.cpp b/packages/tpetra/core/test/CrsMatrix/CrsMatrix_ReplaceDiagonal.cpp index d540737f51b0..cb3cde3dfbfb 100644 --- a/packages/tpetra/core/test/CrsMatrix/CrsMatrix_ReplaceDiagonal.cpp +++ b/packages/tpetra/core/test/CrsMatrix/CrsMatrix_ReplaceDiagonal.cpp @@ -155,7 +155,8 @@ namespace { // (anonymous) * the number of replaced diagonal entries to match the * local number of rows. */ - TEST_EQUALITY(numReplacedDiagEntries, matrix->getNodeNumRows()); + const LO lclNumRows = static_cast (matrix->getNodeNumRows ()); + TEST_EQUALITY(numReplacedDiagEntries, lclNumRows); /* Test for successful replacement * @@ -163,13 +164,20 @@ namespace { // (anonymous) * 2. Test if diagonal element matches rank ID the we intended to set */ - RCP diagCopy = rcp(new vec_type(matrix->getRowMap())); - matrix->getLocalDiagCopy(*diagCopy); - - Teuchos::ArrayRCP diagCopyData = diagCopy->getData(); - - for (size_t i = 0; i < diagCopyData.size(); ++i) - TEST_EQUALITY_CONST(diagCopyData[i], rankAsScalar); + vec_type diagCopy (matrix->getRowMap ()); + matrix->getLocalDiagCopy (diagCopy); + diagCopy.sync_host (); + auto diagCopyData = diagCopy.getLocalViewHost (); + + using impl_scalar_type = typename vec_type::impl_scalar_type; + // If Scalar is std::complex, impl_scalar_type is + // Kokkos::complex. Otherwise, Scalar and impl_scalar_type + // are the same. + const impl_scalar_type rankAsImplScalarType = + static_cast (rankAsScalar); + for (size_t i = 0; i < diagCopyData.size(); ++i) { + TEST_EQUALITY_CONST(diagCopyData(i,0), rankAsImplScalarType); + } } } From aa69b41ea74ca44a697287187835420ae3395368 Mon Sep 17 00:00:00 2001 From: Mark Hoemmen Date: Tue, 5 Mar 2019 21:20:45 -0700 Subject: [PATCH 2/2] Tpetra: Fix build warnings; clean up MultiVector a bit @trilinos/tpetra --- .../tpetra/core/src/Tpetra_CrsMatrix_def.hpp | 1 - .../tpetra/core/src/Tpetra_DistObject_def.hpp | 9 +--- .../core/src/Tpetra_MultiVector_def.hpp | 43 ++++++++----------- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/packages/tpetra/core/src/Tpetra_CrsMatrix_def.hpp b/packages/tpetra/core/src/Tpetra_CrsMatrix_def.hpp index a6314c7f3c00..e8446df09478 100644 --- a/packages/tpetra/core/src/Tpetra_CrsMatrix_def.hpp +++ b/packages/tpetra/core/src/Tpetra_CrsMatrix_def.hpp @@ -6561,7 +6561,6 @@ namespace Tpetra { using Tpetra::Details::dualViewStatusToString; using Tpetra::Details::ProfilingRegion; using std::endl; - typedef typename device_type::memory_space dev_mem_space; // Method name string for TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC. const char tfecfFuncName[] = "copyAndPermuteNew: "; diff --git a/packages/tpetra/core/src/Tpetra_DistObject_def.hpp b/packages/tpetra/core/src/Tpetra_DistObject_def.hpp index 1574b47c4fc0..1e422c0a7b84 100644 --- a/packages/tpetra/core/src/Tpetra_DistObject_def.hpp +++ b/packages/tpetra/core/src/Tpetra_DistObject_def.hpp @@ -1307,7 +1307,6 @@ namespace Tpetra { using Kokkos::Compat::getKokkosViewDeepCopy; using Kokkos::Compat::create_const_view; using std::endl; - using LO = LocalOrdinal; using DT = device_type; using DES = typename DT::execution_space; @@ -1856,13 +1855,7 @@ namespace Tpetra { void removeEmptyProcessesInPlace (Teuchos::RCP& input) { - using Teuchos::RCP; - typedef typename DistObjectType::local_ordinal_type LO; - typedef typename DistObjectType::global_ordinal_type GO; - typedef typename DistObjectType::node_type NT; - typedef Map map_type; - - RCP newMap = input->getMap ()->removeEmptyProcesses (); + auto newMap = input->getMap ()->removeEmptyProcesses (); removeEmptyProcessesInPlace (input, newMap); } diff --git a/packages/tpetra/core/src/Tpetra_MultiVector_def.hpp b/packages/tpetra/core/src/Tpetra_MultiVector_def.hpp index e937337d032b..0c265a836896 100644 --- a/packages/tpetra/core/src/Tpetra_MultiVector_def.hpp +++ b/packages/tpetra/core/src/Tpetra_MultiVector_def.hpp @@ -828,7 +828,6 @@ namespace Tpetra { using KokkosRefactor::Details::permute_array_multi_column; using KokkosRefactor::Details::permute_array_multi_column_variable_stride; using Kokkos::Compat::create_const_view; - using DMS = typename device_type::memory_space; using MV = MultiVector; const char tfecfFuncName[] = "copyAndPermuteNew: "; ProfilingRegion regionCAP ("Tpetra::MultiVector::copyAndPermuteNew"); @@ -2280,11 +2279,8 @@ namespace Tpetra { { using Kokkos::create_mirror_view; using Kokkos::subview; - using Teuchos::Comm; - using Teuchos::null; - using Teuchos::RCP; // View of all the norm results. - typedef Kokkos::View RV; + using RV = Kokkos::View; const size_t numVecs = this->getNumVectors (); if (numVecs == 0) { @@ -2310,18 +2306,17 @@ namespace Tpetra { lclNormType = IMPL_NORM_INF; } - RCP > comm = this->getMap ().is_null () ? null : - this->getMap ()->getComm (); + auto map = this->getMap (); + auto comm = map.is_null () ? Teuchos::null : map->getComm (); // If we need sync to device, then host has the most recent version. - const bool useHostVersion = this->template need_sync (); - if (useHostVersion) { + const bool runOnHost = this->need_sync_device (); + if (runOnHost) { // DualView was last modified on host, so run the local kernel there. // This means we need a host mirror of the array of norms too. - typedef typename dual_view_type::t_host XMV; - typedef typename XMV::memory_space cur_memory_space; + using XMV = typename dual_view_type::t_host; - auto thisView = this->template getLocalView (); + auto thisView = this->getLocalViewHost (); lclNormImpl (normsOut, thisView, lclNumRows, numVecs, this->whichVectors_, this->isConstantStride (), lclNormType); @@ -2329,10 +2324,9 @@ namespace Tpetra { } else { // DualView was last modified on device, so run the local kernel there. - typedef typename dual_view_type::t_dev XMV; - typedef typename XMV::memory_space cur_memory_space; + using XMV = typename dual_view_type::t_dev; - auto thisView = this->template getLocalView (); + auto thisView = this->getLocalViewDevice (); lclNormImpl (normsOut, thisView, lclNumRows, numVecs, this->whichVectors_, this->isConstantStride (), lclNormType); @@ -2520,10 +2514,9 @@ namespace Tpetra { { using ::Tpetra::Details::ProfilingRegion; using ::Tpetra::Details::Blas::fill; - typedef typename dual_view_type::t_dev::memory_space DMS; - typedef typename dual_view_type::t_dev::execution_space DES; - typedef typename dual_view_type::t_host::execution_space HES; - typedef LocalOrdinal LO; + using DES = typename dual_view_type::t_dev::execution_space; + using HES = typename dual_view_type::t_host::execution_space; + using LO = LocalOrdinal; ProfilingRegion region ("Tpetra::MultiVector::putScalar"); // We need this cast for cases like Scalar = std::complex but @@ -2536,11 +2529,11 @@ namespace Tpetra { // avoids sync'ing, which could violate users' expectations. // // If we need sync to device, then host has the most recent version. - const bool useHostVersion = this->template need_sync (); + const bool runOnHost = this->need_sync_device (); - if (! useHostVersion) { // last modified in device memory - this->template modify (); // we are about to modify on the device - auto X = this->template getLocalView (); + if (! runOnHost) { // last modified in device memory + this->modify_device (); + auto X = this->getLocalViewDevice (); if (this->isConstantStride ()) { fill (DES (), X, theAlpha, lclNumRows, numVecs); } @@ -2550,8 +2543,8 @@ namespace Tpetra { } } else { // last modified in host memory, so modify data there. - this->modify_host (); // we are about to modify on the host - auto X = getDualView().view_host(); + this->modify_host (); + auto X = this->getLocalViewHost (); if (this->isConstantStride ()) { fill (HES (), X, theAlpha, lclNumRows, numVecs); }