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

📄 slog_profile.c

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 C
📖 第 1 页 / 共 4 页
字号:
#include <stdio.h>#ifdef HAVE_SLOGCONF_H#include "slog_config.h"#endif#ifdef HAVE_SLOG_WINCONFIG_H#include "slog_winconfig.h"#endif#if defined( STDC_HEADERS ) || defined( HAVE_STDLIB_H )#include <stdlib.h>#endif#if defined( HAVE_UNISTD_H )#include <unistd.h>#endif#if defined( STDC_HEADERS ) || defined( HAVE_STDARG_H )#include <stdarg.h>#endif#if defined( STDC_HEADERS ) || defined( HAVE_STRING_H )#include <string.h>#endif#ifndef __GNUC__# if HAVE_ALLOCA_H#  include <alloca.h># else#  ifdef _AIX #pragma alloca#  else#   ifdef HAVE_ALLOCA#     ifndef alloca /* predefined by HP cc +Olibcalls */char *alloca ();#     endif#   endif#  endif# endif#endif#include "str_util.h"#include "bswp_fileio.h"#include "slog_fileio.h"#include "slog_strlist.h"#include "slog_header.h"#include "slog_bebits.h"#include "slog_profile.h"              /*I "slog_profile.h" I*/int SLOG_PROF_IsDuplicated( const SLOG_prof_t       *profile,                            const SLOG_intvlinfo_t  *in_info ){    SLOG_intvlinfo_t  *cur_info;    int                ii;    int                NotMatched = 1;    for ( ii = 0; NotMatched && (ii < (int)profile->Nentries); ii++ ) {        cur_info = &( profile->entries[ ii ] );        NotMatched = ! SLOG_IntvlInfo_IsKeyEqualTo( cur_info, in_info );    }    return ! NotMatched;}/*@C    SLOG_PROF_Open - Creates the SLOG Display Profile,                      SLOG_prof_t, needed to write the to                     the disk.  Modified Input Variables :. slog - pointer to the SLOG_STREAM where SLOG Display Profile is         located.  Modified Output Variables :. returned value - integer return status.  Include file needed :   slog_profile.h.N SLOG_RETURN_STATUS@*/int SLOG_PROF_Open( SLOG_STREAM  *slog ){    slog->prof = ( SLOG_prof_t * ) malloc( sizeof( SLOG_prof_t ) );    if ( slog->prof == NULL ) {        fprintf( errfile, __FILE__":SLOG_PROF_Open() - "                          "malloc() fails, Cannot allocate memory for "                          "SLOG_prof_t\n" );        fflush( errfile );        return SLOG_FAIL;    }    slog->prof->increment  = 10;    slog->prof->capacity   = slog->prof->increment;    slog->prof->Nentries   = 0;    slog->prof->entries    = ( SLOG_intvlinfo_t * )                               malloc(   slog->prof->capacity                                       * sizeof( SLOG_intvlinfo_t ) );    slog->prof->file_loc   = SLOG_fptr_NULL;    return SLOG_SUCCESS;}/*@C    SLOG_PROF_AddIntvlInfo - Add one display description of an                              interval to 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. Nargs     - Number of MPI call argument for this interval record type.. ...       - optional set of string argument description labels whose total               number should match Nargs supplied, otherwise, unpredicted               behaviour will occur.  Modified Output Variables :. returned value - integer return status.  Usage Notes on this subroutine :     all the input characters strings, classtype, label, color and the     optional string argument description label are NOT allowed to be     longer than SLOG_STRING_LEN - 1, including trailing null character.     ( SLOG_STRING_LEN is defined in slog.h ).  They are also allowed      to contain alphanumeric, underscore, blank and tab characters.     But tab characters, if exist, in the string are all converted to     blanks..N SLOG_EXTRA_INTERVAL_INFOS  Include file needed :   slog_profile.h.N SLOG_RETURN_STATUS@*/int SLOG_PROF_AddIntvlInfo(       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,                            const SLOG_N_args_t      Nargs,                                  ... ){    SLOG_prof_t     *profile;    SLOG_uint32      idx;    va_list          unnamed_arg;    char           **arg_strs;    char            *in_str;    int              in_strlen;    int              ii;    profile = slog->prof;#if defined( DEBUG )    if ( profile == NULL ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddIntvlInfo() - "                          "the SLOG_prof_t pointer in slog is NULL\n" );        fflush( errfile );        return SLOG_FAIL;    }#endif    /*  Check if there is any space left for a new record definition */    if ( profile->Nentries + 1 > profile->capacity ) {        profile->capacity += profile->increment;        profile->entries   = ( SLOG_intvlinfo_t * )                             realloc( profile->entries,                                      profile->capacity                                    * sizeof( SLOG_intvlinfo_t )                                    );        if ( profile->entries == NULL ) {            fprintf( errfile, __FILE__":SLOG_PROF_AddIntvlInfo() -\n"                              "\t""realloc() fails, cannot increase the size "                              "of profile->entries[]\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;        }    }        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 );    arg_strs = NULL;    if ( Nargs > 0 ) {#if ! defined( HAVE_ALLOCA )        arg_strs  = ( char ** ) malloc( Nargs * sizeof( char * ) );#else        arg_strs  = ( char ** ) alloca( Nargs * sizeof( char * ) );#endif        if ( Nargs > 0 && arg_strs == NULL ) {            fprintf( errfile, __FILE__":SLOG_PROF_AddIntvlInfo() - "                              "malloc() for arg_strs[] fails\n" );            fflush( errfile );            return SLOG_FAIL;        }        va_start( unnamed_arg, Nargs );        for ( ii = 0; ii < Nargs; ii++ ) {            in_str = va_arg( unnamed_arg, char * );            in_strlen = strlen( in_str ) + 1;#if ! defined( HAVE_ALLOCA )            arg_strs[ ii ] = ( char * ) malloc( in_strlen * sizeof( char ) );#else            arg_strs[ ii ] = ( char * ) alloca( in_strlen * sizeof( char ) );#endif            if ( in_strlen > 0 && arg_strs[ ii ] == NULL ) {                 fprintf( errfile, __FILE__                                   ":SLOG_PROF_AddIntvlInfo() -\n"                                   "\t""malloc() for arg_strs[ %d ] fails "                                   "for string \"%s\"\n", ii, in_str );                 fflush( errfile );                 return SLOG_FAIL;            }            strcpy( arg_strs[ ii ], in_str );        }        va_end( unnamed_arg );    }    ( profile->entries[ idx ] ).arg_labels    = SLOG_StrList_CreateFromArray( Nargs, arg_strs );#if ! defined( HAVE_ALLOCA )    if ( arg_strs != NULL ) free( arg_strs );#endif    if ( SLOG_PROF_IsDuplicated( profile, &(profile->entries[ idx ]) ) ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddIntvlInfo() - \n"                          "\t""there is already a copy of input interval\n"                          "\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_AddIntvlInfoWithArray - Add one display description of an                                       interval to 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. Nargs     - Number of MPI call argument for this interval record type.. arg_strs  - pointer to an array of strings whose total number should               match Nargs supplied, otherwise, unpredicted behaviour               will occur.   If Nargs is 0, arg_strs will be ignored, so              NULL pointer can be used for this argument.  Modified Output Variables :. returned value - integer return status.  Usage Notes on this subroutine :     all the input characters strings, classtype, label, color and the     optional string argument description label are NOT allowed to be     longer than SLOG_STRING_LEN - 1, including trailing null character.     ( SLOG_STRING_LEN is defined in slog.h ).  They are also allowed      to contain alphanumeric, underscore, blank and tab characters.     But tab characters, if exist, in the string are all converted to     blanks..N SLOG_EXTRA_INTERVAL_INFOS  Include file needed :   slog_profile.h.N SLOG_RETURN_STATUS@*/int SLOG_PROF_AddIntvlInfoWithArray(       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,                                     const SLOG_N_args_t      Nargs,                                           char             **arg_strs ){    SLOG_prof_t     *profile;    SLOG_uint32      idx;    profile = slog->prof;#if defined( DEBUG )    if ( profile == NULL ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddIntvlInfoWithArray() - "                          "the SLOG_prof_t pointer in slog is NULL\n" );        fflush( errfile );        return SLOG_FAIL;    }#endif    /*  Check if there is any space left for a new record definition */    if ( profile->Nentries + 1 > profile->capacity ) {        profile->capacity += profile->increment;        profile->entries   = ( SLOG_intvlinfo_t * )                             realloc( profile->entries,                                      profile->capacity                                    * sizeof( SLOG_intvlinfo_t )                                    );        if ( profile->entries == NULL ) {            fprintf( errfile, __FILE__":SLOG_PROF_AddIntvlInfoWithArray() - "                              "\t""realloc() fails, cannot increase the size "                              "of profile->entries[]\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;        }    }        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 );    if ( Nargs > 0 ) {        ( profile->entries[ idx ] ).arg_labels        = SLOG_StrList_CreateFromArray( Nargs, arg_strs );    }    if ( SLOG_PROF_IsDuplicated( profile, &(profile->entries[ idx ]) ) ) {        fprintf( errfile, __FILE__":SLOG_PROF_AddIntvlInfoWithArray() - \n"                          "\t""there is already a copy of input interval\n"

⌨️ 快捷键说明

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