PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fork_exec_overflow.c File Reference
Include dependency graph for fork_exec_overflow.c:

Go to the source code of this file.

Macros

#define MAX_EVENTS   3
 
#define HERE(str)   printf("[%d] %s, %s\n", getpid(), name, str);
 

Functions

void my_handler (int EventSet, void *pc, long long ovec, void *context)
 
void zero_count (void)
 
void print_rate (char *str)
 
void do_cycles (int program_time)
 
void my_papi_init (void)
 
void my_papi_start (void)
 
void my_papi_stop (void)
 
void run (char *str, int len)
 
int main (int argc, char **argv)
 

Variables

int Event [MAX_EVENTS]
 
int Threshold [MAX_EVENTS]
 
int num_events = 1
 
int EventSet = PAPI_NULL
 
char * name = "unknown"
 
struct timeval start last
 
long count
 
long total
 

Macro Definition Documentation

#define HERE (   str)    printf("[%d] %s, %s\n", getpid(), name, str);

Definition at line 56 of file fork_exec_overflow.c.

#define MAX_EVENTS   3

Definition at line 15 of file fork_exec_overflow.c.

Function Documentation

void do_cycles ( int  program_time)

Definition at line 89 of file fork_exec_overflow.c.

90 {
91  struct timeval start, now;
92  double x, sum;
93 
94  gettimeofday( &start, NULL );
95 
96  for ( ;; ) {
97  sum = 1.0;
98  for ( x = 1.0; x < 250000.0; x += 1.0 )
99  sum += x;
100  if ( sum < 0.0 )
101  printf( "==>> SUM IS NEGATIVE !! <<==\n" );
102 
103  gettimeofday( &now, NULL );
104  if ( now.tv_sec >= start.tv_sec + program_time )
105  break;
106  }
107 }
start
Definition: iozone.c:22736
#define printf
Definition: papi_test.h:125
int program_time
int x
Definition: fileop.c:78

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 161 of file fork_exec_overflow.c.

