📄 ts_increqendtime_resfneqyes.c
字号:
case 3 : irec_Nassocs = idx2state % ( MaxIdx4VarIrec + 1 ); irec_Nargs = idx2state / ( MaxIdx4VarIrec + 1 ); break; default : printf( "Wrong int in the switch statements\n" ); } /* Set the default idx_type */ idx_type = idx2state % FixIrecIdxRange + FixIrec_MinIdx; for ( jj = 0; jj < Nentries_extra_recdefs; jj++ ) { /* Make up some extra idx_type, hence extra irec_intvltype */ if ( idx2state == (jj+1)*3 ) { idx_type = FixIrecIdxRange + jj + 1; break; } } /* Formulas used to match the intvltype in Record Definition Table */ irec_intvltype = GetIntvlType( idx_type, irec_Nassocs, irec_Nargs ); /* Create an record definition which is NOT in Record Definition Table at the moment. Create an interval descriptor which is NOT in Display Profile Table at the moment. */ for ( jj = 0; jj < Nentries_extra_recdefs; jj++ ) { /* Only one of the jj's is true in the if statement */ if ( idx2state == (jj+1)*3 ) { count++; SLOG_RecDef_Assign( &(recdefs_reserved[jj]), irec_intvltype, irec_bebits[0], irec_bebits[1], irec_Nassocs, irec_Nargs ); str_add_num_label( label, fix_label, count*10 ); /* str_add_num_label( color, fix_color, count*10 ); */ strcpy( color, color_strs[ count ] ); SLOG_IntvlInfo_Assign( &(intvlinfos_reserved[jj]), irec_intvltype, irec_bebits[0], irec_bebits[1], classtype, label, color ); break; } } /* Creation of an interval record */ irec = SLOG_Irec_Create(); SLOG_Irec_SetMinRec( irec, irec_rectype, irec_intvltype, irec_bebits[0], irec_bebits[1], irec_starttime, irec_duration, irec_orig_node, irec_orig_cpu, irec_orig_thread, irec_instr_addr ); if ( irec_Nassocs > 0 ) SLOG_Irec_SetAssocs( irec, slog, irec_Nassocs, irec_assocs ); if ( irec_Nargs > 0 ) SLOG_Irec_SetArgs( irec, slog, irec_Nargs, irec_args ); /* Print the irec to the stdout */ SLOG_Irec_Print( irec, stdout ); fprintf( stdout, "\n" ); idx2state ++; /* Make up an array of tagged interval records */ events[ 2*ii ].IsStartEvent = SLOG_TRUE; events[ 2*ii ].irec = irec; events[ 2*ii+1 ].IsStartEvent = SLOG_FALSE; events[ 2*ii+1 ].irec = SLOG_Irec_Copy( irec ); ii++; /* Insert some Message( Arrow ) Record if it is necessary */ if ( idx2state % FixIrec_MaxIdx == 0 && idx2state != 0 && ii < MaxIrec ) { prev_irec = events[ 2*(ii-2) ].irec; irec_rectype = SLOG_RecType4OffDiagRec; if ( IsForwardArrow ) { irec_intvltype = SLOG_IntvlType4ForwardArrow; IsForwardArrow = 0; } else { irec_intvltype = SLOG_IntvlType4BackwardArrow; IsForwardArrow = 1; } irec_bebits[0] = SLOG_Bebit4OffDiagRec; irec_bebits[1] = SLOG_Bebit4OffDiagRec; irec_endtime = irec->starttime + irec->duration; irec_starttime = prev_irec->starttime; irec_duration = irec_endtime - irec_starttime; irec_orig_node = (prev_irec->origID).node; irec_orig_cpu = (prev_irec->origID).cpu; irec_orig_thread = (prev_irec->origID).thread; irec_dest_node = (irec->origID).node; irec_dest_cpu = (irec->origID).cpu; irec_dest_thread = (irec->origID).thread; irec_instr_addr = prev_irec->instr_addr; irec = SLOG_Irec_Create(); SLOG_Irec_SetMinRec( irec, irec_rectype, irec_intvltype, irec_bebits[0], irec_bebits[1], irec_starttime, irec_duration, irec_orig_node, irec_orig_cpu, irec_orig_thread, irec_instr_addr, irec_dest_node, irec_dest_cpu, irec_dest_thread ); /* Make up an array of tagged interval records */ events[ 2*ii ].IsStartEvent = SLOG_TRUE; events[ 2*ii ].irec = irec; events[ 2*ii+1 ].IsStartEvent = SLOG_FALSE; events[ 2*ii+1 ].irec = SLOG_Irec_Copy( irec ); ii++; } } /* while ( ii < MaxIrec ) */ printf( "Finish the creation of records :\n" ); /* Sort the tagged irec array, i.e., events, so we can simulate an event based calling sequence of SLOG_Irec_ReserveSpace() & SLOG_Irec_ToOutputStream(). The SLOG API does NOT demand use of qsort() to use the API. */ qsort( events, 2*MaxIrec, sizeof( tagged_irec ), &event_cmp_fn ); printf( "\t""Append fixed records:\n" ); /* The 1st character in stdout indicates if the call corresponds a Start event or an End event of the interval record. */ for ( ii = 0; ii < 2*MaxIrec; ii++ ) { irec = events[ii].irec; /* Check if new Record Definition needs to be added to the Record Definition Table before either SLOG_Irec_ReserveSpace() or SLOG_Irec_ToOutputStream() is called. */ for ( jj = 0; jj < Nentries_extra_recdefs; jj++ ) { recdef = &(recdefs_reserved[ jj ]); intvlinfo = &(intvlinfos_reserved[ jj ]); if ( irec->intvltype == recdef->intvltype && irec->bebits[0] == recdef->bebits[0] && irec->bebits[1] == recdef->bebits[1] && events[ii].IsStartEvent == SLOG_TRUE ) { ierr = SLOG_RDEF_AddExtraRecDef( slog, recdef->intvltype, recdef->bebits[0], recdef->bebits[1], recdef->Nassocs, recdef->Nargs ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_RDEF_AddExtraRecDef() fails!\n" ); fflush( errfile ); exit( 1 ); } fprintf( stdout, "SLOG_RDEF_AddExtraRecDef(" ); SLOG_RecDef_Print( recdef, stdout ); fprintf( stdout, ") before %d-th event\n", ii ); ierr = SLOG_PROF_AddExtraIntvlInfo( slog, intvlinfo->intvltype, intvlinfo->bebits[0], intvlinfo->bebits[1], intvlinfo->classtype, intvlinfo->label, intvlinfo->color ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_PROF_AddExtraIntvlInfo() fails!\n" ); fflush( errfile ); exit( 1 ); } fprintf( stdout, "SLOG_PROF_AddExtraIntvlInfo(" ); SLOG_IntvlInfo_Print( intvlinfo, stdout ); fprintf( stdout, ") before %d-th event\n", ii ); } } /* Check if the tagged Irec corresponds to a Start Event or End Event. The following comments are based on the irec are arranged in increasing endtime order. For a Start Event tagged Irec, SLOG_Irec_ReserveSpace() should be called if SLOG_SetFrameReservedSpace() has NOT been called. For a End Event tagged Irec, SLOG_Irec_ToOutputStream() should be called. */ if ( events[ii].IsStartEvent == SLOG_TRUE ) { SLOG_Irec_ReserveSpace( slog, irec->rectype, irec->intvltype, irec->bebits[0], irec->bebits[1], irec->starttime ); fprintf( stdout, "S " ); SLOG_Irec_Print( irec, stdout ); fprintf( stdout, "\n" ); fflush( stdout ); } else { SLOG_Irec_ToOutputStream( slog, irec ); fprintf( stdout, "E " ); SLOG_Irec_Print( irec, stdout ); fprintf( stdout, "\n" ); fflush( stdout ); } } /* for ( ii = 0; ii < 2*MaxIrec; ii++ ) */ printf( "Finish appending records :\n" ); for ( ii = 0; ii < 2*MaxIrec; ii++ ) SLOG_Irec_Free( events[ii].irec ); free( events ); SLOG_CloseOutputStream( slog ); return 0;}/* Wrapper for event_cmp() */int event_cmp_fn( const void *event1, const void *event2 ){ return( event_cmp( (tagged_irec *) event1, (tagged_irec *) event2 ) );}/* Compare functions needed in qsort() to sort the starttime or endtime of all interval records ( depend on if it is a start or end event ) in accending time order, so SLOG_Irec_ReserveSpace() and SLOG_Irec_ToOutputStream() can be called at the right order to Simulate a event based input order for SLOG API.*/int event_cmp( const tagged_irec *event1, const tagged_irec *event2 ){ SLOG_time time1, time2; if ( event1->IsStartEvent == SLOG_TRUE ) time1 = event1->irec->starttime; else time1 = event1->irec->starttime + event1->irec->duration; if ( event2->IsStartEvent == SLOG_TRUE ) time2 = event2->irec->starttime; else time2 = event2->irec->starttime + event2->irec->duration; if ( time1 < time2 ) return -1; else if ( time1 == time2 ) return 0; else return 1;}SLOG_intvltype_t GetIntvlType( const SLOG_uint32 IdxType, const SLOG_uint32 IdxAssocs, const SLOG_uint32 IdxArgs ){ const unsigned int UnitType = 100; const unsigned int UnitAssocs = 10; const unsigned int UnitArgs = 1; /* May want to check if UnitXXXX is in the correct range */ return ( IdxType * UnitType + IdxAssocs * UnitAssocs + IdxArgs * UnitArgs );}int str_add_num_label( char *str, const char *fix_str, int num ){ char num_str[ 10 ]; sprintf( num_str, "\t %u", num ); strcpy( str, fix_str ); if (strcat( str, num_str )) return 1; else return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -