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

📄 slog_impl.c

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 C
📖 第 1 页 / 共 5 页
字号:
    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_DepositFrameHdr() - Cannot write "                          "the Nbytes_pas to the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_written += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_deposit( &( frame_hdr->Nrec_pas ),                         SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_DepositFrameHdr() - Cannot write "                          "the Nrec_pas to the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_written += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_deposit( &( frame_hdr->Nbytes_out ),                         SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_DepositFrameHdr() - Cannot write "                          "the Nbytes_out to the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_written += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_deposit( &( frame_hdr->Nrec_out ),                         SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_DepositFrameHdr() - Cannot write "                          "the Nrec_out to the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_written += ierr * SLOG_typesz[ ui32 ];    return Nbytes_written;}int SLOG_STM_WithdrawFrameHdr( SLOG_framehdr_t *frame_hdr,                               filebuf_t       *fbuf ){    SLOG_uint32 Nbytes_read;    int         ierr;    Nbytes_read = 0;    ierr = fbuf_withdraw( &( frame_hdr->Nbytes_cur ),                          SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawFrameHdr() - Cannot read "                          "the Nbytes_cur from the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_read += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_withdraw( &( frame_hdr->Nrec_cur ),                          SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawFrameHdr() - Cannot read "                          "the Nrec_cur from the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_read += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_withdraw( &( frame_hdr->Nbytes_inc ),                          SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawFrameHdr() - Cannot read "                          "the Nbytes_inc from the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_read += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_withdraw( &( frame_hdr->Nrec_inc ),                          SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawFrameHdr() - Cannot read "                          "the Nrec_inc from the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_read += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_withdraw( &( frame_hdr->Nbytes_pas ),                          SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawFrameHdr() - Cannot read "                          "the Nbytes_pas from the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_read += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_withdraw( &( frame_hdr->Nrec_pas ),                          SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawFrameHdr() - Cannot read "                          "the Nrec_pas from the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_read += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_withdraw( &( frame_hdr->Nbytes_out ),                          SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawFrameHdr() - Cannot read "                          "the Nbytes_out from the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_read += ierr * SLOG_typesz[ ui32 ];    ierr = fbuf_withdraw( &( frame_hdr->Nrec_out ),                          SLOG_typesz[ ui32 ], 1, fbuf );    if ( ierr < 1 ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawFrameHdr() - Cannot read "                          "the Nrec_out from the SLOG filebuffer\n" );        fflush( errfile );        return SLOG_FAIL;    }    Nbytes_read += ierr * SLOG_typesz[ ui32 ];    return Nbytes_read;}/*   obsoleted   */int SLOG_STM_UpdateBBuf_endtime(       SLOG_intvlrec_blist_t *out_bbuf,                                 const SLOG_intvlrec_blist_t *in_bbuf,                                 const SLOG_dir_entry_t       frame_dir_entry ){    const SLOG_intvlrec_lptr_t  *lptr;          SLOG_time              frame_endtime;          SLOG_time              irec_endtime;          int                    ierr;    frame_endtime = frame_dir_entry.endtime;    /*        Check the content of the current Frame Buffer to see if there        is any record that needs to be copied to the outgoing Frame Buffer    */    for ( lptr = in_bbuf->lhead; lptr != NULL; lptr = lptr->next ) {        irec_endtime = ( lptr->irec )->starttime + ( lptr->irec )->duration;        if ( irec_endtime > frame_endtime ) {            ierr = SLOG_Bbuf_AddCopiedIntvlRec( out_bbuf, lptr->irec );            if ( ierr != SLOG_SUCCESS ) {                fprintf( errfile, __FILE__":SLOG_STM_UpdateBBuf_endtime() - "                                  "SLOG_Bbuf_AddCopiedIntvlRec() fails at "                                  "adding Interval Record to the "                                  "_Out_ Buffer!!\n" );                fflush( errfile );                return SLOG_FAIL;            }            /*                (lptr->irec)->vhead..vtail does NOT needed to be allocated as                SLOG_Bbuf_AddCopiedIntvlRec() comment said.  Since lptr a                 temporary variable for going through in_bbuf which is                 declared CONSTANT            */        }    }    return SLOG_SUCCESS;}int SLOG_STM_DepositBBuf( const SLOG_intvlrec_blist_t *Bbuf,                                filebuf_t             *fbuf ){    const SLOG_intvlrec_lptr_t *lptr;          SLOG_uint32           Nbytes_written;          SLOG_uint32           N_irec_written;          int                   ierr;    Nbytes_written = 0;    N_irec_written = 0;    for ( lptr = Bbuf->lhead; lptr != NULL; lptr = lptr->next ) {        ierr = SLOG_Irec_DepositToFbuf( lptr->irec, fbuf );        if ( ierr == SLOG_FAIL ) {            fprintf( errfile, __FILE__":SLOG_STM_DepositBBuf() - "                              "SLOG_Irec_DepositToFbuf() fails at writing "                              fmt_ui32"-th Interval Record to the SLOG "                              "filebuffer\n ", N_irec_written  );            fflush( errfile );            return SLOG_FAIL;        }        Nbytes_written += ierr;        N_irec_written ++;    }#if defined( DEBUG )    /*   Redundancy checks of the Byte Sizes and Number of records written  */    if ( Nbytes_written != Bbuf->Nbytes_in_file ) {        fprintf( errfile, __FILE__":SLOG_STM_DepositBBuf() - Nbytes_written = "                          fmt_ui32", but expected Nbytes_in_file = "fmt_ui32                          "\n", Nbytes_written, Bbuf->Nbytes_in_file );        fflush( errfile );        return SLOG_FAIL;    }    if ( N_irec_written != Bbuf->count_irec ) {        fprintf( errfile, __FILE__":SLOG_STM_DepositBBuf() - N_irec_written = "                          fmt_ui32", but expected writing count_irec = "                          fmt_ui32"\n", Nbytes_written, Bbuf->count_irec );        fflush( errfile );        return SLOG_FAIL;    }#endif    return Nbytes_written;}/*    Assume Bbuf->Nbytes_in_file and Bbuf->count_irec have been updated    correctly _before_ this routine is called.  So this routine will use    the values of these 2 variables to update the whole Bbuf.*/int SLOG_STM_WithdrawBBuf(       SLOG_intvlrec_blist_t *Bbuf,                           const SLOG_recdefs_table_t  *slog_recdefs,                                 filebuf_t             *fbuf ){    SLOG_intvlrec_t  *irec;    SLOG_uint32       Nrec_expected;    int               ierr;    int               ii;#if defined( DEBUG )    SLOG_uint32       Nbytes_expected;    Nbytes_expected = Bbuf->Nbytes_in_file;#endif    Nrec_expected   = Bbuf->count_irec;    Bbuf->Nbytes_in_file = 0;    Bbuf->count_irec     = 0;    for ( ii = 0; ii < (int)Nrec_expected; ii++ ) {        irec = SLOG_Irec_WithdrawFromFbuf( slog_recdefs, fbuf );        if ( irec == NULL ) {            fprintf( errfile, __FILE__":SLOG_STM_WithdrawBBuf - "                              "SLOG_Irec_WithdrawFromFbuf() fails\n" );            fprintf( errfile, "       ""SLOG_Irec_WithdrawFromFbuf() returns "                              "a NULL pointer at %d-th expected interval "                              "record.\n", ii );            fflush( errfile );            return SLOG_FAIL;        }        /*        ierr = SLOG_Bbuf_AddCopiedIntvlRec( Bbuf, irec );        if ( ierr != SLOG_SUCCESS ) {            fprintf( errfile, __FILE__":SLOG_STM_WithdrawBBuf - "                              "SLOG_Bbuf_AddCopiedIntvlRec() fails at %d-th "                              "expected interval record.\n", ii );            fflush( errfile );            return SLOG_FAIL;        }        SLOG_Irec_Free( irec );        */        ierr = SLOG_Bbuf_AddMovedIntvlRec( Bbuf, irec );        if ( ierr != SLOG_SUCCESS ) {            fprintf( errfile, __FILE__":SLOG_STM_WithdrawBBuf - "                              "SLOG_Bbuf_AddMovedIntvlRec() fails at %d-th "                              "expected interval record.\n", ii );            fflush( errfile );            return SLOG_FAIL;        }    }   /*  for ( ii = 0; ii < Nrec_expected; ii++ )  */#if defined( DEBUG )    /*  Redundancy checks of the Byte Sizes and Number of records written  */    if ( Bbuf->Nbytes_in_file != Nbytes_expected ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawBBuf() - "                          "Nbytes_expected = "fmt_ui32                          ", Nbytes_in_file read = "fmt_ui32"\n",                          Nbytes_expected, Bbuf->Nbytes_in_file );        fflush( errfile );        return SLOG_FAIL;    }    if ( Bbuf->count_irec != Nrec_expected ) {        fprintf( errfile, __FILE__":SLOG_STM_WithdrawBBuf() - "                          "Nrec_expected = "fmt_ui32                          ", count_irec read = "fmt_ui32"\n",                          Nrec_expected, Bbuf->count_irec );        fflush( errfile );        return SLOG_FAIL;    }#endif    return SLOG_SUCCESS;}/*    SLOG_STM_UpdateFrameDirEntry_Forward() = Update the buffer's Frame     Directory Record's Fptr2FrameHdr, StartTime & EndTime     So, SLOG_STM_UpdateFrameDirEntry_Forward( slog ) HAS To Be Called BEFORE    any operations on the various sectors of the frame, i.e. xxx_bbuf    because the starttime and endtime of the frame determines where    where each interval record should go.*/int SLOG_STM_UpdateFRAME_Forward( SLOG_STREAM *slog ){    /* const SLOG_intvlrec_lptr_t  *lptr;  */          SLOG_intvlrec_lptr_t  *lptr;          SLOG_time              frame_starttime;          SLOG_time              frame_endtime;          SLOG_time              irec_starttime;          SLOG_time              irec_endtime;          int                    ierr;    frame_starttime = ( slog->frame_dir_entry ).starttime;    frame_endtime   = ( slog->frame_dir_entry ).endtime;    /*        Split interval records in TEMPORARY Bbuf into INCOMING and PASSING        THROUGH Bbufs according to the criterion( exceeds the Frame's endtime )    */    lptr = SLOG_Bbuf_GetPointerAtHead( slog->tmp_bbuf );    while ( lptr != NULL ) {        irec_endtime = ( lptr->irec )->starttime + ( lptr->irec )->duration;        /*  Set slog->tmp_bbuf->lptr = lptr  */        ierr = SLOG_Bbuf_SetPointerAt( slog->tmp_bbuf, lptr );        if ( ierr != SLOG_SUCCESS ) {            fprintf( errfile, __FILE__":SLOG_STM_UpdateFRAME_Forward() - "                              "SLOG_Bbuf_SetPointerAt( _tmp_, lptr ) fails\n" );            fflush( errfile );            return SLOG_FAIL;        }        lptr = lptr->next;        if ( irec_endtime <= frame_endtime ) {            ierr = SLOG_Bbufs_MoveIntvlRec( slog->tmp_bbuf,                                            slog->inc_bbuf );            if ( ierr != SLOG_SUCCESS ) {                fprintf( errfile, __FILE__":SLOG_STM_UpdateFRAME_Forward() - "                                  "SLOG_Bbufs_MoveIntvlRec( _tmp_ -> _inc_ ) "

⌨️ 快捷键说明

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