Hi
I've seen something similar before. I'd check whether the call
boost::chrono triggers a fork() in C++11 mode. If it does, Linux will mark
your pages as copy-on-write and slow down the entire thing.
To make check whether that's the case move the memory allocation after the
call to chrono : the pages allocated after fork() won't be affected.
Regards,
Julien
On Mon, Aug 26, 2013 at 9:54 PM, Gaetano Mendola
Hi have tried the following code compiling it with gcc 4.6.3, with four combinations:
1) -O3 2) -O3 (commeting out the chrono call) 3) -O3 -std=c++0x 4) -O3 -std=c++0x (commenting out the chrono call)
and I'm obtaining the following runtime values:
1) 8921 ms 2) 8915 ms 3) 9400 ms 4) 8933 ms
as you can see the combination: "c++11 and chrono call" slows down the entire process. I have tried the same with gcc 4.8.1 and all times are more or less the same.
At this point I'm not sure if it's a problem of chrono with gcc 4.6.3 or simply an issue of 4.6.3 disappeared in 4.8.1 series.
Regards Gaetano Mendola
Here the code I have used:
#include <iostream> #include
#include #include int main() {
cpu_set_t myAffinityMask; CPU_ZERO( &myAffinityMask ); CPU_SET(0, &myAffinityMask ); sched_setaffinity(0, sizeof(myAffinityMask), &myAffinityMask);
volatile float* myMemoryA = new float[(1<<24)]; volatile float* myMemoryB = new float[(1<<24)];
struct timeval myStart; struct timeval myStop; struct timeval myResult;
boost::chrono::time_pointboost::chrono::steady_clock t1 = boost::chrono::high_resolution_clock::now();
gettimeofday(&myStart, 0);
for (size_t i = 0; i < (1<<24); ++i) { myMemoryA[i] = i; myMemoryB[i] = i+1; } delete []myMemoryA; delete []myMemoryB;
for (size_t j = 0; j < 100; ++j) { volatile float* myMemoryA = new float[(1<<24)]; volatile float* myMemoryB = new float[(1<<24)]; for (size_t i = 0; i < (1<<24); ++i) { myMemoryA[i] *= sqrtf(myMemoryB[i]); } delete []myMemoryA; delete []myMemoryB; } gettimeofday(&myStop, 0);
timersub(&myStop,&myStart,&myResult);
std::cout << "Time: " << myResult.tv_sec*1000 + myResult.tv_usec/1000.0 << std::endl; std::cout << "t1: " << t1 << std::endl; }
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost