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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 18 of file inherit.c.

19 {
21  long long int values[] = {0,0};
22  PAPI_option_t opt;
23  char event_name[BUFSIZ];
24  int quiet;
25 
26  quiet=tests_quiet( argc, argv );
27 
28  if ( ( retval = PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT )
29  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
30 
31  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
32  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
33 
34  if ( ( retval = PAPI_assign_eventset_component( EventSet, 0 ) ) != PAPI_OK )
35  test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval );
36 
37  memset( &opt, 0x0, sizeof ( PAPI_option_t ) );
40  if ( ( retval = PAPI_set_opt( PAPI_INHERIT, &opt ) ) != PAPI_OK ) {
41  if ( retval == PAPI_ECMP) {
42  test_skip( __FILE__, __LINE__, "Inherit not supported by current component.\n", retval );
43  } else {
44  test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval );
45  }
46  }
47 
48  if ( ( retval = PAPI_query_event( PAPI_TOT_CYC ) ) != PAPI_OK ) {
49  if (!quiet) printf("Trouble finding PAPI_TOT_CYC\n");
50  test_skip( __FILE__, __LINE__, "PAPI_query_event", retval );
51  }
52 
53  if ( ( retval = PAPI_add_event( EventSet, PAPI_TOT_CYC ) ) != PAPI_OK )
54  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
55 
56  strcpy(event_name,"PAPI_FP_INS");
57  retval = PAPI_add_named_event( EventSet, event_name );
58  if (retval == PAPI_ENOEVNT) {
59  strcpy(event_name,"PAPI_TOT_INS");
60  retval = PAPI_add_named_event( EventSet, event_name );
61  }
62 
63  if ( retval != PAPI_OK ) {
64  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
65  }
66 
67  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
68  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
69 
70  pid = fork( );
71  if ( pid == 0 ) {
73  exit( 0 );
74  }
75  if ( waitpid( pid, &status, 0 ) == -1 ) {
76  perror( "waitpid()" );
77  exit( 1 );
78  }
79 
80  if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
81  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
82 
83  if (!quiet) {
84  printf( "Test case inherit: parent starts, child works, parent stops.\n" );
85  printf( "------------------------------------------------------------\n" );
86 
87  printf( "Test run : \t1\n" );
88  printf( "%s : \t%lld\n", event_name, values[1] );
89  printf( "PAPI_TOT_CYC: \t%lld\n", values[0] );
90  printf( "------------------------------------------------------------\n" );
91 
92  printf( "Verification:\n" );
93  printf( "Row 1 at least %d\n", NUM_FLOPS );
94  printf( "Row 2 greater than row 1\n");
95  }
96 
97  if ( values[1] < 100 ) {
98  test_fail( __FILE__, __LINE__, event_name, 1 );
99  }
100 
101  if ( (!strcmp(event_name,"PAPI_FP_INS")) && (values[1] < NUM_FLOPS)) {
102  test_fail( __FILE__, __LINE__, "PAPI_FP_INS", 1 );
103  }
104 
105  test_pass( __FILE__ );
106 
107  return 0;
108 
109 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_ENOEVNT
Definition: papi.h:260
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_NULL
Definition: papi.h:292
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
PAPI_inherit_option_t inherit
Definition: papi.h:852
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:848
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3465
int int argc
Definition: iozone.c:1609
#define PAPI_INHERIT
Definition: papi.h:458
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
int PAPI_add_named_event(int EventSet, const char *EventName)
Definition: papi.c:1876
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
int quiet
Definition: rapl_overflow.c:18
#define PAPI_TOT_CYC
static int pid
#define PAPI_INHERIT_ALL
Definition: papi.h:425
#define PAPI_ECMP
Definition: papi.h:256
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1526
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
strcpy(filename, default_filename)
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:684
printf("\tTry: -i 0 -i 1 \n\n")
long long status
Definition: iozone.c:1335
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
int PAPI_start(int EventSet)
Definition: papi.c:2096
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
void exit()

Here is the call graph for this function: