46#ifndef MUELU_MATRIXFREETENTATIVEP_KOKKOS_DEF_HPP
47#define MUELU_MATRIXFREETENTATIVEP_KOKKOS_DEF_HPP
51#include "MueLu_Aggregates_kokkos.hpp"
54#include "MueLu_PerfUtils.hpp"
55#include "MueLu_PFactory.hpp"
57#include "MueLu_Utilities_kokkos.hpp"
59#include <KokkosCompat_ClassicNodeAPI_Wrapper.hpp>
61#include "Teuchos_ScalarTraits.hpp"
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class DeviceType>
69 Teuchos::ETransp mode,
73 using impl_scalar_type =
typename Kokkos::ArithTraits<Scalar>::val_type;
74 impl_scalar_type implAlpha = alpha;
80 typename Aggregates_kokkos::aggregates_sizes_type::const_type aggSizes = aggregates_->ComputeAggregateSizes();
82 auto kokkos_view_X = X.getDeviceLocalView(Xpetra::Access::ReadOnly);
83 auto kokkos_view_Y = Y.getDeviceLocalView(Xpetra::Access::ReadWrite);
84 LO numCols = kokkos_view_X.extent(1);
86 if(mode == Teuchos::TRANS) {
87 auto vertex2AggId = aggregates_->GetVertex2AggId();
88 auto vertex2AggIdView = vertex2AggId->getDeviceLocalView(Xpetra::Access::ReadOnly);
89 LO numNodes = kokkos_view_X.extent(0);
93 Kokkos::parallel_for(
"MueLu:MatrixFreeTentativeR_kokkos:apply",
md_range_type({0,0},{numCols,numNodes}),
94 KOKKOS_LAMBDA(
const int colIdx,
const int NodeIdx) {
95 LO aggIdx = vertex2AggIdView(NodeIdx,0);
97 Kokkos::atomic_add(&kokkos_view_Y(aggIdx,colIdx),implAlpha*kokkos_view_X(NodeIdx,colIdx)/Kokkos::sqrt(aggSizes(aggIdx)));
101 const auto vertex2Agg = aggregates_->GetVertex2AggId();
102 auto vertex2AggView = vertex2Agg->getDeviceLocalView(Xpetra::Access::ReadOnly);
103 LO numNodes = kokkos_view_Y.extent(0);
107 Kokkos::parallel_for(
"MueLu:MatrixFreeTentativeP_kokkos:apply",
md_range_type({0,0},{numCols,numNodes}),
108 KOKKOS_LAMBDA(
const int colIdx,
const int fineIdx) {
109 LO aggIdx = vertex2AggView(fineIdx,0);
110 kokkos_view_Y(fineIdx,colIdx) += implAlpha*kokkos_view_X(aggIdx,colIdx)/Kokkos::sqrt(aggSizes(aggIdx));
116 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class DeviceType>
118 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"MatrixFreeTentativeP residual would make no sense as the operator is not square!");
123#define MUELU_MATRIXFREETENTATIVEP_KOKKOS_SHORT
MueLu::DefaultScalar Scalar
Exception throws to report errors in the internal logical of the program.
Kokkos::MDRangePolicy< local_ordinal_type, execution_space, Kokkos::Rank< 2 > > md_range_type
Namespace for MueLu classes and methods.