int NWUNIT_start( hwd_context_t * ctx, hwd_control_state_t * ptr ) { #ifdef DEBUG_BGQ printf( "NWUNIT_start\n" ); #endif ( void ) ctx; int retval; NWUNIT_control_state_t * this_state = ( NWUNIT_control_state_t * ) ptr; retval = Bgpm_Attach( this_state->EventGroup, UPC_NW_ALL_LINKS, 0); retval = _check_BGPM_error( retval, "Bgpm_Attach" ); if ( retval < 0 ) return retval; retval = Bgpm_ResetStart( this_state->EventGroup ); retval = _check_BGPM_error( retval, "Bgpm_ResetStart" ); if ( retval < 0 ) return retval; return ( PAPI_OK ); }
INLINE void PROFILER_INIT() { MPI_Comm_rank(MPI_COMM_WORLD,&myrank); MPI_Comm_size(MPI_COMM_WORLD,&numranks); int coords[6], tmasterRank; MPIX_Rank2torus(myrank, coords); /* choose the MPI rank on (0, 0, 0, 0, 0) [0] as the master rank */ if(coords[0]+coords[1]+coords[2]+coords[3]+coords[4]+coords[5] == 0) { isMaster = 1; printf("Init intercepted by bgqcounter unit\n"); } else { isMaster = 0; } char *filename = getenv("BGQ_COUNTER_FILE"); if(isMaster) { if(filename != NULL) dataFile = fopen(filename,"w"); else dataFile = stdout; } #if BGQ_DEBUG if(isMaster) { printf("File opened, Initializing BGPM\n"); } #endif Bgpm_Init(BGPM_MODE_SWDISTRIB); #if BGQ_DEBUG if(isMaster) { printf("Initialized BGPM, Splitting communicator\n"); } #endif /* split communicator based on the T dimension */ isZero = (coords[5] == 0) ? 1 : 0; MPI_Comm_split(MPI_COMM_WORLD, isZero, myrank, &profile_comm); #if BGQ_DEBUG if(isMaster) { printf("Communicator split done, find master\n"); } #endif /* Every process needs to know the master rank in profile_comm to know the root of the broadcast */ coords[0] = coords[1] = coords[2] = coords[3] = coords[4] = coords[5] = 0; MPIX_Torus2rank(coords, &tmasterRank); #if BGQ_DEBUG if(isMaster) { printf("Found master, informing master\n"); } #endif if(isMaster) { MPI_Comm_rank(profile_comm, &masterRank); } /* Broadcast the rank of the master in profile_comm */ MPI_Bcast(&masterRank, 1, MPI_INT, tmasterRank, MPI_COMM_WORLD); #if BGQ_DEBUG if(isMaster) { printf("Informed master, attaching counters\n"); } #endif if(isZero) { hNWSet = Bgpm_CreateEventSet(); Bgpm_AddEvent(hNWSet, PEVT_NW_USER_PP_SENT); Bgpm_AddEvent(hNWSet, PEVT_NW_USER_DYN_PP_SENT); Bgpm_AddEvent(hNWSet, PEVT_NW_USER_ESC_PP_SENT); Bgpm_AddEvent(hNWSet, PEVT_NW_USER_SUBC_COL_SENT); Bgpm_AddEvent(hNWSet, PEVT_NW_USER_PP_RECV); Bgpm_AddEvent(hNWSet, PEVT_NW_USER_PP_RECV_FIFO); numevents = 6; if (Bgpm_Attach(hNWSet, UPC_NW_ALL_TORUS_LINKS, 0) != 0) { printf("Error: something went wrong in attaching link counters\n"); } curset = maxset = 0; for(unsigned int i = 0; i < NUM_REGIONS; i++) { for(unsigned int j = 0; j < NUM_TORUS_LINKS * numevents; j++) { values[i].counters[j] = 0; } values[i].time = 0; } } if(isMaster) { printf("Init intercept complete\n"); } }