Skip to content

Commit

Permalink
Ifpack2: Purge calls to deprecated Kokkos::View methods
Browse files Browse the repository at this point in the history
@trilinos/ifpack2 See #2705 for context.
  • Loading branch information
Mark Hoemmen authored and mhoemmen committed May 10, 2018
1 parent 52211ec commit 145f8b3
Show file tree
Hide file tree
Showing 25 changed files with 180 additions and 180 deletions.
48 changes: 24 additions & 24 deletions packages/ifpack2/src/Ifpack2_BandedContainer_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,41 +335,41 @@ applyImpl (HostViewLocal& X,
using Teuchos::rcpFromRef;

TEUCHOS_TEST_FOR_EXCEPTION(
X.dimension_0 () != Y.dimension_0 (),
X.extent (0) != Y.extent (0),
std::logic_error, "Ifpack2::BandedContainer::applyImpl: X and Y have "
"incompatible dimensions (" << X.dimension_0 () << " resp. "
<< Y.dimension_0 () << "). Please report this bug to "
"incompatible dimensions (" << X.extent (0) << " resp. "
<< Y.extent (0) << "). Please report this bug to "
"the Ifpack2 developers.");
TEUCHOS_TEST_FOR_EXCEPTION(
X.dimension_0 () != static_cast<size_t> (mode == Teuchos::NO_TRANS ? diagBlocks_[blockIndex].numCols() : diagBlocks_[blockIndex].numRows()),
X.extent (0) != static_cast<size_t> (mode == Teuchos::NO_TRANS ? diagBlocks_[blockIndex].numCols() : diagBlocks_[blockIndex].numRows()),
std::logic_error, "Ifpack2::BandedContainer::applyImpl: The input "
"multivector X has incompatible dimensions from those of the "
"inverse operator (" << X.dimension_0 () << " vs. "
"inverse operator (" << X.extent (0) << " vs. "
<< (mode == Teuchos::NO_TRANS ? diagBlocks_[blockIndex].numCols() : diagBlocks_[blockIndex].numRows())
<< "). Please report this bug to the Ifpack2 developers.");
TEUCHOS_TEST_FOR_EXCEPTION(
Y.dimension_0 () != static_cast<size_t> (mode == Teuchos::NO_TRANS ? diagBlocks_[blockIndex].numRows() : diagBlocks_[blockIndex].numCols()),
Y.extent (0) != static_cast<size_t> (mode == Teuchos::NO_TRANS ? diagBlocks_[blockIndex].numRows() : diagBlocks_[blockIndex].numCols()),
std::logic_error, "Ifpack2::BandedContainer::applyImpl: The output "
"multivector Y has incompatible dimensions from those of the "
"inverse operator (" << Y.dimension_0 () << " vs. "
"inverse operator (" << Y.extent (0) << " vs. "
<< (mode == Teuchos::NO_TRANS ? diagBlocks_[blockIndex].numRows() : diagBlocks_[blockIndex].numCols())
<< "). Please report this bug to the Ifpack2 developers.");

size_t numVecs = (int) X.dimension_1 ();
size_t numVecs = (int) X.extent (1);

auto zero = Teuchos::ScalarTraits<scalar_type>::zero ();
if (alpha == zero) { // don't need to solve the linear system
if (beta == zero) {
// Use BLAS AXPY semantics for beta == 0: overwrite, clobbering
// any Inf or NaN values in Y (rather than multiplying them by
// zero, resulting in NaN values).
for(size_t j = 0; j < Y.dimension_0(); j++)
for(size_t i = 0; i < Y.dimension_1(); i++)
for(size_t j = 0; j < Y.extent(0); j++)
for(size_t i = 0; i < Y.extent(1); i++)
Y(i, j) = zero;
}
else { // beta != 0
for(size_t j = 0; j < Y.dimension_0(); j++)
for(size_t i = 0; i < Y.dimension_1(); i++)
for(size_t j = 0; j < Y.extent(0); j++)
for(size_t i = 0; i < Y.extent(1); i++)
Y(i, j) = beta * (local_impl_scalar_type) Y(i, j);
}
}
Expand All @@ -385,12 +385,12 @@ applyImpl (HostViewLocal& X,
Y_tmp = ptr(&Y);
}
else {
Y_tmp = ptr (new HostViewLocal ("", X.dimension_0 (), X.dimension_1 ())); // constructor copies X
Y_tmp = ptr (new HostViewLocal ("", X.extent (0), X.extent (1))); // constructor copies X
deleteYT = true;
Kokkos::deep_copy(*Y_tmp, X);
}

local_scalar_type* const Y_ptr = (local_scalar_type*) Y_tmp->ptr_on_device();
local_scalar_type* const Y_ptr = (local_scalar_type*) Y_tmp->data();

int INFO = 0;
const char trans =(mode == Teuchos::CONJ_TRANS ? 'C' : (mode == Teuchos::TRANS ? 'T' : 'N'));
Expand All @@ -413,8 +413,8 @@ applyImpl (HostViewLocal& X,
"failed with INFO = " << INFO << " != 0.");

if (beta != zero) {
for(size_t j = 0; j < Y.dimension_1(); j++)
for(size_t i = 0; i < Y.dimension_0(); i++)
for(size_t j = 0; j < Y.extent(1); j++)
for(size_t i = 0; i < Y.extent(0); i++)
Y(i, j) = beta * Y(i, j) + alpha * (*Y_tmp)(i, j);
}
if(deleteYT)
Expand Down Expand Up @@ -446,18 +446,18 @@ apply (HostView& X,

// Tpetra::MultiVector specialization corresponding to MatrixType.
Details::MultiVectorLocalGatherScatter<mv_type, local_mv_type> mvgs;
const size_t numVecs = X.dimension_1();
const size_t numVecs = X.extent(1);

TEUCHOS_TEST_FOR_EXCEPTION(
! IsComputed_, std::runtime_error, "Ifpack2::BandedContainer::apply: "
"You must have called the compute() method before you may call apply(). "
"You may call the apply() method as many times as you want after calling "
"compute() once, but you must have called compute() at least once.");
TEUCHOS_TEST_FOR_EXCEPTION(
X.dimension_1() != Y.dimension_1(), std::runtime_error,
X.extent(1) != Y.extent(1), std::runtime_error,
"Ifpack2::BandedContainer::apply: X and Y have different numbers of "
"vectors. X has " << X.dimension_1()
<< ", but Y has " << Y.dimension_1() << ".");
"vectors. X has " << X.extent(1)
<< ", but Y has " << Y.extent(1) << ".");

if (numVecs == 0) {
return; // done! nothing to do
Expand Down Expand Up @@ -555,7 +555,7 @@ weightedApply (HostView& X,
// typedef Tpetra::Vector<local_scalar_type, local_ordinal_type, global_ordinal_type, node_type> LV; // unused

Details::MultiVectorLocalGatherScatter<mv_type, local_mv_type> mvgs;
const size_t numVecs = X.dimension_1();
const size_t numVecs = X.extent(1);

TEUCHOS_TEST_FOR_EXCEPTION(
! IsComputed_, std::runtime_error, "Ifpack2::BandedContainer::"
Expand All @@ -564,10 +564,10 @@ weightedApply (HostView& X,
"after calling compute() once, but you must have called compute() at least "
"once.");
TEUCHOS_TEST_FOR_EXCEPTION(
numVecs != Y.dimension_1(), std::runtime_error,
numVecs != Y.extent(1), std::runtime_error,
"Ifpack2::BandedContainer::weightedApply: X and Y have different numbers "
"of vectors. X has " << X.dimension_1() << ", but Y has "
<< Y.dimension_1() << ".");
"of vectors. X has " << X.extent(1) << ", but Y has "
<< Y.extent(1) << ".");

if (numVecs == 0) {
return; // done! nothing to do
Expand Down
12 changes: 6 additions & 6 deletions packages/ifpack2/src/Ifpack2_BlockRelaxation_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ getValidParameters () const
validParams->set("Amesos2",dummyList);
validParams->sublist("Amesos2").disableRecursiveValidation();
validParams->set("Amesos2 solver name", "KLU2");

Teuchos::ArrayRCP<int> tmp;
validParams->set("partitioner: map", tmp);

Expand All @@ -156,7 +156,7 @@ getValidParameters () const
typename MatrixType::global_ordinal_type,
typename MatrixType::node_type> > dummy;
validParams->set("partitioner: coordinates",dummy);

return validParams;
}

Expand Down Expand Up @@ -415,9 +415,9 @@ size_t BlockRelaxation<MatrixType,ContainerType>::getNodeSmootherComplexity() co
// Relaxation methods cost roughly one apply + one block-diagonal inverse per iteration
// NOTE: This approximates all blocks as dense, which may overstate the cost if you have a sparse (or banded) container.
size_t block_nnz = 0;
for (local_ordinal_type i = 0; i < NumLocalBlocks_; ++i)
for (local_ordinal_type i = 0; i < NumLocalBlocks_; ++i)
block_nnz += Partitioner_->numRowsInPart(i) *Partitioner_->numRowsInPart(i);

return block_nnz + A_->getNodeNumEntries();
}

Expand Down Expand Up @@ -470,7 +470,7 @@ apply (const Tpetra::MultiVector<typename MatrixType::scalar_type,
{
auto X_lcl_host = X.template getLocalView<Kokkos::HostSpace> ();
auto Y_lcl_host = Y.template getLocalView<Kokkos::HostSpace> ();
if (X_lcl_host.ptr_on_device () == Y_lcl_host.ptr_on_device ()) {
if (X_lcl_host.data () == Y_lcl_host.data ()) {
X_copy = rcp (new MV (X, Teuchos::Copy));
} else {
X_copy = rcpFromRef (X);
Expand Down Expand Up @@ -612,7 +612,7 @@ initialize ()
TEUCHOS_TEST_FOR_EXCEPTION
(hasBlockCrsMatrix_, std::runtime_error,
"Ifpack2::BlockRelaxation::initialize: "
"We do not support overlapped Jacobi yet for Tpetra::BlockCrsMatrix. Sorry!");
"We do not support overlapped Jacobi yet for Tpetra::BlockCrsMatrix. Sorry!");

// weight of each vertex
W_ = rcp (new vector_type (A_->getRowMap ()));
Expand Down
20 changes: 10 additions & 10 deletions packages/ifpack2/src/Ifpack2_BlockTriDiContainer_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ struct DefaultVectorizationMethod<Kokkos::Cuda, double> {
template <>
struct VectorizationTraits<SIMD<double> > {
typedef double value_type;
typedef Kokkos::DefaultHostExecutionSpace exec_space;
typedef Kokkos::DefaultHostExecutionSpace exec_space;
enum : int { vector_length = DefaultVectorLength<double,typename exec_space::memory_space>::value };
typedef Vector<SIMD<double>, vector_length> vector_type;
};
Expand Down Expand Up @@ -1762,7 +1762,7 @@ class Impl {
#else // __KOKKOSBATCHED_PROMOTION__
if (add_to_diag)
KokkosBatched::Details::Todo::Serial_LU_Internal_Unblocked_invoke(
A.dimension_0(), A.dimension_1(), A.data(), A.stride_0(), A.stride_1(), diag_safety);
A.extent(0), A.extent(1), A.data(), A.stride_0(), A.stride_1(), diag_safety);
else {
namespace kbe = KokkosBatched::Experimental;
kbe::SerialLU<kbe::Algo::LU::Blocked>::invoke(A);
Expand Down Expand Up @@ -1989,7 +1989,7 @@ class Impl {
namespace kbe = KokkosBatched::Experimental;
kbe::SerialTrsvInternalLower<kbe::Algo::Trsv::Unblocked>::invoke(
true,
values.dimension_1(),
values.extent(1),
a,
values.data() + i0*bs2, values.stride_1(), values.stride_2(),
X.data() + r0*xsz, X.stride_1());
Expand All @@ -2002,7 +2002,7 @@ class Impl {
namespace kbe = KokkosBatched::Experimental;
kbe::SerialTrsmInternalLeftLower<kbe::Algo::Trsm::Blocked>::invoke(
true,
values.dimension_1(), X.dimension_2(),
values.extent(1), X.extent(2),
a,
values.data() + i0*bs2, values.stride_1(), values.stride_2(),
X.data() + r0*xsz, X.stride_1(), X.stride_2());
Expand All @@ -2015,7 +2015,7 @@ class Impl {
namespace kbe = KokkosBatched::Experimental;
kbe::SerialTrsvInternalUpper<kbe::Algo::Trsv::Unblocked>::invoke(
false,
values.dimension_1(),
values.extent(1),
a,
values.data() + i0*bs2, values.stride_1(), values.stride_2(),
X.data() + r0*xsz, X.stride_1());
Expand All @@ -2028,7 +2028,7 @@ class Impl {
namespace kbe = KokkosBatched::Experimental;
kbe::SerialTrsmInternalLeftUpper<kbe::Algo::Trsm::Blocked>::invoke(
false,
values.dimension_1(), X.dimension_2(),
values.extent(1), X.extent(2),
a,
values.data() + i0*bs2, values.stride_1(), values.stride_2(),
X.data() + r0*xsz, X.stride_1(), X.stride_2());
Expand All @@ -2042,7 +2042,7 @@ class Impl {
typename std::enable_if<std::is_same<Tag, VecTag>::value>::type* = 0) const {
namespace kbe = KokkosBatched::Experimental;
kbe::SerialGemvInternal<kbe::Algo::Gemv::Unblocked>::invoke(
values.dimension_1(), values.dimension_2(),
values.extent(1), values.extent(2),
a,
values.data() + a0*bs2, values.stride_1(), values.stride_2(),
X.data() + b0*xsz, X.stride_1(),
Expand All @@ -2056,7 +2056,7 @@ class Impl {
typename std::enable_if<std::is_same<Tag, MatTag>::value>::type* = 0) const {
namespace kbe = KokkosBatched::Experimental;
kbe::SerialGemmInternal<kbe::Algo::Gemm::Blocked>::invoke(
X.dimension_1(), X.dimension_2(), values.dimension_2(),
X.extent(1), X.extent(2), values.extent(2),
a,
values.data() + a0*bs2, values.stride_1(), values.stride_2(),
X.data() + b0*xsz, X.stride_1(), X.stride_2(),
Expand All @@ -2069,8 +2069,8 @@ class Impl {
const typename Tridiags::PackedMultiVector& X_)
: pack_td_ptr(btdm.pack_td_ptr), values(btdm.values),
packptr(packptr_), part2packrowidx0(part2packrowidx0_),
X(X_), bs2(values.dimension_1()*values.dimension_1()),
xsz(values.dimension_1()*X.dimension_2())
X(X_), bs2(values.extent(1)*values.extent(1)),
xsz(values.extent(1)*X.extent(2))
{}

template <typename Tag>
Expand Down
2 changes: 1 addition & 1 deletion packages/ifpack2/src/Ifpack2_Chebyshev_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ applyImpl (const MV& X,
{
auto X_lcl_host = X.template getLocalView<Kokkos::HostSpace> ();
auto Y_lcl_host = Y.template getLocalView<Kokkos::HostSpace> ();
if (X_lcl_host.ptr_on_device () == Y_lcl_host.ptr_on_device ()) {
if (X_lcl_host.data () == Y_lcl_host.data ()) {
X_copy = rcp (new MV (X, Teuchos::Copy));
copiedInput = true;
} else {
Expand Down
10 changes: 5 additions & 5 deletions packages/ifpack2/src/Ifpack2_Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ void Container<MatrixType>::DoJacobi(HostView& X, HostView& Y, int stride) const
const scalar_type one = STS::one();
// Note: Flop counts copied naively from Ifpack.
// use partitions_ and blockRows_
size_t numVecs = X.dimension_1();
size_t numVecs = X.extent(1);
// Non-overlapping Jacobi
for (local_ordinal_type i = 0; i < numBlocks_; i++)
{
Expand Down Expand Up @@ -503,7 +503,7 @@ void Container<MatrixType>::DoGaussSeidel(HostView& X, HostView& Y, HostView& Y2
// Note: Flop counts copied naively from Ifpack.
const scalar_type one = STS::one();
const size_t Length = inputMatrix_->getNodeMaxNumRowEntries();
auto numVecs = X.dimension_1();
auto numVecs = X.extent(1);
Array<scalar_type> Values;
Array<local_ordinal_type> Indices;
Indices.resize(Length);
Expand All @@ -513,7 +513,7 @@ void Container<MatrixType>::DoGaussSeidel(HostView& X, HostView& Y, HostView& Y2
// One to store the sum of the corrections (initialized to zero)
// One to store the temporary residual (doesn't matter if it is zeroed or not)
// My apologies for making the names clear and meaningful. (X=RHS, Y=guess?! Nice.)
HostView Resid("", X.dimension_0(), X.dimension_1());
HostView Resid("", X.extent(0), X.extent(1));
for(local_ordinal_type i = 0; i < numBlocks_; i++)
{
if(blockRows_[i] > 1 || hasBlockCrs_)
Expand Down Expand Up @@ -608,7 +608,7 @@ void Container<MatrixType>::DoSGS(HostView& X, HostView& Y, HostView& Y2, int st
using Teuchos::rcp;
using Teuchos::rcpFromRef;
const scalar_type one = STS::one();
auto numVecs = X.dimension_1();
auto numVecs = X.extent(1);
const size_t Length = inputMatrix_->getNodeMaxNumRowEntries();
Array<scalar_type> Values;
Array<local_ordinal_type> Indices(Length);
Expand All @@ -617,7 +617,7 @@ void Container<MatrixType>::DoSGS(HostView& X, HostView& Y, HostView& Y2, int st
// One to store the sum of the corrections (initialized to zero)
// One to store the temporary residual (doesn't matter if it is zeroed or not)
// My apologies for making the names clear and meaningful. (X=RHS, Y=guess?! Nice.)
HostView Resid("", X.dimension_0(), X.dimension_1());
HostView Resid("", X.extent(0), X.extent(1));
// Forward Sweep
for(local_ordinal_type i = 0; i < numBlocks_; i++)
{
Expand Down
Loading

0 comments on commit 145f8b3

Please sign in to comment.