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

📄 slog_irec_common.c

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 C
📖 第 1 页 / 共 3 页
字号:
#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( STDC_HEADERS ) || defined( HAVE_STDARG_H )#include <stdarg.h>#endif#include "slog_bebits.h"#include "slog_tasklabel.h"#include "slog_assoc.h"#include "slog_vtrarg.h"#include "slog_header.h"#include "slog_pstat.h"#include "slog_recdefs.h"#include "slog_impl.h"                  /*I  "slog_impl.h"  I*//*@C    SLOG_Irec_Create - Create a bare minimal interval record data structure                       without any of its components set. (SLOG_intvlrec_t's                       constructor)  Modified Output Variables :. returned value - pointer to newly allocated SLOG_intvlrec_t, interval                   record data structure.  Usage Notes on this routine :  The memory can be deallocated by SLOG_Irec_Free().  Include File Needed :  slog.h.N SLOG_RETURN_STATUS@*/SLOG_intvlrec_t *SLOG_Irec_Create( void ){    SLOG_intvlrec_t *irec;    irec = ( SLOG_intvlrec_t * ) malloc( sizeof( SLOG_intvlrec_t ) );    if ( irec == NULL ) {        fprintf( errfile, __FILE__":SLOG_Irec_Create() - "                          "malloc() fails for irec\n" );        fflush( errfile );        return NULL;    }    irec->bytesize  = 0;    irec->N_assocs  = 0;    irec->assocs    = NULL;    irec->vhead     = NULL;    irec->vtail     = NULL;    irec->vptr      = NULL;    return irec;}/*@C    SLOG_Irec_Free - Deallocate the given interval record data structure, i.e.                      free the memory associated with it. (SLOG_intvlrec_t's                     destructor)  Modified Input Variables :. irec - pointer to the interval record data structure to be erased/freed.  Usage Notes on this routine :  Free the memory allocated by SLOG_Irec_Create(), SLOG_Irec_Copy() and  other related routines.  Include File Needed :  slog.h@*/void SLOG_Irec_Free( SLOG_intvlrec_t *irec ){    if ( irec != NULL ) {        SLOG_Irec_DelAllVtrArgs( irec );        if ( irec->assocs   != NULL ) free( irec->assocs );        free( irec );        irec = NULL;    }}void SLOG_Irec_CopyVal( const SLOG_intvlrec_t *src, SLOG_intvlrec_t *dest ){    dest->bytesize    = src->bytesize;    dest->rectype     = src->rectype;    dest->intvltype   = src->intvltype;    dest->bebits[0]   = src->bebits[0];    dest->bebits[1]   = src->bebits[1];    dest->starttime   = src->starttime;    dest->duration    = src->duration;    SLOG_TaskID_Copy( &( dest->origID ), &( src->origID ) );    if ( SLOG_global_IsOffDiagRec( src->rectype ) )        SLOG_TaskID_Copy( &( dest->destID ), &( src->destID ) );    dest->instr_addr  = src->instr_addr;    /*        Here assume memory for the src->args[] has been allocated        All the function does is copying the pointer    */    dest->N_assocs    = src->N_assocs;    dest->assocs      = src->assocs;    dest->vhead       = src->vhead;    dest->vtail       = src->vtail;    dest->vptr        = src->vptr;}/*@C    SLOG_Irec_Copy - Copy the content of the specified interval record                      to a newly allocated one and return it.                       (SLOG_intvlrec_t's Copy constructor)  Unmodified Input Variables :. src - pointer to constant SLOG_intvlrec_t to be copied.  Modified Output Variables :. returned value - dest, pointer to the newly allocated SLOG_intvlrec_t,                    interval record data structure.  Usage Notes on this routine :  This routine is similar to SLOG_Irec_Create(), except it uses  the content of the given SLOG_intvlrec_t to create/copy a new one.  The memory can be deallocated by SLOG_Irec_Free().  Include File Needed :  slog.h@*/SLOG_intvlrec_t *SLOG_Irec_Copy( const SLOG_intvlrec_t *src ){          SLOG_intvlrec_t     *dest;    const SLOG_vtrarg_lptr_t  *vptr;    int ii;    dest = SLOG_Irec_Create();    if ( dest == NULL ) {        fprintf( errfile, __FILE__":SLOG_Irec_Copy() - "                          "SLOG_Irec_Create() fails\n" );        fflush( errfile );        return NULL;    }    dest->bytesize    = src->bytesize;    dest->rectype     = src->rectype;    dest->intvltype   = src->intvltype;    dest->bebits[0]   = src->bebits[0];    dest->bebits[1]   = src->bebits[1];    dest->starttime   = src->starttime;    dest->duration    = src->duration;    SLOG_TaskID_Copy( &( dest->origID ), &( src->origID ) );    if ( SLOG_global_IsOffDiagRec( src->rectype ) )        SLOG_TaskID_Copy( &( dest->destID ), &( src->destID ) );    dest->instr_addr  = src->instr_addr;    dest->N_assocs    = src->N_assocs;    if ( dest->N_assocs == 0 )        dest->assocs = NULL;    else {        dest->assocs = ( SLOG_assoc_t * ) malloc( dest->N_assocs                                                * sizeof( SLOG_assoc_t ) );        if ( dest->N_assocs > 0 && dest->assocs == NULL ) {            fprintf( errfile, __FILE__":SLOG_Irec_Copy() - "                              "malloc() for dest->assocs fails\n" );            fflush( errfile );            return NULL;        }        for ( ii = 0; ii < dest->N_assocs; ii++ )            dest->assocs[ ii ] = src->assocs[ ii ];    }    if ( dest->vhead == NULL && dest->vtail == NULL ) {        for( vptr = src->vhead; vptr != NULL; vptr = vptr->next )            SLOG_Irec_AddVtrArgs( dest, vptr->vtr );    }    else {        fprintf( errfile, __FILE__":SLOG_Irec_Copy() - "                          "dest->vhead != NULL or dest->vtail != NULL\n" );        fflush( errfile );        return NULL;    }    dest->vptr      = src->vptr;    return dest;}/*@C    SLOG_Irec_Print - Print the content of interval record at the                      specified file stream in ASCII format.                        (SLOG_intvlrec_t's Print operator)  Unmodified Input Variables :. irec - constant SLOG_intvlrec_t pointer to be printed to the specified         file stream.  Modified Output variables :. outfd - pointer to the specified file stream.. returned value - integer return status  Usage Notes on this subroutine :  This routine is mainly used for debugging purposes.  Include File Needed :  slog.h.N SLOG_RETURN_STATUS@*/int SLOG_Irec_Print( const SLOG_intvlrec_t *irec, FILE *outfd ){    SLOG_vtrarg_lptr_t *vptr;    int                 ii;    if ( irec == NULL ) {        fprintf( outfd, __FILE__":SLOG_Irec_Print() - the input interval "                        "record pointer is NULL\n" );        fflush( outfd );        return SLOG_FAIL;    }    fprintf( outfd, fmt_sz_t" ",     irec->bytesize );    fprintf( outfd, fmt_rtype_t" ",  irec->rectype );    fprintf( outfd, fmt_itype_t" ",  irec->intvltype );    fprintf( outfd, "( "fmt_bebit_t", "fmt_bebit_t" ) ",                     irec->bebits[0], irec->bebits[1] );    fprintf( outfd, fmt_stime_t" ",  irec->starttime );    fprintf( outfd, fmt_dura_t" ",   irec->duration );    SLOG_TaskID_Print( &( irec->origID ), outfd ); fprintf( outfd, " " );    if ( SLOG_global_IsOffDiagRec( irec->rectype ) )        SLOG_TaskID_Print( &( irec->destID ), outfd ); fprintf( outfd, " " );#if ! defined( NOINSTRUCTION )    fprintf( outfd, fmt_iaddr_t" ",  irec->instr_addr );#endif    fprintf( outfd, "{ " );    for ( ii = 0; ii < irec->N_assocs; ii++ )        fprintf( outfd, fmt_assoc_t" ", irec->assocs[ ii ] );    fprintf( outfd, "} " );    for ( vptr = irec->vhead; vptr != NULL; vptr = vptr->next )        SLOG_Varg_Print( vptr->vtr, outfd );    return SLOG_SUCCESS;}/*@C   SLOG_Irec_IsEmpty - Check if the specified Interval record is empty  Unmodified Input Variables :. irec - constant SLOG_intvlrec_t pointer to be checked  Modified Output variables :. returned value - integer return status  Usage Notes on this subroutine :  This routine is mainly used for debugging purposes.  Include File Needed :  slog.h.N SLOG_RETURN_STATUS@*/int SLOG_Irec_IsEmpty( const SLOG_intvlrec_t *irec ){    return( irec->bytesize == 0 );}/*@C   SLOG_Irec_IsConsistent - Check if the specified Interval record's length,                             bytesize, is consistent with what it contains.   Unmodified Input Variables :. irec - constant SLOG_intvlrec_t pointer to be checked  Modified Output variables :. returned value - integer return status  Usage Notes on this subroutine :  This routine is mainly used for debugging purposes.    Include File Needed :  slog.h.N SLOG_RETURN_STATUS@*/int SLOG_Irec_IsConsistent( const SLOG_intvlrec_t *irec ){    const SLOG_vtrarg_lptr_t  *vptr;          SLOG_uint32          sizeof_irec;    if ( irec->bytesize >= SLOG_typesz[ min_IntvlRec ] ) {        if ( irec->bytesize == SLOG_typesz[ min_IntvlRec ] ) {             if ( irec->N_assocs > 0 || irec->assocs != NULL )                 return SLOG_FALSE;             if ( irec->vhead != NULL || irec->vtail != NULL )                 return SLOG_FALSE;             return SLOG_TRUE;        }        if ( irec->N_assocs > 0 && irec->assocs == NULL )             return SLOG_FALSE;        if ( irec->N_assocs == 0 && irec->assocs != NULL )             return SLOG_FALSE;        /*        if ( irec->N_assocs < 0 )            return SLOG_FALSE;        */        sizeof_irec = SLOG_typesz[ min_IntvlRec ]                    + irec->N_assocs * sizeof( SLOG_assoc_t );        if ( SLOG_global_IsOffDiagRec( irec->rectype ) )            sizeof_irec += SLOG_typesz[ taskID_t ];        for ( vptr = irec->vhead; vptr != NULL; vptr = vptr->next ) {            if ( SLOG_global_IsVarRec( irec->rectype ) )                sizeof_irec += sizeof( SLOG_N_args_t );            if ( vptr->vtr->size > 0 && vptr->vtr->values != NULL )                sizeof_irec += vptr->vtr->size * sizeof( SLOG_arg_t );            else                return SLOG_FALSE;        }        if ( irec->bytesize != sizeof_irec )            return SLOG_FALSE;

⌨️ 快捷键说明

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