Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Graph Concepts and Containers #634

Open
wants to merge 110 commits into
base: development
Choose a base branch
from
Open

[WIP] Graph Concepts and Containers #634

wants to merge 110 commits into from

Conversation

fuchsto
Copy link
Member

@fuchsto fuchsto commented Mar 9, 2019

As the STL has no equivalent, I defined the DASH graph concepts following the Boost Graph Library (BGL).
In his Master thesis, @stiefn refined and extended concepts for several peculiarities and requirements of PGAS and DASH.
This merge contains his reference implementation. Merging current development was surprisingly non-conflicting.
The implementation proved stable and effizient in several productive scenarios like BFS and Connected Components.

Missing: more unit tests, review, some suggestions for improvement in comments here and there.

@codecov
Copy link

codecov bot commented Mar 12, 2019

Codecov Report

Merging #634 into development will increase coverage by 0.65%.
The diff coverage is 95.24%.

@@               Coverage Diff               @@
##           development     #634      +/-   ##
===============================================
+ Coverage        85.08%   85.74%   +0.65%     
===============================================
  Files              336      355      +19     
  Lines            24954    26570    +1616     
  Branches         11338    12040     +702     
===============================================
+ Hits             21232    22782    +1550     
- Misses            3692     3771      +79     
+ Partials            30       17      -13
Impacted Files Coverage Δ
dash/test/algorithm/ConnectedComponentsTest.h 100% <100%> (ø)
dash/include/dash/memory/GlobHeapLocalPtr.h 95.65% <100%> (+0.06%) ⬆️
dash/include/dash/memory/GlobHeapCombinedMem.h 100% <100%> (ø)
dash/include/dash/graph/VertexIterator.h 100% <100%> (ø)
dash/test/algorithm/MinimumSpanningTreeTest.h 100% <100%> (ø)
dash/include/dash/memory/GlobHeapCombinedPtr.h 100% <100%> (ø)
dash/include/dash/graph/OutEdgeIterator.h 100% <100%> (ø)
dash/include/dash/graph/EdgeIterator.h 100% <100%> (ø)
dash/include/dash/graph/InEdgeIterator.h 100% <100%> (ø)
dash/test/container/GraphTest.h 100% <100%> (ø)
... and 33 more

@fuchsto
Copy link
Member Author

fuchsto commented Mar 12, 2019

@stiefn @fuerlinger @rkowalewski @devreal @pascalj

Graph containers and algorithms are fully merged now, including tests and examples.
Algorithms are Minimum Spanning Tree and Connected Components.

Relevant implementation is in:

  • dash/graph
  • dash/algorithms/graph

Integration tests passed, but could use some more unit tests.

Still, I'm voting for merging it into development, that's what the branch is about.

@devreal
Copy link
Member

devreal commented Mar 12, 2019

I will give the review a try tomorrow on the train.

typedef Vertex<self_t> vertex_type;
typedef Edge<self_t> edge_type;

typedef std::vector<vertex_type> vertex_container_type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is _VertexContainer not used? Same for edge_container_type.

typename EdgeProperties = EmptyProperties, // user-defined struct
typename VertexSizeType = int,
typename EdgeSizeType = int,
//template<class, class...> typename EdgeContainer = std::vector,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove dead code

typename EdgeSizeType = int,
//template<class, class...> typename EdgeContainer = std::vector,
//template<class, class...> typename VertexContainer = std::vector
template<class, class...> class _EdgeContainer = std::vector,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order is reversed, above its always vertex, than edge, here it is edge, than vertex

GraphDirection Direction = DirectedGraph,
typename VertexProperties = EmptyProperties, // user-defined struct
typename EdgeProperties = EmptyProperties, // user-defined struct
typename VertexSizeType = int,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enforce an unsigned type

/**
* Removes a given vertex.
*/
void remove_vertex(const local_vertex_iterator & v) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unimplemented

/**
* Removes the edges between two given vertices.
*/
void remove_edge(const local_vertex_iterator & v1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unimplemented

/**
* Removes the edges between two given vertices.
*/
void remove_edge(const global_vertex_iterator & v1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unimplemented

/**
* Removes a given edge.
*/
void remove_edge(const local_out_edge_iterator & e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unimplemented

/**
* Removes a given edge.
*/
void remove_edge(const global_out_edge_iterator & e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unimplemented

}
*/

// TODO: Generalize following methods for other edge attributes than { int }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this limit the usability of the whole Graph, or are these just convenience functions for the user? I.e, they are not used by the implementation itself?

Copy link
Member

@devreal devreal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot claim to have read every line of code but overall I think the PR is in a good shape already. Documentation is rather scarce imo and can be improved. I see some code duplication that maybe can be avoided. Some minor and not-so-minor comments inline. Also, please add an entry to the CHANGELOG :)

"dart_adapt_teamlist_convert failed", teamid);
return DART_ERR_INVAL;
}
if (sendbuf == recvbuf || NULL == sendbuf) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent with the change in dart_allgatherv above.

@@ -2168,6 +2168,150 @@ dart_ret_t dart_allgatherv(
return DART_OK;
}

#if 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it disabled?

int *isenddispls = malloc(sizeof(int) * comm_size);
int *inrecvcounts = malloc(sizeof(int) * comm_size);
int *irecvdispls = malloc(sizeof(int) * comm_size);
for (int i = 0; i < comm_size; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conversion (size_t -> int) pains me. It would be good to extract it and use a common implementation everywhere.


typedef dash::Graph<dash::DirectedGraph, vprop, eprop> graph_t;

int main(int argc, char* argv[]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a single comment in this file. Please document what the example does and maybe add some comments to the code, too.

}

if(dash::myid() == 0) {
std::clock_t g_begin_time = clock();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have dash::Timer for this?


namespace dash {

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is internal/Graph.h the classes in here should be put into the dash::internal namespace.

*/
void add_globmem(glob_mem_type & glob_mem) {
// only GlobMem objects with the same Team can be used
if(*_team == glob_mem.team()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be an error otherwise?

global_iterator _begin;
global_iterator _end;
local_iterator _lbegin;
local_iterator _lend;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iterators are in an undefined state before the first commit call. Is this acceptable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course not, good catch.

namespace dash {

// TODO: Remove this class and add template parameter for bucket list type to
// GlobHeapLocalPtr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this easy to do before merging?


TEST_F(ConnectedComponentsTest, AlgorithmRun)
{
std::list<std::pair<int, int>> edge_list = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity: how was this generated (please tell me not by hand ;)) and can we generate it on the fly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's from a graph sample data set, @stiefn should know more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants