@@ -66,14 +66,33 @@ const ompi_hook_base_component_1_0_0_t mca_hook_comm_method_component = {
66
66
.hookm_mpi_finalize_bottom = NULL ,
67
67
};
68
68
69
+ enum mca_hook_comm_method_mode_flags_t {
70
+ /* Default: Display nothing */
71
+ OMPI_HOOK_COMM_METHOD_NONE = 0x01 ,
72
+ /* Display on MPI_INIT */
73
+ OMPI_HOOK_COMM_METHOD_INIT = 0x02 ,
74
+ /* Display on MPI_FINALIZE */
75
+ OMPI_HOOK_COMM_METHOD_FINALIZE = 0x04 ,
76
+ };
77
+
69
78
int mca_hook_comm_method_verbose = 0 ;
70
79
int mca_hook_comm_method_output = -1 ;
71
80
bool mca_hook_comm_method_enable_mpi_init = false;
72
81
bool mca_hook_comm_method_enable_mpi_finalize = false;
82
+ uint32_t mca_hook_comm_method_enabled_flags = OMPI_HOOK_COMM_METHOD_NONE ;
73
83
int mca_hook_comm_method_max = 12 ;
74
84
int mca_hook_comm_method_brief = 0 ;
75
85
char * mca_hook_comm_method_fakefile = NULL ;
76
86
87
+ static mca_base_var_enum_value_flag_t mca_hook_comm_method_modes [] = {
88
+ {.flag = OMPI_HOOK_COMM_METHOD_NONE , .string = "none" ,
89
+ .conflicting_flag = OMPI_HOOK_COMM_METHOD_INIT | OMPI_HOOK_COMM_METHOD_FINALIZE },
90
+ {.flag = OMPI_HOOK_COMM_METHOD_INIT , .string = "mpi_init" },
91
+ {.flag = OMPI_HOOK_COMM_METHOD_FINALIZE , .string = "mpi_finalize" },
92
+ {0 , NULL , 0 }
93
+ };
94
+
95
+
77
96
static int ompi_hook_comm_method_component_open (void )
78
97
{
79
98
// Nothing to do
@@ -88,6 +107,8 @@ static int ompi_hook_comm_method_component_close(void)
88
107
89
108
static int ompi_hook_comm_method_component_register (void )
90
109
{
110
+ int ret ;
111
+ mca_base_var_enum_flag_t * mca_hook_comm_method_flags = NULL ;
91
112
92
113
/*
93
114
* Component verbosity level
@@ -113,61 +134,70 @@ static int ompi_hook_comm_method_component_register(void)
113
134
/*
114
135
* If the component is active for mpi_init / mpi_finalize
115
136
*/
137
+ // hook_comm_method_enable_mpi_init
116
138
mca_hook_comm_method_enable_mpi_init = false;
117
139
(void ) mca_base_component_var_register (& mca_hook_comm_method_component .hookm_version , "enable_mpi_init" ,
118
- "Enable comm_method behavior on mpi_init " ,
140
+ "Enable the communication protocol report when MPI_INIT is invoked " ,
119
141
MCA_BASE_VAR_TYPE_BOOL , NULL ,
120
142
0 , 0 ,
121
143
OPAL_INFO_LVL_3 ,
122
144
MCA_BASE_VAR_SCOPE_READONLY ,
123
145
& mca_hook_comm_method_enable_mpi_init );
124
146
147
+ // hook_comm_method_enable_mpi_finalize
125
148
mca_hook_comm_method_enable_mpi_finalize = false;
126
149
(void ) mca_base_component_var_register (& mca_hook_comm_method_component .hookm_version , "enable_mpi_finalize" ,
127
- "Enable comm_method behavior on mpi_finalize " ,
150
+ "Enable the communication protocol report when MPI_FINALIZE is invoked " ,
128
151
MCA_BASE_VAR_TYPE_BOOL , NULL ,
129
152
0 , 0 ,
130
153
OPAL_INFO_LVL_3 ,
131
154
MCA_BASE_VAR_SCOPE_READONLY ,
132
155
& mca_hook_comm_method_enable_mpi_finalize );
133
156
134
- // User can set the comm_method mca variable too
135
- int hook_comm_method = -1 ;
136
- (void ) mca_base_var_register ("ompi" , NULL , NULL , "comm_method" ,
137
- "Enable comm_method behavior (1) mpi_init or (2) mpi_finalize" ,
138
- MCA_BASE_VAR_TYPE_INT , NULL ,
139
- 0 , 0 ,
140
- OPAL_INFO_LVL_3 ,
141
- MCA_BASE_VAR_SCOPE_READONLY ,
142
- & hook_comm_method );
143
-
144
- if ( 1 == hook_comm_method ) {
145
- mca_hook_comm_method_enable_mpi_init = true;
157
+ // User can set the ompi_comm_method mca variable too
158
+ mca_base_var_enum_create_flag ("ompi_comm_method" , mca_hook_comm_method_modes , & mca_hook_comm_method_flags );
159
+
160
+ ret = mca_base_var_register ("ompi" , "ompi" , NULL , "comm_method" ,
161
+ "Enable the communication protocol report: when MPI_INIT is invoked (using the 'mpi_init' value) and/or when MPI_FINALIZE is invoked (using the 'mpi_finalize' value)." ,
162
+ MCA_BASE_VAR_TYPE_UNSIGNED_INT ,
163
+ & mca_hook_comm_method_flags -> super ,
164
+ 0 , 0 ,
165
+ OPAL_INFO_LVL_3 ,
166
+ MCA_BASE_VAR_SCOPE_READONLY ,
167
+ & mca_hook_comm_method_enabled_flags );
168
+ OBJ_RELEASE (mca_hook_comm_method_flags );
169
+ if (OPAL_ERR_VALUE_OUT_OF_BOUNDS == ret ) {
170
+ opal_output (0 , "hook:comm_method: Warning invalid comm_method specified." );
146
171
}
147
- else if ( 2 == hook_comm_method ) {
148
- mca_hook_comm_method_enable_mpi_finalize = true;
172
+ else {
173
+ if ( mca_hook_comm_method_enabled_flags & OMPI_HOOK_COMM_METHOD_INIT ) {
174
+ mca_hook_comm_method_enable_mpi_init = true;
175
+ }
176
+ if ( mca_hook_comm_method_enabled_flags & OMPI_HOOK_COMM_METHOD_FINALIZE ) {
177
+ mca_hook_comm_method_enable_mpi_finalize = true;
178
+ }
149
179
}
150
180
151
- // comm_method_max
152
- (void ) mca_base_var_register ( "ompi" , NULL , NULL , "comm_method_max " ,
181
+ // hook_comm_method_max
182
+ (void ) mca_base_component_var_register ( & mca_hook_comm_method_component . hookm_version , "max " ,
153
183
"Number of hosts for which to print unabbreviated 2d table of comm methods." ,
154
184
MCA_BASE_VAR_TYPE_INT , NULL ,
155
185
0 , 0 ,
156
186
OPAL_INFO_LVL_3 ,
157
187
MCA_BASE_VAR_SCOPE_READONLY ,
158
188
& mca_hook_comm_method_max );
159
- // comm_method_brief
160
- (void ) mca_base_var_register ( "ompi" , NULL , NULL , "comm_method_brief " ,
189
+ // hook_comm_method_brief
190
+ (void ) mca_base_component_var_register ( & mca_hook_comm_method_component . hookm_version , "brief " ,
161
191
"Only print the comm method summary, skip the 2d table." ,
162
192
MCA_BASE_VAR_TYPE_INT , NULL ,
163
193
0 , 0 ,
164
194
OPAL_INFO_LVL_3 ,
165
195
MCA_BASE_VAR_SCOPE_READONLY ,
166
196
& mca_hook_comm_method_brief );
167
197
168
- // comm_method_fakefile is just for debugging, allows complete override of all the
198
+ // hook_comm_method_fakefile is just for debugging, allows complete override of all the
169
199
// comm method in the table
170
- (void ) mca_base_var_register ( "ompi" , NULL , NULL , "comm_method_fakefile " ,
200
+ (void ) mca_base_component_var_register ( & mca_hook_comm_method_component . hookm_version , "fakefile " ,
171
201
"For debugging only: read comm methods from a file" ,
172
202
MCA_BASE_VAR_TYPE_STRING , NULL ,
173
203
0 , 0 ,
0 commit comments