All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Go to the documentation of this file.
1 /* Standard headers for PAPI test applications.
2  This file is customized to hide Windows / Unix differences.
3 */
5 #include <stdlib.h>
6 #include <stdio.h>
8 #include <unistd.h>
9 #include <sys/wait.h>
10 #if (!defined(NO_DLFCN) && !defined(_BGL) && !defined(_BGP))
11 #include <dlfcn.h>
12 #endif
14 #include <errno.h>
15 #include <memory.h>
16 #if !defined(__FreeBSD__) && !defined(__APPLE__)
17 #include <malloc.h>
18 #endif
19 #include <assert.h>
20 #include <string.h>
21 #include <fcntl.h>
22 #include <sys/types.h>
23 #include <sys/time.h>
24 #include <math.h>
26 #include "papiStdEventDefs.h"
27 #include "papi.h"
28 #include "test_utils.h"
30 /* Masks to select operations for add_test_events() and remove_test_events()
31  Mask value tells us what events to select.
32 */
33 #define MASK_FP_OPS 0x80000
34 #define MASK_L1_DCA 0x40000 /* three new events for POWER4 */
35 #define MASK_L1_DCW 0x20000
36 #define MASK_L1_DCR 0x10000
37 #define MASK_TOT_IIS 0x04000 /* Try this if TOT_INS won't work */
38 #define MASK_BR_PRC 0x02000
39 #define MASK_BR_MSP 0x01000
40 #define MASK_BR_CN 0x00800
41 #define MASK_L2_TCH 0x00400
42 #define MASK_L2_TCA 0x00200
43 #define MASK_L2_TCM 0x00100
44 #define MASK_L1_DCM 0x00040
45 #define MASK_L1_ICM 0x00020
46 #define MASK_L1_TCM 0x00010
47 #define MASK_FP_INS 0x00004
48 #define MASK_TOT_INS 0x00002
49 #define MASK_TOT_CYC 0x00001
51 #define MAX_TEST_EVENTS 18
53 struct test_events_t {
54  unsigned int mask;
55  unsigned int event;
56 };
58 extern struct test_events_t test_events[];
60 int papi_print_header (char *prompt, const PAPI_hw_info_t **hwinfo);
61 void validate_string(char *name, char *s);
62 void *get_overflow_address(void *context);
63 void free_test_space(long long ** values, int num_tests);
64 long long **allocate_test_space(int num_tests, int num_events);
65 int add_test_events(int *number, int *mask, int allow_derived);
66 int add_two_events(int *num_events, int *papi_event, int *mask);
67 int add_two_nonderived_events(int *num_events, int *papi_event, int *mask);
68 int add_test_events_r(int *number, int *mask, void *handle);
69 int find_nonderived_event( void );
70 int enum_add_native_events(int *num_events, int **evtcodes, int need_interrupts, int no_software_events, int cidx);
71 int remove_test_events(int *EventSet, int mask);
72 void do_flush(void);
73 void do_misses(int n, int size);
74 void do_flops(int n);
75 /* export the next symbol as 'end' address of do_flops for profiling */
76 void fdo_flops(int *n);
77 void do_reads(int n);
78 void do_both(int n);
79 void do_l1misses(int n);
80 void do_stuff(void);
81 void dummy(void *);
82 char *stringify_domain(int domain);
83 char *stringify_all_domains(int domains);
84 char *stringify_granularity(int granularity);
85 char *stringify_all_granularities(int granularities);
86 void tests_quiet(int argc, char **argv);
87 void test_pass(char *file, long long ** values, int num_tests);
88 void test_fail(char *file, int line, char *call, int retval);
89 void test_fail_exit(char *file, int line, char *call, int retval);
90 void test_skip(char *file, int line, char *call, int retval);
91 void test_warn(char *file, int line, char *call, int retval);
92 void test_print_event_header(char *call, int evset);
93 void touch_dummy(double *ptr, int size);
94 int approx_equals(double a, double b);
95 void init_multiplex(void);
97 void clockcore(void);
99 /* Unix systems use %lld to display long long values
100  Windows uses %I64d for the same purpose.
101  Since these occur inside a quoted string,
102  we must #define the entire format string.
103  Below are several common forms of this string
104  for both platforms.
105 */
107 #define ONEHDR " %12s"
108 #define TAB2HDR "%s %12s %12s\n"
109 #define TAB3HDR "%s %12s %12s %12s\n"
110 #define TAB4HDR "%s %12s %12s %12s %12s\n"
111 #define ONENUM " %12lld"
112 #define TAB1 "%-12s %12lld\n"
113 #define TAB2 "%-12s %12lld %12lld\n"
114 #define TAB3 "%-12s %12lld %12lld %12lld\n"
115 #define TAB4 "%-12s %12lld %12lld %12lld %12lld\n"
116 #define TAB5 "%-12s %12lld %12lld %12lld %12lld %12lld\n"
117 #define TWO12 "%12lld %12lld %s"
118 #define LLDFMT "%lld"
119 #define LLDFMT10 "%10lld"
120 #define LLDFMT12 "%12lld"
121 #define LLDFMT15 "%15lld"
123 extern int TESTS_QUIET; /* Declared in test_utils.c */
125 #define printf if (!TESTS_QUIET) printf
Hardware info structure.
Definition: papi.h:777
void do_reads(int n)
Definition: do_loops.c:12
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
int papi_print_header(char *prompt, const PAPI_hw_info_t **hwinfo)
Definition: test_utils.c:21
void * get_overflow_address(void *context)
void do_stuff(void)
Definition: do_loops.c:249
int EventSet
Definition: data_range.c:25
int num_events
char * stringify_all_granularities(int granularities)
Definition: test_utils.c:408
tests_quiet(argc, argv)
void init_multiplex(void)
Definition: test_utils.c:892
test_pass(__FILE__, NULL, 0)
void do_l1misses(int n)
Definition: do_loops.c:213
int int argc
Definition: iozone.c:1609
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
int dummy
Definition: iozone.c:19741
Return codes and api definitions.
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
void test_warn(char *file, int line, char *call, int retval)
Definition: test_utils.c:578
char * stringify_all_domains(int domains)
Definition: test_utils.c:369
char *long long size
Definition: iozone.c:12023
FILE * file
Definition: pscanf.h:13
static int cidx
Definition: event_info.c:40
void do_misses(int n, int bytes)
Definition: do_loops.c:113
int add_two_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:680
Definition: iozone.c:20289
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:131
int approx_equals(double a, double b)
Definition: test_utils.c:94
int add_test_events_r(int *number, int *mask, void *handle)
nvmlDevice_t handle
Definition: linux-nvml.c:399
void touch_dummy(double *array, int size)
Definition: dummy.c:41
int num_tests
Definition: zero_fork.c:46
int enum_add_native_events(int *num_events, int **evtcodes, int need_interrupts, int no_software_events, int cidx)
Definition: test_utils.c:761
void do_flops(int n)
Definition: multiplex.c:23
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
void do_flush(void)
Definition: do_loops.c:165
struct test_events_t test_events[]
Definition: test_utils.c:191
void clockcore(void)
Definition: clockcore.c:99
void do_both(int n)
char * name
Definition: iozone.c:23648
void validate_string(char *name, char *s)
Definition: test_utils.c:84
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:723
char * stringify_domain(int domain)
Definition: test_utils.c:388
unsigned int event
Definition: papi_test.h:55
int find_nonderived_event(void)
Definition: test_utils.c:159
void test_print_event_header(char *call, int evset)
Definition: test_utils.c:645
void test_fail_exit(char *file, int line, char *call, int retval)
Definition: test_utils.c:567
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
void fdo_flops(int *n)
Definition: do_loops.c:83
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277
unsigned int mask
Definition: papi_test.h:54
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:213
int n
Definition: mendes-alt.c:164
char * ptr
Definition: iozone.c:23586