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

📄 slog_profile.c

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 C
📖 第 1 页 / 共 4 页
字号:
                          "\t""information with identical keys "                          "in the SLOG Display Profile table\n" );        fprintf( errfile, "\t""The input Interval Info = [ "                          fmt_itype_t", ("fmt_bebit_t", "fmt_bebit_t"), "                          "%s, %s, %s, "fmt_Nargs_t" ] \n",                          intvltype, bebit_0, bebit_1,                          classtype, label, color, Nargs );        fflush( errfile );        return SLOG_FAIL;    }    profile->Nentries += 1;    return SLOG_SUCCESS;}/*@C    SLOG_PROF_Close - Write the SLOG_prof_t onto the disk  Modified Input Variables :. slog - pointer to the SLOG_STREAM where SLOG Display Profile Table is         located.  Modified Output Variables :. returned value - integer status code.  Usage Notes on this subroutine :.N SLOG_EXTRA_INTERVAL_INFOS  Include file needed :   slog_profile.h.N SLOG_RETURN_STATUS@*/int SLOG_PROF_Close( SLOG_STREAM  *slog ){    SLOG_prof_t            *profile;    int                     ierr;    int                     ii;    /*  Update the content of SLOG_hdr_t to both memory and disk  */    slog->hdr->fptr2profile = slog_ftell( slog->fd );    ierr = SLOG_WriteUpdatedHeader( slog );    if ( ierr != SLOG_SUCCESS ) {        fprintf( errfile,  __FILE__":SLOG_PROF_Close() - "                                   "SLOG_WriteUpdatedHeader() fails\n" );        fflush( errfile );        return ierr;    }    /*  Write the content of SLOG Record Definition Table to the disk  */    profile = slog->prof;        ierr = bswp_fwrite( &( profile->Nentries ),                        sizeof( SLOG_uint32 ), 1, slog->fd );    if ( ierr < 1 ) {        fprintf( errfile,  __FILE__":SLOG_PROF_Close() - \n"                           "\t""fails at "                           "writing the number of interval infos to "                           "table section of logfile\n" );        fflush( errfile );        return SLOG_FAIL;    }    for ( ii = 0; ii < (int)profile->Nentries; ii++ ) {        ierr = SLOG_IntvlInfo_WriteToFile( &( profile->entries[ ii ] ),                                        slog->fd );        if ( ierr != SLOG_TRUE ) {            fprintf( errfile,  __FILE__":SLOG_PROF_Close() - \n"                               "\t""SLOG_IntvlInfo_WriteToFile() fails at "                               "%d-th addition of the interval infos to "                               "table section of logfile\n", ii );            fflush( errfile );            return SLOG_FAIL;        }    }      return SLOG_SUCCESS;}/*@C    SLOG_PROF_SetExtraNumOfIntvlInfos - Write the starting file pointer                                         SLOG_prof_t to the slog's                                        header and then set the maximum                                        extra number of Interval                                         Description entries                                        in Display Profile Table.  Modified Input Variables :. slog - pointer to the SLOG_STREAM where SLOG Display Profile Table is         located.  Unmodifued Input Variables :. Nentries_extra - Number of extra interval description to be reserved                   on the disk  Modified Output Variables :. returned value - integer status code.  Usage Notes on this subroutine :.N SLOG_EXTRA_RECDEFS  Include file needed :   slog_profile.h.N SLOG_RETURN_STATUS@*/int SLOG_PROF_SetExtraNumOfIntvlInfos(       SLOG_STREAM  *slog,                                       const SLOG_uint32   Nentries_extra ){    /*         fill in an unrealistic number for SLOG_uint16, 2^(16)-1, in         intvltype of blank_info which is type SLOG_intvlinfo_t    */    SLOG_prof_t            *profile;    SLOG_intvlinfo_t        blank_info = { 65535, " ", " ", " " };    SLOG_uint32             old_profile_capacity;    int                     ierr;    int                     ii;    /*  Update the content of SLOG_hdr_t to both memory and disk  */    slog->hdr->fptr2profile = slog_ftell( slog->fd );    ierr = SLOG_WriteUpdatedHeader( slog );    if ( ierr != SLOG_SUCCESS ) {        fprintf( errfile,  __FILE__":SLOG_PROF_SetExtraNumOfIntvlInfos() - "                                   "SLOG_WriteUpdatedHeader() fails\n" );        fflush( errfile );        return ierr;    }    profile = slog->prof;        /*  Determine the new storage  */    old_profile_capacity = profile->capacity;    profile->capacity    = profile->Nentries + Nentries_extra;    profile->entries = ( SLOG_intvlinfo_t * )                       realloc( profile->entries,                                profile->capacity * sizeof( SLOG_intvlinfo_t )                              );    if ( profile->entries == NULL ) {        fprintf( errfile, __FILE__":SLOG_PROF_SetExtraNumOfIntvlInfos() - \n"                          "\t""realloc() fails, cannot increase the size "                          "of profile->entries["fmt_ui32"]\n",                          profile->capacity );        fflush( errfile );        profile->capacity = old_profile_capacity;        return SLOG_FAIL;    }    /*  Write the content of SLOG Record Definition Table to the disk  */    ierr = bswp_fwrite( &( profile->Nentries ),                        sizeof( SLOG_uint32 ), 1, slog->fd );    if ( ierr < 1 ) {        fprintf( errfile,  __FILE__":SLOG_PROF_SetExtraNumOfIntvlInfos() - \n"                           "\t""fails at "                           "writing the number of interval descriptors to "                           "table section of logfile\n" );        fflush( errfile );        return SLOG_FAIL;    }    for ( ii = 0; ii < (int)profile->Nentries; ii++ ) {        ierr = SLOG_IntvlInfo_WriteToFile( &( profile->entries[ ii ] ),                                         slog->fd );        if ( ierr != SLOG_TRUE ) {            fprintf( errfile,  __FILE__                               ":SLOG_PROF_SetExtraNumOfIntvlInfos() - \n"                               "\t""SLOG_IntvlInfo_WriteToFile() fails at the "                               "%d-th addition of the interval descriptors to "                               "table section of logfile\n", ii );            fflush( errfile );             return SLOG_FAIL;        }    }    /*        Save the location where the extra interval descriptors        can be inserted    */    profile->file_loc = slog_ftell( slog->fd );     /*  Write some blank record definitions to fill up the reserved space.  */    for ( ii = (int)profile->Nentries; ii < (int)profile->capacity; ii++ ) {        ierr = SLOG_IntvlInfo_WriteToFile( &blank_info, slog->fd );        if ( ierr != SLOG_TRUE ) {            fprintf( errfile,  __FILE__                               ":SLOG_PROF_SetExtraNumOfIntvlInfos() - \n"                               "\t""SLOG_IntvlInfo_WriteToFile() fails at "                               "%d-th addition of the blank descriptor to "                               "table section of logfile\n", ii );            fflush( errfile );             return SLOG_FAIL;        }    }      return SLOG_SUCCESS;}/*@C    SLOG_PROF_AddExtraIntvlInfo - Add one display description of an                                  interval to the reserved space of                                  the SLOG Display Profile table.  Modified Input Variables :. slog - pointer to the SLOG_STREAM where SLOG Display Profile Table is         located.  Unmodified Input Variables :. intvltype - index to the interval type.. bebit_0   - the 1st bebit.. bebit_1   - the 2nd bebit.. classtype - character string for the classtype of the interval. label     - character string for the label of the interval. color     - character string for the color of the interval  Modified Output Variables :. returned value - integer return status.  Usage Notes on this subroutine :     all the input characters strings, classtype, label and color are     allowed to contain alphanumeric, underscore, blank and tab characters.     But tab characters, if exist, in the string are all converted to     blanks for ease of management..N SLOG_EXTRA_INTERVAL_INFOS  Include file needed :   slog_profile.h.N SLOG_RETURN_STATUS@*/int SLOG_PROF_AddExtraIntvlInfo(       SLOG_STREAM      *slog,                                 const SLOG_intvltype_t  intvltype,                                 const SLOG_bebit_t      bebit_0,                                 const SLOG_bebit_t      bebit_1,                                 const char *            classtype,                                 const char *            label,                                 const char *            color ){    SLOG_prof_t            *profile;    SLOG_fptr               file_loc_saved;    SLOG_uint32             idx;    int                     ierr;    profile = slog->prof;#if defined( DEBUG )    if ( profile == NULL ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddExtraIntvlInfo() - "                          "the SLOG_prof_t pointer in slog "                          "is NULL\n" );        fflush( errfile );        return SLOG_FAIL;    }#endif    if ( profile->Nentries + 1 > profile->capacity ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddExtraIntvlInfo() - \n"                          "\t""All reserved space in the "                          "Record Definition Table of the logfile "                          "has been used up!\n" );        fflush( errfile );        return SLOG_FAIL;    }    idx = profile->Nentries;    SLOG_IntvlInfo_Assign( &( profile->entries[ idx ] ),                           intvltype, bebit_0, bebit_1,                           classtype, label, color );    SLOG_IntvlInfo_SetUsed( &( profile->entries[ idx ] ), SLOG_FALSE );    ( profile->entries[ idx ] ).arg_labels = NULL;    if ( SLOG_PROF_IsDuplicated( profile, &(profile->entries[ idx ]) ) ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddExtraIntvlInfo() - "                          "there is already a copy of input interval\n"                          "\t""information with identical keys "                          "in the SLOG record definition table\n" );        fprintf( errfile, "\t""The input Interval Info = [ "                          fmt_itype_t", ("fmt_bebit_t", "fmt_bebit_t"), "                          "%s, %s, %s ] \n",                          intvltype, bebit_0, bebit_1,                          classtype, label, color );        fflush( errfile );        return SLOG_FAIL;    }    profile->Nentries += 1;    /*  Save the current position in the logfile for later restoration  */    file_loc_saved = slog_ftell( slog->fd );    /*  Update the number of interval descriptors on the file/disk  */    ierr = slog_fseek( slog->fd, slog->hdr->fptr2profile, SEEK_SET );    if ( ierr != 0 ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddExtraIntvlInfo() - "                          "slog_fseek( fptr2profile ) fails\n" );        fflush( errfile );        return SLOG_FAIL;    }    ierr = bswp_fwrite( &( profile->Nentries ),                        sizeof( SLOG_uint32 ), 1, slog->fd );    if ( ierr < 1 ) {        fprintf( errfile,  __FILE__":SLOG_PROF_AddExtraIntvlInfo() - \n"                           "\t""Update the number of entries in the record "                           "definition table on the file fails\n" );        fflush( errfile );        return SLOG_FAIL;    }    /*  Insert the new record definition to the reserved space  */    ierr = slog_fseek( slog->fd, profile->file_loc, SEEK_SET );    if ( ierr != 0 ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddExtraIntvlInfo() - "                          "slog_fseek( profile->file_loc ) fails\n" );        fflush( errfile );        return SLOG_FAIL;    }    ierr = SLOG_IntvlInfo_WriteToFile( &( profile->entries[idx] ), slog->fd );    if ( ierr != SLOG_TRUE ) {        fprintf( errfile,  __FILE__":SLOG_PROF_AddExtraIntvlInfo() - \n"                           "\t""SLOG_IntvlInfo_WriteToFile() fails at "                           "%d-th addition of the interval decriptor to "                           "table section of logfile\n", idx );        fflush( errfile );        return SLOG_FAIL;    }    fflush( slog->fd );    /*  Update the file pointer to the reserved space of IntvlInfos in file */    profile->file_loc = slog_ftell( slog->fd );    /*  Restore the original file position in the logfile  */    ierr = slog_fseek( slog->fd, file_loc_saved, SEEK_SET );    return SLOG_SUCCESS;}SLOG_intvlinfo_t *SLOG_PROF_GetIntvlInfo( const SLOG_prof_t       *profile,                                          const SLOG_intvltype_t   intvltype,                                          const SLOG_bebit_t       bebit_0,                                          const SLOG_bebit_t       bebit_1 ){    SLOG_intvlinfo_t  *cur_def;    int                ii;    for ( ii = 0; ii < (int)profile->Nentries; ii++ ) {        cur_def = &( profile->entries[ ii ] );        if (    ( cur_def->intvltype == intvltype )             && ( cur_def->bebits[0] == bebit_0 )             && ( cur_def->bebits[1] == bebit_1 ) ) {             return cur_def;        }    }    fprintf( errfile, __FILE__":SLOG_PROF_GetIntvlInfo() - \n"                      "\t""Cannot find [ intvltype = "fmt_itype_t", ("                      fmt_bebit_t", "fmt_bebit_t") ] "

⌨️ 快捷键说明

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