10#ifndef TPETRA_DETAILS_IDOT_HPP 
   11#define TPETRA_DETAILS_IDOT_HPP 
   30#include "Tpetra_MultiVector.hpp" 
   31#include "Tpetra_Vector.hpp" 
   32#include "Teuchos_CommHelpers.hpp" 
   33#include "KokkosBlas1_dot.hpp" 
   45  using DevView  = 
typename MV::dual_view_type::t_dev::const_type;
 
   46  using HostView = 
typename MV::dual_view_type::t_host::const_type;
 
   48  template <
typename exec_space>
 
   49  static DevView get(
const MV& x, 
typename std::enable_if<std::is_same<exec_space, typename MV::execution_space>::value>::type* = 
nullptr) {
 
   50    return x.getLocalViewDevice(Tpetra::Access::ReadOnly);
 
   53  template <
typename exec_space>
 
   54  static HostView get(
const MV& x, 
typename std::enable_if<!std::is_same<exec_space, typename MV::execution_space>::value>::type* = 
nullptr) {
 
   55    return x.getLocalViewHost(Tpetra::Access::ReadOnly);
 
   61template <
class MV, 
class ResultView, 
bool runOnDevice>
 
   65  using pair_type  = Kokkos::pair<size_t, size_t>;
 
   66  using exec_space = 
typename std::conditional<runOnDevice, typename MV::execution_space, Kokkos::DefaultHostExecutionSpace>::type;
 
   68  static_assert(Kokkos::SpaceAccessibility<exec_space, typename ResultView::memory_space>::accessible,
 
   69                "idotLocal: Execution space must be able to access localResult");
 
   72  Kokkos::View<typename ResultView::data_type, typename exec_space::memory_space, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
 
   74  const size_t numRows = 
X.getLocalLength();
 
   84    std::ostringstream 
os;
 
   85    os << 
"Tpetra::idot: X.getNumVectors() = " << 
X_numVecs 
   86       << 
" != Y.getNumVectors() = " << 
Y_numVecs 
   87       << 
", but neither is 1.";
 
   88    throw std::invalid_argument(
os.str());
 
 
  126template <
typename MV, 
typename ResultView>
 
  128  using dot_type = 
typename MV::dot_type;
 
  131  template <
typename exec_space>
 
  132  static std::shared_ptr<::Tpetra::Details::CommRequest> run(
 
  134      typename std::enable_if<Kokkos::SpaceAccessibility<exec_space, typename ResultView::memory_space>::accessible>::type* = 
nullptr)
 
  137    constexpr bool runOnDevice = std::is_same<exec_space, typename MV::execution_space>::value;
 
  142    auto comm = 
X.getMap()->getComm();
 
  147  template <
typename exec_space>
 
  148  static std::shared_ptr<::Tpetra::Details::CommRequest> run(
 
  149      const ResultView& globalResult, 
const MV& X, 
const MV& Y,
 
  150      typename std::enable_if<!Kokkos::SpaceAccessibility<exec_space, typename ResultView::memory_space>::accessible>::type* = 
nullptr) {
 
  151    constexpr bool runOnDevice = std::is_same<exec_space, typename MV::execution_space>::value;
 
  152    Kokkos::View<dot_type*, typename exec_space::memory_space> localResult(Kokkos::ViewAllocateWithoutInitializing(
"idot:localResult"), X.getNumVectors());
 
  153    idotLocal<MV, decltype(localResult), runOnDevice>(localResult, X, Y);
 
  156      exec_space().fence();
 
  157    auto comm = X.getMap()->getComm();
 
  158    return iallreduce(localResult, globalResult, ::Teuchos::REDUCE_SUM, *comm);
 
  164template <
class MV, 
class ResultView>
 
  165std::shared_ptr<::Tpetra::Details::CommRequest>
 
  169  static_assert(std::is_same<typename ResultView::non_const_value_type, typename MV::dot_type>::value,
 
  170                "Tpetra::idot: result view's element type must match MV::dot_type");
 
  173  if (
X.need_sync_device()) {
 
 
  239template <
class SC, 
class LO, 
class GO, 
class NT>
 
  240std::shared_ptr<::Tpetra::Details::CommRequest>
 
  242     const ::Tpetra::MultiVector<SC, LO, GO, NT>& 
X,
 
  243     const ::Tpetra::MultiVector<SC, LO, GO, NT>& 
Y) {
 
  244  using dot_type         = typename ::Tpetra::Vector<SC, LO, GO, NT>::dot_type;
 
  248  Kokkos::View<dot_type*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
 
 
  315template <
class SC, 
class LO, 
class GO, 
class NT>
 
  316std::shared_ptr<::Tpetra::Details::CommRequest>
 
  317idot(
const Kokkos::View<typename ::Tpetra::MultiVector<SC, LO, GO, NT>::dot_type*,
 
  318                        typename ::Tpetra::MultiVector<SC, LO, GO, NT>::device_type>& 
result,
 
  319     const ::Tpetra::MultiVector<SC, LO, GO, NT>& 
X,
 
  320     const ::Tpetra::MultiVector<SC, LO, GO, NT>& 
Y) {
 
 
  365template <
class SC, 
class LO, 
class GO, 
class NT>
 
  366std::shared_ptr<::Tpetra::Details::CommRequest>
 
  367idot(
const Kokkos::View<typename ::Tpetra::Vector<SC, LO, GO, NT>::dot_type,
 
  368                        typename ::Tpetra::Vector<SC, LO, GO, NT>::device_type>& 
result,
 
  369     const ::Tpetra::Vector<SC, LO, GO, NT>& 
X,
 
  370     const ::Tpetra::Vector<SC, LO, GO, NT>& 
Y) {
 
  371  using dot_type        = typename ::Tpetra::Vector<SC, LO, GO, NT>::dot_type;
 
  372  using result_device_t = typename ::Tpetra::Vector<SC, LO, GO, NT>::device_type;
 
  373  Kokkos::View<dot_type*, result_device_t, Kokkos::MemoryTraits<Kokkos::Unmanaged>> 
result1D(
result.data(), 1);
 
 
Declaration of Tpetra::iallreduce.
 
Struct that holds views of the contents of a CrsMatrix.
 
Implementation details of Tpetra.
 
void idotLocal(const ResultView &localResult, const MV &X, const MV &Y)
Compute dot product locally. Where the kernel runs controlled by runOnDevice.
 
std::shared_ptr<::Tpetra::Details::CommRequest > idotImpl(const ResultView &globalResult, const MV &X, const MV &Y)
Internal (common) version of idot, a global dot product that uses a non-blocking MPI reduction.
 
Namespace Tpetra contains the class and methods constituting the Tpetra library.
 
std::shared_ptr<::Tpetra::Details::CommRequest > idot(typename ::Tpetra::MultiVector< SC, LO, GO, NT >::dot_type *resultRaw, const ::Tpetra::MultiVector< SC, LO, GO, NT > &X, const ::Tpetra::MultiVector< SC, LO, GO, NT > &Y)
Nonblocking dot product, with either Tpetra::MultiVector or Tpetra::Vector inputs,...