|
Packit |
577717 |
/*****************************************************************************
|
|
Packit |
577717 |
* This is an example using the low level function PAPI_get_executable_info *
|
|
Packit |
577717 |
* get the executable address space information. This function returns a *
|
|
Packit |
577717 |
* pointer to a structure containing address information about the current *
|
|
Packit |
577717 |
* program. *
|
|
Packit |
577717 |
******************************************************************************/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include "papi.h" /* This needs to be included every time you use PAPI */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int main()
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int i,tmp=0;
|
|
Packit |
577717 |
int retval;
|
|
Packit |
577717 |
const PAPI_exe_info_t *prginfo = NULL;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/****************************************************************************
|
|
Packit |
577717 |
* This part initializes the library and compares the version number of the *
|
|
Packit |
577717 |
* header file, to the version of the library, if these don't match then it *
|
|
Packit |
577717 |
* is likely that PAPI won't work correctly.If there is an error, retval *
|
|
Packit |
577717 |
* keeps track of the version number. *
|
|
Packit |
577717 |
****************************************************************************/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf("Library initialization error! \n");
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for(i=0;i<1000;i++)
|
|
Packit |
577717 |
tmp=tmp+i;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* PAPI_get_executable_info returns a NULL if there is an error */
|
|
Packit |
577717 |
if ((prginfo = PAPI_get_executable_info()) == NULL)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf("PAPI_get_executable_info error! \n");
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
printf("Start text addess of user program is at %p\n",
|
|
Packit |
577717 |
prginfo->address_info.text_start);
|
|
Packit |
577717 |
printf("End text address of user program is at %p\n",
|
|
Packit |
577717 |
prginfo->address_info.text_end);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
exit(0);
|
|
Packit |
577717 |
}
|