int MPIU_Timer_init(int rank, int size) { if (s_RLOG_Initialized) { /* MPIU_Timer_init already called. */ return -1; } g_pRLOG = RLOG_InitLog(rank, size); if (g_pRLOG == NULL) return -1; RLOG_EnableLogging(g_pRLOG); RLOG_SaveFirstTimestamp(g_pRLOG); RLOG_LogCommID(g_pRLOG, (int)MPI_COMM_WORLD); /* arrow state */ RLOG_DescribeState(g_pRLOG, RLOG_ARROW_EVENT_ID, "Arrow", "255 255 255"); MPIR_Describe_timer_states(); s_RLOG_Initialized = 1; return MPI_SUCCESS; }
RLOG_Struct* RLOG_InitLog(int rank, int size) { RLOG_Struct* pRLOG; pRLOG = (RLOG_Struct*)MPL_malloc(sizeof(RLOG_Struct)); if (pRLOG == NULL) return NULL; pRLOG->nRank = rank; pRLOG->nSize = size; pRLOG->nRecursion = 0; pRLOG->nCurEventId = RLOG_FIRST_EVENT_ID; pRLOG->dFirstTimestamp = 0.0; MPL_snprintf(pRLOG->pszFileName, 256, "log%d.irlog", rank); pRLOG->pOutput = NULL; pRLOG->pOutput = IRLOG_CreateOutputStruct(pRLOG->pszFileName); if (pRLOG->pOutput == NULL) { MPL_error_printf("RLOG Error: unable to allocate an output structure.\n"); MPL_free(pRLOG); return NULL; } RLOG_EnableLogging(pRLOG); /* save the parts of the header and event that do not change */ pRLOG->DiskEvent.event = RLOG_GetNextEventID(pRLOG); pRLOG->DiskEvent.rank = rank; pRLOG->DiskHeader.type = RLOG_EVENT_TYPE; pRLOG->DiskHeader.length = sizeof(RLOG_HEADER) + sizeof(RLOG_EVENT); /* put the description of the state in the log file */ RLOG_DescribeState(pRLOG, pRLOG->DiskEvent.event, "RLOG_DISK", "255 0 0"); RLOG_DisableLogging(pRLOG); return pRLOG; }