<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Try this also:  in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926919#M16275</link>
    <description>Try this also: 

Ipp32s CPUFreq; 

ippGetCpuFreqMhz(&amp;amp;CPUFreq);  

Ipp64u Start = ippGetCpuClocks(); 

Start = ippGetCpuClocks()*2 - Start;         

// do work  

Ipp64u End = ippGetCpuClocks();  

End = ippGetCpuClocks()*2 - End; 

std::cout &amp;lt;&amp;lt; "total runtime: " &amp;lt;&amp;lt; ((Ipp64f)End - (Ipp64f)Start)/((Ipp64f)CPUFreq *1000000.0f) &amp;lt;&amp;lt; " seconds" &amp;lt;&amp;lt; std::endl;</description>
    <pubDate>Fri, 19 Oct 2012 17:42:36 GMT</pubDate>
    <dc:creator>Chuck_De_Sylva</dc:creator>
    <dc:date>2012-10-19T17:42:36Z</dc:date>
    <item>
      <title>How to measure time with ippGetCpuClocks ?</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926909#M16265</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm trying to check the performance of in-place and not-in-place FFT.&lt;/P&gt;
&lt;P&gt;But it seems I do not check the time right.&lt;/P&gt;
&lt;P&gt;I'm running the following code:&lt;/P&gt;
&lt;P&gt;void&amp;nbsp; main (void)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Ipp64u Before,Elapsed;&lt;/P&gt;
&lt;P&gt;Before=ippGetCpuClocks();&lt;BR /&gt;&amp;nbsp;sleep (1);&lt;BR /&gt;&amp;nbsp;Elapsed=(ippGetCpuClocks()-Before);&lt;BR /&gt;&amp;nbsp;printf ("1 Sec=%d\n",Elapsed);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My CPU runs at 2.6GHz so the value of 'Elapsed' should be ~2.6E9&lt;/P&gt;
&lt;P&gt;But the value of 'Elapsed' I'm getting is negative.&lt;/P&gt;
&lt;P&gt;I'm using Intel Compiler 11.1/064 with IPP 6.1 under RedHat 5.3&lt;/P&gt;
&lt;P&gt;Can you help ?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Zvika&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2012 08:34:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926909#M16265</guid>
      <dc:creator>zvivered</dc:creator>
      <dc:date>2012-10-17T08:34:57Z</dc:date>
    </item>
    <item>
      <title>Note: I think the post has to</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926910#M16266</link>
      <description>Note: I think the post has to be moved to IPP forum, please.

&amp;gt;&amp;gt;My CPU runs at 2.6GHz so the value of 'Elapsed' should be ~2.6E9
&amp;gt;&amp;gt;
&amp;gt;&amp;gt;But the value of 'Elapsed' I'm getting is negative.

IPP 'ippGetCpuClocks' function reads a time stamp counter (TSC) register value of the CPU. Is your processing too long? For example, many seconds? If Yes, than try to use less accurate CRT-functions, like 'time' and 'difftime'.</description>
      <pubDate>Wed, 17 Oct 2012 14:26:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926910#M16266</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-10-17T14:26:49Z</dc:date>
    </item>
    <item>
      <title>I've moved your post to the</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926911#M16267</link>
      <description>I've moved your post to the IPP forum. 

Jennifer</description>
      <pubDate>Thu, 18 Oct 2012 16:30:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926911#M16267</guid>
      <dc:creator>JenniferJ</dc:creator>
      <dc:date>2012-10-18T16:30:24Z</dc:date>
    </item>
    <item>
      <title>As Sergey mentioned, there</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926912#M16268</link>
      <description>As Sergey mentioned, there are many ways to measure time.  This is a great idea for future documentation.  The example below isn't perfect, but hopefully it will help in the short term.  BTW, you may see some variability from the Sleep function.

    int MHz;

    Ipp64u Before,Elapsed;
    
    int num_seconds=5;

    ippGetCpuFreqMhz(&amp;amp;MHz);  //Millions of cycles per second
    Before=ippGetCpuClocks();
    Sleep (num_seconds*1000); //Millisecond resolution for Windows Sleep() function
    Elapsed=ippGetCpuClocks()-Before;
   
    printf ("%d MHz, %d Sec=%.0f cycles, %f seconds\n",MHz, num_seconds, (double)Elapsed, (double)Elapsed/((double)(MHz)*1000000.0));</description>
      <pubDate>Thu, 18 Oct 2012 18:51:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926912#M16268</guid>
      <dc:creator>Jeffrey_M_Intel1</dc:creator>
      <dc:date>2012-10-18T18:51:30Z</dc:date>
    </item>
    <item>
      <title>Quick followup: same in Linux</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926913#M16269</link>
      <description>Quick followup: same in Linux (with second resolution for sleep()).  Same disclaimer for sleep() function too.</description>
      <pubDate>Thu, 18 Oct 2012 19:00:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926913#M16269</guid>
      <dc:creator>Jeffrey_M_Intel1</dc:creator>
      <dc:date>2012-10-18T19:00:46Z</dc:date>
    </item>
    <item>
      <title>You might also check your</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926914#M16270</link>
      <description>You might also check your format string, using "%d" for a 64-bit int. On my system that doesn't work. Try "%llu".</description>
      <pubDate>Thu, 18 Oct 2012 21:08:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926914#M16270</guid>
      <dc:creator>RyanS</dc:creator>
      <dc:date>2012-10-18T21:08:48Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926915#M16271</link>
      <description>Hello,

Today I ran the code under Knoppix live CD.
For a 1.06GHz CPU I got: ~1.06E9 clocks.
Same for a 2GHz CPU.

