I tried to compile the following code with g++ 3.3.3 (g++ -m64 -O3):
#include <vector>
#include <algorithm>
#include <ctime>
#include <cstdio>
using namespace std;
#define BENCH_TYPE double
int main()
{
vector v;
printf("Generating 10M elements\n");
for (int i = 0; i < 10000000; i++)
v.push_back((BENCH_TYPE)(rand()*0.5 + rand()));
printf("generated\nSorting...\n");
clock_t start = clock();
sort(v.begin(), v.end());
clock_t end = clock();
printf("%f\n", (end - start)/((double)CLOCKS_PER_SEC));
return 0;
}
The resulting executable doesn't finish in a minute or so and I have to break
its execution. The funny thing is that the same code compiled with g++ -m64
-O0 finishes in 8 sec or so. What's going on? Any ideas?
I have Suse 9.1 x86_64 with the latest updates of all installed packages.
I wouldn't bother a lot about this test code, if it wasn't for a more serious
problem: I downloaded and installed the latest x86_64 build of the kernel
2.6.5-7.145-default and the nVidia graphics driver stopped working. I
manually downloaded the latest driver from the nVidia web site:
NVIDIA-Linux-x86_64-1.0-6629-pkg2.run and installed it and when I started X
it was painfully slow and I had to kill it.
I don't know if the two problems are related. I would appreciate any help on
any of them. Thanks a lot.