Blame man/man3/PAPI_profil.3

Packit 577717
.TH "PAPI_profil" 3 "Mon Dec 18 2017" "Version 5.6.0.0" "PAPI" \" -*- nroff -*-
Packit 577717
.ad l
Packit 577717
.nh
Packit 577717
.SH NAME
Packit 577717
PAPI_profil \- 
Packit 577717
.PP
Packit 577717
Generate a histogram of hardware counter overflows vs\&. PC addresses\&.  
Packit 577717
Packit 577717
.SH SYNOPSIS
Packit 577717
.br
Packit 577717
.PP
Packit 577717
.SH "Detailed Description"
Packit 577717
.PP 
Packit 577717
Packit 577717
.PP
Packit 577717
\fBC Interface:\fP
Packit 577717
.RS 4
Packit 577717
#include <\fBpapi\&.h\fP> 
Packit 577717
.br
Packit 577717
 int \fBPAPI_profil\fP(void *buf, unsigned bufsiz, unsigned long offset, unsigned scale, int EventSet, int EventCode, int threshold, int flags );
Packit 577717
.RE
Packit 577717
.PP
Packit 577717
\fBFortran Interface\fP
Packit 577717
.RS 4
Packit 577717
The profiling routines have no Fortran interface\&.
Packit 577717
.RE
Packit 577717
.PP
Packit 577717
\fBParameters:\fP
Packit 577717
.RS 4
Packit 577717
\fI*buf\fP -- pointer to a buffer of bufsiz bytes in which the histogram counts are stored in an array of unsigned short, unsigned int, or unsigned long long values, or 'buckets'\&. The size of the buckets is determined by values in the flags argument\&. 
Packit 577717
.br
Packit 577717
\fIbufsiz\fP -- the size of the histogram buffer in bytes\&. It is computed from the length of the code region to be profiled, the size of the buckets, and the scale factor as discussed above\&. 
Packit 577717
.br
Packit 577717
\fIoffset\fP -- the start address of the region to be profiled\&. 
Packit 577717
.br
Packit 577717
\fIscale\fP -- broadly and historically speaking, a contraction factor that indicates how much smaller the histogram buffer is than the region to be profiled\&. More precisely, scale is interpreted as an unsigned 16-bit fixed-point fraction with the decimal point implied on the left\&. Its value is the reciprocal of the number of addresses in a subdivision, per counter of histogram buffer\&. Below is a table of representative values for scale\&. 
Packit 577717
.br
Packit 577717
\fIEventSet\fP -- The PAPI EventSet to profile\&. This EventSet is marked as profiling-ready, but profiling doesn't actually start until a \fBPAPI_start()\fP call is issued\&. 
Packit 577717
.br
Packit 577717
\fIEventCode\fP -- Code of the Event in the EventSet to profile\&. This event must already be a member of the EventSet\&. 
Packit 577717
.br
Packit 577717
\fIthreshold\fP -- minimum number of events that must occur before the PC is sampled\&. If hardware overflow is supported for your component, this threshold will trigger an interrupt when reached\&. Otherwise, the counters will be sampled periodically and the PC will be recorded for the first sample that exceeds the threshold\&. If the value of threshold is 0, profiling will be disabled for this event\&. 
Packit 577717
.br
Packit 577717
\fIflags\fP -- bit pattern to control profiling behavior\&. Defined values are shown in the table above\&.
Packit 577717
.RE
Packit 577717
.PP
Packit 577717
\fBReturn values:\fP
Packit 577717
.RS 4
Packit 577717
\fIPAPI_OK\fP 
Packit 577717
.br
Packit 577717
\fIPAPI_EINVAL\fP One or more of the arguments is invalid\&. 
Packit 577717
.br
Packit 577717
\fIPAPI_ENOMEM\fP Insufficient memory to complete the operation\&. 
Packit 577717
.br
Packit 577717
\fIPAPI_ENOEVST\fP The EventSet specified does not exist\&. 
Packit 577717
.br
Packit 577717
\fIPAPI_EISRUN\fP The EventSet is currently counting events\&. 
Packit 577717
.br
Packit 577717
\fIPAPI_ECNFLCT\fP The underlying counter hardware can not count this event and other events in the EventSet simultaneously\&. 
Packit 577717
.br
Packit 577717
\fIPAPI_ENOEVNT\fP The PAPI preset is not available on the underlying hardware\&.
Packit 577717
.RE
Packit 577717
.PP
Packit 577717
\fBPAPI_profil()\fP provides hardware event statistics by profiling the occurence of specified hardware counter events\&. It is designed to mimic the UNIX SVR4 profil call\&.
Packit 577717
.PP
Packit 577717
The statistics are generated by creating a histogram of hardware counter event overflows vs\&. program counter addresses for the current process\&. The histogram is defined for a specific region of program code to be profiled, and the identified region is logically broken up into a set of equal size subdivisions, each of which corresponds to a count in the histogram\&.
Packit 577717
.PP
Packit 577717
With each hardware event overflow, the current subdivision is identified and its corresponding histogram count is incremented\&. These counts establish a relative measure of how many hardware counter events are occuring in each code subdivision\&.
Packit 577717
.PP
Packit 577717
The resulting histogram counts for a profiled region can be used to identify those program addresses that generate a disproportionately high percentage of the event of interest\&.
Packit 577717
.PP
Packit 577717
Events to be profiled are specified with the EventSet and EventCode parameters\&. More than one event can be simultaneously profiled by calling \fBPAPI_profil()\fP several times with different EventCode values\&. Profiling can be turned off for a given event by calling \fBPAPI_profil()\fP with a threshold value of 0\&.
Packit 577717
.PP
Packit 577717
\fBRepresentative values for the scale variable\fP
Packit 577717
.RS 4
Packit 577717
 
