46#ifndef MUELU_AMGXOPERATOR_DECL_HPP
47#define MUELU_AMGXOPERATOR_DECL_HPP
49#if defined (HAVE_MUELU_AMGX)
50#include <Teuchos_ParameterList.hpp>
52#include <Tpetra_Operator.hpp>
53#include <Tpetra_CrsMatrix.hpp>
54#include <Tpetra_MultiVector.hpp>
55#include <Tpetra_Distributor.hpp>
56#include <Tpetra_HashTable.hpp>
57#include <Tpetra_Import.hpp>
58#include <Tpetra_Import_Util.hpp>
62#include "MueLu_TpetraOperator.hpp"
65#include <cuda_runtime.h>
88 typedef Tpetra::Map<LO,GO,NO>
Map;
120 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const {
150 typedef Tpetra::Map<LO,GO,NO>
Map;
156 for (
int p = 0;
p <
comm->getSize();
p++) {
157 if (
comm->getRank() ==
p) {
158 std::cout <<
"========\n" <<
label <<
", lid (gid), PID " <<
p <<
"\n========" << std::endl;
160 for (
size_t i = 0; i <
vec.size(); ++i) {
161 std::cout <<
" neighbor " <<
nbrs[i] <<
" :";
162 for (
size_t j = 0; j <
vec[i].size(); ++j)
163 std::cout <<
" " <<
vec[i][j] <<
" (" <<
map.getGlobalElement(
perm[
vec[i][j]]) <<
")";
164 std::cout << std::endl;
166 std::cout << std::endl;
181 int myRank =
comm->getRank();
195 if (
configs.isParameter(
"json file")) {
198 std::ostringstream
oss;
200 ParameterList::ConstIterator
itr;
204 oss << name <<
"=" << filterValueToString(
entry) <<
", ";
277 for (
int i = 0; i <
sendRanks.size(); i++) {
284 "This is not the case: we send to {" <<
sendRanks <<
"} and receive from {" <<
recvRanks <<
"}");
307 int N = rowMap->getLocalNumElements(),
Nc = colMap->getLocalNumElements();
308 muelu2amgx_.resize(
Nc, -1);
323 for (
int i = 0; i < N; i++)
324 if (muelu2amgx_[i] == -1)
334 for (
int i = 0; i < (
int)muelu2amgx_.size(); i++)
360 recvDatas [index].push_back(muelu2amgx_[i]);
387 for (
int i = 0; i <
ia.size(); i++)
388 ia[i] = Teuchos::as<int>(
ia_s[i]);
390 N_ =
inA->getLocalNumRows();
391 int nnz =
inA->getLocalNumEntries();
408 std::vector<double>
a_new (
a.size());
411 for (
int i = 0; i < N_; i++) {
441 domainMap_ =
inA->getDomainMap();
442 rangeMap_ =
inA->getRangeMap();
450 vectorTimer1_ = Teuchos::TimeMonitor::getNewTimer(
"MueLu: AMGX: transfer vectors CPU->GPU");
451 vectorTimer2_ = Teuchos::TimeMonitor::getNewTimer(
"MueLu: AMGX: transfer vector GPU->CPU");
452 solverTimer_ = Teuchos::TimeMonitor::getNewTimer(
"MueLu: AMGX: Solve (total)");
480 SC alpha = Teuchos::ScalarTraits<SC>::one(),
SC beta = Teuchos::ScalarTraits<SC>::zero())
const;
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
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_
AMGX_resources_handle Resources_
RCP< MueLu::Hierarchy< SC, LO, GO, NO > > GetHierarchy() const
Tpetra::Map< LO, GO, NO > Map
RCP< Teuchos::Time > solverTimer_
AMGX_SOLVE_STATUS getStatus()
Tpetra::MultiVector< SC, LO, GO, NO > MultiVector
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::MultiVector< SC, LO, GO, NO > MultiVector
RCP< MueLu::Hierarchy< SC, LO, GO, NO > > GetHierarchy() const
Tpetra::Map< LO, GO, NO > Map
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
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.