162 {
163  char buf[100];
164 
165  if ( argc < 2 || sscanf( argv[1], "%d", &num_events ) < 1 )
166  num_events = 1;
167  if ( num_events < 0 || num_events > MAX_EVENTS )
168  num_events = 1;
169 
170  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
171  do_cycles( 1 );
172  zero_count( );
173  my_papi_init( );
174  name = argv[0];
175  printf( "[%d] %s, num_events = %d\n", getpid( ), name, num_events );
176  sprintf( buf, "%d", num_events );
177  my_papi_start( );
178  run( name, 3 );
179 #if defined(PCHILD)
180  HERE( "stop" );
181  my_papi_stop( );
182  HERE( "end" );
183  test_pass( name, NULL, 0 );
184 #elif defined(PEXEC)
185  HERE( "stop" );
186  my_papi_stop( );
187  HERE( "exec(./child_overflow)" );
188  if ( access( "./child_overflow", X_OK ) == 0 )
189  execl( "./child_overflow", "./child_overflow",
190  ( TESTS_QUIET ? "TESTS_QUIET" : NULL ), NULL );
191  else if ( access( "./ctests/child_overflow", X_OK ) == 0 )
192  execl( "./ctests/child_overflow", "./ctests/child_overflow",
193  ( TESTS_QUIET ? "TESTS_QUIET" : NULL ), NULL );
194  test_fail( name, __LINE__, "exec failed", 1 );
195 #elif defined(SYSTEM)
196  HERE( "system(./child_overflow)" );
197  if ( access( "./child_overflow", X_OK ) == 0 )
198  ( TESTS_QUIET ? system( "./child_overflow TESTS_QUIET" ) :
199  system( "./child_overflow" ) );
200  else if ( access( "./ctests/child_overflow", X_OK ) == 0 )
201  ( TESTS_QUIET ? system( "./ctests/child_overflow TESTS_QUIET" ) :
202  system( "./ctests/child_overflow" ) );
203  test_pass( name, NULL, 0 );
204 #elif defined(SYSTEM2)
205  HERE( "system(./burn)" );
206  if ( access( "./burn", X_OK ) == 0 )
207  ( TESTS_QUIET ? system( "./burn TESTS_QUIET" ) : system( "./burn" ) );
208  else if ( access( "./ctests/burn", X_OK ) == 0 )
209  ( TESTS_QUIET ? system( "./ctests/burn TESTS_QUIET" ) :
210  system( "./ctests/burn" ) );
211  test_pass( name, NULL, 0 );
212 #else
213  HERE( "fork" );
214  {
215  int ret = fork( );
216  if ( ret < 0 )
217  test_fail( name, __LINE__, "fork failed", 1 );
218  if ( ret == 0 ) {
219  /*
220  * Child process.
221  */
222  zero_count( );
223  my_papi_init( );
224  my_papi_start( );
225  run( "child", 5 );
226  HERE( "stop" );
227  my_papi_stop( );
228  sleep( 3 );
229  HERE( "end" );
230  exit( 0 );
231  }
232  run( "main", 14 );
233  my_papi_stop( );
234  {
235  int status;
236  wait( &status );
237  HERE( "end" );
238  if ( WEXITSTATUS( status ) != 0 )
239  test_fail( name, __LINE__, "child failed", 1 );
240  else
241  test_pass( name, NULL, 0 );
242  }
243  }
244 #endif
245  exit( 0 );
246 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
void do_cycles(int program_time)
void my_papi_start(void)
sleep(1)
int num_events
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
long long ret
Definition: iozone.c:1346
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
#define MAX_EVENTS
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
char buf[200]
Definition: iozone.c:19609
void run(char *str, int len)
int wait()
sscanf(mnc->m_child_port,"%d",&mc.m_child_port)
long long status
Definition: iozone.c:1335
#define HERE(str)
char * name
Definition: iozone.c:23648
void zero_count(void)
void my_papi_init(void)
int system()
void exit()
void my_papi_stop(void)

Here is the call graph for this function:

void my_handler ( int  EventSet,
void pc,
long long  ovec,
void context 
)

Definition at line 36 of file fork_exec_overflow.c.

37 {
38  ( void ) EventSet;
39  ( void ) pc;
40  ( void ) ovec;
41  ( void ) context;
42 
43  count++;
44  total++;
45 }
int count
Definition: iozone.c:22422
void
Definition: iozone.c:18627
int EventSet
static int total
Definition: rapl_overflow.c:5

Here is the caller graph for this function:

void my_papi_init ( void  )

Definition at line 110 of file fork_exec_overflow.c.

111 {
113  test_fail( name, __LINE__, "PAPI_library_init failed", 1 );
114 }
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
char * name
Definition: iozone.c:23648

Here is the call graph for this function:

Here is the caller graph for this function:

void my_papi_start ( void  )

Definition at line 117 of file fork_exec_overflow.c.

118 {
119  int ev;
120 
122 
124  test_fail( name, __LINE__, "PAPI_create_eventset failed", 1 );
125 
126  for ( ev = 0; ev < num_events; ev++ ) {
127  if ( PAPI_add_event( EventSet, Event[ev] ) != PAPI_OK )
128  test_fail( name, __LINE__, "PAPI_add_event failed", 1 );
129  }
130 
131  for ( ev = 0; ev < num_events; ev++ ) {
132  if ( PAPI_overflow( EventSet, Event[ev], Threshold[ev], 0, my_handler )
133  != PAPI_OK ) {
134  test_fail( name, __LINE__, "PAPI_overflow failed", 1 );
135  }
136  }
137 
138  if ( PAPI_start( EventSet ) != PAPI_OK )
139  test_fail( name, __LINE__, "PAPI_start failed", 1 );
140 }
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1597
#define PAPI_NULL
Definition: fpapi.h:13
int num_events
void my_handler(int EventSet, void *pc, long long ovec, void *context)
return PAPI_OK
Definition: linux-nvml.c:458
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4655
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1399
int EventSet
char * name
Definition: iozone.c:23648
int Event[MAX_EVENTS]
int Threshold[MAX_EVENTS]
int PAPI_start(int EventSet)
Definition: papi.c:2019

Here is the call graph for this function:

Here is the caller graph for this function:

void my_papi_stop ( void  )

Definition at line 143 of file fork_exec_overflow.c.

144 {
145  if ( PAPI_stop( EventSet, NULL ) != PAPI_OK )
146  test_fail( name, __LINE__, "PAPI_stop failed", 1 );
147 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2225
return PAPI_OK
Definition: linux-nvml.c:458
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int EventSet
char * name
Definition: iozone.c:23648

Here is the call graph for this function:

Here is the caller graph for this function:

void print_rate ( char *  str)

Definition at line 59 of file fork_exec_overflow.c.

60 {
61  static int last_count = -1;
62  struct timeval now;
63  double st_secs, last_secs;
64 
65  gettimeofday( &now, NULL );
66  st_secs = ( double ) ( now.tv_sec - start.tv_sec )
67  + ( ( double ) ( now.tv_usec - start.tv_usec ) ) / 1000000.0;
68  last_secs = ( double ) ( now.tv_sec - last.tv_sec )
69  + ( ( double ) ( now.tv_usec - last.tv_usec ) ) / 1000000.0;
70  if ( last_secs <= 0.001 )
71  last_secs = 0.001;
72 
73  printf( "[%d] %s, time = %.3f, total = %ld, last = %ld, rate = %.1f/sec\n",
74  getpid( ), str, st_secs, total, count,
75  ( ( double ) count ) / last_secs );
76 
77  if ( last_count != -1 ) {
78  if ( count < .1 * last_count ) {
79  test_fail( name, __LINE__, "Interrupt rate changed!", 1 );
80  exit( 1 );
81  }
82  }
83  last_count = ( int ) count;
84  count = 0;
85  last = now;
86 }
start
Definition: iozone.c:22736
int count
Definition: iozone.c:22422
#define printf
Definition: papi_test.h:125
static double
Definition: fileop.c:1281
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
static struct temp_event * last
char * name
Definition: iozone.c:23648
static int total
Definition: rapl_overflow.c:5
int
Definition: iozone.c:18528
void exit()

Here is the call graph for this function:

Here is the caller graph for this function:

void run ( char *  str,
int  len 
)

Definition at line 150 of file fork_exec_overflow.c.

151 {
152  int n;
153 
154  for ( n = 1; n <= len; n++ ) {
155  do_cycles( 1 );
156  print_rate( str );
157  }
158 }
void do_cycles(int program_time)
void print_rate(char *str)
int n
Definition: mendes-alt.c:164

Here is the call graph for this function:

Here is the caller graph for this function:

void zero_count ( void  )

Definition at line 48 of file fork_exec_overflow.c.

49 {
50  gettimeofday( &start, NULL );
51  last = start;
52  count = 0;
53  total = 0;
54 }
start
Definition: iozone.c:22736
int count
Definition: iozone.c:22422
static struct temp_event * last
static int total
Definition: rapl_overflow.c:5

Here is the caller graph for this function:

Variable Documentation

long count

Definition at line 33 of file fork_exec_overflow.c.

int Event[MAX_EVENTS]
Initial value:
= {
}
#define PAPI_TOT_CYC
Definition: fpapi.h:194
#define PAPI_FP_INS
Definition: fpapi.h:187
#define PAPI_FAD_INS
Definition: fpapi.h:233

Definition at line 17 of file fork_exec_overflow.c.

int EventSet = PAPI_NULL

Definition at line 30 of file fork_exec_overflow.c.

struct timeval start last

Definition at line 32 of file fork_exec_overflow.c.

char* name = "unknown"

Definition at line 31 of file fork_exec_overflow.c.

int num_events = 1

Definition at line 29 of file fork_exec_overflow.c.

int Threshold[MAX_EVENTS]
Initial value:
= {
8000000,
4000000,
4000000,
}

Definition at line 23 of file fork_exec_overflow.c.

long total

Definition at line 33 of file fork_exec_overflow.c.