📄 mpe_log.c
字号:
/* (C) 2001 by Argonne National Laboratory. See COPYRIGHT in top-level directory.*/#include "mpe_logging_conf.h"#if defined( HAVE_SYS_TYPES_H)#include <sys/types.h>#endif#if defined( STDC_HEADERS ) || defined( HAVE_STDLIB_H )/* Needed for getenv */#include <stdlib.h>#endif#if defined( STDC_HEADERS ) || defined( HAVE_STRING_H )#include <string.h>#endif#if defined( STDC_HEADERS ) || defined( HAVE_STDIO_H )#include <stdio.h>#endif#include "mpe_log.h"#if !defined( CLOG_NOMPI )#include "mpi.h" /* Needed for PMPI routines */#endif#include "clog.h"#include "clog_const.h"#include "clog_util.h"#include "clog_timer.h"#include "clog_sync.h"#include "clog_commset.h"/* we want to use the PMPI routines instead of the MPI routines for all of the logging calls internal to the mpe_log package */#ifdef USE_PMPI#define MPI_BUILD_PROFILING#include "mpiprof.h"#endifextern CLOG_Uuid_t CLOG_UUID_NULL;/* Global variables for MPE logging */ CLOG_Stream_t *CLOG_Stream = NULL; CLOG_Buffer_t *CLOG_Buffer = NULL;MPEU_DLL_SPEC CLOG_CommSet_t *CLOG_CommSet = NULL; const CLOG_CommIDs_t *CLOG_CommIDs4Self ;MPEU_DLL_SPEC const CLOG_CommIDs_t *CLOG_CommIDs4World ; int MPE_Log_hasBeenInit = 0; int MPE_Log_hasBeenClosed = 0;/*@ MPE_Init_log - Initialize the logging of events. Notes: This routine must be called before any of the other MPE logging routines. It is a collective call over 'MPI_COMM_WORLD'. MPE_Init_log() & MPE_Finish_log() are NOT needed when liblmpe.a is linked because MPI_Init() would have called MPE_Init_log() already. liblmpe.a will be included in the final executable if it is linked with either "mpicc -mpe=mpilog" or "mpecc -mpilog" Returns: Always return MPE_LOG_OK..seealso: MPE_Finish_log()@*/int MPE_Init_log( void ){ if (!MPE_Log_hasBeenInit || MPE_Log_hasBeenClosed) { CLOG_Stream = CLOG_Open(); CLOG_Local_init( CLOG_Stream, NULL ); CLOG_Buffer = CLOG_Stream->buffer; CLOG_CommSet = CLOG_Buffer->commset;#if !defined( CLOG_NOMPI ) CLOG_CommIDs4World = CLOG_CommSet_get_IDs( CLOG_CommSet, MPI_COMM_WORLD ); MPE_Log_commIDs_intracomm( CLOG_CommIDs4World, 0, CLOG_COMM_WORLD_CREATE, CLOG_CommIDs4World ); CLOG_CommIDs4Self = CLOG_CommSet_get_IDs( CLOG_CommSet, MPI_COMM_SELF ); MPE_Log_commIDs_intracomm( CLOG_CommIDs4World, 0, CLOG_COMM_SELF_CREATE, CLOG_CommIDs4Self ); if ( CLOG_Buffer->world_rank == 0 ) { CLOG_Buffer_save_constdef( CLOG_Buffer, CLOG_CommIDs4World, 0, CLOG_EVT_CONST, MPI_PROC_NULL, "MPI_PROC_NULL" ); CLOG_Buffer_save_constdef( CLOG_Buffer, CLOG_CommIDs4World, 0, CLOG_EVT_CONST, MPI_ANY_SOURCE, "MPI_ANY_SOURCE" ); CLOG_Buffer_save_constdef( CLOG_Buffer, CLOG_CommIDs4World, 0, CLOG_EVT_CONST, MPI_ANY_TAG, "MPI_ANY_TAG" ); }#else CLOG_CommIDs4World = NULL;#endif MPE_Log_hasBeenInit = 1; /* set MPE_Log as being initialized */ MPE_Log_hasBeenClosed = 0; } MPE_Start_log(); return MPE_LOG_OK;}/*@ MPE_Start_log - Start the logging of events.@*/int MPE_Start_log( void ){ if (!MPE_Log_hasBeenInit) return MPE_LOG_NOT_INITIALIZED; CLOG_Buffer->status = CLOG_INIT_AND_ON; return MPE_LOG_OK;}/*@ MPE_Stop_log - Stop the logging of events@*/int MPE_Stop_log( void ){ if (!MPE_Log_hasBeenInit) return MPE_LOG_NOT_INITIALIZED; CLOG_Buffer->status = CLOG_INIT_AND_OFF; return MPE_LOG_OK;}/*@ MPE_Initialized_logging - Indicate whether MPE_Init_log() or MPE_Finish_log() have been called. Returns: 0 if MPE_Init_log() has not been called, 1 if MPE_Init_log() has been called but MPE_Finish_log() has not been called, and 2 otherwise.@*/int MPE_Initialized_logging( void ){ return MPE_Log_hasBeenInit + MPE_Log_hasBeenClosed;}/* The is to log CLOG intracommunicator event.*/int MPE_Log_commIDs_intracomm( const CLOG_CommIDs_t *commIDs, int local_thread, int comm_etype, const CLOG_CommIDs_t *intracommIDs ){#if !defined( CLOG_NOMPI ) CLOG_Buffer_save_commevt( CLOG_Buffer, commIDs, local_thread, comm_etype, intracommIDs->global_ID, intracommIDs->local_ID, intracommIDs->comm_rank, intracommIDs->world_rank );#endif return MPE_LOG_OK;}int MPE_Log_commIDs_nullcomm( const CLOG_CommIDs_t *commIDs, int local_thread, int comm_etype ){#if !defined( CLOG_NOMPI ) CLOG_Buffer_save_commevt( CLOG_Buffer, commIDs, local_thread, comm_etype, CLOG_UUID_NULL, CLOG_COMM_LID_NULL, CLOG_COMM_RANK_NULL, CLOG_COMM_WRANK_NULL );#endif return MPE_LOG_OK;}int MPE_Log_commIDs_intercomm( const CLOG_CommIDs_t *commIDs, int local_thread, int comm_etype, const CLOG_CommIDs_t *intercommIDs ){#if !defined( CLOG_NOMPI ) CLOG_CommIDs_t *local_intracommIDs; CLOG_CommIDs_t *remote_intracommIDs; CLOG_Buffer_save_commevt( CLOG_Buffer, commIDs, local_thread, comm_etype, intercommIDs->global_ID, intercommIDs->local_ID, intercommIDs->comm_rank, intercommIDs->world_rank ); /* Don't check for local_intracommIDs = NULL or remote_intracommIDs = NULL prefer sigfault than fail silently. */ local_intracommIDs = intercommIDs->next; CLOG_Buffer_save_commevt( CLOG_Buffer, commIDs, local_thread, CLOG_COMM_INTRA_LOCAL, local_intracommIDs->global_ID, local_intracommIDs->local_ID, local_intracommIDs->comm_rank, local_intracommIDs->world_rank ); remote_intracommIDs = local_intracommIDs->next; CLOG_Buffer_save_commevt( CLOG_Buffer, commIDs, local_thread, CLOG_COMM_INTRA_REMOTE, remote_intracommIDs->global_ID, remote_intracommIDs->local_ID, remote_intracommIDs->comm_rank, remote_intracommIDs->world_rank );#endif return MPE_LOG_OK;}/*N MPE_LOG_BYTE_FORMAT Notes on storage format control support: The format control string is printf like, e.g. "Comment = %s". All the MPE %-token storage support is provided by SLOG-2. That is whatever supported by SLOG-2 will be supported by MPE. Currently, the following is supported. %s : variable length string, byte buffer size is length of string + 2. %h : 2-byte integer, printed as decimal integer, byte buffer size is 2. %d : 4-byte integer, printed as decimal integer, byte buffer size is 4. %l : 8-byte integer, printed as decimal integer, byte buffer size is 8. %x : 4-byte integer, printed as hexadecimal integer, byte buffer size is 4. %X : 8-byte integer, printed as hexadecimal integer, byte buffer size is 8. %e : 4-byte float, printed as decimal float, byte buffer size is 4. %E : 8-byte float, printed as decimal float, byte buffer size is 8..nN*//*@ MPE_Describe_comm_state - Describe attributes of a state with byte informational data in a specified MPI_Comm. Input Parameters:+ comm - MPI_Comm where this process is part of.. local_thread - local thread ID where the state is being defined.. state_startID - event number for the starting of the state.. state_finalID - event number for the ending of the state.. name - name of the state, the maximum length of the NULL-terminated string is, sizeof(CLOG_DESC), 32.. color - color of the state, the maximum length of the NULL-terminated string is, sizeof(CLOG_COLOR), 24.- format - printf style %-token format control string for the state, the maximum length of the NULL-terminated string is, sizeof(CLOG_FORMAT), 40. If format is NULL, it is equivalent to calling MPE_Describe_state(). The fortran interface of this routine considers the zero-length string, "", and single-blank string, " ", as NULL. Notes: Adds a state definition to the logfile. States are added to a logfile by calling 'MPE_Log_comm_event()' for the start and end event numbers..N MPE_LOG_BYTE_FORMAT.seealso: MPE_Log_get_state_eventIDs()@*/int MPE_Describe_comm_state( MPI_Comm comm, int local_thread, int state_startID, int state_finalID, const char *name, const char *color, const char *format ){ const CLOG_CommIDs_t *commIDs; int stateID; if (!MPE_Log_hasBeenInit) return MPE_LOG_NOT_INITIALIZED; commIDs = CLOG_CommSet_get_IDs( CLOG_CommSet, comm ); stateID = CLOG_Get_user_stateID( CLOG_Stream ); CLOG_Buffer_save_statedef( CLOG_Buffer, commIDs, local_thread, stateID, state_startID, state_finalID, color, name, format ); return MPE_LOG_OK;}/*@ MPE_Describe_info_state - Describe attributes of a state with byte informational data in MPI_COMM_WORLD. Input Parameters:+ state_startID - event number for the beginning of the state.. state_finalID - event number for the ending of the state.. name - name of the state, the maximum length of the NULL-terminated string is, sizeof(CLOG_DESC), 32.. color - color of the state, the maximum length of the NULL-terminated string is, sizeof(CLOG_COLOR), 24.- format - printf style %-token format control string for the state, the maximum length of the NULL-terminated string is, sizeof(CLOG_FORMAT), 40. If format is NULL, it is equivalent to calling MPE_Describe_state(). The fortran interface of this routine considers the zero-length string, "", and single-blank string, " ", as NULL. Notes: Adds a state definition to the logfile. States are added to a logfile by calling 'MPE_Log_event()' for the start and end event numbers. The function is provided for backward compatibility purpose. Users are urged to use 'MPE_Describe_comm_state' and 'MPE_Log_comm_event()' instead..N MPE_LOG_BYTE_FORMAT.seealso: MPE_Log_get_state_eventIDs().
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -