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

📄 d2s_util.c

📁 刚才是说明 现在是安装程序在 LINUX环境下进行编程的MPICH安装文件
💻 C
📖 第 1 页 / 共 3 页
字号:
    /*    checking to see if state has not already been defined     and also to see if the start or end event id or both    are not already defined. DLOG2SLOG requires unique event ids'    to distinguish between DLOG records.  */    if ((findState_strtEvnt(state->endetype) != D2S_ERROR) ||	(findState_endEvnt(state->startetype) != D2S_ERROR))    {	fprintf(stderr, __FILE__":%d: event ids defined for state %s already "	    "exist. Use MPE_Log_get_event_number() to define new event ids.\n",	    __LINE__,state->description); 	return D2S_ERROR;    }    if ((findState_strtEvnt(state->startetype) != D2S_ERROR) &&	  (findState_endEvnt(state->endetype) != D2S_ERROR))    {	return D2S_SUCCESS;    }    if ( addState(state->stateid, state->startetype, state->endetype,	       state->color, state->description) == D2S_ERROR )    {	return D2S_ERROR;    }    intvltype = (unsigned int)(state_id - 1);    ierr = SLOG_RDEF_AddExtraRecDef( slog, intvltype, bebit_0, bebit_1,                                   Nassocs, Nargs );    if ( ierr != SLOG_SUCCESS )    {	fprintf( stderr, __FILE__":%d: SLOG Record Definition initialization"	     " failed. \n", __LINE__);	DLOG_free_resources();	return D2S_ERROR;    }    ierr = SLOG_PROF_AddExtraIntvlInfo( slog, intvltype, bebit_0, bebit_1,                                      CLASS_TYPE,				      state->description, state->color );    if ( ierr != SLOG_SUCCESS )    {	fprintf( stderr, __FILE__":%d: SLOG_PROF_AddExtraIntvlInfo failed - "	     "check SLOG documentation for more information. \n",	     __LINE__);	DLOG_free_resources();	return D2S_ERROR;    }        return D2S_SUCCESS;}       	     /****     writes an SLOG event interval****/int writeSLOGEvent(int state_id, double start_time, double end_time, int procid){  /*    SLOG STUFF:    we are not interested in bebits, cpu_id, thread_id, irec_iaddr    and the rec_type is always a constant, NON_MSG_RECORD, a fixed    interval record as opposed to a variable interval record.  */    SLOG_Irec irec;  /*    finally an slog fixed interval record is created and logged.  */    irec = SLOG_Irec_Create();    if (irec == NULL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_Create returned null - "	    "system might be low on memory.\n",__LINE__);	return D2S_ERROR;    }    if (SLOG_Irec_SetMinRec(	irec,	(SLOG_rectype_t)NON_MSG_RECORD,	(SLOG_intvltype_t)state_id,	(SLOG_bebit_t)1,	(SLOG_bebit_t)1,	(SLOG_starttime_t)start_time,	(SLOG_duration_t)(end_time - start_time),	(SLOG_nodeID_t)procid,	(SLOG_cpuID_t)0,	(SLOG_threadID_t)0,	(SLOG_iaddr_t)0 ) == SLOG_FAIL)    {	SLOG_Irec_Free(irec);	fprintf(stderr, __FILE__":%d: SLOG_Irec_SetMinRec returns failure - "	    "check SLOG documentation for more information.\n",__LINE__);	return D2S_ERROR;    }    if (SLOG_Irec_ToOutputStream( slog, irec ) == SLOG_FAIL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_ToOutputStream returns failure - "	    "check SLOG documentation for more information.\n", __LINE__);	SLOG_Irec_Free(irec);	return D2S_ERROR;    }    SLOG_Irec_Free(irec);    return D2S_SUCCESS;}/****     writes an SLOG interval****/int writeSLOGInterval(double timestamp, int procid, struct list_elemnt one){  /*    SLOG STUFF:    we are not interested in bebits, cpu_id, thread_id, irec_iaddr    and the rec_type is always a constant, NON_MSG_RECORD, a fixed    interval record as opposed to a variable interval record.  */    SLOG_Irec irec;  /*    finally an slog fixed interval record is created and logged.  */    irec = SLOG_Irec_Create();    if (irec == NULL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_Create returned null - "	    "system might be low on memory.\n",__LINE__);	return D2S_ERROR;    }    if (SLOG_Irec_SetMinRec( 	irec, 	(SLOG_rectype_t)NON_MSG_RECORD, 	(SLOG_intvltype_t)one.state_id,	(SLOG_bebit_t)1, 	(SLOG_bebit_t)1, 	(SLOG_starttime_t)one.start_time, 	(SLOG_duration_t)(timestamp - one.start_time),	(SLOG_nodeID_t)procid, 	(SLOG_cpuID_t)0, 	(SLOG_threadID_t)0,	(SLOG_iaddr_t)0 ) == SLOG_FAIL)    {	SLOG_Irec_Free(irec);	fprintf(stderr, __FILE__":%d: SLOG_Irec_SetMinRec returns failure - "	    "check SLOG documentation for more information.\n",__LINE__);	return D2S_ERROR;    }    if (SLOG_Irec_ToOutputStream( slog, irec ) == SLOG_FAIL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_ToOutputStream returns failure - "	    "check SLOG documentation for more information.\n", __LINE__);	SLOG_Irec_Free(irec);	return D2S_ERROR;    }    SLOG_Irec_Free(irec);    return D2S_SUCCESS;}/****     writes an SLOG interval****/int writeSLOGMsgInterval(double timestamp, int procid, int event, struct list_elemnt one){  /*    SLOG STUFF:    we are not interested in bebits, cpu_id, thread_id, irec_iaddr    and the rec_type is always a constant, NON_MSG_RECORD, a fixed    interval record as opposed to a variable interval record.  */    SLOG_Irec irec;    SLOG_intvltype_t irec_intvltype;  /*    finally an slog fixed interval record is created and logged.  */    irec = SLOG_Irec_Create();    if (irec == NULL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_Create returned null - "	    "system might be low on memory.\n", __LINE__);	return D2S_ERROR;    }    if (event == LOG_MESG_RECV)	irec_intvltype = FORWARD_MSG;    else	irec_intvltype = BACKWARD_MSG;        if (SLOG_Irec_SetMinRec(	irec,	(SLOG_rectype_t)MSG_RECORD,	irec_intvltype,	(SLOG_bebit_t)1,	(SLOG_bebit_t)1,	(SLOG_starttime_t)one.start_time,	(SLOG_duration_t)timestamp - one.start_time,	(SLOG_nodeID_t)one.process_id,	(SLOG_cpuID_t)0,	(SLOG_threadID_t)0,	(SLOG_iaddr_t)0,	(SLOG_nodeID_t)one.data,	(SLOG_cpuID_t)0,	(SLOG_threadID_t)0 ) == SLOG_FAIL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_SetMinRec returns failure - "	    "check SLOG documentation for more information.\n",__LINE__);	SLOG_Irec_Free(irec);	return D2S_ERROR;    }    if (SLOG_Irec_ToOutputStream( slog, irec ) == SLOG_FAIL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_ToOutputStream returns failure - "	    "check SLOG documentation for more information.\n",	     __LINE__);	SLOG_Irec_Free(irec);	return D2S_ERROR;    }    SLOG_Irec_Free(irec);    return D2S_SUCCESS;}/****     add incoming event to list of start events. aka "list_first/list_last"     list. ****/int handleStartEvent(int stat_id, double start_time, int proc_id, int data){  /*    SLOG STUFF:    we are not interested in bebits, cpu_id, thread_id, irec_iaddr    and the rec_type is always a constant, NON_MSG_RECORD, a fixed    interval record as opposed to a variable interval record.  */    if (addToList( stat_id, data, proc_id, start_time) == D2S_ERROR)	return D2S_ERROR;    if (SLOG_Irec_ReserveSpace(		slog,		(SLOG_rectype_t)NON_MSG_RECORD,		(SLOG_intvltype_t)stat_id,		(SLOG_bebit_t)1, 		(SLOG_bebit_t)1,		(SLOG_starttime_t)start_time ) == SLOG_FAIL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_ReserveSpace returns FAILURE"	    " - system might have run out of memory. Check SLOG "	    "documentation for more information.\n", __LINE__);	return D2S_ERROR;    }    return D2S_SUCCESS;}int handleStartMsgEvent(int stat_id, double start_time, int proc_id, int data, int etype){  /*    SLOG STUFF:    we are not interested in bebits, cpu_id, thread_id, irec_iaddr    and the rec_type is always a constant, NON_MSG_RECORD, a fixed    interval record as opposed to a variable interval record.  */    int error = SLOG_SUCCESS;    if (addToMsgList( stat_id, data, proc_id, etype, start_time) == D2S_ERROR)	return D2S_ERROR;        if (etype == LOG_MESG_SEND)    {	error = SLOG_Irec_ReserveSpace(	    slog,	    (SLOG_rectype_t)MSG_RECORD,	    (SLOG_intvltype_t)FORWARD_MSG,	    (SLOG_bebit_t)1,	    (SLOG_bebit_t)1,	    (SLOG_starttime_t)start_time );    }    else    {	error = SLOG_Irec_ReserveSpace(	    slog,	    (SLOG_rectype_t)MSG_RECORD,	    (SLOG_intvltype_t)BACKWARD_MSG,	    (SLOG_bebit_t)1,	    (SLOG_bebit_t)1,	    (SLOG_starttime_t)start_time );    }    if (error == SLOG_FAIL)    {	fprintf(stderr, __FILE__":%d: SLOG_Irec_ReserveSpace returns FAILURE"	    " - system might have run out of memory. Check SLOG "	    "documentation for more information.\n", __LINE__);	return D2S_ERROR;    }    return D2S_SUCCESS;}/****     initialzes the thread table.****/int init_SLOG_TTAB(){    int ierr, ii;    SLOG_nodeID_t      node_id;    SLOG_threadID_t    thread_id    = 0;    SLOG_OSprocessID_t OSprocess_id = 0;    SLOG_OSthreadID_t  OSthread_id  = 0;    SLOG_appID_t       app_id;    if ( SLOG_TTAB_Open( slog ) != SLOG_SUCCESS )    {	fprintf(stderr, __FILE__":%d: SLOG_TTAB_Open() fails! \n",__LINE__ );	DLOG_free_resources();	return D2S_ERROR;    }    for( ii=0 ; ii <= proc_num ; ii++)    {	node_id = app_id = ii;	ierr = SLOG_TTAB_AddThreadInfo( slog, node_id, thread_id,				    OSprocess_id, OSthread_id, app_id);	if ( ierr != SLOG_SUCCESS )	{	    fprintf( stderr,__FILE__":%d: SLOG Thread Table initialization "	       "failed.\n",__LINE__);	    DLOG_free_resources();	    return D2S_ERROR;	}    }    if ((ierr = SLOG_TTAB_Close( slog )) != SLOG_SUCCESS )    {	fprintf(stderr, __FILE__":%d: SLOG_TTAB_Close() fails! \n", __LINE__ );	DLOG_free_resources();	return D2S_ERROR;    }        return D2S_SUCCESS;}/****     initializes the profiling as well as the record definition tables.     for details look at the slog api documentation.     dlog counterparts:     state definitions  =  record definition + profiling****/int init_SLOG_PROF_RECDEF(){    struct state_info *pState;    int ierr;    struct state_info *one  = NULL,                      *two  = NULL;    if ( SLOG_PROF_Open( slog ) != SLOG_SUCCESS )    {	fprintf(stderr, __FILE__":%d: SLOG_PROF_Open() fails! \n", __LINE__);	DLOG_free_resources();	return D2S_ERROR;    }    /* initialization of the interval table */    for( one = first ; one != NULL ; one = two )    {	two = one->next;	if ((one->start_event_num != LOG_MESG_SEND) || (one->end_event_num != LOG_MESG_RECV))	{	    ierr = SLOG_PROF_AddIntvlInfo(			slog,			(SLOG_intvltype_t)one->state_id,			(SLOG_bebit_t)1,			(SLOG_bebit_t)1,			CLASS_TYPE,			one->description,			one->color,			(SLOG_N_args_t)0 );	}	else	{	    ierr = SLOG_PROF_AddIntvlInfo(			slog,			FORWARD_MSG,			(SLOG_bebit_t)1,			(SLOG_bebit_t)1,			FORWARD_MSG_CLASSTYPE,			FORWARD_MSG_LABEL,			FORWARD_MSG_COLOR,			(SLOG_N_args_t)0 );	    if ( ierr != SLOG_SUCCESS )	    {		fprintf( stderr,__FILE__":%d: SLOG Profile initialization failed.\n",		    __LINE__);		DLOG_free_resources();		return D2S_ERROR;	    }	    ierr = SLOG_PROF_AddIntvlInfo(			slog,			BACKWARD_MSG,			(SLOG_bebit_t)1,			(SLOG_bebit_t)1,			BACKWARD_MSG_CLASSTYPE,			BACKWARD_MSG_LABEL,			BACKWARD_MSG_COLOR,			(SLOG_N_args_t)0 );	}	if ( ierr != SLOG_SUCCESS )	{	    fprintf( stderr,__FILE__":%d: SLOG Profile initialization failed. \n",		__LINE__);	    DLOG_free_resources();	    return D2S_ERROR;	}    }    pState = pEventStateList;    while (pState)    {	if (SLOG_PROF_AddIntvlInfo(	    slog,	    (SLOG_intvltype_t)pState->state_id,	    (SLOG_bebit_t)1,	    (SLOG_bebit_t)1,	    CLASS_TYPE,	    pState->description,	    pState->color,	    (SLOG_N_args_t)0 ) != SLOG_SUCCESS)	{	    fprintf( stderr,__FILE__":%d: SLOG Profile initialization failed. \n", __LINE__);	    DLOG_free_resources();	    return D2S_ERROR;	}	pState = pState->next;    }    if ( SLOG_PROF_SetExtraNumOfIntvlInfos( slog, EXTRA_STATES ) != SLOG_SUCCESS )    {	fprintf(stderr, __FILE__":%d: SLOG_PROF_SetExtraNumOfIntvlInfos() fails! \n", __LINE__);	DLOG_free_resources();	return D2S_ERROR;    }    if ( SLOG_RDEF_Open( slog ) != SLOG_SUCCESS )    {	fprintf(stderr, __FILE__":%d: SLOG_RDEF_Open() fails! \n", __LINE__);	DLOG_free_resources();	return D2S_ERROR;    }    for( one = first ; one != NULL ; one = two )    {	two = one->next;	if ((one->start_event_num != LOG_MESG_SEND) || (one->end_event_num != LOG_MESG_RECV))

⌨️ 快捷键说明

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