Under Red Hat 5.3 I got the weired negative result. 
So it seems the negative result concerns with the OS version. 

Thanks,
Zvika</description>
      <pubDate>Thu, 18 Oct 2012 21:13:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926915#M16271</guid>
      <dc:creator>zvivered</dc:creator>
      <dc:date>2012-10-18T21:13:39Z</dc:date>
    </item>
    <item>
      <title>Hi everybody,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926916#M16272</link>
      <description>Hi everybody,

&amp;gt;&amp;gt;...You might also check your format string, using "%d" for a 64-bit int. On my system that doesn't work. Try "%llu".

Try to use %I64d instead of %d to display a 64-bit value in a 'printf' CRT-function.

Here is a small test-case:

...
RTint64 i64ValueS   = 0x0fffffffffffffff;
CrtPrintf( RTU("Case #1.1 - Signed   64-bit Value: %d\t\t\tspecificator I64 NOT used\n"), i64ValueS );
CrtPrintf( RTU("Case #1.2 - Signed   64-bit Value: %I64d\tspecificator I64 used\n"), i64ValueS );

RTuint64 ui64ValueU = 0x0fffffffffffffff;
CrtPrintf( RTU("Case #2.1 - UnSigned 64-bit Value: %d\t\t\tspecificator I64 NOT used\n"), ui64ValueU );
CrtPrintf( RTU("Case #2.2 - UnSigned 64-bit Value: %I64d\tspecificator I64 used\n"), ui64ValueU );
...

Here are results:

...
Case #1.1 - Signed   64-bit Value: -1                   specificator I64 NOT used
Case #1.2 - Signed   64-bit Value: 1152921504606846975  specificator I64 used
Case #2.1 - UnSigned 64-bit Value: -1                   specificator I64 NOT used
Case #2.2 - UnSigned 64-bit Value: 1152921504606846975  specificator I64 used
...</description>
      <pubDate>Thu, 18 Oct 2012 23:09:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926916#M16272</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-10-18T23:09:30Z</dc:date>
    </item>
    <item>
      <title>The specificator I64 is more</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926917#M16273</link>
      <description>The specificator I64 is more than 15 years old and is fully supported even in legacy C/C++ compilers. However, you could experience some problems and issues with MinGW C/C++ compiler:
...
RTint64 i64ValueS   = 0x0fffffffffffffff;
...
Compilation error is:
...
../PrtTests.cpp:7221: error: integer constant is too large for "long" type
...

Note: Regarding 64-bit pragramming issues please take a look at a thread:

Forum topic: Tips for Porting software to a 64-bit platform
Web-link: &lt;A href="http://software.intel.com/en-us/forums/topic/277738" target="_blank"&gt;http://software.intel.com/en-us/forums/topic/277738&lt;/A&gt;

if interested.</description>
      <pubDate>Thu, 18 Oct 2012 23:20:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926917#M16273</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-10-18T23:20:16Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;void main ( void )</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926918#M16274</link>
      <description>&amp;gt;&amp;gt;void main ( void )
&amp;gt;&amp;gt;{
&amp;gt;&amp;gt;Ipp64u Before,Elapsed;
&amp;gt;&amp;gt;Before=ippGetCpuClocks();
&amp;gt;&amp;gt;sleep (1);
&amp;gt;&amp;gt;Elapsed=(ippGetCpuClocks()-Before);
&amp;gt;&amp;gt;printf ("1 Sec=%d\n",Elapsed);
&amp;gt;&amp;gt;}
&amp;gt;&amp;gt;
&amp;gt;&amp;gt;My CPU runs at 2.6GHz so the value of 'Elapsed' should be ~2.6E9
&amp;gt;&amp;gt;
&amp;gt;&amp;gt;But the value of 'Elapsed' I'm getting is negative.

I've done a quick test and if rounded to just one digit after the point and divided by 1000000000 it has to be 2.6. Here is another example:

...
Ipp64u u64bitValueA = 0;
Ipp64u u64bitValueB = 0;

u64bitValueA = ippGetCpuClocks();
::Sleep( [ some number greater than 5 ] );
u64bitValueB = ippGetCpuClocks();

CrtPrintf( RTU("Elapsed time: %d\n"), ( u64bitValueB - u64bitValueA ) );
CrtPrintf( RTU("Elapsed time: %I64d\n"), ( u64bitValueB - u64bitValueA ) );
...

Example of output:

...
Elapsed time: -618302688
Elapsed time: 7971631904
...</description>
      <pubDate>Thu, 18 Oct 2012 23:22:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926918#M16274</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-10-18T23:22:03Z</dc:date>
    </item>
    <item>
      <title>Try this also:</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926919#M16275</link>
      <description>Try this also: 

Ipp32s CPUFreq; 

ippGetCpuFreqMhz(&amp;amp;CPUFreq);  

Ipp64u Start = ippGetCpuClocks(); 

Start = ippGetCpuClocks()*2 - Start;         

// do work  

Ipp64u End = ippGetCpuClocks();  

End = ippGetCpuClocks()*2 - End; 

std::cout &amp;lt;&amp;lt; "total runtime: " &amp;lt;&amp;lt; ((Ipp64f)End - (Ipp64f)Start)/((Ipp64f)CPUFreq *1000000.0f) &amp;lt;&amp;lt; " seconds" &amp;lt;&amp;lt; std::endl;</description>
      <pubDate>Fri, 19 Oct 2012 17:42:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/How-to-measure-time-with-ippGetCpuClocks/m-p/926919#M16275</guid>
      <dc:creator>Chuck_De_Sylva</dc:creator>
      <dc:date>2012-10-19T17:42:36Z</dc:date>
    </item>
  </channel>
</rss>

