\doxysection{include/sphinxbase/profile.h File Reference}
\label{profile_8h}\index{include/sphinxbase/profile.h@{include/sphinxbase/profile.h}}


Implementation of profiling, include counting , timing, cpu clock checking.  


{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\newline
\doxysubsubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ pctr\+\_\+t}
\begin{DoxyCompactList}\small\item\em Generic event counter for profiling. \end{DoxyCompactList}\item 
struct \textbf{ ptmr\+\_\+t}
\begin{DoxyCompactList}\small\item\em Generic timer structures and functions for coarse-\/grained performance measurements using standard system calls. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
SPHINXBASE\+\_\+\+EXPORT \textbf{ pctr\+\_\+t} $\ast$ \textbf{ pctr\+\_\+new} (char $\ast$name)
\begin{DoxyCompactList}\small\item\em operations of \doxyref{pctr\+\_\+t}{p.}{structpctr__t} \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ pctr\+\_\+reset} (\textbf{ pctr\+\_\+t} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Reset a counter. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ pctr\+\_\+print} (FILE $\ast$fp, \textbf{ pctr\+\_\+t} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Print a counter. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ pctr\+\_\+increment} (\textbf{ pctr\+\_\+t} $\ast$ctr, int32 inc)
\begin{DoxyCompactList}\small\item\em Increment a counter. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ pctr\+\_\+free} (\textbf{ pctr\+\_\+t} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Free the counter. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ ptmr\+\_\+start} (\textbf{ ptmr\+\_\+t} $\ast$tmr)
\begin{DoxyCompactList}\small\item\em Start timing using tmr. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ ptmr\+\_\+stop} (\textbf{ ptmr\+\_\+t} $\ast$tmr)
\begin{DoxyCompactList}\small\item\em Stop timing and accumulate tmr-\/$>$\{t\+\_\+cpu, t\+\_\+elapsed, t\+\_\+tot\+\_\+cpu, t\+\_\+tot\+\_\+elapsed\}. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ ptmr\+\_\+reset} (\textbf{ ptmr\+\_\+t} $\ast$tmr)
\begin{DoxyCompactList}\small\item\em Reset tmr-\/$>$\{t\+\_\+cpu, t\+\_\+elapsed\} to 0.\+0. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ ptmr\+\_\+init} (\textbf{ ptmr\+\_\+t} $\ast$tmr)
\begin{DoxyCompactList}\small\item\em Reset tmr-\/$>$\{t\+\_\+cpu, t\+\_\+elapsed, t\+\_\+tot\+\_\+cpu, t\+\_\+tot\+\_\+elapsed\} to 0.\+0. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ ptmr\+\_\+reset\+\_\+all} (\textbf{ ptmr\+\_\+t} $\ast$tmr)
\begin{DoxyCompactList}\small\item\em Reset t\+\_\+cpu, t\+\_\+elapsed of all timer modules in array tmr[] to 0.\+0. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ ptmr\+\_\+print\+\_\+all} (FILE $\ast$fp, \textbf{ ptmr\+\_\+t} $\ast$tmr, float64 norm)
\begin{DoxyCompactList}\small\item\em Print t\+\_\+cpu for all timer modules in tmr[], normalized by norm (i.\+e., t\+\_\+cpu/norm). \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ host\+\_\+pclk} (int32 dummy)
\begin{DoxyCompactList}\small\item\em Return the processor clock speed (in MHz); only available on some machines (Alphas). \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ host\+\_\+endian} (void)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Implementation of profiling, include counting , timing, cpu clock checking. 

Currently, function host\+\_\+endian is also in this function. It is not documented. ~\newline
 

Definition in file \textbf{ profile.\+h}.



