void F77_FUNC(mpix_torus2rank,MPIX_TORUS2RANK)(MPI_Fint * coords, MPI_Fint * rank, MPI_Fint * ierr) { int torusdim = -1; int rc = MPIX_Torus_ndims(&torusdim); if (rc!=MPI_SUCCESS) { *ierr = (MPI_Fint)rc; return; } int * mycoords = malloc(torusdim*sizeof(int)); for (int i=0; i<torusdim; i++) safecast(mycoords[i], &(mycoords[i]) ); int myrank = -1; *ierr = (MPI_Fint)MPIX_Torus2rank(mycoords, &myrank); *rank = (MPI_Fint)myrank; free(mycoords); return; }
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"); } }