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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
e76743a
added rough graph concept
stiefn Dec 12, 2016
e9a2857
added empty partition concept
stiefn Dec 12, 2016
cbeedc9
added starting point for vertex partitioning scheme concept
stiefn Dec 14, 2016
3e2c0f6
added starting point for load balanced vertex partitioning scheem con…
stiefn Dec 14, 2016
c4d54cc
renamed file
stiefn Dec 14, 2016
31af333
changed define in Partition.h
stiefn Dec 14, 2016
c4f1aa5
refactored partitions and graph iterators
stiefn Jan 17, 2017
82d08f9
added raw signature for graph patterns
stiefn Jan 30, 2017
6235446
updated graph interface
stiefn Jan 30, 2017
befde77
added working frame for graph implementation
stiefn Mar 7, 2017
3bd2868
merged development
stiefn Mar 9, 2017
f155179
added local vertex list allocation
stiefn Mar 9, 2017
162d6c6
added local vertex iterator
stiefn Mar 9, 2017
8f3dfa8
fixed local vertex iterators
stiefn Mar 10, 2017
245556f
fixed seq globmem shrink
stiefn Mar 10, 2017
21128bb
merged development
stiefn Mar 10, 2017
a2ba2a2
fixed increment of LocalBucketIter
stiefn Mar 10, 2017
dc592f0
changed seq globmem functionality
stiefn Mar 13, 2017
10594f9
renamed GlobDynamicSequentialMem
stiefn Mar 13, 2017
091aac9
added (non-working) collective allocation
stiefn Mar 13, 2017
465ea3a
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Mar 14, 2017
d0d21ba
Minor, added notes
fuchsto Mar 14, 2017
e823a29
added global vertex iterator
stiefn Mar 17, 2017
a533654
merged Graph.h and Graph-impl.h
stiefn Mar 17, 2017
da3fef7
added local vertex index support
stiefn Mar 20, 2017
be6abb7
refactored GlobDynamicContiguousMem to support multiple containers
stiefn Mar 20, 2017
93a38e6
added local edge iteration capabilities
stiefn Mar 21, 2017
3f2e0e9
fixed global iterators for more than one globmem container
stiefn Mar 22, 2017
f8a109d
chnaged index types
stiefn Mar 29, 2017
d2a743c
added alltoall dart function
stiefn Mar 29, 2017
535d9d0
added edge exchange functionality
stiefn Mar 29, 2017
a00dfd8
merged development
stiefn Mar 29, 2017
ec6ef3b
adjusted to changes from merge (NOT working with current state of DART)
stiefn Mar 29, 2017
fd4ec76
specialized GlobPtr for GlobDynamicContiguousMem
stiefn Mar 30, 2017
3723ca8
removed GlobGraphIter
stiefn Mar 30, 2017
a15872b
simplified global iteration
stiefn Mar 31, 2017
bdfca65
added support for allocating different amounts of containers on diffe…
stiefn Mar 31, 2017
c904835
changed edge index
stiefn Apr 3, 2017
5182926
added in- and out-edge iteration functionality
stiefn Apr 3, 2017
bdf0656
added memory space unifier
stiefn Apr 8, 2017
85c3ad8
refactored Edge and Vertex
stiefn Apr 19, 2017
985c8a3
added adjacency iterators
stiefn Apr 19, 2017
b52de74
added various refactorings and comments
stiefn Apr 20, 2017
d28e5f0
added missing memory detach
stiefn Apr 20, 2017
e270878
minor bug fixes
stiefn Apr 28, 2017
34deff0
fixed include error
stiefn Apr 28, 2017
8ca5796
Added Stefan's graph example
fuchsto Apr 28, 2017
328585a
renamed example main to include it in build
stiefn Apr 30, 2017
7e67e97
fixed double deallocation bug
stiefn Apr 30, 2017
e24b120
fixed template parameter for underlying container
stiefn May 1, 2017
7513e9c
added integration test for graph iterators
stiefn Jun 1, 2017
3b7b344
exchanged indices with iterators
stiefn Oct 30, 2017
cdc9a59
adapted code to concept change
stiefn Nov 6, 2017
ac85bd3
fixed combined edge adjacency iteration
stiefn Nov 7, 2017
04e9886
finished proxy types
stiefn Nov 7, 2017
040cbd3
merged development
stiefn Nov 10, 2017
4d3e858
fixed dart_storage call
stiefn Nov 10, 2017
14fb545
fixed set_attributes for local pointers
stiefn Nov 13, 2017
0642e94
fixed dart_alltoallv
stiefn Dec 6, 2017
062a8a4
added graph constructor with edge-list initialization
stiefn Dec 6, 2017
c5688e1
fixed constructor for edge-list initialization
stiefn Dec 11, 2017
e148ac2
fixed wrong size type in GlobHeapContiguousMem
stiefn Dec 11, 2017
2fc13a2
optimized performance
stiefn Dec 14, 2017
b471e83
removed unnecessary code
stiefn Dec 14, 2017
d6af382
fixed dart_allgatherv
stiefn Dec 14, 2017
e27c4ff
optimized iterator performance
stiefn Jan 8, 2018
f2cfbc6
added local iterator range for adjacency iteration
stiefn Jan 8, 2018
86becf7
fixed wrong pointer type
stiefn Jan 28, 2018
213c78e
fixed bottleneck in GlobPtr
stiefn Feb 1, 2018
c636f79
cleaned up old cold fragments
stiefn Feb 6, 2018
a74525d
added graph algorithms
stiefn Feb 6, 2018
9ccd6fa
added support for construction with whole edge list per unit
stiefn Feb 8, 2018
db8d7dc
fixed connected components algorithm
stiefn Feb 8, 2018
0537f48
fixed alltoallv
stiefn Feb 8, 2018
bf1903a
merged development
stiefn Feb 8, 2018
8d15d25
fixed dart_alltoall
stiefn Feb 8, 2018
24fcec2
added graph constructor test
stiefn Feb 8, 2018
72b2a4c
added connected components test
stiefn Feb 8, 2018
ba8fbe2
fixed set_attributes for edges
stiefn Feb 8, 2018
3d0a8b8
added graph constructor for edge lists with edge attributes
stiefn Feb 8, 2018
cb1b622
updated mst algorithm to put mark minimum edges directly in the graph…
stiefn Feb 12, 2018
0c409bd
added minimum spanning tree test
stiefn Feb 12, 2018
fa6a97f
reduced algorithm complexity
stiefn Feb 14, 2018
eda7554
added element accumulation map for whole units
stiefn Feb 14, 2018
690af65
added further algorithm optimizations
stiefn Feb 18, 2018
a5b2f07
removed bucket sizes of other units to reduce memory consumption
stiefn Feb 19, 2018
16a7ed8
fixed cc algorithm
stiefn Feb 20, 2018
a625001
further optimizations
stiefn Feb 21, 2018
ba45f34
optimized MST algorithm
stiefn Feb 21, 2018
5aed324
adapted tests
stiefn Feb 21, 2018
2f7f5ad
updated cc algorithm
stiefn Feb 23, 2018
5531da9
optimized cc again
stiefn Feb 23, 2018
6051bc2
updated mst algorithm
stiefn Feb 23, 2018
cc0cafb
further optimized algorithms
stiefn Feb 26, 2018
17e0b48
added meta functions
stiefn Feb 26, 2018
0453ca1
updated algorithms
stiefn Feb 26, 2018
61376d8
added external vertex->unit mapping to graph constructor
stiefn Mar 1, 2018
cf8f89f
fixed mst algorithm
stiefn Mar 8, 2018
4a78459
fixed logarithmic vertex mapper
stiefn Mar 8, 2018
4e83239
fixed algorithm tests
stiefn Mar 8, 2018
f2d31ff
fixed mst algorithm again
stiefn Mar 8, 2018
e9de737
added size method to wrapper function objects
stiefn Mar 9, 2018
97d12db
removed unnecessary code
stiefn Mar 18, 2018
68db7de
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Mar 8, 2019
79bbac0
Updated dart_alltoallv feat-graph (missing in dev)
fuchsto Mar 8, 2019
3e6ce99
added dart_alltoallv, added graph examples, fixing compiler errors
fuchsto Mar 12, 2019
ec7e50f
Fixed compiler errors in Graph
fuchsto Mar 12, 2019
8eb4a0d
Added graph microbench examples
fuchsto Mar 12, 2019
1a86e36
Fixed clang compiler errors, added acknowledgements
fuchsto Mar 12, 2019
d25cb8e
Merge branch 'development' into feat-graph
fuchsto Dec 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions dart-if/include/dash/dart/if/dart_communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,60 @@ dart_ret_t dart_allgatherv(
const size_t * recvdispls,
dart_team_t teamid) DART_NOTHROW;