\doxysubsection{Function Documentation}
\label{profile_8h_aa23a14aa8ae716d64e632d61b1c2ed77} 
\index{profile.h@{profile.h}!host\_endian@{host\_endian}}
\index{host\_endian@{host\_endian}!profile.h@{profile.h}}
\doxysubsubsection{host\_endian()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 host\+\_\+endian (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Definition at line \textbf{ 294} of file \textbf{ profile.\+c}.

\label{profile_8h_a4315a0c6da4e9d3ef3c0ce264620ce28} 
\index{profile.h@{profile.h}!host\_pclk@{host\_pclk}}
\index{host\_pclk@{host\_pclk}!profile.h@{profile.h}}
\doxysubsubsection{host\_pclk()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 host\+\_\+pclk (\begin{DoxyParamCaption}\item[{int32}]{dummy }\end{DoxyParamCaption})}



Return the processor clock speed (in MHz); only available on some machines (Alphas). 

The dummy argument can be any integer value. \label{profile_8h_a90821b8f5c4593ead9f8ebea8ca6994c} 
\index{profile.h@{profile.h}!pctr\_free@{pctr\_free}}
\index{pctr\_free@{pctr\_free}!profile.h@{profile.h}}
\doxysubsubsection{pctr\_free()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void pctr\+\_\+free (\begin{DoxyParamCaption}\item[{\textbf{ pctr\+\_\+t} $\ast$}]{ctr }\end{DoxyParamCaption})}



Free the counter. 


\begin{DoxyParams}{Parameters}
{\em ctr} & A pointer of a counter \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 140} of file \textbf{ profile.\+c}.



References \textbf{ ckd\+\_\+free()}, \textbf{ pctr\+\_\+t\+::name}, and \textbf{ pctr\+\_\+free()}.



Referenced by \textbf{ pctr\+\_\+free()}.

\label{profile_8h_a29e1c5d5f5b462d24a84204e532943fa} 
\index{profile.h@{profile.h}!pctr\_increment@{pctr\_increment}}
\index{pctr\_increment@{pctr\_increment}!profile.h@{profile.h}}
\doxysubsubsection{pctr\_increment()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void pctr\+\_\+increment (\begin{DoxyParamCaption}\item[{\textbf{ pctr\+\_\+t} $\ast$}]{ctr,  }\item[{int32}]{inc }\end{DoxyParamCaption})}



Increment a counter. 


\begin{DoxyParams}{Parameters}
{\em ctr} & A pointer of a counter  \\
\hline
{\em inc} & The increment of the counter \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 126} of file \textbf{ profile.\+c}.



References \textbf{ pctr\+\_\+t\+::count}, and \textbf{ pctr\+\_\+increment()}.



Referenced by \textbf{ pctr\+\_\+increment()}.

\label{profile_8h_a6cf86e967fbf7b683bbb50036fb9e815} 
\index{profile.h@{profile.h}!pctr\_new@{pctr\_new}}
\index{pctr\_new@{pctr\_new}!profile.h@{profile.h}}
\doxysubsubsection{pctr\_new()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT \textbf{ pctr\+\_\+t} $\ast$ pctr\+\_\+new (\begin{DoxyParamCaption}\item[{char $\ast$}]{name }\end{DoxyParamCaption})}



operations of \doxyref{pctr\+\_\+t}{p.}{structpctr__t} 

Initialize a counter \begin{DoxyReturn}{Returns}
an initialized counter 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em name} & The name of the counter \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 107} of file \textbf{ profile.\+c}.



References \textbf{ ckd\+\_\+calloc}, \textbf{ ckd\+\_\+salloc}, \textbf{ pctr\+\_\+t\+::count}, \textbf{ pctr\+\_\+t\+::name}, and \textbf{ pctr\+\_\+new()}.



Referenced by \textbf{ pctr\+\_\+new()}.

\label{profile_8h_a4333e06af6db1fd806846c9f9b1f3f78} 
\index{profile.h@{profile.h}!pctr\_print@{pctr\_print}}
\index{pctr\_print@{pctr\_print}!profile.h@{profile.h}}
\doxysubsubsection{pctr\_print()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void pctr\+\_\+print (\begin{DoxyParamCaption}\item[{FILE $\ast$}]{fp,  }\item[{\textbf{ pctr\+\_\+t} $\ast$}]{ctr }\end{DoxyParamCaption})}



