I would like to parallelize a code section which executes 2 function calls using OpenMP. I tried using "sections" parameter like this:
int func(int *V1, int *V2, int length){
int result=0;
int i;
for(i=0;i<length;i++){
result = result + V1[i] + V2[i];
}
return result;
}
int main(){
omp_set_num_threads(32);
#pragma omp parallel sections
{
#pragma omp section
{
result1 = func(array_A,array_B,1000000);
}
#pragma omp section
{
result2 = func(array_X,array_Y,2000000);
}
}
}
But I get only like 33% of efficiency (only 1 thread executes each function). For example I would like to use 16 threads to execute each function, but I can't find the solution (I tried using #pragma omp parallel for in each function with no good results).