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

📄 clog_buffer.c

📁 mpi并行计算的c++代码 可用vc或gcc编译通过 可以用来搭建并行计算试验环境
💻 C
📖 第 1 页 / 共 3 页
字号:
                                const char *color, const char *name,                                const char *format ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_StateDef_t  *statedef;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_STATEDEF );        blkdata               = buffer->curr_block->data;        statedef              = (CLOG_Rec_StateDef_t *) blkdata->ptr;        statedef->stateID     = stateID;        statedef->startetype  = startetype;        statedef->finaletype  = finaletype;        if ( color ) {            strncpy( statedef->color, color, sizeof(CLOG_Str_Color_t) );            statedef->color[ sizeof(CLOG_Str_Color_t) - 1 ] = '\0';        }        else            * ( (char *) statedef->color ) = '\0';        if ( name ) {            strncpy( statedef->name, name, sizeof(CLOG_Str_Desc_t) );            statedef->name[ sizeof(CLOG_Str_Desc_t) - 1 ] = '\0';        }        else            * ( (char *) statedef->name ) = '\0';        if ( format ) {            strncpy( statedef->format, format, sizeof(CLOG_Str_Format_t) );            statedef->format[ sizeof(CLOG_Str_Format_t) - 1 ] = '\0';        }        else            * ( (char *) statedef->format ) = '\0';        blkdata->ptr          = statedef->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_statedef() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_eventdef( CLOG_Buffer_t *buffer,                                const CLOG_CommIDs_t *commIDs,                                CLOG_ThreadLID_t thd,                                int etype, const char *color,                                const char *name, const char *format ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_EventDef_t  *eventdef;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_EVENTDEF );        blkdata               = buffer->curr_block->data;        eventdef              = (CLOG_Rec_EventDef_t *) blkdata->ptr;        eventdef->etype       = etype;        if ( color ) {            strncpy( eventdef->color, color, sizeof(CLOG_Str_Color_t) );            eventdef->color[ sizeof(CLOG_Str_Color_t) - 1 ] = '\0';        }        else            * ( (char *) eventdef->color ) = '\0';        if ( name ) {            strncpy( eventdef->name, name, sizeof(CLOG_Str_Desc_t) );            eventdef->name[ sizeof(CLOG_Str_Desc_t) - 1 ] = '\0';        }        else            * ( (char *) eventdef->name ) = '\0';        if ( format ) {            strncpy( eventdef->format, format, sizeof(CLOG_Str_Format_t) );            eventdef->format[ sizeof(CLOG_Str_Format_t) - 1 ] = '\0';        }        else            * ( (char *) eventdef->format ) = '\0';        blkdata->ptr          = eventdef->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_eventdef() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_constdef( CLOG_Buffer_t *buffer,                                const CLOG_CommIDs_t *commIDs,                                CLOG_ThreadLID_t thd,                                int etype, int value, const char *name ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_ConstDef_t  *constdef;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_CONSTDEF );        blkdata               = buffer->curr_block->data;        constdef              = (CLOG_Rec_ConstDef_t *) blkdata->ptr;        constdef->etype       = etype;        constdef->value       = value;        if ( name ) {            strncpy( constdef->name, name, sizeof(CLOG_Str_Desc_t) );            constdef->name[ sizeof(CLOG_Str_Desc_t) - 1 ] = '\0';        }        else            * ( (char *) constdef->name ) = '\0';        blkdata->ptr          = constdef->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_constdef() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_bareevt_0chk( CLOG_Buffer_t *buffer,                                    const CLOG_CommIDs_t *commIDs,                                    CLOG_ThreadLID_t thd,                                    int etype ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_BareEvt_t   *bareevt;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header_0chk( buffer, commIDs, thd, CLOG_REC_BAREEVT );        blkdata               = buffer->curr_block->data;        bareevt               = (CLOG_Rec_BareEvt_t *) blkdata->ptr;        bareevt->etype        = etype;        blkdata->ptr          = bareevt->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_bareevt_0chk() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_bareevt( CLOG_Buffer_t *buffer,                               const CLOG_CommIDs_t *commIDs,                               CLOG_ThreadLID_t thd,                               int etype ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_BareEvt_t   *bareevt;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_BAREEVT );        blkdata               = buffer->curr_block->data;        bareevt               = (CLOG_Rec_BareEvt_t *) blkdata->ptr;        bareevt->etype        = etype;        blkdata->ptr          = bareevt->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_bareevt() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_cargoevt( CLOG_Buffer_t *buffer,                                const CLOG_CommIDs_t *commIDs,                                CLOG_ThreadLID_t thd,                                int etype, const char *bytes ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_CargoEvt_t  *cargoevt;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_CARGOEVT );        blkdata               = buffer->curr_block->data;        cargoevt              = (CLOG_Rec_CargoEvt_t *) blkdata->ptr;        cargoevt->etype       = etype;        if ( bytes )            memcpy( cargoevt->bytes, bytes, sizeof(CLOG_Str_Bytes_t) );        blkdata->ptr          = cargoevt->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_cargoevt() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_msgevt( CLOG_Buffer_t *buffer,                              const CLOG_CommIDs_t *commIDs,                              CLOG_ThreadLID_t thd,                              int etype, int tag, int remote_rank, int size ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_MsgEvt_t    *msgevt;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_MSGEVT );        blkdata               = buffer->curr_block->data;        msgevt                = (CLOG_Rec_MsgEvt_t *) blkdata->ptr;        msgevt->etype         = etype;        msgevt->icomm         = CLOG_COMM_LID_NULL; /* will be patched later */         msgevt->rank          = remote_rank;        msgevt->tag           = tag;        msgevt->size          = size;        blkdata->ptr          = msgevt->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_msgevt() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_collevt( CLOG_Buffer_t *buffer,                               const CLOG_CommIDs_t *commIDs,                               CLOG_ThreadLID_t thd,                               int etype, int root, int size ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_CollEvt_t   *collevt;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_COLLEVT );        blkdata               = buffer->curr_block->data;        collevt               = (CLOG_Rec_CollEvt_t *) blkdata->ptr;        collevt->etype        = etype;        collevt->root         = root;        collevt->size         = size;        blkdata->ptr          = collevt->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_collevt() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_commevt( CLOG_Buffer_t *buffer,                               const CLOG_CommIDs_t *commIDs,                               CLOG_ThreadLID_t thd,                               int etype, const CLOG_CommGID_t guid,                               CLOG_CommLID_t icomm, int comm_rank,                               int world_rank ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_CommEvt_t   *commevt;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_COMMEVT );        blkdata               = buffer->curr_block->data;        commevt               = (CLOG_Rec_CommEvt_t *) blkdata->ptr;        commevt->etype        = etype;        commevt->icomm        = icomm;        commevt->rank         = comm_rank;        commevt->wrank        = world_rank;        memcpy( commevt->gcomm, guid, CLOG_UUID_SIZE );        blkdata->ptr          = commevt->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_commevt() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_srcloc( CLOG_Buffer_t *buffer,                              const CLOG_CommIDs_t *commIDs,                              CLOG_ThreadLID_t thd,                              int srcloc, int lineno, const char *filename ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_Srcloc_t    *srcevt;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_SRCLOC );        blkdata               = buffer->curr_block->data;        srcevt                = (CLOG_Rec_Srcloc_t *) blkdata->ptr;        srcevt->srcloc        = srcloc;        srcevt->lineno        = lineno;        strncpy( srcevt->filename, filename, sizeof(CLOG_Str_File_t) );        srcevt->filename[ sizeof(CLOG_Str_File_t) - 1 ] = '\0';        blkdata->ptr          = srcevt->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_srcloc() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}void CLOG_Buffer_save_timeshift( CLOG_Buffer_t *buffer,                                 const CLOG_CommIDs_t *commIDs,                                 CLOG_ThreadLID_t thd,                                 CLOG_Time_t    timeshift ){    CLOG_BlockData_t     *blkdata;    CLOG_Rec_Timeshift_t *tshift;    if ( buffer->status == CLOG_INIT_AND_ON ) {        CLOG_Buffer_save_header( buffer, commIDs, thd, CLOG_REC_TIMESHIFT );        blkdata               = buffer->curr_block->data;        tshift                = (CLOG_Rec_Timeshift_t *) blkdata->ptr;        tshift->timeshift     = timeshift;        blkdata->ptr          = tshift->end;    }    else if ( buffer->status == CLOG_UNINIT ) {        fprintf( stderr, __FILE__":CLOG_Buffer_save_timeshift() - \n"                         "\t""CLOG is used before being initialized.\n" );        fflush( stderr );        CLOG_Util_abort( 1 );    }}

⌨️ 快捷键说明

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