1)How are you measuring time? I suggest you use omp_get_wtime ()
I measure time as follows:
- Code: Select all
clock_t start, stop;
start = clock();
stop = clock();
cout << ((double)(stop - start)/1000.0) << "sec\n";
but it is not so important.
2) How much runtime is involved?
Sequential code is executed for ~0 milliseconds. Parallel code with the directive Atomic runs for 0.34 milliseconds. Parallel code without directive Atomic runs for ~0 milliseconds, but it gives a wrong result.
3) Compiler? Compiler options? Computer?
Intel Core 2 CPU 6300 @ 1.86GHz, MS Windows 7 Ultimate x64, Visual Studio 2010 Pro, Intel Parallel Studio XE 2011
In this case, I've simplified algorithm. In fact, the program runs a few minutes because of this I want this code to parallel. Possible to replace the directive atomic to something else? Or, for example, do not use the directives. And to use a functions? Or need to change the algorithm, although this algorithm is simple