I'm using OpenMP in Visual Studio 2010 to speed up loops.
I wrote a very simple test to see the performance increase using OpenMP. I use omp parallel on an empty loop
int time_before = clock();
#pragma omp parallel for
for(i = 0; i < 4; i++){
}
int time_after = clock();
std::cout << "time elapsed: " << (time_after - time_before) << " milliseconds" << std::endl;
Without the omp pragma it consistently takes 0 milliseconds to complete (as expected), and with the pragma it usually takes 0 as well. The problem is that with the opm pragma it spikes occasionally, anywhere from 10 to 32 milliseconds. Every time I tried parallel with OpenMP I get these random spikes, so I tried this very basic test. Are the spikes an inherent part of OpenMP, or can they be avoided?
The parallel for gives me great speed boosts on some loops, but these random spikes are too big for me to be able to use it.