I want to run two absolutely different functions simultaneously. I tried this to check if it works:
#pragma omp parallel
{
#pragma omp single nowait
{
#pragma omp task
{
for (unsigned long long i=0; i<numSteps; i++)
sum1 = sum1 + 4.0/(1.+ (i + .5)*step*(i + .5)*step);
}
#pragma omp task
{
for (unsigned long long i=0; i<numSteps; i++)
sum2 = sum2 + 4.0/(1.+ (i + .5)*step*(i + .5)*step);
}
#pragma omp taskwait
}
}
With only one cycle it ends in 10s and loads my cpu over 100%.
With 2 cycles that I want to run simultaneously on two different cores it ends in 24s and loads cpu over 200% but I expected near 10s.
Without #pragma omp single nowait
it ends calculations in 138s and loads my cpu over 400%.
What am I doing wrong?