Example 2.1
|
Write a C program to Initilize and shutdown PAPI library.
|
Example 2.2
|
Write a C program to get the values of the hardware counters using event sets.
|
Example 2.3
|
Write a C program to get Hardware info (CPU info) using PAPI_get_hardware_info() .
|
Example 2.4
|
Write a C program to get executable info using PAPI_get_executable_info().
|
Note : For compiling the above programs use either command line or Makefile.
Description of Programs using PAPI Low-level API's |
Example 2.1: |
Write a C program to Initilize and shutdown PAPI library.
(Download source code :
initilize-papi.c)
|
Objective
Initilize the PAPI Library before the usage of any PAPI call and at the end shutdown the PAPI library for freeing the resources held by PAPI
Description
This program uses the basic PAPI API PAPI_library_init() and PAPI_shutdown(void)
initializes the PAPI library and shutdown the PAPI lib at the end of the program.
Input
None
Output
Error message is displayed in case of error during initilzing or shutdown of the PAPI lib.
|
Example 2.2: |
Write a C program to get the values of the hardware counters using event sets.
(Download source code :
event-functions.c)
|
Objective
Collect the values of the Hardware counters using event set with low level API.
Description
Program to create event set, start events, read the events values, add events to the event set, remove the events from the event set, clean the event set and destroy the event set.
Functions used are:
int PAPI_create_eventset(int *EventSet)
int PAPI_add_event(int *EventSet, int Event)
int PAPI_start(int EventSet)
int PAPI_read(int *EventSet, long_long *values)
int PAPI_remove_event(int EventSet, int Event)
int PAPI_cleanup_eventset(EventSet)
int PAPI_destroy_eventset(EventSet)
Input
None
Output
Displays the total number of instructions, Total Cycles, And Cache misses of matrix-matrix multiplication.
|
Example 2.3: |
Write a C program to get Hardware info (CPU info) using PAPI_get_hardware_info().
(Download source code :
cpu-info.c)
|
Objective
PRogram to print the CPU info such as CPU vendor name, CPU Type, Number of CPU's present.
Description
This program uses PAPI_get_hardware_info(void) to get the CPU information.
Input
None
Output
Displays the CPU information such as CPU Type, CPU name, Vendor, Number of CPU's and CPU's Frequency.
|
Example 2.4: |
Write a C program to get executable info using PAPI_get_executable_info().
(Download source code :
executable-info.c )
|
Objective
Write a C program to get the infor of executable file.
Description
This program uses the API const PAPI_exe_info_t *PAPI_get_executable_info(void) and returns the starting and ending address of text and Data segmnet of the executable file.
Input
None
Output
Displays the values start and end address of test and data segments of the executable info.
|
|