@@ -22,10 +22,8 @@ opal_timer_t sys_clock_freq_mhz = 0;
2222static void ompi_spc_dump (void );
2323
2424/* Array for converting from SPC indices to MPI_T indices */
25- OMPI_DECLSPEC int mpi_t_offset = -1 ;
26- OMPI_DECLSPEC bool mpi_t_enabled = false;
27-
28- 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 ;
2927
3028typedef struct ompi_spc_event_t {
3129 const char * counter_name ;
@@ -187,6 +185,8 @@ static int ompi_spc_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, v
187185 return MPI_SUCCESS ;
188186 }
189187
188+ index = (int )(uintptr_t )pvar -> ctx ; /* Convert from MPI_T pvar index to SPC index */
189+
190190 /* For this event, we need to set count to the number of long long type
191191 * values for this counter. All SPC counters are one long long, so we
192192 * always set count to 1.
@@ -196,14 +196,10 @@ static int ompi_spc_notify(mca_base_pvar_t *pvar, mca_base_pvar_event_t event, v
196196 }
197197 /* For this event, we need to turn on the counter */
198198 else if (MCA_BASE_PVAR_HANDLE_START == event ) {
199- /* Convert from MPI_T pvar index to SPC index */
200- index = pvar -> pvar_index - mpi_t_offset ;
201199 SET_SPC_BIT (ompi_spc_attached_event , index );
202200 }
203201 /* For this event, we need to turn off the counter */
204202 else if (MCA_BASE_PVAR_HANDLE_STOP == event ) {
205- /* Convert from MPI_T pvar index to SPC index */
206- index = pvar -> pvar_index - mpi_t_offset ;
207203 CLEAR_SPC_BIT (ompi_spc_attached_event , index );
208204 }
209205
@@ -233,7 +229,7 @@ static int ompi_spc_get_count(const struct mca_base_pvar_t *pvar, void *value, v
233229 }
234230
235231 /* Convert from MPI_T pvar index to SPC index */
236- int index = pvar -> pvar_index - mpi_t_offset ;
232+ int index = ( int )( uintptr_t ) pvar -> ctx ;
237233 /* Set the counter value to the current SPC value */
238234 * counter_value = (long long )ompi_spc_events [index ].value ;
239235 /* If this is a timer-based counter, convert from cycles to microseconds */
@@ -324,18 +320,11 @@ void ompi_spc_init(void)
324320 OPAL_INFO_LVL_4 , MPI_T_PVAR_CLASS_SIZE ,
325321 MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG , NULL , MPI_T_BIND_NO_OBJECT ,
326322 MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS ,
327- ompi_spc_get_count , NULL , ompi_spc_notify , NULL );
328- if ( matched ) { /* if the SPC has not been required we don't really care if we fail to register it */
329- if ( (ret >= 0 ) && (-1 == mpi_t_offset ) )
330- mpi_t_offset = ret ;
331-
332- /* We need the SPC counters to be contiguous in the PVAR array */
333- if ( (ret < 0 ) || (ret != (mpi_t_offset + found - 1 )) ) {
334- mpi_t_enabled = false;
335- mpi_t_offset = -1 ;
336- opal_show_help ("help-mpi-runtime.txt" , "spc: MPI_T disabled" , true);
337- break ;
338- }
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 ;
339328 }
340329 }
341330
0 commit comments