Skip to content

Commit

Permalink
Merge Pull Request trilinos#4556 from mhoemmen/Trilinos/Fix-Tpetra-bu…
Browse files Browse the repository at this point in the history
…ild-warnings-05mar2019

Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Tpetra: Fix build warnings
PR Author: mhoemmen
  • Loading branch information
trilinos-autotester authored Mar 9, 2019
2 parents ef0fbe2 + aa69b41 commit 625e220
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 42 deletions.
1 change: 0 additions & 1 deletion packages/tpetra/core/src/Tpetra_CrsMatrix_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: ";
Expand Down
9 changes: 1 addition & 8 deletions packages/tpetra/core/src/Tpetra_DistObject_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1856,13 +1855,7 @@ namespace Tpetra {
void
removeEmptyProcessesInPlace (Teuchos::RCP<DistObjectType>& 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<LO, GO, NT> map_type;

RCP<const map_type> newMap = input->getMap ()->removeEmptyProcesses ();
auto newMap = input->getMap ()->removeEmptyProcesses ();
removeEmptyProcessesInPlace<DistObjectType> (input, newMap);
}

Expand Down
43 changes: 18 additions & 25 deletions packages/tpetra/core/src/Tpetra_MultiVector_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
const char tfecfFuncName[] = "copyAndPermuteNew: ";
ProfilingRegion regionCAP ("Tpetra::MultiVector::copyAndPermuteNew");
Expand Down Expand Up @@ -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<mag_type*, Kokkos::HostSpace> RV;
using RV = Kokkos::View<mag_type*, Kokkos::HostSpace>;

const size_t numVecs = this->getNumVectors ();
if (numVecs == 0) {
Expand All @@ -2310,29 +2306,27 @@ namespace Tpetra {
lclNormType = IMPL_NORM_INF;
}

RCP<const Comm<int> > 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<device_type> ();
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<cur_memory_space> ();
auto thisView = this->getLocalViewHost ();
lclNormImpl<RV, XMV> (normsOut, thisView, lclNumRows, numVecs,
this->whichVectors_, this->isConstantStride (),
lclNormType);
gblNormImpl (normsOut, comm, this->isDistributed (), lclNormType);
}
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<cur_memory_space> ();
auto thisView = this->getLocalViewDevice ();
lclNormImpl<RV, XMV> (normsOut, thisView, lclNumRows, numVecs,
this->whichVectors_, this->isConstantStride (),
lclNormType);
Expand Down Expand Up @@ -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<T> but
Expand All @@ -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<DMS> ();
const bool runOnHost = this->need_sync_device ();

if (! useHostVersion) { // last modified in device memory
this->template modify<DMS> (); // we are about to modify on the device
auto X = this->template getLocalView<DMS> ();
if (! runOnHost) { // last modified in device memory
this->modify_device ();
auto X = this->getLocalViewDevice ();
if (this->isConstantStride ()) {
fill (DES (), X, theAlpha, lclNumRows, numVecs);
}
Expand All @@ -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);
}
Expand Down
24 changes: 16 additions & 8 deletions packages/tpetra/core/test/CrsMatrix/CrsMatrix_ReplaceDiagonal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,29 @@ 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<LO> (matrix->getNodeNumRows ());
TEST_EQUALITY(numReplacedDiagEntries, lclNumRows);

/* Test for successful replacement
*
* 1. Extract diagonal copy
* 2. Test if diagonal element matches rank ID the we intended to set
*/

RCP<vec_type> diagCopy = rcp(new vec_type(matrix->getRowMap()));
matrix->getLocalDiagCopy(*diagCopy);

Teuchos::ArrayRCP<const Scalar> 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<T>, impl_scalar_type is
// Kokkos::complex<T>. Otherwise, Scalar and impl_scalar_type
// are the same.
const impl_scalar_type rankAsImplScalarType =
static_cast<impl_scalar_type> (rankAsScalar);
for (size_t i = 0; i < diagCopyData.size(); ++i) {
TEST_EQUALITY_CONST(diagCopyData(i,0), rankAsImplScalarType);
}
}
}

Expand Down

0 comments on commit 625e220

Please sign in to comment.