PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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

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++ ) {
144  retval = PAPI_event_name_to_code( native_name[i], &native );
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 
168  retval = PAPI_cleanup_eventset( EventSet );
169  if ( retval != PAPI_OK )
170  test_fail( __FILE__, __LINE__, "PAPI_cleanup", retval );
171  retval = PAPI_destroy_eventset( &EventSet );
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 PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
Hardware info structure.
Definition: papi.h:777
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
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
#define PAPI_EMISC
Definition: papi.h:265
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
int i
Definition: fileop.c:140
static int native
Definition: event_info.c:39
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2834
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
native_name
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1010
#define LLDFMT
Definition: papi_test.h:118
void do_both(int n)
int model
Definition: papi.h:786
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1971
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:787
int PAPI_start(int EventSet)
Definition: papi.c:2053
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6111
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:223
void exit()

Here is the call graph for this function:

Variable Documentation

int EventSet = PAPI_NULL
static

Definition at line 19 of file native.c.

int TESTS_QUIET

Definition at line 11 of file test_utils.c.