Reputation: 1
Why the program did not speed up and become slower than the sequential version? Will it be faster if I change the lock to omp reduction?
The omp code for the calculation avgvalue
Upvotes: 0
Views: 63
Reputation: 149
You have multiple threads running a single critical command. That is basically just as efficient as a serial code since only one thread will execute at a time. And you are also adding overhead by creating multiple threads and having them wait on one another to finish their execution before they can execute.
I think that making a reduction would be faster, since there are optimizations for that command in OpenMP.
Upvotes: 1