i've been trying to learn how to use OpenMP for c++ and i'm having a huge headache trying to apply it to a code that uses the Riemann Zeta function, i only found it this way(in the code), but if you run it you will see that the serial process is way faster. Can anyone help me to find why the serial is faster than the parallel?
double rzfParallel(int n, long inf)
{
double sum = 0.0;
#pragma omp parallel for reduction(+:sum) num_threads(8)
for(int k = 1; k <= inf; k++)
sum += 1.0/pow(k, (double)n);
return sum;
}
The method to chath time:
startTime = clock();
funcResult = rzfParallel(n, inf);
endTime = clock();
timeResult = (endTime/CLOCKS_PER_SEC) -(startTime/CLOCKS_PER_SEC);
I solved this with the flag -mavx in the Intel compiler. I'm trying to understand the problem, not sure yet. Something that my processor wasn't vectorizing. Still cant get a -vec-report. If anyone know how to do it, please tell me. Special thanks to NoseKnowsAll