PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nineth.c
Go to the documentation of this file.
1 /* This file performs the following test: start, stop and timer functionality for derived events
2 
3  NOTE: This test becomes useless when rate events like PAPI_FLOPS are removed.
4 
5  - It tests the derived metric FLOPS using the following two counters.
6  They are counted in the default counting domain and default
7  granularity, depending on the platform. Usually this is
8  the user domain (PAPI_DOM_USER) and thread context (PAPI_GRN_THR).
9  + PAPI_FP_INS
10  + PAPI_TOT_CYC
11  - Get us.
12  - Start counters
13  - Do flops
14  - Stop and read counters
15  - Get us.
16 */
17 
18 #include "papi_test.h"
19 
20 extern int TESTS_QUIET; /* Declared in test_utils.c */
21 
22 int
23 main( int argc, char **argv )
24 {
25  int retval, num_tests = 2, tmp;
26  int EventSet1 = PAPI_NULL;
27  int EventSet2 = PAPI_NULL;
28  int mask1 = 0x80001; /* FP_OPS and TOT_CYC */
29  int mask2 = 0x8; /* FLOPS */
30  int num_events1;
31  int num_events2;
32  long long **values;
33  int clockrate;
34  double test_flops;
35 
36 
37  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
38 
40  if ( retval != PAPI_VER_CURRENT )
41  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
42 
43  /* gotta count flops to run this test */
44  if ( ( retval = PAPI_query_event( PAPI_FP_OPS ) ) != PAPI_OK )
45  test_skip( __FILE__, __LINE__, "PAPI_query_event", retval );
46 
47  EventSet1 = add_test_events( &num_events1, &mask1 );
48 /* EventSet2 = add_test_events(&num_events2, &mask2); */
49 
50  if ( num_events1 == 0 || num_events2 == 0 )
51  test_skip( __FILE__, __LINE__, "add_test_events", PAPI_ENOEVNT );
52 
53  /* num_events1 is greater than num_events2 so don't worry. */
54 
55  values = allocate_test_space( num_tests, num_events1 );
56 
57  clockrate = PAPI_get_opt( PAPI_CLOCKRATE, NULL );
58  if ( clockrate < 1 )
59  test_fail( __FILE__, __LINE__, "PAPI_get_opt", retval );
60 
61  retval = PAPI_start( EventSet1 );
62  if ( retval != PAPI_OK )
63  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
64 
66 
67  retval = PAPI_stop( EventSet1, values[0] );
68  if ( retval != PAPI_OK )
69  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
70 /*
71  retval = PAPI_start(EventSet2);
72  if (retval != PAPI_OK)
73  test_fail(__FILE__, __LINE__, "PAPI_start", retval);
74 
75  do_flops(NUM_FLOPS);
76 
77  retval = PAPI_stop(EventSet2, values[1]);
78  if (retval != PAPI_OK)
79  test_fail(__FILE__, __LINE__, "PAPI_stop", retval);
80 */
81  remove_test_events( &EventSet1, mask1 );
82 /* remove_test_events(&EventSet2, mask2); */
83 
84  test_flops =
85  ( double ) ( values[0] )[0] *
86  ( double ) clockrate *( double ) 1000000.0;
87  test_flops = test_flops / ( double ) ( values[0] )[1];
88 
89  if ( !TESTS_QUIET ) {
90  printf( "Test case 9: start, stop for derived event PAPI_FLOPS.\n" );
91  printf( "------------------------------------------------------\n" );
92  tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
93  printf( "Default domain is: %d (%s)\n", tmp,
95  tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
96  printf( "Default granularity is: %d (%s)\n", tmp,
98  printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
99  printf
100  ( "-------------------------------------------------------------------------\n" );
101 
102  printf( "Test type : %12s%12s\n", "1", "2" );
103  printf( TAB2, "PAPI_FP_OPS : ", ( values[0] )[0], ( long long ) 0 );
104  printf( TAB2, "PAPI_TOT_CYC: ", ( values[0] )[1], ( long long ) 0 );
105  printf( TAB2, "PAPI_FLOPS : ", ( long long ) 0, ( values[1] )[0] );
106  printf
107  ( "-------------------------------------------------------------------------\n" );
108 
109  printf( "Verification:\n" );
110  printf( "Last number in row 3 approximately equals %f\n", test_flops );
111  printf( "This test is no longer valid: PAPI_FLOPS is deprecated.\n" );
112  }
113 /* {
114  double min, max;
115  min = values[1][0] * .9;
116  max = values[1][0] * 1.1;
117  if (test_flops > max || test_flops < min)
118  test_fail(__FILE__, __LINE__, "PAPI_FLOPS", 1);
119  }
120 */
121  test_pass( __FILE__, values, num_tests );
122  exit( 1 );
123 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
#define NUM_FLOPS
int mask1
Definition: zero_fork.c:41
#define PAPI_NULL
Definition: fpapi.h:13
char * stringify_granularity(int granularity)
Definition: test_utils.c:429
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
#define PAPI_ENOEVNT
Definition: fpapi.h:112
int num_events1
Definition: zero_fork.c:42
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_FP_OPS
Definition: fpapi.h:237
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
static double
Definition: fileop.c:1281
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
char * stringify_all_domains(int domains)
Definition: test_utils.c:369
#define TAB2
Definition: papi_test.h:113
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4041
#define PAPI_DEFDOM
Definition: fpapi.h:49
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
#define PAPI_DEFGRN
Definition: fpapi.h:51
int EventSet2
Definition: rapl_overflow.c:12
int num_tests
Definition: zero_fork.c:46
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:696
int PAPI_start(int EventSet)
Definition: papi.c:2026
#define PAPI_CLOCKRATE
Definition: fpapi.h:57
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
int main(int argc, char **argv)
List all appio events codes and names.
void exit()
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:213
int EventSet1
Definition: zero_fork.c:40