|
PAPI
5.0.1.0
|
00001 /**************************************************************************** 00002 * This is a simple low level example for getting information on the system * 00003 * hardware. This function PAPI_get_hardware_info(), returns a pointer to a * 00004 * structure of type PAPI_hw_info_t, which contains number of CPUs, nodes, * 00005 * vendor number/name for CPU, CPU revision, clock speed. * 00006 ****************************************************************************/ 00007 00008 #include <stdio.h> 00009 #include <stdlib.h> 00010 #include "papi.h" /* This needs to be included every time you use PAPI */ 00011 00012 int main() 00013 { 00014 const PAPI_hw_info_t *hwinfo = NULL; 00015 int retval; 00016 00017 /*************************************************************************** 00018 * This part initializes the library and compares the version number of the* 00019 * header file, to the version of the library, if these don't match then it * 00020 * is likely that PAPI won't work correctly.If there is an error, retval * 00021 * keeps track of the version number. * 00022 ***************************************************************************/ 00023 00024 00025 if((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT ) 00026 { 00027 printf("Library initialization error! \n"); 00028 exit(1); 00029 } 00030 00031 /* Get hardware info*/ 00032 if ((hwinfo = PAPI_get_hardware_info()) == NULL) 00033 { 00034 printf("PAPI_get_hardware_info error! \n"); 00035 exit(1); 00036 } 00037 /* when there is an error, PAPI_get_hardware_info returns NULL */ 00038 00039 00040 printf("%d CPU at %f Mhz.\n",hwinfo->totalcpus,hwinfo->mhz); 00041 printf(" model string is %s \n", hwinfo->model_string); 00042 00043 /* clean up */ 00044 PAPI_shutdown(); 00045 00046 exit(0); 00047 00048 } 00049