A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Unlike errors on communicators and windows, the default behavior for files is to...
[simgrid.git]
/
src
/
smpi
/
colls
/
gather
/
gather-ompi.cpp
diff --git
a/src/smpi/colls/gather/gather-ompi.cpp
b/src/smpi/colls/gather/gather-ompi.cpp
index
0420e51
..
812ec45
100644
(file)
--- a/
src/smpi/colls/gather/gather-ompi.cpp
+++ b/
src/smpi/colls/gather/gather-ompi.cpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2013-201
7
. The SimGrid Team.
+/* Copyright (c) 2013-201
9
. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
@@
-19,13
+19,13
@@
* Additional copyrights may follow
*/
* Additional copyrights may follow
*/
-#include "../coll
s_private.h
"
-#include "../coll
_tuned_topo.h
"
+#include "../coll
_tuned_topo.hpp
"
+#include "../coll
s_private.hpp
"
namespace simgrid{
namespace smpi{
namespace simgrid{
namespace smpi{
-int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
+int Coll_gather_ompi_binomial::gather(
const
void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
MPI_Datatype rdtype, int root, MPI_Comm comm)
{
int line = -1;
MPI_Datatype rdtype, int root, MPI_Comm comm)
{
int line = -1;
@@
-34,12
+34,13
@@
int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtyp
int vrank;
int size;
int total_recv = 0;
int vrank;
int size;
int total_recv = 0;
- char *ptmp = NULL;
- char *tempbuf = NULL;
+ unsigned char* ptmp = nullptr;
+ unsigned char* tempbuf = nullptr;
+ const unsigned char* src_buf;
int err;
ompi_coll_tree_t* bmtree;
MPI_Status status;
int err;
ompi_coll_tree_t* bmtree;
MPI_Status status;
- MPI_Aint sextent, slb, strue_lb, strue_extent;
+ MPI_Aint sextent, slb, strue_lb, strue_extent;
MPI_Aint rextent, rlb, rtrue_lb, rtrue_extent;
MPI_Aint rextent, rlb, rtrue_lb, rtrue_extent;
@@
-63,7
+64,7
@@
int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtyp
rdtype->extent(&rtrue_lb, &rtrue_extent);
if (0 == root) {
/* root on 0, just use the recv buffer */
rdtype->extent(&rtrue_lb, &rtrue_extent);
if (0 == root) {
/* root on 0, just use the recv buffer */
- ptmp =
(char*)rbuf
;
+ ptmp =
static_cast<unsigned char*>(rbuf)
;
if (sbuf != MPI_IN_PLACE) {
err = Datatype::copy(sbuf, scount, sdtype, ptmp, rcount, rdtype);
if (MPI_SUCCESS != err) {
if (sbuf != MPI_IN_PLACE) {
err = Datatype::copy(sbuf, scount, sdtype, ptmp, rcount, rdtype);
if (MPI_SUCCESS != err) {
@@
-74,7
+75,7
@@
int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtyp
} else {
/* root is not on 0, allocate temp buffer for recv,
* rotate data at the end */
} else {
/* root is not on 0, allocate temp buffer for recv,
* rotate data at the end */
- tempbuf =
(char*)
smpi_get_tmp_recvbuffer(rtrue_extent + (rcount * size - 1) * rextent);
+ tempbuf = smpi_get_tmp_recvbuffer(rtrue_extent + (rcount * size - 1) * rextent);
if (NULL == tempbuf) {
err = MPI_ERR_OTHER;
line = __LINE__;
if (NULL == tempbuf) {
err = MPI_ERR_OTHER;
line = __LINE__;
@@
-99,11
+100,12
@@
int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtyp
}
}
total_recv = rcount;
}
}
total_recv = rcount;
+ src_buf = ptmp;
} else if (!(vrank % 2)) {
/* other non-leaf nodes, allocate temp buffer for data received from
* children, the most we need is half of the total data elements due
* to the property of binimoal tree */
} else if (!(vrank % 2)) {
/* other non-leaf nodes, allocate temp buffer for data received from
* children, the most we need is half of the total data elements due
* to the property of binimoal tree */
- tempbuf =
(char*)
smpi_get_tmp_sendbuffer(strue_extent + (scount * size - 1) * sextent);
+ tempbuf = smpi_get_tmp_sendbuffer(strue_extent + (scount * size - 1) * sextent);
if (NULL == tempbuf) {
err = MPI_ERR_OTHER;
line = __LINE__;
if (NULL == tempbuf) {
err = MPI_ERR_OTHER;
line = __LINE__;
@@
-124,11
+126,12
@@
int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtyp
rcount = scount;
rextent = sextent;
total_recv = rcount;
rcount = scount;
rextent = sextent;
total_recv = rcount;
+ src_buf = ptmp;
} else {
/* leaf nodes, no temp buffer needed, use sdtype,scount as
* rdtype,rdcount since they are ignored on non-root procs */
} else {
/* leaf nodes, no temp buffer needed, use sdtype,scount as
* rdtype,rdcount since they are ignored on non-root procs */
- ptmp = (char*)sbuf;
total_recv = scount;
total_recv = scount;
+ src_buf = static_cast<const unsigned char*>(sbuf);
}
if (!(vrank % 2)) {
}
if (!(vrank % 2)) {
@@
-156,7
+159,7
@@
int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtyp
/* all nodes except root send to parents */
XBT_DEBUG("smpi_coll_tuned_gather_ompi_binomial rank %d send %d count %d\n", rank, bmtree->tree_prev, total_recv);
/* all nodes except root send to parents */
XBT_DEBUG("smpi_coll_tuned_gather_ompi_binomial rank %d send %d count %d\n", rank, bmtree->tree_prev, total_recv);
- Request::send(
ptmp
, total_recv, sdtype, bmtree->tree_prev, COLL_TAG_GATHER, comm);
+ Request::send(
src_buf
, total_recv, sdtype, bmtree->tree_prev, COLL_TAG_GATHER, comm);
}
if (rank == root) {
if (root != 0) {
}
if (rank == root) {
if (root != 0) {
@@
-181,7
+184,7
@@
int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtyp
/* other non-leaf nodes */
smpi_free_tmp_buffer(tempbuf);
}
/* other non-leaf nodes */
smpi_free_tmp_buffer(tempbuf);
}
-
xbt_free(
bmtree);
+
ompi_coll_tuned_topo_destroy_tree(&
bmtree);
return MPI_SUCCESS;
err_hndl:
return MPI_SUCCESS;
err_hndl:
@@
-199,11
+202,11
@@
int Coll_gather_ompi_binomial::gather(void* sbuf, int scount, MPI_Datatype sdtyp
* Accepts: - same arguments as MPI_Gather(), first segment size
* Returns: - MPI_SUCCESS or error code
*/
* Accepts: - same arguments as MPI_Gather(), first segment size
* Returns: - MPI_SUCCESS or error code
*/
-int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
+int Coll_gather_ompi_linear_sync::gather(
const
void *sbuf, int scount,
MPI_Datatype sdtype,
void *rbuf, int rcount,
MPI_Datatype rdtype,
MPI_Datatype sdtype,
void *rbuf, int rcount,
MPI_Datatype rdtype,
- int root,
+ int root,
MPI_Comm comm)
{
int i;
MPI_Comm comm)
{
int i;
@@
-217,7
+220,7
@@
int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
int first_segment_size=0;
size = comm->size();
rank = comm->rank();
int first_segment_size=0;
size = comm->size();
rank = comm->rank();
-
+
size_t dsize, block_size;
if (rank == root) {
dsize= rdtype->size();
size_t dsize, block_size;
if (rank == root) {
dsize= rdtype->size();
@@
-226,7
+229,7
@@
int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
dsize=sdtype->size();
block_size = dsize * scount;
}
dsize=sdtype->size();
block_size = dsize * scount;
}
-
+
if (block_size > 92160){
first_segment_size = 32768;
}else{
if (block_size > 92160){
first_segment_size = 32768;
}else{
@@
-247,7
+250,7
@@
int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
first_segment_count = scount;
COLL_TUNED_COMPUTED_SEGCOUNT((size_t)first_segment_size, typelng, first_segment_count);
first_segment_count = scount;
COLL_TUNED_COMPUTED_SEGCOUNT((size_t)first_segment_size, typelng, first_segment_count);
- Request::recv(
sbuf
, 0, MPI_BYTE, root, COLL_TAG_GATHER, comm, MPI_STATUS_IGNORE);
+ Request::recv(
nullptr
, 0, MPI_BYTE, root, COLL_TAG_GATHER, comm, MPI_STATUS_IGNORE);
Request::send(sbuf, first_segment_count, sdtype, root, COLL_TAG_GATHER, comm);
Request::send(sbuf, first_segment_count, sdtype, root, COLL_TAG_GATHER, comm);
@@
-266,32
+269,32
@@
int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
- Waitall for all the second segments to complete.
*/
char* ptmp;
- Waitall for all the second segments to complete.
*/
char* ptmp;
- MPI_Request
*reqs = NULL,
first_segment_req;
-
reqs = (MPI_Request*)calloc(size, sizeof(MPI_Request))
;
+ MPI_Request first_segment_req;
+
MPI_Request* reqs = new (std::nothrow) MPI_Request[size]
;
if (NULL == reqs) {
ret = -1;
line = __LINE__;
goto error_hndl; }
if (NULL == reqs) {
ret = -1;
line = __LINE__;
goto error_hndl; }
-
+
typelng=rdtype->size();
rdtype->extent(&lb, &extent);
first_segment_count = rcount;
typelng=rdtype->size();
rdtype->extent(&lb, &extent);
first_segment_count = rcount;
- COLL_TUNED_COMPUTED_SEGCOUNT( (size_t)first_segment_size, typelng,
+ COLL_TUNED_COMPUTED_SEGCOUNT( (size_t)first_segment_size, typelng,
first_segment_count );
for (i = 0; i < size; ++i) {
first_segment_count );
for (i = 0; i < size; ++i) {
- if (i == rank) {
+ if (i == rank) {
/* skip myself */
/* skip myself */
- reqs[i] = MPI_REQUEST_NULL;
- continue;
- }
+ reqs[i] = MPI_REQUEST_NULL;
+ continue;
+ }
/* irecv for the first segment from i */
ptmp = (char*)rbuf + i * rcount * extent;
first_segment_req = Request::irecv(ptmp, first_segment_count, rdtype, i,
COLL_TAG_GATHER, comm
);
/* irecv for the first segment from i */
ptmp = (char*)rbuf + i * rcount * extent;
first_segment_req = Request::irecv(ptmp, first_segment_count, rdtype, i,
COLL_TAG_GATHER, comm
);
-
+
/* send sync message */
Request::send(rbuf, 0, MPI_BYTE, i,
COLL_TAG_GATHER,
/* send sync message */
Request::send(rbuf, 0, MPI_BYTE, i,
COLL_TAG_GATHER,
@@
-299,7
+302,7
@@
int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
/* irecv for the second segment */
ptmp = (char*)rbuf + (i * rcount + first_segment_count) * extent;
/* irecv for the second segment */
ptmp = (char*)rbuf + (i * rcount + first_segment_count) * extent;
- reqs[i]=Request::irecv(ptmp, (rcount - first_segment_count),
+ reqs[i]=Request::irecv(ptmp, (rcount - first_segment_count),
rdtype, i, COLL_TAG_GATHER, comm
);
rdtype, i, COLL_TAG_GATHER, comm
);
@@
-310,24
+313,24
@@
int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
/* copy local data if necessary */
if (MPI_IN_PLACE != sbuf) {
ret = Datatype::copy(sbuf, scount, sdtype,
/* copy local data if necessary */
if (MPI_IN_PLACE != sbuf) {
ret = Datatype::copy(sbuf, scount, sdtype,
- (char*)rbuf + rank * rcount * extent,
+ (char*)rbuf + rank * rcount * extent,
rcount, rdtype);
if (ret != MPI_SUCCESS) { line = __LINE__; goto error_hndl; }
}
rcount, rdtype);
if (ret != MPI_SUCCESS) { line = __LINE__; goto error_hndl; }
}
-
+
/* wait all second segments to complete */
ret = Request::waitall(size, reqs, MPI_STATUSES_IGNORE);
if (ret != MPI_SUCCESS) { line = __LINE__; goto error_hndl; }
/* wait all second segments to complete */
ret = Request::waitall(size, reqs, MPI_STATUSES_IGNORE);
if (ret != MPI_SUCCESS) { line = __LINE__; goto error_hndl; }
-
free(reqs)
;
+
delete[] reqs
;
}
/* All done */
return MPI_SUCCESS;
error_hndl:
}
/* All done */
return MPI_SUCCESS;
error_hndl:
- XBT_DEBUG(
- "ERROR_HNDL: node %d file %s line %d error %d\n",
+ XBT_DEBUG(
+ "ERROR_HNDL: node %d file %s line %d error %d\n",
rank, __FILE__, line, ret );
return ret;
}
rank, __FILE__, line, ret );
return ret;
}
@@
-335,8
+338,8
@@
int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
/*
* Linear functions are copied from the BASIC coll module
* they do not segment the message and are simple implementations
/*
* Linear functions are copied from the BASIC coll module
* they do not segment the message and are simple implementations
- * but for some small number of nodes and/or small data sizes they
- * are just as fast as tuned/tree based segmenting operations
+ * but for some small number of nodes and/or small data sizes they
+ * are just as fast as tuned/tree based segmenting operations
* and as such may be selected by the decision functions
* These are copied into this module due to the way we select modules
* in V1. i.e. in V2 we will handle this differently and so will not
* and as such may be selected by the decision functions
* These are copied into this module due to the way we select modules
* in V1. i.e. in V2 we will handle this differently and so will not
@@
-352,7
+355,7
@@
int Coll_gather_ompi_linear_sync::gather(void *sbuf, int scount,
* Accepts: - same arguments as MPI_Gather()
* Returns: - MPI_SUCCESS or error code
*/
* Accepts: - same arguments as MPI_Gather()
* Returns: - MPI_SUCCESS or error code
*/
-int Coll_gather_ompi_basic_linear::gather(void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
+int Coll_gather_ompi_basic_linear::gather(
const
void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount,
MPI_Datatype rdtype, int root, MPI_Comm comm)
{
int i;
MPI_Datatype rdtype, int root, MPI_Comm comm)
{
int i;