11/*
2- * Copyright (c) 2018 The University of Tennessee and The University
2+ * Copyright (c) 2018-2019 The University of Tennessee and The University
33 * of Tennessee Research Foundation. All rights
44 * reserved.
55 *
66 * Copyright (c) 2018 Cisco Systems, Inc. All rights reserved
77 * Copyright (c) 2018 Research Organization for Information Science
88 * and Technology (RIST). All rights reserved.
9+ * Copyright (c) 2019 Mellanox Technologies, Inc.
10+ * All rights reserved.
911 * $COPYRIGHT$
1012 *
1113 * Additional copyrights may follow
@@ -287,14 +289,6 @@ void ompi_spc_init(void)
287289 char * * arg_strings = opal_argv_split (ompi_mpi_spc_attach_string , ',' );
288290 int num_args = opal_argv_count (arg_strings );
289291
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-
298292 /* If there is only one argument and it is 'all', then all counters
299293 * should be turned on. If the size is 0, then no counters will be enabled.
300294 */
@@ -304,47 +298,50 @@ void ompi_spc_init(void)
304298 }
305299 }
306300
307- /* Turn on only the counters that were specified in the MCA parameter */
308301 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 */
302+ /* Reset all timer-based counters */
303+ CLEAR_SPC_BIT (ompi_spc_timer_event , i );
304+ matched = all_on ;
305+
306+ if ( !matched ) {
307+ /* Turn on only the counters that were specified in the MCA parameter */
314308 for (j = 0 ; j < num_args ; j ++ ) {
315309 if ( 0 == strcmp (ompi_spc_events_names [i ].counter_name , arg_strings [j ]) ) {
316- found ++ ;
317310 matched = 1 ;
318311 break ;
319312 }
320313 }
321314 }
322315
323- if (all_on || matched ) {
316+ if (matched ) {
324317 SET_SPC_BIT (ompi_spc_attached_event , i );
325318 mpi_t_enabled = true;
319+ found ++ ;
320+ }
326321
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- }
322+ /* Registers the current counter as an MPI_T pvar regardless of whether it's been turned on or not */
323+ ret = mca_base_pvar_register ("ompi" , "runtime" , "spc" , ompi_spc_events_names [i ].counter_name , ompi_spc_events_names [i ].counter_description ,
324+ OPAL_INFO_LVL_4 , MPI_T_PVAR_CLASS_SIZE ,
325+ MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG , NULL , MPI_T_BIND_NO_OBJECT ,
326+ MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS ,
327+ ompi_spc_get_count , NULL , ompi_spc_notify , NULL );
328+
329+ /* Check to make sure that ret is a valid index and not an error code */
330+ if ( ret >= 0 ) {
331+ if ( mpi_t_offset == -1 )
332+ mpi_t_offset = ret ;
333+ }
334+ /* We need the SPC counters to be contiguous in the PVAR array */
335+ if ( (ret < 0 ) || (ret != (mpi_t_offset + found - 1 )) ) {
336+ mpi_t_enabled = false;
337+ opal_show_help ("help-mpi-runtime.txt" , "spc: MPI_T disabled" , true);
338+ break ;
345339 }
346340 }
347341
342+ /* If this is a timer event, set the corresponding timer_event entry */
343+ SET_SPC_BIT (ompi_spc_timer_event , OMPI_SPC_MATCH_TIME );
344+
348345 opal_argv_free (arg_strings );
349346}
350347
0 commit comments