Skip to content

Commit d0629f1

Browse files
committed
coll/libnbc: optimize size one communicators
simply "return" with ompi_request_empty if the communicator size is 1 Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 9d6e048 commit d0629f1

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

ompi/mca/coll/libnbc/nbc_iallgather.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Corporation. All rights reserved.
66
* Copyright (c) 2006 The Technical University of Chemnitz. All
77
* rights reserved.
8-
* Copyright (c) 2014-2016 Research Organization for Information Science
8+
* Copyright (c) 2014-2017 Research Organization for Information Science
99
* and Technology (RIST). All rights reserved.
1010
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1111
* reserved.
@@ -74,6 +74,10 @@ int ompi_coll_libnbc_iallgather(const void* sendbuf, int sendcount, MPI_Datatype
7474
return res;
7575
}
7676
}
77+
if (1 == p) {
78+
*request = &ompi_request_empty;
79+
return OMPI_SUCCESS;
80+
}
7781

7882
#ifdef NBC_CACHE_SCHEDULE
7983
/* search schedule in communicator specific tree */

ompi/mca/coll/libnbc/nbc_iallreduce.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* rights reserved.
88
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
99
* reserved.
10-
* Copyright (c) 2014-2016 Research Organization for Information Science
10+
* Copyright (c) 2014-2017 Research Organization for Information Science
1111
* and Technology (RIST). All rights reserved.
1212
*
1313
* Author(s): Torsten Hoefler <[email protected]>
@@ -82,6 +82,19 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
8282
return res;
8383
}
8484

85+
if (1 == p) {
86+
if (!inplace) {
87+
/* for a single node - copy data to receivebuf */
88+
res = NBC_Copy(sendbuf, count, datatype, recvbuf, count, datatype, comm);
89+
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
90+
NBC_Return_handle (handle);
91+
return res;
92+
}
93+
}
94+
*request = &ompi_request_empty;
95+
return OMPI_SUCCESS;
96+
}
97+
8598
res = NBC_Init_handle (comm, &handle, libnbc_module);
8699
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
87100
return res;
@@ -94,15 +107,6 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
94107
return OMPI_ERR_OUT_OF_RESOURCE;
95108
}
96109

97-
if ((p == 1) && !inplace) {
98-
/* for a single node - copy data to receivebuf */
99-
res = NBC_Copy(sendbuf, count, datatype, recvbuf, count, datatype, comm);
100-
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
101-
NBC_Return_handle (handle);
102-
return res;
103-
}
104-
}
105-
106110
/* algorithm selection */
107111
if(p < 4 || size*count < 65536 || !ompi_op_is_commute(op) || inplace) {
108112
alg = NBC_ARED_BINOMIAL;

ompi/mca/coll/libnbc/nbc_ibcast.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Corporation. All rights reserved.
66
* Copyright (c) 2006 The Technical University of Chemnitz. All
77
* rights reserved.
8-
* Copyright (c) 2014-2015 Research Organization for Information Science
8+
* Copyright (c) 2014-2017 Research Organization for Information Science
99
* and Technology (RIST). All rights reserved.
1010
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1111
* reserved.
@@ -58,6 +58,11 @@ int ompi_coll_libnbc_ibcast(void *buffer, int count, MPI_Datatype datatype, int
5858
rank = ompi_comm_rank (comm);
5959
p = ompi_comm_size (comm);
6060

61+
if (1 == p) {
62+
*request = &ompi_request_empty;
63+
return OMPI_SUCCESS;
64+
}
65+
6166
res = ompi_datatype_type_size(datatype, &size);
6267
if (MPI_SUCCESS != res) {
6368
NBC_Error("MPI Error in ompi_datatype_type_size() (%i)", res);

ompi/mca/coll/libnbc/nbc_ireduce.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* rights reserved.
88
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
99
* reserved.
10-
* Copyright (c) 2014-2016 Research Organization for Information Science
10+
* Copyright (c) 2014-2017 Research Organization for Information Science
1111
* and Technology (RIST). All rights reserved.
1212
*
1313
* Author(s): Torsten Hoefler <[email protected]>
@@ -80,12 +80,13 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
8080
}
8181

8282
/* only one node -> copy data */
83-
if ((p == 1) && !inplace) {
84-
res = NBC_Copy (sendbuf, count, datatype, recvbuf, count, datatype, comm);
85-
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
86-
return res;
83+
if (p == 1) {
84+
if (!inplace) {
85+
res = NBC_Copy (sendbuf, count, datatype, recvbuf, count, datatype, comm);
86+
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
87+
return res;
88+
}
8789
}
88-
8990
*request = &ompi_request_empty;
9091
return OMPI_SUCCESS;
9192
}

0 commit comments

Comments
 (0)