\section{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
\subsection*{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}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ pctr\+\_\+reset} (\textbf{ pctr\+\_\+t} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Reset a counter. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ pctr\+\_\+print} (F\+I\+LE $\ast$fp, \textbf{ pctr\+\_\+t} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Print a counter. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ pctr\+\_\+increment} (\textbf{ pctr\+\_\+t} $\ast$ctr, int32 inc)
\begin{DoxyCompactList}\small\item\em Increment a counter. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ pctr\+\_\+free} (\textbf{ pctr\+\_\+t} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Free the counter. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ ptmr\+\_\+start} (\textbf{ ptmr\+\_\+t} $\ast$tmr)
\begin{DoxyCompactList}\small\item\em Start timing using tmr. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ ptmr\+\_\+print\+\_\+all} (F\+I\+LE $\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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ host\+\_\+pclk} (int32 dummy)
\begin{DoxyCompactList}\small\item\em Return the processor clock speed (in M\+Hz); only available on some machines (Alphas). \end{DoxyCompactList}\item 
\mbox{\label{profile_8h_aa23a14aa8ae716d64e632d61b1c2ed77}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 {\bfseries host\+\_\+endian} (void)
\end{DoxyCompactItemize}


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

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

\subsection{Function Documentation}
\mbox{\label{profile_8h_a4315a0c6da4e9d3ef3c0ce264620ce28}} 
\index{profile.\+h@{profile.\+h}!host\+\_\+pclk@{host\+\_\+pclk}}
\index{host\+\_\+pclk@{host\+\_\+pclk}!profile.\+h@{profile.\+h}}
\subsubsection{host\+\_\+pclk()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 host\+\_\+pclk (\begin{DoxyParamCaption}\item[{int32}]{dummy }\end{DoxyParamCaption})}



Return the processor clock speed (in M\+Hz); only available on some machines (Alphas). 

The dummy argument can be any integer value. \mbox{\label{profile_8h_a90821b8f5c4593ead9f8ebea8ca6994c}} 
\index{profile.\+h@{profile.\+h}!pctr\+\_\+free@{pctr\+\_\+free}}
\index{pctr\+\_\+free@{pctr\+\_\+free}!profile.\+h@{profile.\+h}}
\subsubsection{pctr\+\_\+free()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 140 of file profile.\+c.



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

\mbox{\label{profile_8h_a29e1c5d5f5b462d24a84204e532943fa}} 
\index{profile.\+h@{profile.\+h}!pctr\+\_\+increment@{pctr\+\_\+increment}}
\index{pctr\+\_\+increment@{pctr\+\_\+increment}!profile.\+h@{profile.\+h}}
\subsubsection{pctr\+\_\+increment()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 126 of file profile.\+c.



References pctr\+\_\+t\+::count.

\mbox{\label{profile_8h_acc5bd9ca1cc61377433a308b082d34b8}} 
\index{profile.\+h@{profile.\+h}!pctr\+\_\+new@{pctr\+\_\+new}}
\index{pctr\+\_\+new@{pctr\+\_\+new}!profile.\+h@{profile.\+h}}
\subsubsection{pctr\+\_\+new()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 107 of file profile.\+c.



References ckd\+\_\+calloc, ckd\+\_\+salloc, pctr\+\_\+t\+::count, and pctr\+\_\+t\+::name.

\mbox{\label{profile_8h_a4333e06af6db1fd806846c9f9b1f3f78}} 
\index{profile.\+h@{profile.\+h}!pctr\+\_\+print@{pctr\+\_\+print}}
\index{pctr\+\_\+print@{pctr\+\_\+print}!profile.\+h@{profile.\+h}}
\subsubsection{pctr\+\_\+print()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void pctr\+\_\+print (\begin{DoxyParamCaption}\item[{F\+I\+LE $\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 133 of file profile.\+c.



References pctr\+\_\+t\+::count, and pctr\+\_\+t\+::name.

\mbox{\label{profile_8h_a7d072965099f09c49a58e3fd422c48f4}} 
\index{profile.\+h@{profile.\+h}!pctr\+\_\+reset@{pctr\+\_\+reset}}
\index{pctr\+\_\+reset@{pctr\+\_\+reset}!profile.\+h@{profile.\+h}}
\subsubsection{pctr\+\_\+reset()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 119 of file profile.\+c.



References pctr\+\_\+t\+::count.

\mbox{\label{profile_8h_a5260d9143ed28fa82c2ab410abce6749}} 
\index{profile.\+h@{profile.\+h}!ptmr\+\_\+init@{ptmr\+\_\+init}}
\index{ptmr\+\_\+init@{ptmr\+\_\+init}!profile.\+h@{profile.\+h}}
\subsubsection{ptmr\+\_\+init()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 265 of file profile.\+c.



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

\mbox{\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}}
\subsubsection{ptmr\+\_\+print\+\_\+all()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void ptmr\+\_\+print\+\_\+all (\begin{DoxyParamCaption}\item[{F\+I\+LE $\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 = N\+U\+LL. 
\begin{DoxyParams}{Parameters}
{\em fp} & The file pointer \\
\hline
{\em tmr} & The timer \\
\hline
\end{DoxyParams}


Definition at line 283 of file profile.\+c.



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

\mbox{\label{profile_8h_a32b1bf9f877946fb455c493a6aa3613f}} 
\index{profile.\+h@{profile.\+h}!ptmr\+\_\+reset@{ptmr\+\_\+reset}}
\index{ptmr\+\_\+reset@{ptmr\+\_\+reset}!profile.\+h@{profile.\+h}}
\subsubsection{ptmr\+\_\+reset()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 257 of file profile.\+c.



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



Referenced by ptmr\+\_\+reset\+\_\+all().

\mbox{\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}}
\subsubsection{ptmr\+\_\+reset\+\_\+all()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 = N\+U\+LL. 
\begin{DoxyParams}{Parameters}
{\em tmr} & The timer \\
\hline
\end{DoxyParams}


Definition at line 275 of file profile.\+c.



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

\mbox{\label{profile_8h_aada447eb3dc8c9ffb17fd7331ae671e7}} 
\index{profile.\+h@{profile.\+h}!ptmr\+\_\+start@{ptmr\+\_\+start}}
\index{ptmr\+\_\+start@{ptmr\+\_\+start}!profile.\+h@{profile.\+h}}
\subsubsection{ptmr\+\_\+start()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 178 of file profile.\+c.



References ptmr\+\_\+t\+::start\+\_\+cpu, and ptmr\+\_\+t\+::start\+\_\+elapsed.

\mbox{\label{profile_8h_ade42334cf2db0bc8858ff966e55a4ffb}} 
\index{profile.\+h@{profile.\+h}!ptmr\+\_\+stop@{ptmr\+\_\+stop}}
\index{ptmr\+\_\+stop@{ptmr\+\_\+stop}!profile.\+h@{profile.\+h}}
\subsubsection{ptmr\+\_\+stop()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 212 of file profile.\+c.



References ptmr\+\_\+t\+::start\+\_\+cpu, and ptmr\+\_\+t\+::start\+\_\+elapsed.

