PAPI  5.7.0.0
system_child_overflow.c File Reference
Include dependency graph for system_child_overflow.c:

Go to the source code of this file.

Macros

#define MAX_EVENTS   3
 

Functions

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

Variables

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

Macro Definition Documentation

◆ MAX_EVENTS

#define MAX_EVENTS   3

Definition at line 16 of file system_child_overflow.c.

Function Documentation

◆ do_cycles()

static void do_cycles ( int  program_time)
static

Definition at line 96 of file system_child_overflow.c.

97 {
98  struct timeval start, now;
99  double x, sum;
100 
101  gettimeofday( &start, NULL );
102 
103  for ( ;; ) {
104  sum = 1.0;
105  for ( x = 1.0; x < 250000.0; x += 1.0 )
106  sum += x;
107  if ( sum < 0.0 )
108  printf( "==>> SUM IS NEGATIVE !! <<==\n" );
109 
110  gettimeofday( &now, NULL );
111  if ( now.tv_sec >= start.tv_sec + program_time )
112  break;
113  }
114 }
static struct timeval start
static int program_time
__time_t tv_sec
int gettimeofday(void *ptr1, void *ptr2)
int x
Definition: fileop.c:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 156 of file system_child_overflow.c.

157 {
158  char buf[100];
159 
160  int quiet,retval,result=0;
161 
162  /* Used to be able to set this via command line */
163  num_events=1;
164 
165  /* Set TESTS_QUIET variable */
166  quiet=tests_quiet( argc, argv );
167 
168  do_cycles( 1 );
169 
170  zero_count( );
171 
172  /* Init library */
174  if (retval!=PAPI_VER_CURRENT) {
175  test_fail( name, __LINE__, "PAPI_library_init failed", 1 );
176  }
177 
178  name = argv[0];
179  if (!quiet) printf( "[%d] %s, num_events = %d\n", getpid( ), name, num_events );
180  sprintf( buf, "%d", num_events );
181  my_papi_start( );
182  run( name, 3 );
183 
184  print_here( "system(./child_overflow)" );
185 
186  if ( access( "./child_overflow", X_OK ) == 0 ) {
187  if ( quiet) result=system( "./child_overflow TESTS_QUIET" );
188  else result=system( "./child_overflow" );
189  }
190  else if ( access( "./ctests/child_overflow", X_OK ) == 0 ) {
191  if ( quiet) result=system( "./ctests/child_overflow TESTS_QUIET" );
192  else result=system( "./ctests/child_overflow" );
193  }
194 
195  if (result<0) {
196  test_fail(__FILE__,__LINE__,"system failed\n",1);
197  }
198 
199  if (!quiet) printf("Successfully returned from system\n");
200 
201  // Rely on test_pass from child_overflow
202  // otherwise the run_tests.sh output is ugly
203  //test_pass(__FILE__);
204 
205  return 0;
206 }
static void my_papi_start(void)
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int retval
Definition: zero_fork.c:53
int PAPI_library_init(int version)
Definition: papi.c:500
int quiet
Definition: rapl_overflow.c:18
static void do_cycles(int program_time)
static int num_events
static void zero_count(void)
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
static void print_here(const char *str)
static void run(const char *str, int len)
int system()
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
Definition: do_loops.c:12
static const char * name
Here is the call graph for this function:

◆ my_handler()

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

Definition at line 37 of file system_child_overflow.c.

38 {
39  ( void ) EventSet;
40  ( void ) pc;
41  ( void ) ovec;
42  ( void ) context;
43 
44  count++;
45  total++;
46 }
static int EventSet
static long total
static long count
Here is the caller graph for this function:

◆ my_papi_start()

static void my_papi_start ( void  )
static

