PAPI 7.1.0.0
Loading...
Searching...
No Matches
native.c File Reference
Include dependency graph for native.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Variables

static int EventSet = PAPI_NULL
 
int TESTS_QUIET
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 110 of file native.c.

111{
112 int i, retval, native;
113 const PAPI_hw_info_t *hwinfo;
114 long long values[8];
115
116 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
117
118 if ( ( retval =
120 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
121
122 if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
123 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
124
125 if ( ( hwinfo = PAPI_get_hardware_info( ) ) == NULL )
126 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", PAPI_EMISC );
127
128 printf( "Architecture %s, %d\n", hwinfo->model_string, hwinfo->model );
129
130#if ((defined(linux) && (defined(__i386__) || (defined __x86_64__))) )
131 if ( !strncmp( hwinfo->model_string, "Intel Pentium 4", 15 ) ) {
132 native_name = p4_native_name;
133 } else if ( !strncmp( hwinfo->model_string, "AMD K7", 6 ) ) {
134 native_name = k7_native_name;
135 } else if ( !strncmp( hwinfo->model_string, "AMD K8", 6 ) ) {
136 native_name = k8_native_name;
137 } else if ( !strncmp( hwinfo->model_string, "Intel Core", 17 ) ||
138 !strncmp( hwinfo->model_string, "Intel Core 2", 17 ) ) {
139 native_name = core_native_name;
140 }
141#endif
142
143 for ( i = 0; native_name[i] != NULL; i++ ) {
145 if ( retval != PAPI_OK )
146 test_fail( __FILE__, __LINE__, "PAPI_event_name_to_code", retval );
147 printf( "Adding %s\n", native_name[i] );
148 if ( ( retval = PAPI_add_event( EventSet, native ) ) != PAPI_OK )
149 test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
150 }
151
152 if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
153 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
154
155 do_both( 1000 );
156
157 if ( ( retval = PAPI_stop( EventSet, values ) ) != PAPI_OK )
158 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
159
160 if ( !TESTS_QUIET ) {
161 for ( i = 0; native_name[i] != NULL; i++ ) {
162 fprintf( stderr, "%-40s: ", native_name[i] );
163 fprintf( stderr, LLDFMT, values[i] );
164 fprintf( stderr, "\n" );
165 }
166 }
167
169 if ( retval != PAPI_OK )
170 test_fail( __FILE__, __LINE__, "PAPI_cleanup", retval );
172 if ( retval != PAPI_OK )
173 test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
174
175 test_pass( __FILE__, NULL, 0 );
176 exit( 0 );
177}
int i
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Convert a name to a numeric hardware event code.
get information about the system hardware
initialize the PAPI library.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
void do_both(int n)
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_EMISC
Definition: f90papi.h:122
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
static int EventSet
Definition: native.c:19
int TESTS_QUIET
Definition: test_utils.c:18
FILE * stderr
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
#define LLDFMT
Definition: papi_test.h:104
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
static int native
Hardware info structure.
Definition: papi.h:774
int model
Definition: papi.h:783
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

Variable Documentation

◆ EventSet

int EventSet = PAPI_NULL
static

Definition at line 19 of file native.c.

◆ TESTS_QUIET

int TESTS_QUIET
extern

Definition at line 18 of file test_utils.c.