22
22
* and Technology (RIST). All rights reserved.
23
23
* Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
24
24
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
25
- * Copyright (c) 2018 Triad National Security, LLC. All rights
25
+ * Copyright (c) 2018-2019 Triad National Security, LLC. All rights
26
26
* reserved.
27
27
* $COPYRIGHT$
28
28
*
49
49
#include "ompi/dpm/dpm.h"
50
50
#include "ompi/memchecker.h"
51
51
#include "ompi/instance/instance.h"
52
+ #include "ompi/mpi/fortran/use-mpi-f08/constants.h"
52
53
53
54
/*
54
55
** Table for Fortran <-> C communicator handle conversion
@@ -112,6 +113,31 @@ int ompi_comm_init(void)
112
113
return OMPI_ERROR ;
113
114
}
114
115
116
+ /*
117
+ * reserve indices in the F to C table for:
118
+ * MPI_COMM_WORLD
119
+ * MPI_COMM_SELF
120
+ * MPI_COMM_NULL
121
+ */
122
+
123
+ if (OPAL_SUCCESS != opal_pointer_array_set_item (& ompi_comm_f_to_c_table ,
124
+ OMPI_MPI_COMM_NULL ,
125
+ (void * )-1L )) {
126
+ return OMPI_ERROR ;
127
+ }
128
+
129
+ if (OPAL_SUCCESS != opal_pointer_array_set_item (& ompi_comm_f_to_c_table ,
130
+ OMPI_MPI_COMM_WORLD ,
131
+ (void * )-1L )) {
132
+ return OMPI_ERROR ;
133
+ }
134
+
135
+ if (OPAL_SUCCESS != opal_pointer_array_set_item (& ompi_comm_f_to_c_table ,
136
+ OMPI_MPI_COMM_SELF ,
137
+ (void * )-1L )) {
138
+ return OMPI_ERROR ;
139
+ }
140
+
115
141
/* Setup MPI_COMM_NULL */
116
142
OBJ_CONSTRUCT (& ompi_mpi_comm_null , ompi_communicator_t );
117
143
ompi_mpi_comm_null .comm .c_local_group = & ompi_mpi_group_null .group ;
@@ -157,7 +183,7 @@ int ompi_comm_init_mpi3 (void)
157
183
158
184
/* Setup MPI_COMM_WORLD */
159
185
OBJ_CONSTRUCT (& ompi_mpi_comm_world , ompi_communicator_t );
160
- assert (ompi_mpi_comm_world .comm .c_f_to_c_index == 1 );
186
+ assert (ompi_mpi_comm_world .comm .c_f_to_c_index == OMPI_MPI_COMM_WORLD );
161
187
162
188
ret = ompi_group_from_pset (ompi_mpi_instance_default , "mpi://world" , & group );
163
189
if (OPAL_UNLIKELY (OMPI_SUCCESS != ret )) {
@@ -211,7 +237,7 @@ int ompi_comm_init_mpi3 (void)
211
237
}
212
238
/* Setup MPI_COMM_SELF */
213
239
OBJ_CONSTRUCT (& ompi_mpi_comm_self , ompi_communicator_t );
214
- assert (ompi_mpi_comm_self .comm .c_f_to_c_index == 2 );
240
+ assert (ompi_mpi_comm_self .comm .c_f_to_c_index == OMPI_MPI_COMM_SELF );
215
241
216
242
ret = ompi_group_from_pset (ompi_mpi_instance_default , "mpi://self" , & group );
217
243
if (OPAL_UNLIKELY (OMPI_SUCCESS != ret )) {
@@ -380,7 +406,7 @@ static int ompi_comm_finalize (void)
380
406
381
407
static void ompi_comm_construct (ompi_communicator_t * comm )
382
408
{
383
- comm -> c_f_to_c_index = opal_pointer_array_add ( & ompi_comm_f_to_c_table , comm ) ;
409
+ int idx ;
384
410
comm -> c_name [0 ] = '\0' ;
385
411
comm -> c_index = MPI_UNDEFINED ;
386
412
comm -> c_flags = 0 ;
@@ -393,6 +419,20 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
393
419
comm -> c_topo = NULL ;
394
420
comm -> c_coll = NULL ;
395
421
422
+ /*
423
+ * magic numerology - see TOPDIR/ompi/include/mpif-values.pl
424
+ */
425
+ idx = (comm == ompi_mpi_comm_world_addr ) ? OMPI_MPI_COMM_WORLD :
426
+ (comm == ompi_mpi_comm_self_addr ) ? OMPI_MPI_COMM_SELF :
427
+ (comm == ompi_mpi_comm_null_addr ) ? OMPI_MPI_COMM_NULL : -1 ;
428
+ if (-1 == idx ) {
429
+ comm -> c_f_to_c_index = opal_pointer_array_add (& ompi_comm_f_to_c_table ,
430
+ comm );
431
+ } else {
432
+ opal_pointer_array_set_item (& ompi_comm_f_to_c_table , idx , comm );
433
+ comm -> c_f_to_c_index = idx ;
434
+ }
435
+
396
436
/* A keyhash will be created if/when an attribute is cached on
397
437
this communicator */
398
438
comm -> c_keyhash = NULL ;
0 commit comments