/**
* DART Equivalent to MPI alltoall.
*
* \param sendbuf The buffer containing the data to be sent by each unit.
* \param recvbuf The buffer to hold the received data.
* \param nelem Number of values sent by each process and received from
* each unit.
* \param dtype The data type of values in \c sendbuf and \c recvbuf.
* \param team The team to participate in the allgather.
*
* \return \c DART_OK on success, any other of \ref dart_ret_t otherwise.
*
* \threadsafe_data{team}
* \ingroup DartCommunication
*/
dart_ret_t dart_alltoall(
const void * sendbuf,
void * recvbuf,
size_t nelem,
dart_datatype_t dtype,
dart_team_t team) DART_NOTHROW;

/**
* DART Equivalent to MPI alltoallv.
*
* \param sendbuf The buffer containing the data to be sent by each unit.
* \param nsendcounts Array containing the number of values to be sent by
* each unit.
* \param senddispls Array containing the displacements of data to be sent
* by each unit.
* \param dtype The data type of values in \c sendbuf and \c recvbuf.
* \param recvbuf The buffer to hold the received data.
* \param nrecvelem Array containing the number of values to receive from
* each unit.
* \param recvdispls Array containing the displacements of data received
* from each unit in \c recvbuf.
* \param teamid The team to participate in the allgatherv.
*
* \return \c DART_OK on success, any other of \ref dart_ret_t otherwise.
*
* \threadsafe_data{team}
* \ingroup DartCommunication
*/
dart_ret_t dart_alltoallv(
const void * sendbuf,
const size_t * nsendcounts,
const size_t * senddispls,
dart_datatype_t dtype,
void * recvbuf,
const size_t * nrecvelem,
const size_t * recvdispls,
dart_team_t teamid) DART_NOTHROW;


/**
* DART Equivalent to MPI allreduce.
*
Expand Down
146 changes: 145 additions & 1 deletion dart-impl/mpi/src/dart_communication.c
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,7 @@ dart_ret_t dart_allgatherv(
DART_LOG_ERROR("dart_allgatherv ! unknown teamid %d", teamid);
return DART_ERR_INVAL;
}
if (sendbuf == recvbuf || NULL == sendbuf) {
if (sendbuf == recvbuf) {
sendbuf = MPI_IN_PLACE;
}
MPI_Comm comm = team_data->comm;
Expand Down Expand Up @@ -2173,6 +2173,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?

/*
* Implementation from branch feat-graph, to be discussed
*/
dart_ret_t dart_alltoall(
const void * sendbuf,
void * recvbuf,
size_t nelem,
dart_datatype_t dtype,
dart_team_t teamid)
{
MPI_Datatype mpi_dtype = dart__mpi__datatype_struct(dtype)->basic.mpi_type;
MPI_Comm comm;
DART_LOG_TRACE("dart_alltoall() team:%d nelem:%"PRIu64"",
teamid, nelem);

if (teamid == DART_UNDEFINED_TEAM_ID) {
DART_LOG_ERROR("dart_alltoall ! failed: team may not be DART_UNDEFINED_TEAM_ID");
return DART_ERR_INVAL;
}

/*
* MPI uses offset type int, do not copy more than INT_MAX elements:
*/
if (nelem > INT_MAX) {
DART_LOG_ERROR("dart_alltoall ! failed: nelem > INT_MAX");
return DART_ERR_INVAL;
}

dart_team_data_t *team_data = dart_adapt_teamlist_get(teamid);
if (team_data == NULL) {
DART_LOG_ERROR("dart_alltoall ! team:%d "
"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.

sendbuf = MPI_IN_PLACE;
}
comm = team_data->comm;
if (MPI_Alltoall(
sendbuf,
nelem,
mpi_dtype,
recvbuf,
nelem,
mpi_dtype,
comm) != MPI_SUCCESS) {
DART_LOG_ERROR("dart_alltoall ! team:%d nelem:%"PRIu64" failed",
teamid, nelem);
return DART_ERR_INVAL;
}
DART_LOG_TRACE("dart_alltoall > team:%d nelem:%"PRIu64"",
teamid, nelem);
return DART_OK;
}
#endif

/*
* Implementation from branch feat-graph, to be discussed
*/
dart_ret_t dart_alltoallv(
const void * sendbuf,
const size_t * nsendcounts,
const size_t * senddispls,
dart_datatype_t dtype,
void * recvbuf,
const size_t * nrecvcounts,
const size_t * recvdispls,
dart_team_t teamid)
{
MPI_Datatype mpi_dtype = dart__mpi__datatype_struct(dtype)->contiguous.mpi_type;
MPI_Comm comm;
int comm_size;
DART_LOG_TRACE("dart_alltoallv() team:%d nsendelem:%"PRIu64"",
teamid, nsendcounts);

if (teamid == DART_UNDEFINED_TEAM_ID) {
DART_LOG_ERROR(
"dart_alltoallv ! failed: team may not be DART_UNDEFINED_TEAM_ID");
return DART_ERR_INVAL;
}

dart_team_data_t *team_data = dart_adapt_teamlist_get(teamid);
if (team_data == NULL) {
DART_LOG_ERROR("dart_alltoallv ! team:%d "
"dart_adapt_teamlist_convert failed", teamid);
return DART_ERR_INVAL;
}
comm = team_data->comm;

// convert nrecvcounts and recvdispls
MPI_Comm_size(comm, &comm_size);
int *insendcounts = malloc(sizeof(int) * comm_size);
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.

if (nsendcounts[i] > INT_MAX || senddispls[i] > INT_MAX) {
DART_LOG_ERROR(
"dart_alltoallv ! failed: "
"nsendcounts[%i] > INT_MAX || senddispls[%i] > INT_MAX", i, i);
free(insendcounts);
free(isenddispls);
return DART_ERR_INVAL;
}
if (nrecvcounts[i] > INT_MAX || recvdispls[i] > INT_MAX) {
DART_LOG_ERROR(
"dart_alltoallv ! failed: "
"nrecvcounts[%i] > INT_MAX || recvdispls[%i] > INT_MAX", i, i);
free(inrecvcounts);
free(irecvdispls);
return DART_ERR_INVAL;
}
insendcounts[i] = nsendcounts[i];
isenddispls[i] = senddispls[i];
inrecvcounts[i] = nrecvcounts[i];
irecvdispls[i] = recvdispls[i];
}

if (MPI_Alltoallv(
sendbuf,
insendcounts,
isenddispls,
mpi_dtype,
recvbuf,
inrecvcounts,
irecvdispls,
mpi_dtype,
comm) != MPI_SUCCESS) {
DART_LOG_ERROR("dart_alltoallv ! team:%d failed", teamid);
free(insendcounts);
free(isenddispls);
free(inrecvcounts);
free(irecvdispls);
return DART_ERR_INVAL;
}
free(insendcounts);
free(isenddispls);
free(inrecvcounts);
free(irecvdispls);
DART_LOG_TRACE("dart_alltoallv > team:%d", teamid);
return DART_OK;
}

