📄 ts_increqstarttime.c
字号:
#include <stdio.h>#ifdef HAVE_SLOGCONF_H#include "slog_config.h"#endif#ifdef HAVE_SLOG_WINCONFIG_H#include "slog_winconfig.h"#endif#if defined( STDC_HEADERS ) || defined( HAVE_STDLIB_H )#include <stdlib.h>#endif#if defined( STDC_HEADERS ) || defined( HAVE_STRING_H )#include <string.h>#endif#if defined( STDC_HEADERS ) || defined( HAVE_CTYPE_H )#include <ctype.h>#endif#include "slog.h"#define MaxNdirFrames 64#define FrameByteSize 256#define SLOG_PREVIEWNAME "SLOG_Preview.txt"#define SLOG_PROFILENAME "SLOG_Profile.txt" /* Not used */#define USER_MARKER #define MaxIdx4VarIrec 4#define MaxNumOfProc 4#if 0 #define MaxAssocs 10#define MaxArgs 10#else#define MaxAssocs 0#define MaxArgs 0#endiftypedef struct { int IsStartEvent; SLOG_Irec irec;} tagged_irec;int event_cmp_fn( const void *event1, const void *event2 );int event_cmp( const tagged_irec *event1, const tagged_irec *event2 );SLOG_intvltype_t GetIntvlType( const SLOG_uint32 IdxType, const SLOG_uint32 IdxAssocs, const SLOG_uint32 IdxArgs );int str_add_num_label( char *str, const char *fix_str, int num );int main( int argc, char **argv ){ const char slog_name[] = "slogfile.data"; const SLOG_intvltype_t VarIrec_MinIdx = 0; const SLOG_intvltype_t FixIrec_MinIdx = 1; const SLOG_intvltype_t FixIrec_MaxIdx = 5; const SLOG_intvltype_t MaxIdxType = FixIrec_MaxIdx - FixIrec_MinIdx + 1; /* const SLOG_intvltype_t VarIrec_MaxAssocs = 2 * MaxIdx4VarIrec; */ SLOG slog; SLOG_Irec irec; int MaxIrec = 7; int ii, jj, count, idx_type, ierr; /* Variables for SLOG Thread Table */ SLOG_nodeID_t node_id; SLOG_threadID_t thread_id; SLOG_OSprocessID_t OSprocess_id; SLOG_OSthreadID_t OSthread_id; SLOG_appID_t app_id; /* Variables for SLOG Display Profile */ /* const char fix_classtype[10] = "state"; */ const char fix_label[10] = "label"; /* const char fix_color[10] = "color"; */ char classtype[10] = "state"; char label[10] = "label"; char color[10] = "color"; char *color_strs[10] = { "red", "green", "blue", "yellow", "orange", "gold", "RoyalBlue", "navy", "pink", "grey" }; /* Variables for SLOG Record Definition Table */ SLOG_intvltype_t intvltype; SLOG_bebit_t bebit_0 = 1; SLOG_bebit_t bebit_1 = 1; SLOG_N_assocs_t Nassocs; SLOG_N_args_t Nargs; /* Variables for SLOG Interval Record */ SLOG_rectype_t irec_rectype; SLOG_intvltype_t irec_intvltype; SLOG_starttime_t irec_starttime; SLOG_duration_t irec_duration; SLOG_time irec_endtime; SLOG_bebit_t irec_bebits[2]; SLOG_nodeID_t irec_node_id; SLOG_cpuID_t irec_cpu_id; SLOG_threadID_t irec_thread_id; SLOG_iaddr_t irec_instr_addr; SLOG_N_assocs_t irec_Nassocs; SLOG_assoc_t irec_assocs[ 100 ]; SLOG_N_args_t irec_Nargs; SLOG_arg_t irec_args[ 100 ]; /* SLOG_uint32 irec_Nvtrargs = 2; */ /* Generate an array of events from a set of interval records. */ tagged_irec *events; SLOG_uint32 Nentries_extra_recdefs; SLOG_recdef_t *recdefs_reserved; SLOG_recdef_t *recdef; SLOG_intvlinfo_t *intvlinfos_reserved; SLOG_intvlinfo_t *intvlinfo; /* Change the Number of Interval Records created in slogfile based on command line argument */ if ( argc > 1 ) { printf( "argv[1] = _%s_\n", argv[1] ); if ( isdigit( (int) argv[1][0] ) ) MaxIrec = atoi( argv[1] ); } /* MaxIrec = 15; */ /* Initialization */ for ( jj = 0; jj < MaxAssocs; jj++ ) irec_assocs[ jj ] = jj+1; for ( jj = 0; jj < MaxArgs; jj++ ) irec_args[ jj ] = jj+1; irec_starttime = 0.0; irec_duration = 0.0; /* Get a handle to the SLOG_STREAM data structure */ slog = SLOG_OpenOutputStream( slog_name ); /* Tell the API the properties of the slog file by using SLOG_SetXXXX() */ /* Set the maimum number of frames per directory in slog file */ SLOG_SetMaxNumOfFramesPerDir( slog, MaxNdirFrames ); /* Set the byte size per frame */ SLOG_SetFrameByteSize( slog, FrameByteSize ); /* Set the reserved space in each frame */ /* SLOG_SetFrameReservedSpace( slog, 3 * SLOG_typesz[ min_IntvlRec ] ); */ /* Set the flag for the time order arrangement of the interval record */ SLOG_SetIncreasingStarttimeOrder( slog ); /* Set the SLOG Preview to be read from a given file, filename, and then init SLOG's Preview section */ /* SLOG_SetPreviewName( slog, SLOG_PREVIEWNAME ); */ SLOG_SetPreviewName( slog, "/dev/null" );#if defined( USER_MARKER ) Nentries_extra_recdefs = 2; recdefs_reserved = ( SLOG_recdef_t * ) malloc( Nentries_extra_recdefs * sizeof ( SLOG_recdef_t ) ); intvlinfos_reserved = ( SLOG_intvlinfo_t * ) malloc( Nentries_extra_recdefs * sizeof ( SLOG_intvlinfo_t ) );#else Nentries_extra_recdefs = 0; recdefs_reserved = NULL; intvlinfos_reserved = NULL;#endif /* Initialize the SLOG Thread Table */ if ( SLOG_TTAB_Open( slog ) != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - SLOG_TTAB_Open() fails!\n" ); fflush( errfile ); exit( 1 ); } /* Add the entries of SLOG Thread Table */ for ( ii = 0; ii < MaxIrec; ii++ ) { node_id = ii % MaxNumOfProc; thread_id = ii / MaxNumOfProc; OSprocess_id = ii % ( MaxNumOfProc / 2 ); OSthread_id = ii % ( MaxNumOfProc * 2 ); app_id = node_id; ierr = SLOG_TTAB_AddThreadInfo( slog, node_id, thread_id, OSprocess_id, OSthread_id, app_id ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__"Main() - " "SLOG_TTAB_AddTheadInfo() fails!\n" ); fflush( errfile ); /* exit( 1 ); */ } } /* Finalize the Record Definition Table in SLOG file */ ierr = SLOG_TTAB_Close( slog ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__"Main() - " "SLOG_TTAB_Close() fails!\n" ); fflush( errfile ); exit( 1 ); } /* Set the SLOG Display Profile with a given filename and init SLOG */ /* SLOG_SetProfileName( slog, SLOG_PROFILENAME ); */ /* Initialize the SLOG Display Profile Table */ if ( SLOG_PROF_Open( slog ) != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - SLOG_PROF_Open() fails\n " ); fflush( errfile ); exit( 1 ); } count = -1; /* Create the Indexes for Variable Interval's display profile */ Nargs = 0; /* Initialization, does NOT mean anything */ for ( Nassocs = 0; Nassocs <= MaxAssocs; Nassocs++ ) { count++; intvltype = GetIntvlType( VarIrec_MinIdx, Nassocs, Nargs ); str_add_num_label( label, fix_label, count ); /* str_add_num_label( color, fix_color, count ); */ strcpy( color, color_strs[ count ] ); ierr = SLOG_PROF_AddIntvlInfo( slog, intvltype, bebit_0, bebit_1, classtype, label, color, 0 ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_PROF_AddIntvlInfo() fails!\n" ); fflush( errfile ); exit( 1 ); } } /* Create the Indexes for Fixed Interval Record's display profile */ for ( idx_type = FixIrec_MinIdx; idx_type < FixIrec_MaxIdx; idx_type++ ) { for ( Nassocs = 0; Nassocs <= MaxAssocs; Nassocs++ ) { for ( Nargs = 0; Nargs <= MaxArgs; Nargs++ ) { count++; intvltype = GetIntvlType( idx_type, Nassocs, Nargs ); str_add_num_label( label, fix_label, count ); /* str_add_num_label( color, fix_color, count ); */ strcpy( color, color_strs[ count ] ); ierr = SLOG_PROF_AddIntvlInfo( slog, intvltype, bebit_0, bebit_1, classtype, label, color, 0 ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_PROF_AddIntvlInfo() fails!\n" ); fflush( errfile ); exit( 1 ); } } } }#if defined( USER_MARKER ) ierr = SLOG_PROF_SetExtraNumOfIntvlInfos( slog, Nentries_extra_recdefs ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_PROF_SetExtraNumOfIntvlInfos(%d) fails!\n", Nentries_extra_recdefs ); fflush( errfile ); exit( 1 ); }#else /* Finalize the Display Profile Table in SLOG file */ ierr = SLOG_PROF_Close( slog ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_PROF_Close() fails!\n" ); fflush( errfile ); exit( 1 ); }#endif /* Initialize the SLOG Record Definition Table */ if ( SLOG_RDEF_Open( slog ) != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - SLOG_RDEF_Open() fails\n " ); fflush( errfile ); exit( 1 ); } /* Create the Indexes for Variable Interval Record Definition */ Nargs = 0; /* Initialization, does NOT mean anything */ for ( Nassocs = 0; Nassocs <= MaxAssocs; Nassocs++ ) { intvltype = GetIntvlType( VarIrec_MinIdx, Nassocs, Nargs ); ierr = SLOG_RDEF_AddRecDef( slog, intvltype, bebit_0, bebit_1, Nassocs, Nargs ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_RDEF_AddRecDef() fails!\n" ); fflush( errfile ); exit( 1 ); } } /* Create the Indexes for Fixed Interval Record Definition */ for ( idx_type = FixIrec_MinIdx; idx_type < FixIrec_MaxIdx; idx_type++ ) { for ( Nassocs = 0; Nassocs <= MaxAssocs; Nassocs++ ) { for ( Nargs = 0; Nargs <= MaxArgs; Nargs++ ) { intvltype = GetIntvlType( idx_type, Nassocs, Nargs ); ierr = SLOG_RDEF_AddRecDef( slog, intvltype, bebit_0, bebit_1, Nassocs, Nargs ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_RDEF_AddRecDef() fails!\n" ); fflush( errfile ); exit( 1 ); } } } } #if defined( USER_MARKER ) ierr = SLOG_RDEF_SetExtraNumOfRecDefs( slog, Nentries_extra_recdefs ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - " "SLOG_RDEF_SetExtraNumOfRecDefs(%d) fails!\n", Nentries_extra_recdefs ); fflush( errfile ); exit( 1 ); } #else /* Finalize the Record Definition Table in SLOG file */ ierr = SLOG_RDEF_Close( slog ); if ( ierr != SLOG_SUCCESS ) { fprintf( errfile, __FILE__":Main() - "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -