1
1
/*
2
- * Copyright (c) 2018 The University of Tennessee and The University
2
+ * Copyright (c) 2018-2019 The University of Tennessee and The University
3
3
* of Tennessee Research Foundation. All rights
4
4
* reserved.
5
5
*
6
6
* Copyright (c) 2018 Cisco Systems, Inc. All rights reserved
7
7
* Copyright (c) 2018 Research Organization for Information Science
8
8
* and Technology (RIST). All rights reserved.
9
+ * Copyright (c) 2019 Mellanox Technologies, Inc.
10
+ * All rights reserved.
9
11
* $COPYRIGHT$
10
12
*
11
13
* Additional copyrights may follow
@@ -20,10 +22,8 @@ opal_timer_t sys_clock_freq_mhz = 0;
20
22
static void ompi_spc_dump (void );
21
23
22
24
/* Array for converting from SPC indices to MPI_T indices */
23
- OMPI_DECLSPEC int mpi_t_offset = -1 ;
24
- OMPI_DECLSPEC bool mpi_t_enabled = false;
25
-
26
- OPAL_DECLSPEC ompi_communicator_t * ompi_spc_comm = NULL ;
25
+ static bool mpi_t_enabled = false;
26
+ static ompi_communicator_t * ompi_spc_comm = NULL ;
27
27
28
28
typedef struct ompi_spc_event_t {
29
29
const char * counter_name ;
@@ -185,6 +185,8 @@ static int ompi_spc_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, v
185
185
return MPI_SUCCESS ;
186
186
}
187
187
188
+ index = (int )(uintptr_t )pvar -> ctx ; /* Convert from MPI_T pvar index to SPC index */
189
+
188
190
/* For this event, we need to set count to the number of long long type
189
191
* values for this counter. All SPC counters are one long long, so we
190
192
* always set count to 1.
@@ -194,14 +196,10 @@ static int ompi_spc_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, v
194
196
}
195
197
/* For this event, we need to turn on the counter */
196
198
else if (MCA_BASE_PVAR_HANDLE_START == event ) {
197
- /* Convert from MPI_T pvar index to SPC index */
198
- index = pvar -> pvar_index - mpi_t_offset ;
199
199
SET_SPC_BIT (ompi_spc_attached_event , index );
200
200
}
201
201
/* For this event, we need to turn off the counter */
202
202
else if (MCA_BASE_PVAR_HANDLE_STOP == event ) {
203
- /* Convert from MPI_T pvar index to SPC index */
204
- index = pvar -> pvar_index - mpi_t_offset ;
205
203
CLEAR_SPC_BIT (ompi_spc_attached_event , index );
206
204
}
207
205
@@ -231,7 +229,7 @@ static int ompi_spc_get_count(const struct mca_base_pvar_t *pvar, void *value, v
231
229
}
232
230
233
231
/* Convert from MPI_T pvar index to SPC index */
234
- int index = pvar -> pvar_index - mpi_t_offset ;
232
+ int index = ( int )( uintptr_t ) pvar -> ctx ;
235
233
/* Set the counter value to the current SPC value */
236
234
* counter_value = (long long )ompi_spc_events [index ].value ;
237
235
/* If this is a timer-based counter, convert from cycles to microseconds */
@@ -287,14 +285,6 @@ void ompi_spc_init(void)
287
285
char * * arg_strings = opal_argv_split (ompi_mpi_spc_attach_string , ',' );
288
286
int num_args = opal_argv_count (arg_strings );
289
287
290
- /* Reset all timer-based counters */
291
- for (i = 0 ; i < OMPI_SPC_NUM_COUNTERS ; i ++ ) {
292
- CLEAR_SPC_BIT (ompi_spc_timer_event , i );
293
- }
294
-
295
- /* If this is a timer event, set the corresponding timer_event entry */
296
- SET_SPC_BIT (ompi_spc_timer_event , OMPI_SPC_MATCH_TIME );
297
-
298
288
/* If there is only one argument and it is 'all', then all counters
299
289
* should be turned on. If the size is 0, then no counters will be enabled.
300
290
*/
@@ -304,47 +294,43 @@ void ompi_spc_init(void)
304
294
}
305
295
}
306
296
307
- /* Turn on only the counters that were specified in the MCA parameter */
308
297
for (i = 0 ; i < OMPI_SPC_NUM_COUNTERS ; i ++ ) {
309
- if (all_on ) {
310
- found ++ ;
311
- } else {
312
- matched = 0 ;
313
- /* Note: If no arguments were given, this will be skipped */
298
+ /* Reset all timer-based counters */
299
+ CLEAR_SPC_BIT (ompi_spc_timer_event , i );
300
+ matched = all_on ;
301
+
302
+ if ( !matched ) {
303
+ /* Turn on only the counters that were specified in the MCA parameter */
314
304
for (j = 0 ; j < num_args ; j ++ ) {
315
305
if ( 0 == strcmp (ompi_spc_events_names [i ].counter_name , arg_strings [j ]) ) {
316
- found ++ ;
317
306
matched = 1 ;
318
307
break ;
319
308
}
320
309
}
321
310
}
322
311
323
- if (all_on || matched ) {
312
+ if (matched ) {
324
313
SET_SPC_BIT (ompi_spc_attached_event , i );
325
314
mpi_t_enabled = true;
315
+ found ++ ;
316
+ }
326
317
327
- /* Registers the current counter as an MPI_T pvar regardless of whether it's been turned on or not */
328
- ret = mca_base_pvar_register ("ompi" , "runtime" , "spc" , ompi_spc_events_names [i ].counter_name , ompi_spc_events_names [i ].counter_description ,
329
- OPAL_INFO_LVL_4 , MPI_T_PVAR_CLASS_SIZE ,
330
- MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG , NULL , MPI_T_BIND_NO_OBJECT ,
331
- MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS ,
332
- ompi_spc_get_count , NULL , ompi_spc_notify , NULL );
333
-
334
- /* Check to make sure that ret is a valid index and not an error code */
335
- if ( ret >= 0 ) {
336
- if ( mpi_t_offset == -1 ) {
337
- mpi_t_offset = ret ;
338
- }
339
- }
340
- if ( (ret < 0 ) || (ret != (mpi_t_offset + found - 1 )) ) {
341
- mpi_t_enabled = false;
342
- opal_show_help ("help-mpi-runtime.txt" , "spc: MPI_T disabled" , true);
343
- break ;
344
- }
318
+ /* Registers the current counter as an MPI_T pvar regardless of whether it's been turned on or not */
319
+ ret = mca_base_pvar_register ("ompi" , "runtime" , "spc" , ompi_spc_events_names [i ].counter_name , ompi_spc_events_names [i ].counter_description ,
320
+ OPAL_INFO_LVL_4 , MPI_T_PVAR_CLASS_SIZE ,
321
+ MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG , NULL , MPI_T_BIND_NO_OBJECT ,
322
+ MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS ,
323
+ ompi_spc_get_count , NULL , ompi_spc_notify , (void * )(uintptr_t )i );
324
+ if ( ret < 0 ) {
325
+ mpi_t_enabled = false;
326
+ opal_show_help ("help-mpi-runtime.txt" , "spc: MPI_T disabled" , true);
327
+ break ;
345
328
}
346
329
}
347
330
331
+ /* If this is a timer event, set the corresponding timer_event entry */
332
+ SET_SPC_BIT (ompi_spc_timer_event , OMPI_SPC_MATCH_TIME );
333
+
348
334
opal_argv_free (arg_strings );
349
335
}
350
336
0 commit comments