⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpe_log.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 3 页
字号:
    const CLOG_CommIDs_t *commIDs;          int             ierr;    MPE_LOG_THREADSTM_DECL    MPE_LOG_THREADSTM_GET    MPE_LOG_THREAD_LOCK    commIDs  = CLOG_CommSet_get_IDs( CLOG_CommSet, comm );    ierr = MPE_Log_commIDs_receive( commIDs, THREADID,                                    other_party, tag, size );    MPE_LOG_THREAD_UNLOCK    return ierr;}/*@    MPE_Log_receive - log the receive event of a message within MPI_COMM_WORLD.                      (on the calling thread where send event takes place)    Input Parameters:+ other_party   -  the rank of the other party, i.e. send event's rank.. tag           -  message tag ID.- size          -  message size in byte.    Notes:    This function is threadsafe.@*/int MPE_Log_receive( int other_party, int tag, int size ){    int   ierr;    MPE_LOG_THREADSTM_DECL    MPE_LOG_THREADSTM_GET    MPE_LOG_THREAD_LOCK    ierr = MPE_Log_commIDs_receive( CLOG_CommSet->IDs4world, THREADID,                                    other_party, tag, size );    MPE_LOG_THREAD_UNLOCK    return ierr;}/*@    MPE_Log_pack - pack the informational data into the byte buffer to                   be stored in a infomational event.  The routine will                   byteswap the data if it is invoked on a small endian                   machine.    Output Parameters:+ bytebuf    - output byte buffer which is of sizeof(MPE_LOG_BYTES),               i.e. 32 bytes.  For C, bytebuf could be of type               MPE_LOG_BYTES.  For Fortran, bytebuf could be of               type 'character*32'.- position   - an offset measured from the beginning of the bytebuf.               On input, data will be written to the offset position.               On Output, position will be updated to reflect the next               available position in the byte buffer.                    Input Parameters:+ tokentype  - a character token type indicator, currently supported tokens               are 's', 'h', 'd', 'l', 'x', 'X', 'e' and 'E'.. count      - the number of continuous storage units as indicated by               tokentype.- data       - pointer to the beginning of the storage units being copied..N MPE_LOG_BYTE_FORMAT@*/int MPE_Log_pack( MPE_LOG_BYTES bytebuf, int *position,                  char tokentype, int count, const void *data ){    void *vptr;    int   tot_sz;    vptr = ( (char *) bytebuf + *position );    /*      * Do the byte swapping here for now.     * Moving byteswapping to clog2TOslog2 convertor should speed up logging.     */    switch (tokentype) {        case 's':  /* STR */            tot_sz = sizeof( CLOG_int16_t ) + count;            if ( *position + tot_sz <= sizeof( MPE_LOG_BYTES ) ) {                *((CLOG_int16_t *) vptr) = (CLOG_int16_t) count;#if !defined( WORDS_BIGENDIAN )                CLOG_Util_swap_bytes( vptr, sizeof( CLOG_int16_t ) , 1 );#endif                vptr = (void *)( (char *) vptr + sizeof( CLOG_int16_t ) );                memcpy( vptr, data, count );                *position += tot_sz;                return MPE_LOG_OK;            }            break;        case 'h':  /* INT2 */            tot_sz = count * 2;            if ( *position + tot_sz <= sizeof( MPE_LOG_BYTES ) ) {                memcpy( vptr, data, tot_sz );#if !defined( WORDS_BIGENDIAN )                 CLOG_Util_swap_bytes( vptr, 2 , count );#endif                *position += tot_sz;                return MPE_LOG_OK;            }            break;        case 'd': /* INT4 */        case 'x': /* BYTE4 */        case 'e': /* FLT4 */            tot_sz = count * 4;            if ( *position + tot_sz <= sizeof( MPE_LOG_BYTES ) ) {                memcpy( vptr, data, tot_sz );#if !defined( WORDS_BIGENDIAN )                CLOG_Util_swap_bytes( vptr, 4, count );#endif                *position += tot_sz;                return MPE_LOG_OK;            }            break;        case 'l': /* INT8 */        case 'X': /* BYTE8 */        case 'E': /* FLT8 */            tot_sz = count * 8;            if ( *position + tot_sz <= sizeof( MPE_LOG_BYTES ) ) {                memcpy( vptr, data, tot_sz );#if !defined( WORDS_BIGENDIAN )                CLOG_Util_swap_bytes( vptr, 8, count );#endif                *position += tot_sz;                return MPE_LOG_OK;            }            break;        default:            fprintf( stderr, "MPE_Log_pack(): Unknown tokentype %c\n",                             tokentype );    }    return MPE_LOG_PACK_FAIL;}/*    This is a MPE internal function in defining MPI logging wrappers.    It is not meant for user application.    This function is NOT threadsafe.*/int MPE_Log_commIDs_event( const CLOG_CommIDs_t *commIDs, int local_thread,                           int event, const char *bytebuf ){    if ( bytebuf )        CLOG_Buffer_save_cargoevt( CLOG_Buffer, commIDs, local_thread,                                   event, bytebuf );    else        CLOG_Buffer_save_bareevt( CLOG_Buffer, commIDs, local_thread,                                  event );    return MPE_LOG_OK;}/*@    MPE_Log_comm_event - Log an event in a specified MPI_Comm.                         (on the calling thread where the event takes place)    Input Parameters:+ comm          - MPI_Comm where this process is part of.. event         - event number.- bytebuf       - optional byte informational array.  In C, bytebuf should be                  set to NULL when no extra byte informational data.  In                  Fortran, an zero-length string "", or a single blank string                  " ", is equivalent to NULL in C.    Notes:    This function is threadsafe.    Returns:    alway returns MPE_LOG_OK@*/int MPE_Log_comm_event( MPI_Comm comm, int event, const char *bytebuf ){    const CLOG_CommIDs_t *commIDs;          int             ierr;    MPE_LOG_THREADSTM_DECL    MPE_LOG_THREADSTM_GET    MPE_LOG_THREAD_LOCK    commIDs  = CLOG_CommSet_get_IDs( CLOG_CommSet, comm );    ierr = MPE_Log_commIDs_event( commIDs, THREADID, event, bytebuf );    MPE_LOG_THREAD_UNLOCK    return ierr;}/*@    MPE_Log_event - Log an event in MPI_COMM_WORLD.    Input Parameters:+   event   - event number..   data    - integer data value              (not used, provided for backward compatibility purpose).-   bytebuf - optional byte informational array.  In C, bytebuf should be              set to NULL when no extra byte informational data.  In Fortran,              an zero-length string "", or a single blank string " ",              is equivalent to NULL in C.    Notes:    This function is threadsafe.    Returns:    alway returns MPE_LOG_OK@*/int MPE_Log_event( int event, int data, const char *bytebuf ){    int ierr;    MPE_LOG_THREADSTM_DECL    MPE_LOG_THREADSTM_GET    MPE_LOG_THREAD_LOCK    ierr = MPE_Log_commIDs_event( CLOG_CommSet->IDs4world, THREADID,                                   event, bytebuf );    MPE_LOG_THREAD_UNLOCK    return ierr;}/*@    MPE_Log_bare_event - Logs a bare event in MPI_COMM_WORLD.    Input Parameters:.   event   - event number.    Notes:    This function is threadsafe.    Returns:    alway returns MPE_LOG_OK@*/int MPE_Log_bare_event( int event ){    MPE_LOG_THREADSTM_DECL    MPE_LOG_THREADSTM_GET    MPE_LOG_THREAD_LOCK    CLOG_Buffer_save_bareevt( CLOG_Buffer, CLOG_CommSet->IDs4world, THREADID,                              event );    MPE_LOG_THREAD_UNLOCK    return MPE_LOG_OK;}/*@    MPE_Log_info_event - Logs an infomational event in MPI_COMM_WORLD.    Input Parameters:+   event   - event number.-   bytebuf - byte informational array.  If no byte inforamtional array,              use MPE_Log_bare_event() instead.    Notes:    This function is threadsafe.    Returns:    alway returns MPE_LOG_OK@*/int MPE_Log_info_event( int event, const char *bytebuf ){    MPE_LOG_THREADSTM_DECL    MPE_LOG_THREADSTM_GET    MPE_LOG_THREAD_LOCK    CLOG_Buffer_save_cargoevt( CLOG_Buffer, CLOG_CommSet->IDs4world, THREADID,                               event, bytebuf );    MPE_LOG_THREAD_UNLOCK    return MPE_LOG_OK;}/*@    MPE_Log_sync_clocks - synchronize or recalibrate all MPI clocks to                          minimize the effect of time drift.  It is like a                           longer version of MPI_Comm_barrier( MPI_COMM_WORLD );    Notes:    This function is threadsafe.    Returns:    alway returns MPE_LOG_OK@*/int MPE_Log_sync_clocks( void ){    CLOG_Sync_t  *clog_syncer;    CLOG_Time_t   local_timediff;    MPE_LOG_THREAD_LOCK    clog_syncer = CLOG_Stream->syncer;    if ( clog_syncer->is_ok_to_sync == CLOG_BOOL_TRUE ) {        local_timediff = CLOG_Sync_run( clog_syncer );        CLOG_Buffer_set_timeshift( CLOG_Buffer, local_timediff,                                   CLOG_BOOL_TRUE );    }    MPE_LOG_THREAD_UNLOCK    return MPE_LOG_OK;}/*    This is a MPE internal function.    It is not meant for user application.    This function is NOT threadsafe.*/void MPE_Log_thread_sync( int local_thread_count ){     int max_thread_count;     PMPI_Allreduce( &local_thread_count, &max_thread_count, 1, MPI_INT,                     MPI_MAX, MPI_COMM_WORLD );     CLOG_Stream->buffer->preamble->max_thread_count = max_thread_count;}/* Declare clog_merged_filename same as CLOG_Merger_t.out_filename */static char clog_merged_filename[ CLOG_PATH_STRLEN ] = {0};/*@    MPE_Finish_log - Send log to master, who writes it out    Notes:    MPE_Finish_log() & MPE_Init_log() are NOT needed when liblmpe.a is linked    because MPI_Finalize() would have called MPE_Finish_log() already.    liblmpe.a will be included in the final executable if it is linked with    either "mpicc -mpe=mpilog" or "mpecc -mpilog"    This routine outputs the logfile in CLOG2 format, i.e.    a collective call over 'MPI_COMM_WORLD'.    This function is threadsafe, but    MPE_Finish_log() is expected to be called only on the main thread    which initializes MPE logging through MPE_Init_log().    Returns:    Always return MPE_LOG_OK..seealso: MPE_Init_log()@*/int MPE_Finish_log( const char *filename ){/*   The environment variable MPE_LOG_FORMAT is NOT read*/    char         *env_logfile_prefix;    MPE_LOG_THREAD_LOCK    MPE_LOG_THREAD_FINALIZE    if ( MPE_Log_hasBeenClosed == 0 ) {        CLOG_Local_finalize( CLOG_Stream );        /*           Invoke non-threadsafe version of MPE_Stop_log()           before CLOG_Close() which nullifies CLOG_Stream.        */        CLOG_Buffer->status = CLOG_INIT_AND_OFF;        /* Even every process reads MPE_LOGFILE_PREFIX, only rank=0 needs it */        env_logfile_prefix = (char *) getenv( "MPE_LOGFILE_PREFIX" );        if ( env_logfile_prefix != NULL )            CLOG_Converge_init( CLOG_Stream, env_logfile_prefix );        else            CLOG_Converge_init( CLOG_Stream, filename );        /*           Save the merged filename in the local memory so           CLOG_Stream_t can be freed to be destroyed        */        strncpy( clog_merged_filename, CLOG_Stream->merger->out_filename,                 CLOG_PATH_STRLEN );        CLOG_Converge_sort( CLOG_Stream );        CLOG_Converge_finalize( CLOG_Stream );        /*           Finalize the CLOG_Stream_t and nullify CLOG_Buffer so calling           other MPE routines after MPE_Finish_log will cause seg. fault.        */        CLOG_Close( &CLOG_Stream );        CLOG_Buffer = NULL;        MPE_Log_hasBeenClosed = 1;    }    MPE_LOG_THREAD_UNLOCK#if defined( CLOG_NOMPI )    /* Finalize the serial-MPI implementation */    PMPI_Finalize();#endif    return MPE_LOG_OK;}/*@    MPE_Log_merged_logfilename - return the immutable name of                                 the merged final logfile.    Notes:    This function has no fortran interface.@*/const char *MPE_Log_merged_logfilename( void ){    return clog_merged_filename;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -