📄 ts_increqendtime_resfneqno.c
字号:
/* Finalize the Record Definition Table in SLOG file */ ierr = SLOG_RDEF_Close( slog ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_RDEF_Close() fails!\n" ); fflush( errfile ); exit( 1 ); } #endif printf( "Start appending records :\n" ); events = ( tagged_irec * ) malloc( 2*MaxIrec * sizeof( tagged_irec ) );/* printf( "\t""Append variable records:\n" ); for ( ii = 0; ii <= VarIrec_MaxAssocs; ii++ ) { irec_rectype = ( SLOG_rectype_t ) 0; irec_bebits[0] = ( SLOG_bebit_t ) 1; irec_bebits[1] = ( SLOG_bebit_t ) 1; irec_starttime = ( SLOG_starttime_t ) ii*0.1; irec_duration = ( SLOG_duration_t ) 0.1; irec_node_id = ( SLOG_nodeID_t ) ii % MaxNumOfProc; irec_cpu_id = ( SLOG_cpuID_t ) 1; irec_thread_id = ( SLOG_threadID_t ) ii / MaxNumOfProc; irec_instr_addr = ( SLOG_iaddr_t ) 8888; irec_Nassocs = ii % ( MaxIdx4VarIrec + 1 ); irec_Nargs = 2; irec_intvltype = GetIntvlType( VarIrec_MinIdx, irec_Nassocs, irec_Nargs ); irec = SLOG_Irec_Create(); SLOG_Irec_SetMinRec( irec, irec_rectype, irec_intvltype, irec_bebits[0], irec_bebits[1], irec_starttime, irec_duration, irec_node_id, irec_cpu_id, irec_thread_id, irec_instr_addr ); if ( irec_Nassocs > 0 ) SLOG_Irec_SetAssocs( irec, slog, irec_Nassocs, irec_assocs ); for ( jj = 0; jj < irec_Nvtrargs; jj++ ) { if ( irec_Nargs > 0 ) SLOG_Irec_SetArgs( irec, slog, irec_Nargs, irec_args ); irec_Nargs++; } printf( "MAIN: %d, irec = ( " fmt_itype_t", "fmt_stime_t", "fmt_dura_t", " fmt_Nassocs_t" )\n", ii, irec_intvltype, irec_starttime, irec_duration, irec_Nassocs ); SLOG_Irec_Print( irec, stdout ); fprintf( stdout, "\n" ); SLOG_Irec_ToOutputStream( slog, irec ); SLOG_Irec_Free( irec ); } irec_endtime = irec_starttime + irec_duration;*/ printf( "\t""Creation of fixed records:\n" ); for ( ii = 0; ii < MaxIrec; ii++ ) { /* Set up the default value of the irec's components */ irec_rectype = ( SLOG_rectype_t ) 100; irec_bebits[0] = ( SLOG_bebit_t ) 1; irec_bebits[1] = ( SLOG_bebit_t ) 1; irec_endtime = ( SLOG_time ) ( ii + 1 ) * 0.1; irec_duration = ( SLOG_duration_t ) 0.08; irec_starttime = ( SLOG_starttime_t ) ( irec_endtime - irec_duration ); irec_node_id = ( SLOG_nodeID_t ) ii % MaxNumOfProc; irec_cpu_id = ( SLOG_cpuID_t ) 1; irec_thread_id = ( SLOG_threadID_t ) ii / MaxNumOfProc; irec_instr_addr = ( SLOG_iaddr_t ) 8888; /* Make up some starttime and endtime stamps of interval records to check various features of the SLOG WRITE API */ if ( ii == 3 ) { irec_duration = ( SLOG_duration_t ) 0.15; irec_starttime = irec_endtime - irec_duration; } if ( ii == 7 ) { irec_duration = ( SLOG_duration_t ) 0.55; irec_starttime = irec_endtime - irec_duration; } if ( ii == 12 ) { irec_duration = ( SLOG_duration_t ) 0.75; irec_starttime = irec_endtime - irec_duration; } if ( ii == 17 ) { irec_duration = ( SLOG_duration_t ) 1.55; irec_starttime = irec_endtime - irec_duration; } /* - Check the support of variable length Association arguments is OK. - Check if the support of variable length MPI arguments is OK. Modify the irec_intvltype to reflect the number of association arguments attached in the interval records. */ switch ( 0 ) { case 0 : irec_Nassocs = 0; irec_Nargs = 0; break; case 1 : irec_Nassocs = 0; irec_Nargs = ii % ( MaxIdx4VarIrec + 1 ); break; case 2 : irec_Nassocs = ii % ( MaxIdx4VarIrec + 1 ); irec_Nargs = 0; break; case 3 : irec_Nassocs = ii % ( MaxIdx4VarIrec + 1 ); irec_Nargs = ii / ( MaxIdx4VarIrec + 1 ); break; default : printf( "Wrong int in the switch statements\n" ); } /* Set the default idx_type */ idx_type = ii % MaxIdxType; for ( jj = 0; jj < Nentries_extra_recdefs; jj++ ) { /* Make up some extra idx_type, hence extra irec_intvltype */ if ( ii == (jj+1)*3 ) { idx_type = MaxIdxType + jj; 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 ( ii == (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_node_id, irec_cpu_id, irec_thread_id, 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" ); /* 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 ); } /* for ( ii = 0; ii < MaxIrec; ii++ ) */ 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 ) { /* Does Nothing */ } else { SLOG_Irec_ToOutputStream( slog, irec ); fprintf( stdout, "E " ); SLOG_Irec_Print( irec, stdout ); fprintf( stdout, "\n" ); } } /* 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, " %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 + -