-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: development
Are you sure you want to change the base?
Changes from all commits
e76743a
e9a2857
cbeedc9
3e2c0f6
c4d54cc
31af333
c4f1aa5
82d08f9
6235446
befde77
3bd2868
f155179
162d6c6
8f3dfa8
245556f
21128bb
a2ba2a2
dc592f0
10594f9
091aac9
465ea3a
d0d21ba
e823a29
a533654
da3fef7
be6abb7
93a38e6
3f2e0e9
f8a109d
d2a743c
535d9d0
a00dfd8
ec6ef3b
fd4ec76
3723ca8
a15872b
bdfca65
c904835
5182926
bdf0656
85c3ad8
985c8a3
b52de74
d28e5f0
e270878
34deff0
8ca5796
328585a
7e67e97
e24b120
7513e9c
3b7b344
cdc9a59
ac85bd3
04e9886
040cbd3
4d3e858
14fb545
0642e94
062a8a4
c5688e1
e148ac2
2fc13a2
b471e83
d6af382
e27c4ff
f2cfbc6
86becf7
213c78e
c636f79
a74525d
9ccd6fa
db8d7dc
0537f48
bf1903a
8d15d25
24fcec2
72b2a4c
ba8fbe2
3d0a8b8
cb1b622
0c409bd
fa6a97f
eda7554
690af65
a5b2f07
16a7ed8
a625001
ba45f34
5aed324
2f7f5ad
5531da9
6051bc2
cc0cafb
17e0b48
0453ca1
61376d8
cf8f89f
4a78459
4e83239
f2d31ff
e9de737
97d12db
68db7de
79bbac0
3e6ce99
ec7e50f
8eb4a0d
1a86e36
d25cb8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -2173,6 +2173,150 @@ dart_ret_t dart_allgatherv( | |
return DART_OK; | ||
} | ||
|
||
#if 0 | ||
/* | ||
* 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please be consistent with the change in |
||
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++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This conversion ( |
||
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, | ||
|
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[]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we have |
||
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; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it disabled?