46 #ifndef MUELU_LWGRAPH_KOKKOS_DEF_HPP 47 #define MUELU_LWGRAPH_KOKKOS_DEF_HPP 49 #include <Kokkos_Core.hpp> 51 #include <Teuchos_ArrayView.hpp> 59 template<
class LocalOrdinal,
class RowType>
60 class MaxNumRowEntriesFunctor {
62 MaxNumRowEntriesFunctor(RowType rowPointers) :
rowPointers_(rowPointers) { }
64 KOKKOS_INLINE_FUNCTION
65 void operator()(
const LocalOrdinal i,
size_t& maxLength)
const {
68 maxLength = (d > maxLength ? d : maxLength);
71 KOKKOS_INLINE_FUNCTION
72 void join(
volatile size_t& dest,
const volatile size_t& src) {
73 dest = (dest > src ? dest : src);
76 KOKKOS_INLINE_FUNCTION
77 void init(
size_t& initValue) {
87 template<
class LocalOrdinal,
class GlobalOrdinal,
class DeviceType>
88 LWGraph_kokkos<LocalOrdinal,GlobalOrdinal,Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType>>::
89 LWGraph_kokkos(
const local_graph_type& graph,
90 const RCP<const map_type>& domainMap,
91 const RCP<const map_type>& importMap,
92 const std::string& objectLabel)
93 : graph_(graph), domainMap_(domainMap), importMap_(importMap), objectLabel_(objectLabel)
95 minLocalIndex_ = domainMap_->getMinLocalIndex();
96 maxLocalIndex_ = domainMap_->getMaxLocalIndex();
98 MaxNumRowEntriesFunctor<LO,typename local_graph_type::row_map_type> maxNumRowEntriesFunctor(graph_.row_map);
99 Kokkos::parallel_reduce(
"MueLu:LWGraph:LWGraph:maxnonzeros", range_type(0,graph_.numRows()), maxNumRowEntriesFunctor, maxNumRowEntries_);
102 template<
class LocalOrdinal,
class GlobalOrdinal,
class DeviceType>
103 void LWGraph_kokkos<LocalOrdinal,GlobalOrdinal,Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType>>::
104 print(Teuchos::FancyOStream &out,
const VerbLevel verbLevel)
const {
106 if (verbLevel &
Debug) {
107 RCP<const Map> col_map = importMap_.is_null() ? domainMap_ : importMap_;
108 int mypid = col_map->getComm()->getRank();
111 std::ostringstream ss;
112 ss <<
"[pid " << mypid <<
"] num entries=" << graph_.entries.size();
113 out << ss.str() << std::endl;
116 const size_t numRows = graph_.numRows();
117 auto rowPtrs = graph_.row_map;
118 auto columns = graph_.entries;
119 for (
size_t i=0; i < numRows; ++i) {
120 std::ostringstream ss;
121 ss <<
"[pid " << mypid <<
"] row " << domainMap_->getGlobalElement(i) <<
":";
122 ss <<
" (numEntries=" << rowPtrs(i+1)-rowPtrs(i) <<
")";
124 auto rowView = graph_.rowConst(i);
125 for (LO j = 0; j < rowView.length; j++) {
126 ss <<
" " << col_map->getGlobalElement(rowView.colidx(j));
128 out << ss.str() << std::endl;
135 #endif // MUELU_LWGRAPH_KOKKOS_DEF_HPP MueLu::DefaultLocalOrdinal LocalOrdinal
Print additional debugging information.
Namespace for MueLu classes and methods.