10#ifndef MUELU_AMGXOPERATOR_DECL_HPP
11#define MUELU_AMGXOPERATOR_DECL_HPP
13#if defined(HAVE_MUELU_AMGX)
14#include <Teuchos_ParameterList.hpp>
16#include <Tpetra_Operator.hpp>
17#include <Tpetra_CrsMatrix.hpp>
18#include <Tpetra_MultiVector.hpp>
19#include <Tpetra_Distributor.hpp>
20#include <Tpetra_HashTable.hpp>
21#include <Tpetra_Import.hpp>
22#include <Tpetra_Import_Util.hpp>
26#include "MueLu_TpetraOperator.hpp"
29#include <cuda_runtime.h>
51 typedef Tpetra::Map<LO, GO, NO>
Map;
82 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const {
112 typedef Tpetra::Map<LO, GO, NO>
Map;
117 for (
int p = 0;
p <
comm->getSize();
p++) {
118 if (
comm->getRank() ==
p) {
119 std::cout <<
"========\n"
120 <<
label <<
", lid (gid), PID " <<
p <<
"\n========" << std::endl;
122 for (
size_t i = 0; i <
vec.size(); ++i) {
123 std::cout <<
" neighbor " <<
nbrs[i] <<
" :";
124 for (
size_t j = 0; j <
vec[i].size(); ++j)
125 std::cout <<
" " <<
vec[i][j] <<
" (" <<
map.getGlobalElement(
perm[
vec[i][j]]) <<
")";
126 std::cout << std::endl;
128 std::cout << std::endl;
142 int myRank =
comm->getRank();
154 if (
configs.isParameter(
"json file")) {
157 std::ostringstream
oss;
159 ParameterList::ConstIterator
itr;
163 oss << name <<
"=" << filterValueToString(
entry) <<
", ";
236 for (
int i = 0; i <
sendRanks.size(); i++) {
243 "AMGX requires that the processors that we send to and receive from are the same. "
244 "This is not the case: we send to {"
268 int N = rowMap->getLocalNumElements(),
Nc = colMap->getLocalNumElements();
269 muelu2amgx_.resize(
Nc, -1);
284 for (
int i = 0; i < N; i++)
285 if (muelu2amgx_[i] == -1)
295 for (
int i = 0; i < (
int)muelu2amgx_.size(); i++)
321 recvDatas[index].push_back(muelu2amgx_[i]);
348 for (
int i = 0; i <
ia.size(); i++)
349 ia[i] = Teuchos::as<int>(
ia_s[i]);
351 N_ =
inA->getLocalNumRows();
352 int nnz =
inA->getLocalNumEntries();
368 std::vector<double>
a_new(
a.size());
371 for (
int i = 0; i < N_; i++) {
401 domainMap_ =
inA->getDomainMap();
402 rangeMap_ =
inA->getRangeMap();
410 vectorTimer1_ = Teuchos::TimeMonitor::getNewTimer(
"MueLu: AMGX: transfer vectors CPU->GPU");
411 vectorTimer2_ = Teuchos::TimeMonitor::getNewTimer(
"MueLu: AMGX: transfer vector GPU->CPU");
412 solverTimer_ = Teuchos::TimeMonitor::getNewTimer(
"MueLu: AMGX: Solve (total)");
438 SC alpha = Teuchos::ScalarTraits<SC>::one(),
SC beta = Teuchos::ScalarTraits<SC>::zero())
const;
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Tpetra::Map< LO, GO, NO > Map
AMGX_solver_handle Solver_
void printMaps(Teuchos::RCP< const Teuchos::Comm< int > > &comm, const std::vector< std::vector< int > > &vec, const std::vector< int > &perm, const int *nbrs, const Map &map, const std::string &label)
AMGX_config_handle Config_
AMGXOperator(const Teuchos::RCP< Tpetra::CrsMatrix< SC, LO, GO, NO > > &inA, Teuchos::ParameterList ¶mListIn)
RCP< Teuchos::Time > vectorTimer1_
RCP< const Map > domainMap_
std::string filterValueToString(const Teuchos::ParameterEntry &entry)
virtual ~AMGXOperator()
Destructor.
std::vector< int > muelu2amgx_
RCP< const Map > rangeMap_
Tpetra::MultiVector< SC, LO, GO, NO > MultiVector
AMGX_resources_handle Resources_
RCP< MueLu::Hierarchy< SC, LO, GO, NO > > GetHierarchy() const
RCP< Teuchos::Time > solverTimer_
AMGX_SOLVE_STATUS getStatus()
RCP< Teuchos::Time > vectorTimer2_
Adapter for AmgX library from Nvidia.
virtual ~AMGXOperator()
Destructor.
void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Returns a solution for the linear system AX=Y in the Tpetra::MultiVector X.
Teuchos::RCP< const Map > getRangeMap() const
Returns the Tpetra::Map object associated with the range of this operator.
AMGXOperator(const Teuchos::RCP< Tpetra::CrsMatrix< SC, LO, GO, NO > > &InA, Teuchos::ParameterList ¶mListIn)
Constructor.
Tpetra::Map< LO, GO, NO > Map
RCP< MueLu::Hierarchy< SC, LO, GO, NO > > GetHierarchy() const
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Tpetra::MultiVector< SC, LO, GO, NO > MultiVector
Teuchos::RCP< const Map > getDomainMap() const
Returns the Tpetra::Map object associated with the domain of this operator.
Base class for MueLu classes.
Exception throws to report errors in the internal logical of the program.
Wraps an existing MueLu::Hierarchy as a Tpetra::Operator.
Namespace for MueLu classes and methods.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.