PAPI 7.1.0.0
Loading...
Searching...
No Matches
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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 117 of file zero_fork.c.

118{
119 int flops1;
120 int retval;
121
122 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
123# if (defined(__ALPHA) && defined(__osf__))
124 test_skip( __FILE__, __LINE__, "main: fork not supported.", 0 );
125#endif
126
127 if (!TESTS_QUIET) {
128 printf( "This tests if PAPI_library_init(),2*fork(),PAPI_library_init() works.\n" );
129 }
130 /* Initialize PAPI for this process */
131 process_init( );
132 flops1 = 1000000;
133 if ( fork( ) == 0 ) {
134 /* Initialize PAPI for the child process */
135 process_init( );
136 /* Let the child process do work */
137 do_flops( flops1 );
138 /* Measure the child process */
139 process_fini( );
140 exit( 0 );
141 }
142 flops1 = 2000000;
143 if ( fork( ) == 0 ) {
144 /* Initialize PAPI for the child process */
145 process_init( );
146 /* Let the child process do work */
147 do_flops( flops1 );
148 /* Measure the child process */
149 process_fini( );
150 exit( 0 );
151 }
152 /* Let this process do work */
153 flops1 = 4000000;
154 do_flops( flops1 );
155
156 /* Wait for child to finish */
157 wait( &retval );
158 /* Wait for child to finish */
159 wait( &retval );
160
161 /* Measure this process */
162 process_fini( );
163
164 test_pass( __FILE__ );
165 return 0;
166}
void do_flops(int n)
Definition: multiplex.c:23
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int retval
Definition: zero_fork.c:53
void process_fini(void)
Definition: zero_fork.c:89
void process_init(void)
Definition: zero_fork.c:56
Here is the call graph for this function:

◆ process_fini()

void process_fini ( void  )

Definition at line 89 of file zero_fork.c.

90{
92 if ( retval != PAPI_OK ) {
93 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
94 }
95
98
100
101 if (!TESTS_QUIET) {
102 printf( "Process %d %-12s : \t%lld\n", ( int ) getpid( ), event_name,
103 values[0][1] );
104 printf( "Process %d PAPI_TOT_CYC : \t%lld\n", ( int ) getpid( ),
105 values[0][0] );
106 printf( "Process %d Real usec : \t%lld\n", ( int ) getpid( ),
107 elapsed_us );
108 printf( "Process %d Real cycles : \t%lld\n", ( int ) getpid( ),
109 elapsed_cyc );
110 }
111
113
114}
get real time counter value in clock cycles Returns the total real time passed since some arbitrary s...
get real time counter value in microseconds
Stop counting hardware events in an event set.
#define PAPI_OK
Definition: f90papi.h:73
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:70
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
int EventSet1
Definition: zero_fork.c:47
int mask1
Definition: zero_fork.c:48
long long elapsed_cyc
Definition: zero_fork.c:50
long long elapsed_us
Definition: zero_fork.c:50
int num_tests
Definition: zero_fork.c:53
char event_name[PAPI_MAX_STR_LEN]
Definition: zero_fork.c:52
long long ** values
Definition: zero_fork.c:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_init()

void process_init ( void  )

Definition at line 56 of file zero_fork.c.

57{
58 if (!TESTS_QUIET) printf( "Process %d \n", ( int ) getpid( ) );
59
60 /* Initialize PAPI library */
62 if ( retval != PAPI_VER_CURRENT ) {
63 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
64 }
65
66 /* add PAPI_TOT_CYC and one of the events in
67 PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS,
68 depends on the availability of the event
69 on the platform */
71
73
75 if ( retval != PAPI_OK ) {
76 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
77 }
78
81
83 if ( retval != PAPI_OK ) {
84 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
85 }
86}
Convert a numeric hardware event code to a name.
initialize the PAPI library.
Start counting hardware events in an event set.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46
int add_two_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:640
int num_events1
Definition: zero_fork.c:49
int PAPI_event
Definition: zero_fork.c:48
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ elapsed_cyc

long long elapsed_cyc

Definition at line 50 of file zero_fork.c.

◆ elapsed_us

long long elapsed_us

Definition at line 50 of file zero_fork.c.

◆ event_name

char event_name[PAPI_MAX_STR_LEN]

Definition at line 52 of file zero_fork.c.

◆ EventSet1

int EventSet1 = PAPI_NULL

Definition at line 47 of file zero_fork.c.

◆ mask1

int mask1

Definition at line 48 of file zero_fork.c.

◆ num_events1

int num_events1 = 2

Definition at line 49 of file zero_fork.c.

◆ num_tests

int num_tests = 1

Definition at line 53 of file zero_fork.c.

◆ PAPI_event

int PAPI_event

Definition at line 48 of file zero_fork.c.

◆ retval

int retval

Definition at line 53 of file zero_fork.c.

◆ values

long long** values

Definition at line 51 of file zero_fork.c.