Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > ff8e7344076b5fbaa54d805766a057bd > files > 37

libscs-devel-1.4.1-4.fc15.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>tbx_timing.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; </center>
<hr><h1>tbx_timing.h</h1><div class="fragment"><pre>00001 <font class="preprocessor">#ifndef TBX_TIMING_H</font>
00002 <font class="preprocessor"></font><font class="preprocessor">#define TBX_TIMING_H</font>
00003 <font class="preprocessor"></font>
00004 <font class="preprocessor">#include &lt;sys/types.h&gt;</font>
00005 <font class="preprocessor">#include &lt;sys/time.h&gt;</font>
00006 
00007 <font class="comment">/*</font>
00008 <font class="comment"> * For the user interested in High resolution timer, to my knowledge </font>
00009 <font class="comment"> * the best library is "RTAI", unfortunately it works only on Linux OS</font>
00010 <font class="comment"> */</font>
00011 
00012 
00013 <font class="keyword">typedef</font> <font class="keyword">union </font>u_tbx_tick
00014 {
00015   <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <font class="keywordtype">long</font> tick;
00016 
00017   <font class="keyword">struct</font>
00018 <font class="keyword">  </font>{
00019     <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> low;
00020     <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> high;
00021   } sub;
00022 
00023   <font class="keyword">struct </font>timeval timev;
00024 } tbx_tick_t, *p_tbx_tick_t;
00025 
00026 <font class="preprocessor">#if defined(SCS_TYPECPU_ITANIUM)</font>
00027 <font class="preprocessor"></font><font class="preprocessor">#define TBX_GET_TICK(t) \</font>
00028 <font class="preprocessor">   __asm__ __volatile__("mov %0=ar.itc" : "=r"((t).tick) :: "memory")</font>
00029 <font class="preprocessor"></font><font class="preprocessor">#define TBX_TICK_RAW_DIFF(t1, t2) \</font>
00030 <font class="preprocessor">   ((t2).tick - (t1).tick)</font>
00031 <font class="preprocessor"></font>
00032 <font class="comment">/* Hum hum... Here we suppose that X86ARCH =&gt; Pentium! */</font>
00033 <font class="preprocessor">#elif defined(SCS_TYPECPU_X86)</font>
00034 <font class="preprocessor"></font><font class="preprocessor">#define TBX_GET_TICK(t) \</font>
00035 <font class="preprocessor">   __asm__ volatile("cpuid; rdtsc" : "=a" ((t).sub.low), "=d" ((t).sub.high))</font>
00036 <font class="preprocessor"></font><font class="preprocessor">#define TBX_TICK_RAW_DIFF(t1, t2) \</font>
00037 <font class="preprocessor">   ((t2).tick - (t1).tick)</font>
00038 <font class="preprocessor"></font>
00039 <font class="preprocessor">#elif defined(SCS_TYPECPU_ALPHA)</font>
00040 <font class="preprocessor"></font><font class="preprocessor">#define TBX_GET_TICK(t) \</font>
00041 <font class="preprocessor">   __asm__ volatile("rpcc %0\n\t" : "=r"((t).tick))</font>
00042 <font class="preprocessor"></font><font class="preprocessor">#define TBX_TICK_RAW_DIFF(t1, t2) \</font>
00043 <font class="preprocessor">   (((t2).tick &amp; 0xFFFFFFFF) - ((t1).tick &amp; 0xFFFFFFFF))</font>
00044 <font class="preprocessor"></font>
00045 <font class="preprocessor">#elif defined(SCS_TYPECPU_SPARC)</font>
00046 <font class="preprocessor"></font><font class="preprocessor">#define TBX_GET_TICK(t) \</font>
00047 <font class="preprocessor">    (t).tick = gethrtime()</font>
00048 <font class="preprocessor"></font><font class="preprocessor">#define TBX_TICK_RAW_DIFF(t1, t2) \</font>
00049 <font class="preprocessor">   ((t2).tick  - (t1).tick)</font>
00050 <font class="preprocessor"></font><font class="comment">/*</font>
00051 <font class="comment">The following instructions are done only for ppc 601 (which is an old processor!)</font>
00052 <font class="comment">#elif defined(SCS_TYPECPU_POWERPC)</font>
00053 <font class="comment">#define TBX_GET_TICK(t) \</font>
00054 <font class="comment">   __asm__ volatile("li %0,64;mtspr UMMCR0,%0;mfspr %0,UPMC1": "=r"((t).sub.low))</font>
00055 <font class="comment">#define TBX_TICK_RAW_DIFF(t1, t2) \</font>
00056 <font class="comment">   ((t2).tick  - (t1).tick)</font>
00057 <font class="comment"></font>
00058 <font class="comment"></font>
00059 <font class="comment">The following one is extracted from Motorola reference manual for 32 bits PPCs.</font>
00060 <font class="comment">But apparently it give randomly numbers, may be the clock generator is a random generator !</font>
00061 <font class="comment">Silly processor !!!!</font>
00062 <font class="comment"></font>
00063 <font class="comment">#elif defined(SCS_TYPECPU_POWERPC)</font>
00064 <font class="comment">#define TBX_GET_TICK(t) \</font>
00065 <font class="comment"> {unsigned long chk; \</font>
00066 <font class="comment">   __asm__ volatile("0: mftbu %0; mftb %1; mftbu %2; cmpw %2, %0; bne 0b" \</font>
00067 <font class="comment">                    : "=r" ((t).sub.low), "=r" ((t).sub.high), "=r" (chk) );}</font>
00068 <font class="comment">*/</font> 
00069 <font class="preprocessor">#define TBX_TICK_RAW_DIFF(t1, t2) \</font>
00070 <font class="preprocessor">   ((t2).tick  - (t1).tick)</font>
00071 <font class="preprocessor"></font>
00072 <font class="preprocessor">#else</font>
00073 <font class="preprocessor"></font><font class="preprocessor">#define TBX_GET_TICK(t) \</font>
00074 <font class="preprocessor">   gettimeofday(&amp;(t).timev, 0)</font>
00075 <font class="preprocessor"></font><font class="preprocessor">#define TBX_TICK_RAW_DIFF(t1, t2) \</font>
00076 <font class="preprocessor">   ((t2.timev.tv_sec * 1000000L + t2.timev.tv_usec) - \</font>
00077 <font class="preprocessor">    (t1.timev.tv_sec * 1000000L + t1.timev.tv_usec))</font>
00078 <font class="preprocessor"></font>
00079 <font class="preprocessor">#endif</font>
00080 <font class="preprocessor"></font>
00081 <font class="preprocessor">#define TBX_TICK_DIFF(t1, t2) (TBX_TICK_RAW_DIFF(t1, t2) - tbx_residual + 1)</font>
00082 <font class="preprocessor"></font><font class="preprocessor">#define TBX_TIMING_DELAY(t1, t2) tbx_tick2usec(TBX_TICK_DIFF(t1, t2))</font>
00083 <font class="preprocessor"></font>
00084 <font class="keyword">extern</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <font class="keywordtype">long</font> tbx_residual;
00085 <font class="keyword">extern</font> tbx_tick_t         tbx_new_event;
00086 <font class="keyword">extern</font> tbx_tick_t         tbx_last_event;
00087 
00088 <font class="preprocessor">#endif </font><font class="comment">/* TBX_TIMING_H */</font>
</pre></div><hr><address align="right"><small>Generated on Tue Jun 17 10:15:51 2003 for SCSLib by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>