- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using icc 14.0.0 on Xubuntu 13.04 and std::chrono::duration_cast returns results which are 1000 times too small. Here is the test code:
[cpp]
#include <iostream>
#include <chrono>
#include <thread>using namespace std;
int main()
{
auto start = chrono::high_resolution_clock::now();
this_thread::sleep_for(chrono::milliseconds(10));
auto end = chrono::high_resolution_clock::now();
cout << "chrono::duration [ns]: " << chrono::duration_cast<chrono::nanoseconds>(end - start).count() << "\n";
}
[/cpp]
When built with icc (icc -std=c++11 clock.cpp) it produces:
chrono::duration [ns]: 10057
The same code built with gcc 4.8.1 (g++-4.8 -std=c++11 clock.cpp) produces a correct result:
chrono::duration [ns]: 10058344
The same problem occures when cast is made to microseconds or milliseconds.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't have Xubuntu, I tried your program with gcc 4.8.1 headers and icc on RHEL with intel64 compiler and the results didn't have a scale problem. Could you preprocess your program with both icc and gcc and attach both files? e.g. icpc -c -std=c++0x -E clock.cpp > clock-iccE.cpp ; and the same command using g++. Also, could you attach the assembly from both gcc and icpc? (Use -S switch when compiling). If you use the -# switch on icpc compilation line, it will also show the library search path (and a lot of other details!).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the tip. I have both gcc 4.8.1 and 4.7 installed on my system and icc is using the default gcc 4.7 libraries, which are the source of std::chrono problem. Since I need both versions of gcc, is there an easy way to configure icc to use gcc 4.8.1 libraries (non-default)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found a solution by lucky accident. I was playing with optimization options and when I used -fast, problems with std::chrono disappeared. With -Ofast the problem was still there. My guess is that -fast forces -xHost, which causes different CPU clocks to be used (my CPU supports AVX) and it automagically works now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sounds like you solved your problem, thanks for your reply.
When I need to use a different version of gcc/++, I modify the PATH environment variable.
Here's a discussion here about some icc compiler options which are related: http://software.intel.com/en-us/forums/topic/366102

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page