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.

00109 {
00110     int flops1;
00111     int retval;
00112 
00113     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00114 # if (defined(__ALPHA) && defined(__osf__))
00115     test_skip( __FILE__, __LINE__, "main: fork not supported.", 0 );
00116 #endif
00117 
00118     printf( "This tests if PAPI_library_init(),2*fork(),PAPI_library_init() works.\n" );
00119     /* Initialize PAPI for this process */
00120     process_init(  );
00121     flops1 = 1000000;
00122     if ( fork(  ) == 0 ) {
00123         /* Initialize PAPI for the child process */
00124         process_init(  );
00125         /* Let the child process do work */
00126         do_flops( flops1 );
00127         /* Measure the child process */
00128         process_fini(  );
00129         exit( 0 );
00130     }
00131     flops1 = 2000000;
00132     if ( fork(  ) == 0 ) {
00133         /* Initialize PAPI for the child process */
00134         process_init(  );
00135         /* Let the child process do work */
00136         do_flops( flops1 );
00137         /* Measure the child process */
00138         process_fini(  );
00139         exit( 0 );
00140     }
00141     /* Let this process do work */
00142     flops1 = 4000000;
00143     do_flops( flops1 );
00144 
00145     /* Wait for child to finish */
00146     wait( &retval );
00147     /* Wait for child to finish */
00148     wait( &retval );
00149 
00150     /* Measure this process */
00151     process_fini(  );
00152 
00153     test_pass( __FILE__, NULL, 0 );
00154     return 0;
00155 }

Here is the call graph for this function:

void process_fini ( void   ) 

Definition at line 82 of file zero_fork.c.

00083 {
00084     retval = PAPI_stop( EventSet1, values[0] );
00085     if ( retval != PAPI_OK ) {
00086         test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
00087     }
00088 
00089     elapsed_us = PAPI_get_real_usec(  ) - elapsed_us;
00090     elapsed_cyc = PAPI_get_real_cyc(  ) - elapsed_cyc;
00091 
00092     remove_test_events( &EventSet1, mask1 );
00093 
00094     printf( "Process %d %-12s : \t%lld\n", ( int ) getpid(  ), event_name,
00095             values[0][1] );
00096     printf( "Process %d PAPI_TOT_CYC : \t%lld\n", ( int ) getpid(  ),
00097             values[0][0] );
00098     printf( "Process %d Real usec    : \t%lld\n", ( int ) getpid(  ),
00099             elapsed_us );
00100     printf( "Process %d Real cycles  : \t%lld\n", ( int ) getpid(  ),
00101             elapsed_cyc );
00102 
00103     free_test_space( values, num_tests );
00104 
00105 }

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.

00050 {
00051     printf( "Process %d \n", ( int ) getpid(  ) );
00052 
00053     /* Initialize PAPI library */
00054     retval = PAPI_library_init( PAPI_VER_CURRENT );
00055     if ( retval != PAPI_VER_CURRENT ) {
00056        test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00057     }
00058 
00059     /* add PAPI_TOT_CYC and one of the events in 
00060        PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS, 
00061        depends on the availability of the event 
00062        on the platform                           */
00063     EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 );
00064 
00065     values = allocate_test_space( num_tests, num_events1 );
00066 
00067     retval = PAPI_event_code_to_name( PAPI_event, event_name );
00068     if ( retval != PAPI_OK ) {
00069        test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
00070     }
00071 
00072     elapsed_us = PAPI_get_real_usec(  );
00073     elapsed_cyc = PAPI_get_real_cyc(  );
00074 
00075     retval = PAPI_start( EventSet1 );
00076     if ( retval != PAPI_OK ) {
00077         test_fail( __FILE__, __LINE__, "PAPI_start", retval );
00078     }
00079 }

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.

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.


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1