Skip to content

Commit

Permalink
Tpetra: Fix build warnings; clean up MultiVector a bit
Browse files Browse the repository at this point in the history
@trilinos/tpetra
  • Loading branch information
Mark Hoemmen committed Mar 6, 2019
1 parent 8676d7a commit aa69b41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 34 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

0 comments on commit aa69b41

Please sign in to comment.