@@ -30,7 +30,6 @@ static pthread_mutex_t gmr_list_mutex = PTHREAD_MUTEX_INITIALIZER;
30
30
*/
31
31
gmr_t * gmr_create (gmr_size_t local_size , void * * base_ptrs , ARMCI_Group * group ) {
32
32
int i ;
33
- gmr_size_t aggregate_size ;
34
33
int alloc_me , alloc_nproc ;
35
34
int world_me , world_nproc ;
36
35
MPI_Group world_group , alloc_group ;
@@ -40,6 +39,21 @@ gmr_t *gmr_create(gmr_size_t local_size, void **base_ptrs, ARMCI_Group *group) {
40
39
ARMCII_Assert (local_size >= 0 );
41
40
ARMCII_Assert (group != NULL );
42
41
42
+ /* determine if the GMR construction is pointless and exit early */
43
+ {
44
+ gmr_size_t max_local_size = 1 <<30 ;
45
+
46
+ /* if gmr_size_t changes from long, this needs to change... */
47
+ MPI_Allreduce (& local_size , & max_local_size , 1 , MPI_LONG , MPI_MAX , group -> comm );
48
+
49
+ if (max_local_size == 0 ) {
50
+ for (i = 0 ; i < alloc_nproc ; i ++ ) {
51
+ base_ptrs [i ] = NULL ;
52
+ }
53
+ return NULL ;
54
+ }
55
+ }
56
+
43
57
MPI_Comm_rank (group -> comm , & alloc_me );
44
58
MPI_Comm_size (group -> comm , & alloc_nproc );
45
59
MPI_Comm_rank (ARMCI_GROUP_WORLD .comm , & world_me );
@@ -114,24 +128,6 @@ gmr_t *gmr_create(gmr_size_t local_size, void **base_ptrs, ARMCI_Group *group) {
114
128
MPI_Allgather ( & gmr_slice , sizeof (gmr_slice_t ), MPI_BYTE ,
115
129
alloc_slices , sizeof (gmr_slice_t ), MPI_BYTE , group -> comm );
116
130
117
- /* Check for a global size 0 allocation */
118
- for (i = aggregate_size = 0 ; i < alloc_nproc ; i ++ ) {
119
- aggregate_size += alloc_slices [i ].size ;
120
- }
121
-
122
- /* Everyone asked for 0 bytes, return a NULL vector */
123
- if (aggregate_size == 0 ) {
124
- free (alloc_slices );
125
- free (mreg -> slices );
126
- MPI_Win_free (& mreg -> window );
127
- free (mreg );
128
-
129
- for (i = 0 ; i < alloc_nproc ; i ++ )
130
- base_ptrs [i ] = NULL ;
131
-
132
- return NULL ;
133
- }
134
-
135
131
/* Populate the base pointers array */
136
132
for (i = 0 ; i < alloc_nproc ; i ++ )
137
133
base_ptrs [i ] = alloc_slices [i ].base ;
0 commit comments