Packit 577717
  HEX      DECIMAL  DEFININTION  
Packit 577717
  0x20000  131072   Maps precisely one instruction address to a unique bucket in buf.  
Packit 577717
  0x10000   65536   Maps precisely two instruction addresses to a unique bucket in buf.  
Packit 577717
  0x0FFFF   65535   Maps approximately two instruction addresses to a unique bucket in buf.  
Packit 577717
  0x08000   32768   Maps every four instruction addresses to a bucket in buf.  
Packit 577717
  0x04000   16384   Maps every eight instruction addresses to a bucket in buf.  
Packit 577717
  0x00002       2   Maps all instruction addresses to the same bucket in buf.  
Packit 577717
  0x00001       1   Undefined.  
Packit 577717
  0x00000       0   Undefined.  
Packit 577717
   
Packit 577717
.RE
Packit 577717
.PP
Packit 577717
Historically, the scale factor was introduced to allow the allocation of buffers smaller than the code size to be profiled\&. Data and instruction sizes were assumed to be multiples of 16-bits\&. These assumptions are no longer necessarily true\&. \fBPAPI_profil()\fP has preserved the traditional definition of scale where appropriate, but deprecated the definitions for 0 and 1 (disable scaling) and extended the range of scale to include 65536 and 131072 to allow for exactly two addresses and exactly one address per profiling bucket\&.
Packit 577717
.PP
Packit 577717
The value of bufsiz is computed as follows:
Packit 577717
.PP
Packit 577717
bufsiz = (end - start)*(bucket_size/2)*(scale/65536) where 
Packit 577717
.PD 0
Packit 577717
Packit 577717
.IP "\(bu" 2
Packit 577717
bufsiz - the size of the buffer in bytes 
Packit 577717
.IP "\(bu" 2
Packit 577717
end, start - the ending and starting addresses of the profiled region 
Packit 577717
.IP "\(bu" 2
Packit 577717
bucket_size - the size of each bucket in bytes; 2, 4, or 8 as defined in flags
Packit 577717
.PP
Packit 577717
\fBDefined bits for the flags variable:\fP
Packit 577717
.RS 4
Packit 577717
Packit 577717
.PD 0
Packit 577717
Packit 577717
.IP "\(bu" 2
Packit 577717
PAPI_PROFIL_POSIX Default type of profiling, similar to profil (3)\&.
Packit 577717
.br
Packit 577717
 
Packit 577717
.IP "\(bu" 2
Packit 577717
PAPI_PROFIL_RANDOM Drop a random 25% of the samples\&.
Packit 577717
.br
Packit 577717
 
Packit 577717
.IP "\(bu" 2
Packit 577717
PAPI_PROFIL_WEIGHTED Weight the samples by their value\&.
Packit 577717
.br
Packit 577717
 
Packit 577717
.IP "\(bu" 2
Packit 577717
PAPI_PROFIL_COMPRESS Ignore samples as values in the hash buckets get big\&.
Packit 577717
.br
Packit 577717
 
Packit 577717
.IP "\(bu" 2
Packit 577717
PAPI_PROFIL_BUCKET_16 Use unsigned short (16 bit) buckets, This is the default bucket\&.
Packit 577717
.br
Packit 577717
 
Packit 577717
.IP "\(bu" 2
Packit 577717
PAPI_PROFIL_BUCKET_32 Use unsigned int (32 bit) buckets\&.
Packit 577717
.br
Packit 577717
 
Packit 577717
.IP "\(bu" 2
Packit 577717
PAPI_PROFIL_BUCKET_64 Use unsigned long long (64 bit) buckets\&.
Packit 577717
.br
Packit 577717
 
Packit 577717
.IP "\(bu" 2
Packit 577717
PAPI_PROFIL_FORCE_SW Force software overflow in profiling\&. 
Packit 577717
.br
Packit 577717
 
Packit 577717
.PP
Packit 577717
.RE
Packit 577717
.PP
Packit 577717
\fBExample\fP
Packit 577717
.RS 4
Packit 577717
Packit 577717
.PP
Packit 577717
.nf
Packit 577717
* int retval;
Packit 577717
* unsigned long length;
Packit 577717
* PAPI_exe_info_t *prginfo;
Packit 577717
* unsigned short *profbuf;
Packit 577717
*
Packit 577717
* if ((prginfo = PAPI_get_executable_info()) == NULL)
Packit 577717
*    handle_error(1);
Packit 577717
*
Packit 577717
* length = (unsigned long)(prginfo->text_end - prginfo->text_start);
Packit 577717
*
Packit 577717
* profbuf = (unsigned short *)malloc(length);
Packit 577717
* if (profbuf == NULL)
Packit 577717
*    handle_error(1);
Packit 577717
* memset(profbuf,0x00,length);
Packit 577717
*
Packit 577717
* if ((retval = PAPI_profil(profbuf, length, start, 65536, EventSet,
Packit 577717
*     PAPI_FP_INS, 1000000, PAPI_PROFIL_POSIX | PAPI_PROFIL_BUCKET_16)) 
Packit 577717
*    != PAPI_OK)
Packit 577717
*    handle_error(retval);
Packit 577717
* 
Packit 577717
Packit 577717
.fi
Packit 577717
.PP
Packit 577717
.RE
Packit 577717
.PP
Packit 577717
.PP
Packit 577717
\fBSee Also:\fP
Packit 577717
.RS 4
Packit 577717
\fBPAPI_overflow\fP 
Packit 577717
.PP
Packit 577717
\fBPAPI_sprofil\fP 
Packit 577717
.RE
Packit 577717
.PP
Packit 577717
Packit 577717
Packit 577717
.SH "Author"
Packit 577717
.PP 
Packit 577717
Generated automatically by Doxygen for PAPI from the source code\&.