예제 #1
0
int MPIU_Timer_finalize()
{
    if (g_pRLOG == NULL)
	return -1;
    if (!s_RLOG_Initialized)
	return 0;

    RLOG_DisableLogging(g_pRLOG);

    /* The code originally included output statements that surrounded the
       writing of the logfiles with "Writing logfile." and "finished."
       While sometimes useful, it is often valuable to have 
       the use of logging make no changes in the observable output 
       from the program, for example, in testing that the logging 
       does not impact the correctness of the code or while used 
       within an environment that expects all stdout/err to come
       from code that the user has specifically written.

       To that end, the output lines have been commented out.  Should
       there be a strong desire to provide this output, it should be
       made optional, turned on (off by default) with a runtime parameter.
     */
    /* MPL_msg_printf( "Writing logfile.\n");fflush(stdout); */
    RLOG_FinishLog(g_pRLOG);
    /* MPL_msg_printf("finished.\n");fflush(stdout); */
    s_RLOG_Initialized = 0;

    return MPI_SUCCESS;
}
예제 #2
0
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;
}