PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PAPI_hw_info.c
Go to the documentation of this file.
1 /****************************************************************************
2  * This is a simple low level example for getting information on the system *
3  * hardware. This function PAPI_get_hardware_info(), returns a pointer to a *
4  * structure of type PAPI_hw_info_t, which contains number of CPUs, nodes, *
5  * vendor number/name for CPU, CPU revision, clock speed. *
6  ****************************************************************************/
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "papi.h" /* This needs to be included every time you use PAPI */
11 
12 int main()
13 {
14  const PAPI_hw_info_t *hwinfo = NULL;
15  int retval;
16 
17  /***************************************************************************
18  * This part initializes the library and compares the version number of the*
19  * header file, to the version of the library, if these don't match then it *
20  * is likely that PAPI won't work correctly.If there is an error, retval *
21  * keeps track of the version number. *
22  ***************************************************************************/
23 
24 
26  {
27  printf("Library initialization error! \n");
28  exit(1);
29  }
30 
31  /* Get hardware info*/
32  if ((hwinfo = PAPI_get_hardware_info()) == NULL)
33  {
34  printf("PAPI_get_hardware_info error! \n");
35  exit(1);
36  }
37  /* when there is an error, PAPI_get_hardware_info returns NULL */
38 
39 
40  printf("%d CPU at %f Mhz.\n",hwinfo->totalcpus,hwinfo->mhz);
41  printf(" model string is %s \n", hwinfo->model_string);
42 
43  /* clean up */
44  PAPI_shutdown();
45 
46  exit(0);
47 
48 }
49 
Hardware info structure.
Definition: papi.h:775
#define printf
Definition: papi_test.h:125
Return codes and api definitions.
float mhz
Definition: papi.h:802
int PAPI_library_init(int version)
Definition: papi.c:495
void PAPI_shutdown(void)
Definition: papi.c:4344
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int totalcpus
Definition: papi.h:781
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6046
ssize_t retval
Definition: libasync.c:338
int main(int argc, char **argv)
List all appio events codes and names.
void exit()