Print a counter. 


\begin{DoxyParams}{Parameters}
{\em fp} & A file pointer  \\
\hline
{\em ctr} & A pointer of a counter \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 133} of file \textbf{ profile.\+c}.



References \textbf{ pctr\+\_\+t\+::count}, \textbf{ pctr\+\_\+t\+::name}, and \textbf{ pctr\+\_\+print()}.



Referenced by \textbf{ pctr\+\_\+print()}.

\label{profile_8h_a7d072965099f09c49a58e3fd422c48f4} 
\index{profile.h@{profile.h}!pctr\_reset@{pctr\_reset}}
\index{pctr\_reset@{pctr\_reset}!profile.h@{profile.h}}
\doxysubsubsection{pctr\_reset()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void pctr\+\_\+reset (\begin{DoxyParamCaption}\item[{\textbf{ pctr\+\_\+t} $\ast$}]{ctr }\end{DoxyParamCaption})}



Reset a counter. 


\begin{DoxyParams}{Parameters}
{\em ctr} & A pointer of a counter \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 119} of file \textbf{ profile.\+c}.



References \textbf{ pctr\+\_\+t\+::count}, and \textbf{ pctr\+\_\+reset()}.



Referenced by \textbf{ pctr\+\_\+reset()}.

\label{profile_8h_a5260d9143ed28fa82c2ab410abce6749} 
\index{profile.h@{profile.h}!ptmr\_init@{ptmr\_init}}
\index{ptmr\_init@{ptmr\_init}!profile.h@{profile.h}}
\doxysubsubsection{ptmr\_init()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void ptmr\+\_\+init (\begin{DoxyParamCaption}\item[{\textbf{ ptmr\+\_\+t} $\ast$}]{tmr }\end{DoxyParamCaption})}



Reset tmr-\/$>$\{t\+\_\+cpu, t\+\_\+elapsed, t\+\_\+tot\+\_\+cpu, t\+\_\+tot\+\_\+elapsed\} to 0.\+0. 


\begin{DoxyParams}{Parameters}
{\em tmr} & The timer \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 265} of file \textbf{ profile.\+c}.



References \textbf{ ptmr\+\_\+t\+::t\+\_\+cpu}, \textbf{ ptmr\+\_\+t\+::t\+\_\+elapsed}, \textbf{ ptmr\+\_\+t\+::t\+\_\+tot\+\_\+cpu}, and \textbf{ ptmr\+\_\+t\+::t\+\_\+tot\+\_\+elapsed}.

\label{profile_8h_a08a625009ff1a5e2ee8aa02b53009f66} 
\index{profile.h@{profile.h}!ptmr\_print\_all@{ptmr\_print\_all}}
\index{ptmr\_print\_all@{ptmr\_print\_all}!profile.h@{profile.h}}
\doxysubsubsection{ptmr\_print\_all()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void ptmr\+\_\+print\+\_\+all (\begin{DoxyParamCaption}\item[{FILE $\ast$}]{fp,  }\item[{\textbf{ ptmr\+\_\+t} $\ast$}]{tmr,  }\item[{float64}]{norm }\end{DoxyParamCaption})}



Print t\+\_\+cpu for all timer modules in tmr[], normalized by norm (i.\+e., t\+\_\+cpu/norm). 

The array should be terminated with a sentinel with .name = NULL. 
\begin{DoxyParams}{Parameters}
{\em fp} & The file pointer  \\
\hline
{\em tmr} & The timer \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 283} of file \textbf{ profile.\+c}.



References \textbf{ ptmr\+\_\+t\+::name}, and \textbf{ ptmr\+\_\+t\+::t\+\_\+cpu}.

\label{profile_8h_a32b1bf9f877946fb455c493a6aa3613f} 
\index{profile.h@{profile.h}!ptmr\_reset@{ptmr\_reset}}
\index{ptmr\_reset@{ptmr\_reset}!profile.h@{profile.h}}
\doxysubsubsection{ptmr\_reset()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void ptmr\+\_\+reset (\begin{DoxyParamCaption}\item[{\textbf{ ptmr\+\_\+t} $\ast$}]{tmr }\end{DoxyParamCaption})}



