@@ -54,14 +54,20 @@ int mca_scoll_mpi_broadcast(struct oshmem_group_t *group,
5454 }
5555 dtype = & ompi_mpi_char .dt ;
5656 root = oshmem_proc_group_find_id (group , PE_root );
57+
58+ /* Do nothing on zero-length request */
59+ if (OPAL_UNLIKELY (!nlong )) {
60+ return OSHMEM_SUCCESS ;
61+ }
62+
5763 /* Open SHMEM specification has the following constrains (page 85):
5864 * "If using C/C++, nelems must be of type integer. If you are using Fortran, it must be a
5965 * default integer value". And also fortran signature says "INTEGER".
6066 * Since ompi coll components doesn't support size_t at the moment,
6167 * and considering this contradiction, we cast size_t to int here
6268 * in case if the value is less than INT_MAX and fallback to previous module otherwise. */
6369#ifdef INCOMPATIBLE_SHMEM_OMPI_COLL_APIS
64- if (( INT_MAX < nlong ) || ! nlong ) {
70+ if (INT_MAX < nlong ) {
6571 MPI_COLL_VERBOSE (20 ,"RUNNING FALLBACK BCAST" );
6672 PREVIOUS_SCOLL_FN (mpi_module , broadcast , group ,
6773 PE_root ,
@@ -104,7 +110,13 @@ int mca_scoll_mpi_collect(struct oshmem_group_t *group,
104110 void * sbuf , * rbuf ;
105111 MPI_COLL_VERBOSE (20 ,"RUNNING MPI ALLGATHER" );
106112 mpi_module = (mca_scoll_mpi_module_t * ) group -> g_scoll .scoll_collect_module ;
107- if ((nlong_type == true) && nlong ) {
113+
114+ /* Do nothing on zero-length request */
115+ if (OPAL_UNLIKELY (!nlong )) {
116+ return OSHMEM_SUCCESS ;
117+ }
118+
119+ if (nlong_type == true) {
108120 sbuf = (void * ) source ;
109121 rbuf = target ;
110122 stype = & ompi_mpi_char .dt ;
@@ -177,14 +189,20 @@ int mca_scoll_mpi_reduce(struct oshmem_group_t *group,
177189 dtype = shmem_dtype_to_ompi_dtype (op );
178190 h_op = shmem_op_to_ompi_op (op -> op );
179191 count = nlong /op -> dt_size ;
192+
193+ /* Do nothing on zero-length request */
194+ if (OPAL_UNLIKELY (!nlong )) {
195+ return OSHMEM_SUCCESS ;
196+ }
197+
180198 /* Open SHMEM specification has the following constrains (page 85):
181199 * "If using C/C++, nelems must be of type integer. If you are using Fortran, it must be a
182200 * default integer value". And also fortran signature says "INTEGER".
183201 * Since ompi coll components doesn't support size_t at the moment,
184202 * and considering this contradiction, we cast size_t to int here
185203 * in case if the value is less than INT_MAX and fallback to previous module otherwise. */
186204#ifdef INCOMPATIBLE_SHMEM_OMPI_COLL_APIS
187- if (( INT_MAX < count ) || ! nlong ) {
205+ if (INT_MAX < count ) {
188206 MPI_COLL_VERBOSE (20 ,"RUNNING FALLBACK REDUCE" );
189207 PREVIOUS_SCOLL_FN (mpi_module , reduce , group ,
190208 op ,
0 commit comments