-
Notifications
You must be signed in to change notification settings - Fork 51
PAPI System Information
Information about the executable’s address space can be obtained by using the following low-level function:
const PAPI_exe_info_t *prg_info = PAPI_get_executable_info();
No arguments for PAPI_get_executable_info
. See PAPI_exe_info_t
within the papi.h
header file to see what information of the current program is contained within the returned pointer to a structure.
use iso_c_binding
character(PAPI_MAX_STR_LEN, c_char) fullname, name
integer(c_long_long) text_start, text_end, data_start
integer(c_long_long) data_end, bss_start, bss_end
integer(c_int) check
call PAPIF_get_exe_info(fullname, name, text_start, text_end,
& data_start, data_end, bss_start, bss_end, check)
Fortran arguments that are explicitly returned by PAPIF_get_exe_info
:
- fullname -- fully qualified path + filename of the executable.
- name -- filename of the executable with no path information.
- text_start -- start address of program text segment.
- test_end -- end address of program text segment.
- data_start -- start address of program data segment.
- data_end -- end address of program data segment.
- bss_start -- start address of program bss segment.
- bss_end -- end address of program bss segment.
- check -- an error return value for Fortran.
Note that the arguments text_start and text_end are the only fields that are filled on every architecture.
In C, this function returns a pointer to a structure containing information about the current program, such as the start and end addresses of the text, data, and bss segments.
In Fortran, the fields of the structure are returned explicitly.
In the following code example, PAPI_get_executable_info is used to acquire information about the start and end addresses of the program’s text segment:
#include <papi.h>
#include <stdio.h>
#include <stdlib.h>
void handle_error (int retval)
{
printf("PAPI error %d: %s\n", retval, PAPI_strerror(retval));
exit(1);
}
int main()
{
int retval;
const PAPI_exe_info_t *prginfo = NULL;
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT)
handle_error(retval);
prginfo = PAPI_get_executable_info();
if (prginfo == NULL)
handle_error(1);
printf("Start of user program is at %p\n",prginfo->address_info.text_start);
printf("End of user program is at %p\n",prginfo->address_info.text_end);
/* Executes if all low-level PAPI
function calls returned PAPI_OK */
printf("\033[0;32m\n\nPASSED\n\033[0m");
exit(0);
}
Start of user program is at 0x4000000000000f20
End of user program is at 0x4000000000034e00
PASSED
In C, on success, the PAPI functions returns a non-NULL pointer and the possible above output is returned. On error, a non-zero error code is returned.
In Fortran, on success, the PAPI function returns PAPI_OK and on error, a non-zero error code is returned.
Information about the system hardware can be obtained by using the following low-level function:
const PAPI_hw_info_t *hwinfo = PAPI_get_hardware_info();
No arguments for PAPI_get_hardware_info
. See PAPI_hw_info_t
within the papi.h
header file to see what hardware information is contained within the returned pointer to a structure.
use iso_c_binding
integer(c_int) ncpu, nnodes, totalcpus, vendor, model
character(PAPI_MAX_STR_LEN, c_char) vendor_string, model_string
real(c_float) revision, mhz
call PAPIF_get_hardware_info(ncpu, nnodes, totalcpus, vendor,
& vendor_string, model, model_string, revision, mhz)
Fortran arguments that are explicitly returned for PAPIF_get_hardware_info
:
- ncpu -- number of CPUs in an SMP Node
- nnodes -- number of Nodes in the entire system
- totalcpus -- total number of CPUs in the entire system
- vendor -- vendor id number of CPU
- vendor_string -- vendor id string of CPU
- model -- model number of CPU
- model_string -- model string of CPU
- revision -- revision number of CPU
- mhz -- cycle time of this CPU; may be an estimate generated at initialization time with a quick timing routine
In C, this function returns a pointer to a structure containing information about the hardware on which the program runs, such as: the number of CPUs, CPU model information, and the cycle time of the CPU.
In Fortran, the fields of the structure are returned explicitly.
Note that if this function were called before PAPI_library_init, it would be undefined.
In the following code example, PAPI_get_hardware_info is used to acquire hardware information about the total number of CPUs and the cycle time of the CPU:
#include <papi.h>
#include <stdio.h>
#include <stdlib.h>
void handle_error (int retval)
{
printf("PAPI error %d: %s\n", retval, PAPI_strerror(retval));
exit(1);
}
int main()
{
int retval;
const PAPI_hw_info_t *hwinfo = NULL;
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT)
handle_error(retval);
hwinfo = PAPI_get_hardware_info();
if (hwinfo == NULL)
handle_error(1);
printf("%d CPUs at %f Mhz.\n",hwinfo->totalcpus,hwinfo->mhz);
/* Executes if all low-level PAPI
function calls returned PAPI_OK */
printf("\033[0;32m\n\nPASSED\n\033[0m");
exit(0);
}
1 CPUs at 733.000000 Mhz.
PASSED
In C, on success, this PAPI function returns a non-NULL pointer and the possible above output is returned. On error, a non-zero error code is returned.
In Fortran, on success, this PAPI function returns PAPI_OK and on error, a non-zero error code is returned.
Implementation details about the current component features can be obtained by using the following low-level function:
int index = 0; /* 0 is always the cpu component */
const PAPI_component_info_t *cmpinfo = PAPI_get_component_info(index);
Arguments for PAPI_get_component_info
:
- index -- component index.
This call is not implemented in the Fortran interface.
In C, this function returns a pointer to a structure containing implementation details about the component features currently in use, such as: name of components being used, the number of preset and native events the component supports, and many more component specific details. For more information, refer to the definition of the PAPI_component_info_t structure found in papi.h, or see the discussion under getting and setting options. Note: if this function is called before PAPI_library_init, its output is undefined.
In the following code example, PAPI_get_component_info is used to determine how many preset and native events can be counted for a given component:
#include <papi.h>
#include <stdio.h>
#include <stdlib.h>
void handle_error (int retval)
{
printf("PAPI error %d: %s\n", retval, PAPI_strerror(retval));
exit(1);
}
int main()
{
int retval;
const PAPI_component_info_t *cmpinfo = NULL;
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT)
handle_error(retval);
/* Must pass component index */
cmpinfo = PAPI_get_component_info(0);
if (cmpinfo == NULL)
handle_error(1);
printf("num_preset_events: %d\n",cmpinfo->num_preset_events);
printf("num_native_events: %d\n",cmpinfo->num_native_events);
/* Executes if all low-level PAPI
function calls returned PAPI_OK */
printf("\033[0;32m\n\nPASSED\n\033[0m");
exit(0);
}
num_preset_events: 47
num_native_events: 193
PASSED
On success, this PAPI function returns a non-NULL pointer and the possible above output is returned. On error, a non-zero error code is returned.