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

Go to the source code of this file.

Functions

void process_init (void)
 
void process_fini (void)
 
int main (int argc, char **argv)
 

Variables

int EventSet1 = PAPI_NULL
 
int PAPI_event
 
int mask1
 
int num_events1 = 2
 
long long elapsed_us
 
long long elapsed_cyc
 
long long ** values
 
char event_name [PAPI_MAX_STR_LEN]
 
int retval
 
int num_tests = 1
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 108 of file zero_fork.c.

109 {
110  int flops1;
111  int retval;
112 
113  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
114 # if (defined(__ALPHA) && defined(__osf__))
115  test_skip( __FILE__, __LINE__, "main: fork not supported.", 0 );
116 #endif
117 
118  printf( "This tests if PAPI_library_init(),2*fork(),PAPI_library_init() works.\n" );
119  /* Initialize PAPI for this process */
120  process_init( );
121  flops1 = 1000000;
122  if ( fork( ) == 0 ) {
123  /* Initialize PAPI for the child process */
124  process_init( );
125  /* Let the child process do work */
126  do_flops( flops1 );
127  /* Measure the child process */
128  process_fini( );
129  exit( 0 );
130  }
131  flops1 = 2000000;
132  if ( fork( ) == 0 ) {
133  /* Initialize PAPI for the child process */
134  process_init( );
135  /* Let the child process do work */
136  do_flops( flops1 );
137  /* Measure the child process */
138  process_fini( );
139  exit( 0 );
140  }
141  /* Let this process do work */
142  flops1 = 4000000;
143  do_flops( flops1 );
144 
145  /* Wait for child to finish */
146  wait( &retval );
147  /* Wait for child to finish */
148  wait( &retval );
149 
150  /* Measure this process */
151  process_fini( );
152 
153  test_pass( __FILE__, NULL, 0 );
154  return 0;
155 }
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
void process_init(void)
Definition: zero_fork.c:49
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
int wait()
void process_fini(void)
Definition: zero_fork.c:82
void do_flops(int n)
Definition: multiplex.c:23
ssize_t retval
Definition: libasync.c:338
void exit()

Here is the call graph for this function:

void process_fini ( void  )

Definition at line 82 of file zero_fork.c.

83 {
85  if ( retval != PAPI_OK ) {
86  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
87  }
88 
91 
93 
94  printf( "Process %d %-12s : \t%lld\n", ( int ) getpid( ), event_name,
95  values[0][1] );
96  printf( "Process %d PAPI_TOT_CYC : \t%lld\n", ( int ) getpid( ),
97  values[0][0] );
98  printf( "Process %d Real usec : \t%lld\n", ( int ) getpid( ),
99  elapsed_us );
100  printf( "Process %d Real cycles : \t%lld\n", ( int ) getpid( ),
101  elapsed_cyc );
102 
104 
105 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2225
int mask1
Definition: zero_fork.c:41
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
long long elapsed_cyc
Definition: zero_fork.c:43
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:131
int num_tests
Definition: zero_fork.c:46
long long PAPI_get_real_usec(void)
Definition: papi.c:6125
long long PAPI_get_real_cyc(void)
Definition: papi.c:6078
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long elapsed_us
Definition: zero_fork.c:43
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277
int EventSet1
Definition: zero_fork.c:40

Here is the call graph for this function:

Here is the caller graph for this function:

void process_init ( void  )

Definition at line 49 of file zero_fork.c.

50 {
51  printf( "Process %d \n", ( int ) getpid( ) );
52 
53  /* Initialize PAPI library */
55  if ( retval != PAPI_VER_CURRENT ) {
56  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
57  }
58 
59  /* add PAPI_TOT_CYC and one of the events in
60  PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS,
61  depends on the availability of the event
62  on the platform */
64 
66 
68  if ( retval != PAPI_OK ) {
69  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
70  }
71 
74 
76  if ( retval != PAPI_OK ) {
77  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
78  }
79 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int mask1
Definition: zero_fork.c:41
int PAPI_event[2]
Definition: data_range.c:24
int num_events1
Definition: zero_fork.c:42
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
long long elapsed_cyc
Definition: zero_fork.c:43
int add_two_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:680
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:920
int num_tests
Definition: zero_fork.c:46
long long PAPI_get_real_usec(void)
Definition: papi.c:6125
long long PAPI_get_real_cyc(void)
Definition: papi.c:6078
int PAPI_start(int EventSet)
Definition: papi.c:2019
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long elapsed_us
Definition: zero_fork.c:43
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
int EventSet1
Definition: zero_fork.c:40

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

long long elapsed_cyc

Definition at line 43 of file zero_fork.c.

long long elapsed_us

Definition at line 43 of file zero_fork.c.

char event_name[PAPI_MAX_STR_LEN]

Definition at line 45 of file zero_fork.c.

int EventSet1 = PAPI_NULL

Definition at line 40 of file zero_fork.c.

int mask1

Definition at line 41 of file zero_fork.c.

int num_events1 = 2

Definition at line 42 of file zero_fork.c.

int num_tests = 1

Definition at line 46 of file zero_fork.c.

int PAPI_event

Definition at line 41 of file zero_fork.c.

int retval

Definition at line 46 of file zero_fork.c.

long long** values

Definition at line 44 of file zero_fork.c.