Why is the parallel application taking more time to execute than the one with the single thread? I am using an 8 CPU computer with Ubuntu 14.04. The code is just my simple way to test omp parallel sections, the aim later is to run two different functions in two different threads at the same time, so I do not want to use #pragma omp parallel for.
parallel:
int main()
{
int k = 0;
int m = 0;
omp_set_num_threads(2);
#pragma omp parallel
{
#pragma omp sections
{
#pragma omp section
{
for( k = 0; k < 1e9; k++ ){};
}
#pragma omp section
{
for( m = 0; m < 1e9; m++ ){};
}
}
}
return 0;
}
and the single thread:
int main()
{
int m = 0;
int k = 0;
for( k = 0; k < 1e9; k++ ){};
for( m = 0; m < 1e9; m++ ){};
return 0;
}