Skip to content

Commit

Permalink
Merge 'trilinos/Trilinos:develop' (643aa3a) into 'tcad-charon/Trilino…
Browse files Browse the repository at this point in the history
…s:develop' (b6b763a).

* trilinos-develop:
  MueLu: interfacing distance2 coloring work with Aggregates and Phase 1 aggregation issue trilinos#5838
  MueLu: adding unit-test for LWGraph_kokkos
  MueLu: extending the interface of LWGraph to give direct access to rowPtrs and entries
  • Loading branch information
Jenkins Pipeline committed Sep 5, 2019
2 parents b6b763a + 643aa3a commit c0fdf13
Show file tree
Hide file tree
Showing 8 changed files with 425 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

#include "MueLu_BaseClass.hpp"

#include "MueLu_LWGraph_kokkos_fwd.hpp"
#include "MueLu_LWGraph_kokkos.hpp"
#include "MueLu_IndexManager_kokkos.hpp"

#define MUELU_UNAGGREGATED -1 /* indicates that a node is unassigned to */
Expand Down Expand Up @@ -106,15 +106,18 @@ namespace MueLu {
template <class LocalOrdinal, class GlobalOrdinal, class DeviceType>
class Aggregates_kokkos<LocalOrdinal, GlobalOrdinal, Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType> > : public BaseClass {
public:
typedef LocalOrdinal local_ordinal_type;
typedef GlobalOrdinal global_ordinal_type;
typedef typename DeviceType::execution_space execution_space;
typedef Kokkos::RangePolicy<local_ordinal_type, execution_space> range_type;
typedef Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType> node_type;
typedef DeviceType device_type;

typedef Kokkos::View<LocalOrdinal*, DeviceType> aggregates_sizes_type;
typedef Kokkos::StaticCrsGraph<LocalOrdinal, Kokkos::LayoutLeft, execution_space> local_graph_type;
// For some reason we seem intent on having these declared before pulling the short names in
// I am not sure why but I will keep things as it is for now
// If you need to define a type that depend on a short name please do it further down after
// the header has been included!
using local_ordinal_type = LocalOrdinal;
using global_ordinal_type = GlobalOrdinal;
using execution_space = typename DeviceType::execution_space;
using node_type = Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType>;
using device_type = DeviceType;
using range_type = Kokkos::RangePolicy<local_ordinal_type, execution_space>;

using aggregates_sizes_type = Kokkos::View<LocalOrdinal*, DeviceType>;

private:
// For compatibility
Expand All @@ -124,7 +127,10 @@ namespace MueLu {

public:

public:
// Defining types that require the short names included above
using local_graph_type = typename LWGraph_kokkos::local_graph_type;
using colors_view_type = Kokkos::View<typename local_graph_type::entries_type::data_type,
typename local_graph_type::device_type::memory_space>;

/*! @brief Standard constructor for Aggregates structure
*
Expand All @@ -147,29 +153,42 @@ namespace MueLu {
*/
virtual ~Aggregates_kokkos() { }

///< returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLocalAggregates?
KOKKOS_INLINE_FUNCTION LO GetNumAggregates() const {
return numAggregates_;
}

/*! @brief Set number of local aggregates on current processor.
This has to be done by the aggregation routines.
*/
void SetNumAggregates(LO nAggregates) { numAggregates_ = nAggregates; }
//! @name Set/Get Methods for specific aggregation data
//@{

/*! @brief Get the index manager used by structured aggregation algorithms.
This has to be done by the aggregation factory.
*/
RCP<IndexManager_kokkos>& GetIndexManager() { return geoData_; }

/*! @brief Get the index manager used by structured aggregation algorithms.
/*! @brief Set the index manager used by structured aggregation algorithms.
This has to be done by the aggregation factory.
*/
void SetIndexManager(RCP<IndexManager_kokkos> & geoData) { geoData_ = geoData; }

/*! @brief Get a distance 2 coloring of the underlying graph.
The coloring is computed and set during Phase1 of aggregation.
*/
colors_view_type& GetGraphColors() { return graphColors_; }

/*! @brief Set a distance 2 coloring of the underlying graph.
The coloring is computed and set during Phase1 of aggregation.
*/
void SetGraphColors(colors_view_type graphColors) { graphColors_ = graphColors; }

//@}

/*! @brief Set number of local aggregates on current processor.
This has to be done by the aggregation routines.
*/
void SetNumAggregates(LO nAggregates) { numAggregates_ = nAggregates; }

///< returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLocalAggregates?
KOKKOS_INLINE_FUNCTION LO GetNumAggregates() const {
return numAggregates_;
}

//! @brief Record whether aggregates include DOFs from other processes.
KOKKOS_INLINE_FUNCTION void AggregatesCrossProcessors(const bool& flag) {
aggregatesIncludeGhosts_ = flag;
Expand Down Expand Up @@ -262,6 +281,11 @@ namespace MueLu {
*/
RCP<IndexManager_kokkos> geoData_;

/*! graphColors_ stores a view that assigns a color to each node in the graph
* These colors are used to parallelize the aggregation process in UncoupledAggregation
*/
colors_view_type graphColors_;

Kokkos::View<bool*, DeviceType> isRoot_;

//! Set to false iff aggregates do not include any DOFs belong to other processes.
Expand Down
20 changes: 15 additions & 5 deletions packages/muelu/src/Graph/Containers/MueLu_LWGraph_kokkos_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ namespace MueLu {
return graph_.row_map(GetNodeNumVertices());
}

//! Returns the maximum number of entries across all rows/columns on this node
KOKKOS_INLINE_FUNCTION size_type getNodeMaxNumRowEntries () const {
return maxNumRowEntries_;
}

//! Return the row pointers of the local graph
KOKKOS_INLINE_FUNCTION typename local_graph_type::row_map_type getRowPtrs() const {
return graph_.row_map;
}

//! Return the list entries in the local graph
KOKKOS_INLINE_FUNCTION typename local_graph_type::entries_type getEntries() const {
return graph_.entries;
}

//! Return the list of vertices adjacent to the vertex 'v'.
// Unfortunately, C++11 does not support the following:
// auto getNeighborVertices(LO i) const -> decltype(rowView)
Expand All @@ -153,11 +168,6 @@ namespace MueLu {
dirichletBoundaries_ = bndry;
}

//! Returns the maximum number of entries across all rows/columns on this node
KOKKOS_INLINE_FUNCTION size_type getNodeMaxNumRowEntries () const {
return maxNumRowEntries_;
}

//! Returns map with global ids of boundary nodes.
KOKKOS_INLINE_FUNCTION const boundary_nodes_type GetBoundaryNodeMap() const {
return dirichletBoundaries_;
Expand Down
Loading

0 comments on commit c0fdf13

Please sign in to comment.