Skip to content

Commit ff207ee

Browse files
committed
Remove inter-dependencies between OSC modules.
The osc monitoring component needed to include other OSC components header in order to be able tu access communicator through the component specific ompi_osc_*_module_t structures. This commit remove the dependency, and resolve the issue open-mpi#4523. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> Extend the common monitoring API. * Now it's possible to translate from local rank to world rank from both the communicator and the group. * Remove useless hashtable as we directly use the w_group contained in window structure. Signed-off-by: Clement Foyer <clement.foyer@inria.fr>
1 parent a4755b6 commit ff207ee

File tree

6 files changed

+30
-45
lines changed

6 files changed

+30
-45
lines changed

ompi/mca/common/monitoring/common_monitoring.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ OMPI_DECLSPEC void mca_common_monitoring_record_osc(int world_rank, size_t data_
6666
/* Records COLL communications. */
6767
OMPI_DECLSPEC void mca_common_monitoring_record_coll(int world_rank, size_t data_size);
6868

69-
/* Translate the rank from the given communicator of a process to its rank in MPI_COMM_RANK. */
70-
static inline int mca_common_monitoring_get_world_rank(int dst, struct ompi_communicator_t*comm,
71-
int*world_rank)
69+
/* Translate the rank from the given rank of a process to its rank in MPI_COMM_RANK. */
70+
static inline int mca_common_monitoring_get_world_rank_grp(int dest, ompi_group_t *group,
71+
int *world_rank)
7272
{
7373
opal_process_name_t tmp;
7474

7575
/* find the processor of the destination */
76-
ompi_proc_t *proc = ompi_group_get_proc_ptr(comm->c_remote_group, dst, true);
76+
ompi_proc_t *proc = ompi_group_get_proc_ptr(group, dest, true);
7777
if( ompi_proc_is_sentinel(proc) ) {
7878
tmp = ompi_proc_sentinel_to_name((uintptr_t)proc);
7979
} else {
@@ -94,6 +94,13 @@ static inline int mca_common_monitoring_get_world_rank(int dst, struct ompi_comm
9494
return ret;
9595
}
9696

97+
/* Translate the rank from the given communicator of a process to its rank in MPI_COMM_RANK. */
98+
static inline int mca_common_monitoring_get_world_rank(int dst, struct ompi_communicator_t*comm,
99+
int*world_rank)
100+
{
101+
return mca_common_monitoring_get_world_rank_grp(dst, comm->c_remote_group, world_rank);
102+
}
103+
97104
/* Return the current status of the monitoring system 0 if off or the
98105
* seperation between internal tags and external tags is disabled. Any
99106
* other positive value if the segregation between point-to-point and

ompi/mca/osc/monitoring/osc_monitoring_accumulate.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* If this fails the destination is not part of my MPI_COM_WORLD \
3030
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
3131
*/ \
32-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(target_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
32+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(target_rank, win->w_group, &world_rank)) { \
3333
size_t type_size; \
3434
ompi_datatype_type_size(dt, &type_size); \
3535
mca_common_monitoring_record_osc(world_rank, type_size, SEND); \
@@ -56,7 +56,7 @@
5656
* If this fails the destination is not part of my MPI_COM_WORLD \
5757
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
5858
*/ \
59-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(target_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
59+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(target_rank, win->w_group, &world_rank)) { \
6060
size_t type_size, data_size; \
6161
ompi_datatype_type_size(origin_datatype, &type_size); \
6262
data_size = origin_count*type_size; \
@@ -88,7 +88,7 @@
8888
* If this fails the destination is not part of my MPI_COM_WORLD \
8989
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
9090
*/ \
91-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(target_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
91+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(target_rank, win->w_group, &world_rank)) { \
9292
size_t type_size, data_size; \
9393
ompi_datatype_type_size(origin_datatype, &type_size); \
9494
data_size = origin_count*type_size; \
@@ -116,7 +116,7 @@
116116
* If this fails the destination is not part of my MPI_COM_WORLD \
117117
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
118118
*/ \
119-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(target_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
119+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(target_rank, win->w_group, &world_rank)) { \
120120
size_t type_size, data_size; \
121121
ompi_datatype_type_size(origin_datatype, &type_size); \
122122
data_size = origin_count*type_size; \
@@ -140,7 +140,7 @@
140140
* If this fails the destination is not part of my MPI_COM_WORLD \
141141
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
142142
*/ \
143-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(target_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
143+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(target_rank, win->w_group, &world_rank)) { \
144144
size_t type_size, data_size; \
145145
ompi_datatype_type_size(origin_datatype, &type_size); \
146146
data_size = origin_count*type_size; \
@@ -162,7 +162,7 @@
162162
* If this fails the destination is not part of my MPI_COM_WORLD \
163163
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
164164
*/ \
165-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(target_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
165+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(target_rank, win->w_group, &world_rank)) { \
166166
size_t type_size; \
167167
ompi_datatype_type_size(dt, &type_size); \
168168
mca_common_monitoring_record_osc(world_rank, type_size, SEND); \

ompi/mca/osc/monitoring/osc_monitoring_comm.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* If this fails the destination is not part of my MPI_COM_WORLD \
3131
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
3232
*/ \
33-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(target_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
33+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(target_rank, win->w_group, &world_rank)) { \
3434
size_t type_size, data_size; \
3535
ompi_datatype_type_size(origin_datatype, &type_size); \
3636
data_size = origin_count*type_size; \
@@ -55,7 +55,7 @@
5555
* If this fails the destination is not part of my MPI_COM_WORLD \
5656
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
5757
*/ \
58-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(target_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
58+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(target_rank, win->w_group, &world_rank)) { \
5959
size_t type_size, data_size; \
6060
ompi_datatype_type_size(origin_datatype, &type_size); \
6161
data_size = origin_count*type_size; \
@@ -78,7 +78,7 @@
7878
* If this fails the destination is not part of my MPI_COM_WORLD \
7979
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
8080
*/ \
81-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(source_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
81+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(source_rank, win->w_group, &world_rank)) { \
8282
size_t type_size, data_size; \
8383
ompi_datatype_type_size(origin_datatype, &type_size); \
8484
data_size = origin_count*type_size; \
@@ -103,7 +103,7 @@
103103
* If this fails the destination is not part of my MPI_COM_WORLD \
104104
* Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank \
105105
*/ \
106-
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank(source_rank, ompi_osc_monitoring_## template ##_get_comm(win), &world_rank)) { \
106+
if(OPAL_SUCCESS == mca_common_monitoring_get_world_rank_grp(source_rank, win->w_group, &world_rank)) { \
107107
size_t type_size, data_size; \
108108
ompi_datatype_type_size(origin_datatype, &type_size); \
109109
data_size = origin_count*type_size; \

ompi/mca/osc/monitoring/osc_monitoring_component.c

+4-17
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,10 @@
2222
/* Include template generating macros */
2323
#include "osc_monitoring_template.h"
2424

25-
#include <ompi/mca/osc/rdma/osc_rdma.h>
26-
OSC_MONITORING_MODULE_TEMPLATE_GENERATE(rdma, ompi_osc_rdma_module_t, comm)
27-
#undef GET_MODULE
28-
29-
#include <ompi/mca/osc/sm/osc_sm.h>
30-
OSC_MONITORING_MODULE_TEMPLATE_GENERATE(sm, ompi_osc_sm_module_t, comm)
31-
#undef GET_MODULE
32-
33-
#include <ompi/mca/osc/pt2pt/osc_pt2pt.h>
34-
OSC_MONITORING_MODULE_TEMPLATE_GENERATE(pt2pt, ompi_osc_pt2pt_module_t, comm)
35-
#undef GET_MODULE
36-
37-
#ifdef OMPI_WITH_OSC_PORTALS4
38-
#include <ompi/mca/osc/portals4/osc_portals4.h>
39-
OSC_MONITORING_MODULE_TEMPLATE_GENERATE(portals4, ompi_osc_portals4_module_t, comm)
40-
#undef GET_MODULE
41-
#endif /* OMPI_WITH_OSC_PORTALS4 */
25+
OSC_MONITORING_MODULE_TEMPLATE_GENERATE(rdma)
26+
OSC_MONITORING_MODULE_TEMPLATE_GENERATE(sm)
27+
OSC_MONITORING_MODULE_TEMPLATE_GENERATE(pt2pt)
28+
OSC_MONITORING_MODULE_TEMPLATE_GENERATE(portals4)
4229

4330
/***************************************/
4431

ompi/mca/osc/monitoring/osc_monitoring_module.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040

4141
/* Define and set the ompi_osc_monitoring_## template ##_template
4242
* variable. The functions recorded here are linked to the original
43-
* functions of the original {template} module that were replaced.
43+
* functions of the original {template} module that weas replaced.
4444
*/
4545
#define MCA_OSC_MONITORING_MODULE_TEMPLATE_GENERATE(template) \
46-
static ompi_osc_base_module_t OMPI_OSC_MONITORING_TEMPLATE_VARIABLE(template) = { \
46+
static const ompi_osc_base_module_t OMPI_OSC_MONITORING_TEMPLATE_VARIABLE(template) = { \
4747
.osc_win_attach = ompi_osc_monitoring_## template ##_attach, \
4848
.osc_win_detach = ompi_osc_monitoring_## template ##_detach, \
4949
.osc_free = ompi_osc_monitoring_## template ##_free, \

ompi/mca/osc/monitoring/osc_monitoring_template.h

+3-12
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
#include "osc_monitoring_module.h"
2424
#include "osc_monitoring_passive_target.h"
2525

26-
/* module_type correspond to the ompi_osc_## template ##_module_t type
27-
* comm correspond to the comm field name in ompi_osc_## template ##_module_t
28-
*
29-
* The magic used here is that for a given module type (given with the
26+
/* The magic used here is that for a given module type (given with the
3027
* {template} parameter), we generate a set of every functions defined
3128
* in ompi_osc_base_module_t, the ompi_osc_monitoring_module_##
3229
* template ##_template variable recording the original set of
@@ -37,17 +34,11 @@
3734
* the original function that had been saved in the
3835
* ompi_osc_monitoring_module_## template ##_template variable.
3936
*/
40-
#define OSC_MONITORING_MODULE_TEMPLATE_GENERATE(template, module_type, comm) \
37+
#define OSC_MONITORING_MODULE_TEMPLATE_GENERATE(template) \
4138
/* Generate the proper symbol for the \
4239
ompi_osc_monitoring_module_## template ##_template variable */ \
4340
OMPI_OSC_MONITORING_MODULE_GENERATE(template); \
44-
OMPI_OSC_MONITORING_MODULE_INIT_GENERATE(template); \
45-
/* Generate module specific module->comm accessor */ \
46-
static inline struct ompi_communicator_t* \
47-
ompi_osc_monitoring_## template ##_get_comm(ompi_win_t*win) \
48-
{ \
49-
return ((module_type*)win->w_osc_module)->comm; \
50-
} \
41+
OMPI_OSC_MONITORING_MODULE_INIT_GENERATE(template); \
5142
/* Generate each module specific functions */ \
5243
OSC_MONITORING_GENERATE_TEMPLATE_ACCUMULATE(template) \
5344
OSC_MONITORING_GENERATE_TEMPLATE_ACTIVE_TARGET(template) \

0 commit comments

Comments
 (0)