dart_ret_t dart_allreduce(
const void * sendbuf,
void * recvbuf,
Expand Down
121 changes: 121 additions & 0 deletions dash/examples/ex.02.graph-deref/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#include <libdash.h>
#include <iostream>
#include <ctime>
#include <math.h>
// #include "rmatrandom.h"

struct vprop {
int comp;
};

struct eprop {
int comp;
};

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.

dash::init(&argc, &argv);

int n_unit_edges = 1;
int n_vertices_full = 448;
int n_edges_full = n_vertices_full * n_unit_edges;
// not exactly n_vertices_full are generated due to rounding
int n_vertices_start = n_vertices_full / dash::size();
int n_size_rounds = 5;
int n_rounds = 1;
for(int rounds = 0; rounds < n_size_rounds; ++rounds) {
for(int i = 0; i < n_rounds; ++i) {
int scale = rounds + 1;
int n_vertices = n_vertices_start * scale;
graph_t g(n_vertices, n_unit_edges);

for(int j = 0; j < n_vertices; ++j) {
g.add_vertex();
}

g.commit();

int n_edges = n_vertices * n_unit_edges;
auto src = g.vertices().lbegin();
auto trg = src + 1;
auto end = g.vertices().lend();
for(int j = 0; j < n_edges; ++j) {
g.add_edge(src, trg);
++src;
++trg;
if(trg == end) {
src = g.vertices().lbegin();
trg = src + 1;
}
}

g.commit();

std::clock_t g_begin_time = clock();
for(auto it = g.vertices().lbegin(); it != g.vertices().lend(); ++it) {
auto v = g[it];
v.attributes();
}
std::clock_t g_end_time = clock();
double time = double(g_end_time - g_begin_time) / CLOCKS_PER_SEC;

double all_time;
dart_reduce(&time, &all_time, 1, DART_TYPE_DOUBLE, DART_OP_SUM, 0,
g.team().dart_id());

if(dash::myid() == 0) {
std::cout << "[round " << i << "] " << n_vertices_full * scale <<
" vertices per node dereferenced (local): " << all_time <<
std::endl;
}

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?

for(auto it = g.vertices().begin(); it != g.vertices().end(); ++it) {
auto v = g[it];
v.attributes();
}
std::clock_t g_end_time = clock();
std::cout << "[round " << i << "] " << n_vertices_full * scale <<
" vertices per node dereferenced (global): " <<
double(g_end_time - g_begin_time) / CLOCKS_PER_SEC << std::endl;
}

g_begin_time = clock();
for(auto it = g.out_edges().lbegin(); it != g.out_edges().lend(); ++it) {
auto e = g[it];
e.attributes();
}
g_end_time = clock();
time = double(g_end_time - g_begin_time) / CLOCKS_PER_SEC;

dart_reduce(&time, &all_time, 1, DART_TYPE_DOUBLE, DART_OP_SUM, 0,
g.team().dart_id());

if(dash::myid() == 0) {
std::cout << "[round " << i << "] " << n_edges_full * scale <<
" edges per node dereferenced (local): " << all_time << std::endl;
}

if(dash::myid() == 0) {
std::clock_t g_begin_time = clock();
for(auto it = g.out_edges().begin(); it != g.out_edges().end(); ++it) {
auto e = g[it];
e.attributes();
}
std::clock_t g_end_time = clock();
std::cout << "[round " << i << "] " << n_edges_full * scale <<
" edges per node dereferenced (global): " <<
double(g_end_time - g_begin_time) / CLOCKS_PER_SEC << std::endl;
}
dash::barrier();
}
if(dash::myid() == 0) std::cout << "-----------------" << std::endl;
}

dash::finalize();
return 0;
}


Loading