Definition at line 117 of file system_child_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  if (!TESTS_QUIET) printf("Trouble adding event\n");
129  test_skip( name, __LINE__, "PAPI_add_event failed", 1 );
130  }
131  }
132 
133  for ( ev = 0; ev < num_events; ev++ ) {
134  if ( PAPI_overflow( EventSet, Event[ev], Threshold[ev], 0, my_handler )
135  != PAPI_OK ) {
136  test_fail( name, __LINE__, "PAPI_overflow failed", 1 );
137  }
138  }
139 
140  if ( PAPI_start( EventSet ) != PAPI_OK )
141  test_fail( name, __LINE__, "PAPI_start failed", 1 );
142 }
#define PAPI_OK
Definition: fpapi.h:105
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
static int Threshold[MAX_EVENTS]
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4788
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:561
static int Event[MAX_EVENTS]
#define PAPI_NULL
Definition: fpapi.h:13
static void my_handler(int EventSet, void *pc, long long ovec, void *context)
static int EventSet
static int num_events
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int TESTS_QUIET
Definition: test_utils.c:18
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int PAPI_start(int EventSet)
Definition: papi.c:2096
static const char * name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_here()

static void print_here ( const char *  str)
static

Definition at line 58 of file system_child_overflow.c.

58  {
59 
60  if (!TESTS_QUIET) printf("[%d] %s, %s\n", getpid(), name, str);
61 }
int TESTS_QUIET
Definition: test_utils.c:18
static const char * name
Here is the caller graph for this function:

◆ print_rate()

static void print_rate ( const char *  str)
static

Definition at line 64 of file system_child_overflow.c.

65 {
66  static int last_count = -1;
67  struct timeval now;
68  double st_secs, last_secs;
69 
70  gettimeofday( &now, NULL );
71  st_secs = ( double ) ( now.tv_sec - start.tv_sec )
72  + ( ( double ) ( now.tv_usec - start.tv_usec ) ) / 1000000.0;
73  last_secs = ( double ) ( now.tv_sec - last.tv_sec )
74  + ( ( double ) ( now.tv_usec - last.tv_usec ) ) / 1000000.0;
75  if ( last_secs <= 0.001 )
76  last_secs = 0.001;
77 
78  if (!TESTS_QUIET) {
79  printf( "[%d] %s, time = %.3f, total = %ld, last = %ld, rate = %.1f/sec\n",
80  getpid( ), str, st_secs, total, count,
81  ( ( double ) count ) / last_secs );
82  }
83 
84  if ( last_count != -1 ) {
85  if ( count < .1 * last_count ) {
86  test_fail( name, __LINE__, "Interrupt rate changed!", 1 );
87  exit( 1 );
88  }
89  }
90  last_count = ( int ) count;
91  count = 0;
92  last = now;
93 }
static struct timeval start
__time_t tv_sec
__suseconds_t tv_usec
int gettimeofday(void *ptr1, void *ptr2)
int TESTS_QUIET
Definition: test_utils.c:18
static long total
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
static struct timeval start last
static long count
void exit()
static const char * name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( const char *  str,
int  len 
)
static

Definition at line 145 of file system_child_overflow.c.

146 {
147  int n;
148 
149  for ( n = 1; n <= len; n++ ) {
150  do_cycles( 1 );
151  print_rate( str );
152  }
153 }
static void print_rate(const char *str)
static void do_cycles(int program_time)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zero_count()

static void zero_count ( void  )
static

Definition at line 49 of file system_child_overflow.c.

50 {
51  gettimeofday( &start, NULL );
52  last = start;
53  count = 0;
54  total = 0;
55 }
static struct timeval start
int gettimeofday(void *ptr1, void *ptr2)
static long total
static struct timeval start last
static long count
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ count

long count
static

Definition at line 34 of file system_child_overflow.c.

◆ Event

int Event[MAX_EVENTS]
static
Initial value:
= {
}
#define PAPI_FAD_INS
Definition: fpapi.h:234
#define PAPI_TOT_CYC
Definition: fpapi.h:195
#define PAPI_FP_INS
Definition: fpapi.h:188

Definition at line 18 of file system_child_overflow.c.

◆ EventSet

int EventSet = PAPI_NULL
static

Definition at line 31 of file system_child_overflow.c.

◆ last

struct timeval start last
static

Definition at line 33 of file system_child_overflow.c.

◆ name

const char* name = "unknown"
static

Definition at line 32 of file system_child_overflow.c.

◆ num_events

int num_events = 1
static

Definition at line 30 of file system_child_overflow.c.

◆ Threshold

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

Definition at line 24 of file system_child_overflow.c.

◆ total

long total
static

Definition at line 34 of file system_child_overflow.c.