1PAPI_get_hardware_info(3) PAPI PAPI_get_hardware_info(3)
2
3
4
6 PAPI_get_hardware_info - get information about the system hardware
7
8
10 C Interface
11 #include <papi.h>
12 const PAPI_hw_info_t *PAPI_get_hardware_info(void);
13 Fortran Interface
14 #include fpapi.h
15 PAPIF_get_hardware_info(C_INT ncpu, C_INT nnodes, C_INT totalcpus, C_INT vendor, C_STRING vendor_string, C_INT model, C_STRING model_string,C_FLOAT revision, C_FLOAT mhz)
16
17
19 In C, this function returns a pointer to a structure containing inforā
20 mation about the hardware on which the program runs. In Fortran, the
21 values of the structure are returned explicitly.
22
23
25 The C structure contains detailed information about cache and TLB
26 sizes. This information is not available from Fortran.
27
28
30 The following arguments are implicit in the structure returned by the C
31 function, or explicitly returned by Fortran.
32
33 ncpu -- number of CPUs in an SMP Node
34
35 nnodes -- number of Nodes in the entire system
36
37 totalcpus -- total number of CPUs in the entire system
38
39 vendor -- vendor id number of CPU
40
41 vendor_string -- vendor id string of CPU
42
43 model -- model number of CPU
44
45 model_string -- model string of CPU
46
47 revision -- Revision number of CPU
48
49 mhz -- Cycle time of this CPU; *may* be an estimate generated at init
50 time with a quick timing routine
51
52 mem_hierarchy -- PAPI memory heirarchy description
53
54
56 On success, the C function returns a non-NULL pointer, and the Fortran
57 function returns PAPI_OK.
58 On error, NULL is returned by the C function, and a non-zero error
59 code is returned by the Fortran function.
60
61
63 PAPI_EINVAL
64 One or more of the arguments is invalid.
65
66
68 const PAPI_hw_info_t *hwinfo = NULL;
69
70 if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT)
71 exit(1);
72
73 if ((hwinfo = PAPI_get_hardware_info()) == NULL)
74 exit(1);
75
76 printf("%d CPU's at %f Mhz.\n",hwinfo->totalcpus,hwinfo->mhz);
77
78
80 The C data structure returned by this function is found in papi.h and
81 reproduced below:
82
83 typedef struct _papi_mh_tlb_info {
84 int type; /* See papi.h for PAPI_MH definitions. */
85 int num_entries;
86 int associativity;
87 } PAPI_mh_tlb_info_t;
88
89 typedef struct _papi_mh_cache_info {
90 int type; /* See papi.h for PAPI_MH definitions. */
91 int size;
92 int line_size;
93 int num_lines;
94 int associativity;
95 } PAPI_mh_cache_info_t;
96
97 typedef struct _papi_mh_level_info {
98 PAPI_mh_tlb_info_t tlb[2];
99 PAPI_mh_cache_info_t cache[2];
100 } PAPI_mh_level_t;
101
102 typedef struct _papi_mh_info { /* mh for mem hierarchy maybe? */
103 int levels;
104 PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS];
105 } PAPI_mh_info_t;
106
107 typedef struct _papi_hw_info {
108 int ncpu; /* Number of CPU's in an SMP Node */
109 int nnodes; /* Number of Nodes in the entire system */
110 int totalcpus; /* Total number of CPU's in the entire system */
111 int vendor; /* Vendor number of CPU */
112 char vendor_string[PAPI_MAX_STR_LEN]; /* Vendor string of CPU */
113 int model; /* Model number of CPU */
114 char model_string[PAPI_MAX_STR_LEN]; /* Model string of CPU */
115 float revision; /* Revision of CPU */
116 float mhz; /* Cycle time of this CPU, *may* be estimated at
117 init time with a quick timing routine */
118 PAPI_mh_info_t mem_hierarchy; /* PAPI memory heirarchy description */
119 } PAPI_hw_info_t;
120
121
122
124 If called before PAPI_library_init() the behavior of the routine is
125 undefined.
126
127
129 PAPI_library_init(3), PAPI_get_dmem_info(3), PAPI_get_opt(3),
130 PAPI_get_executable_info(3)
131
132
133
134PAPI Programmer's Reference September, 2004 PAPI_get_hardware_info(3)