Reset tmr-\/$>$\{t\+\_\+cpu, t\+\_\+elapsed\} to 0.\+0. 


\begin{DoxyParams}{Parameters}
{\em tmr} & The timer \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 257} of file \textbf{ profile.\+c}.



References \textbf{ ptmr\+\_\+t\+::t\+\_\+cpu}, and \textbf{ ptmr\+\_\+t\+::t\+\_\+elapsed}.



Referenced by \textbf{ ptmr\+\_\+reset\+\_\+all()}.

\label{profile_8h_a0aaa0953b76ae8c9947d6d982bbbd4a7} 
\index{profile.h@{profile.h}!ptmr\_reset\_all@{ptmr\_reset\_all}}
\index{ptmr\_reset\_all@{ptmr\_reset\_all}!profile.h@{profile.h}}
\doxysubsubsection{ptmr\_reset\_all()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void ptmr\+\_\+reset\+\_\+all (\begin{DoxyParamCaption}\item[{\textbf{ ptmr\+\_\+t} $\ast$}]{tmr }\end{DoxyParamCaption})}



Reset t\+\_\+cpu, t\+\_\+elapsed of all timer modules in array tmr[] to 0.\+0. 

The array should be terminated with a sentinel with .name = NULL. 
\begin{DoxyParams}{Parameters}
{\em tmr} & The timer \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 275} of file \textbf{ profile.\+c}.



References \textbf{ ptmr\+\_\+t\+::name}, and \textbf{ ptmr\+\_\+reset()}.

\label{profile_8h_aada447eb3dc8c9ffb17fd7331ae671e7} 
\index{profile.h@{profile.h}!ptmr\_start@{ptmr\_start}}
\index{ptmr\_start@{ptmr\_start}!profile.h@{profile.h}}
\doxysubsubsection{ptmr\_start()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void ptmr\+\_\+start (\begin{DoxyParamCaption}\item[{\textbf{ ptmr\+\_\+t} $\ast$}]{tmr }\end{DoxyParamCaption})}



Start timing using tmr. 


\begin{DoxyParams}{Parameters}
{\em tmr} & The timer \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 178} of file \textbf{ profile.\+c}.



References \textbf{ ptmr\+\_\+start()}, \textbf{ ptmr\+\_\+t\+::start\+\_\+cpu}, and \textbf{ ptmr\+\_\+t\+::start\+\_\+elapsed}.



Referenced by \textbf{ ptmr\+\_\+start()}.

\label{profile_8h_ade42334cf2db0bc8858ff966e55a4ffb} 
\index{profile.h@{profile.h}!ptmr\_stop@{ptmr\_stop}}
\index{ptmr\_stop@{ptmr\_stop}!profile.h@{profile.h}}
\doxysubsubsection{ptmr\_stop()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void ptmr\+\_\+stop (\begin{DoxyParamCaption}\item[{\textbf{ ptmr\+\_\+t} $\ast$}]{tmr }\end{DoxyParamCaption})}



Stop timing and accumulate tmr-\/$>$\{t\+\_\+cpu, t\+\_\+elapsed, t\+\_\+tot\+\_\+cpu, t\+\_\+tot\+\_\+elapsed\}. 


\begin{DoxyParams}{Parameters}
{\em tmr} & The timer \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 212} of file \textbf{ profile.\+c}.



References \textbf{ ptmr\+\_\+t\+::start\+\_\+cpu}, \textbf{ ptmr\+\_\+t\+::start\+\_\+elapsed}, \textbf{ ptmr\+\_\+t\+::t\+\_\+cpu}, \textbf{ ptmr\+\_\+t\+::t\+\_\+elapsed}, \textbf{ ptmr\+\_\+t\+::t\+\_\+tot\+\_\+cpu}, and \textbf{ ptmr\+\_\+t\+::t\+\_\+tot\+\_\+elapsed}.

