| 1 |
.\" Copyright IBM Corp. 2014 |
| 2 |
.\" |
| 3 |
.\" The MIT License (MIT) |
| 4 |
.\" |
| 5 |
.\" Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
.\" of this software and associated documentation files (the "Software"), to |
| 7 |
.\" deal in the Software without restriction, including without limitation the |
| 8 |
.\" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 9 |
.\" sell copies of the Software, and to permit persons to whom the Software is |
| 10 |
.\" furnished to do so, subject to the following conditions: |
| 11 |
.\" |
| 12 |
.\" The above copyright notice and this permission notice shall be included in |
| 13 |
.\" all copies or substantial portions of the Software. |
| 14 |
.\" |
| 15 |
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
.\" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
.\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 |
.\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 |
.\" IN THE SOFTWARE. |
| 22 |
.\" |
| 23 |
.\" Contributors: |
| 24 |
.\" IBM Corporation, Adhemerval Zanella - Initial implementation. |
| 25 |
.\" IBM Corporation, Rajalakshmi S - Initial implementation. |
| 26 |
.TH LIBPAF 2014-04-13 "Linux" "Time Base Header" |
| 27 |
.SH NAME |
| 28 |
The Power Architecture Facilities - Timebase header |
| 29 |
.SH SYNOPSIS |
| 30 |
.B #include <paf/tb.h> |
| 31 |
.sp |
| 32 |
.BI "uint64_t paf_timing_now(void); |
| 33 |
.sp |
| 34 |
.BI "void paf_timing_accum(uint64_t " *sum ", uint64_t " diff "); |
| 35 |
.sp |
| 36 |
.BI "uint64_t paf_timing_diff(uint64_t " start ", uint64_t " end "); |
| 37 |
.sp |
| 38 |
|
| 39 |
.SH DESCRIPTION |
| 40 |
|
| 41 |
The Time Base header tb.h provides a mechanism to read the |
| 42 |
Time Base Register |
| 43 |
.RB ( TB ) |
| 44 |
available on Power Architecture. This register follows the layout specified in |
| 45 |
the corresponding Power ISA. |
| 46 |
|
| 47 |
.PP |
| 48 |
The function |
| 49 |
.BR paf_timing_now() |
| 50 |
reads the current value of the Time Base Register. |
| 51 |
|
| 52 |
.PP |
| 53 |
The function |
| 54 |
.BR paf_timing_accum() |
| 55 |
adds time difference to variable |
| 56 |
.I *sum |
| 57 |
. |
| 58 |
|
| 59 |
The function |
| 60 |
.BR paf_timing_diff() |
| 61 |
computes difference between two times. |
| 62 |
. |
| 63 |
|
| 64 |
.SH RETURN VALUE |
| 65 |
.BR paf_timing_now() |
| 66 |
returns the current value of the Time Base Register. |
| 67 |
|
| 68 |
.BR paf_timing_diff() |
| 69 |
returns the difference between two times. |
| 70 |
|
| 71 |
.SH EXAMPLES |
| 72 |
.SS Program source |
| 73 |
\& |
| 74 |
.nf |
| 75 |
#include <stdio.h> |
| 76 |
#include <paf/tb.h> |
| 77 |
|
| 78 |
int |
| 79 |
main () |
| 80 |
{ |
| 81 |
int i, j; |
| 82 |
uint64_t load_time, start, stop, sum = 0; |
| 83 |
|
| 84 |
for (i = 0; i < 3; i++) |
| 85 |
{ |
| 86 |
start = paf_timing_now (); |
| 87 |
for (j = 0; j < 1000; j++); |
| 88 |
stop = paf_timing_now (); |
| 89 |
load_time = paf_timing_diff (start, stop); |
| 90 |
paf_timing_accum (&sum, load_time); |
| 91 |
printf ("Time taken by the for loop is %ld ticks\n", load_time); |
| 92 |
} |
| 93 |
printf ("Total time taken is %ld ticks\n",sum); |
| 94 |
return 0; |
| 95 |
} |
| 96 |
|
| 97 |
.ED |
| 98 |
|
| 99 |
.SH REFERENCES |
| 100 |
.TP |
| 101 |
.B Power ISA\(tm Version 2.05 |
| 102 |
.TP |
| 103 |
.B Power ISA\(tm Version 2.06 |
| 104 |
.TP |
| 105 |
.B Power ISA\(tm Version 2.06+ |
| 106 |
.TP |
| 107 |
.B Power ISA\(tm Version 2.07 |
| 108 |
|
| 109 |
.SH REPORTING BUGS |
| 110 |
.PP |
| 111 |
Email bug reports to Rajalakshmi S<[email protected]>. |
| 112 |
.SH AUTHORS |
| 113 |
This manual page was written by Rajalakshmi S<[email protected]> |
| 114 |
and Adhemerval Zanella <[email protected]>. |
| 115 |
|
| 116 |
|