- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm trying to check the performance of in-place and not-in-place FFT.
But it seems I do not check the time right.
I'm running the following code:
void main (void)
{
Ipp64u Before,Elapsed;
Before=ippGetCpuClocks();
sleep (1);
Elapsed=(ippGetCpuClocks()-Before);
printf ("1 Sec=%d\n",Elapsed);}
My CPU runs at 2.6GHz so the value of 'Elapsed' should be ~2.6E9
But the value of 'Elapsed' I'm getting is negative.
I'm using Intel Compiler 11.1/064 with IPP 6.1 under RedHat 5.3
Can you help ?
Thanks,
Zvika
- Tags:
- Intel® C++ Compiler
Link Copied
10 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note: I think the post has to be moved to IPP forum, please.
>>My CPU runs at 2.6GHz so the value of 'Elapsed' should be ~2.6E9
>>
>>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'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've moved your post to the IPP forum.
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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(&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));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quick followup: same in Linux (with second resolution for sleep()). Same disclaimer for sleep() function too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might also check your format string, using "%d" for a 64-bit int. On my system that doesn't work. Try "%llu".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody,
>>...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
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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: http://software.intel.com/en-us/forums/topic/277738
if interested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>void main ( void )
>>{
>>Ipp64u Before,Elapsed;
>>Before=ippGetCpuClocks();
>>sleep (1);
>>Elapsed=(ippGetCpuClocks()-Before);
>>printf ("1 Sec=%d\n",Elapsed);
>>}
>>
>>My CPU runs at 2.6GHz so the value of 'Elapsed' should be ~2.6E9
>>
>>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
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this also:
Ipp32s CPUFreq;
ippGetCpuFreqMhz(&CPUFreq);
Ipp64u Start = ippGetCpuClocks();
Start = ippGetCpuClocks()*2 - Start;
// do work
Ipp64u End = ippGetCpuClocks();
End = ippGetCpuClocks()*2 - End;
std::cout << "total runtime: " << ((Ipp64f)End - (Ipp64f)Start)/((Ipp64f)CPUFreq *1000000.0f) << " seconds" << std::endl;
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page