I am using Visual Studio 2015 and need to compile some tree code, which is parallelized with OpenMP tasks like this:
void recursiveFunction(Object *input_obj) {
for(Obj * loop_obj=input_obj->child; loop_obj!= input_obj->child + input_obj->numChildren; loop_obj++) {
#pragma omp task untied if(loop_obj->numValues > 100)
recursiveFunction(loop_obj);
}
#pragma omp taskwait
}
As Visual Studio 2015 does not support OpenMP 3.0 tasks, I need to refactor it using OpenMP 2.0 functions. I do not know what is the best way to do it, i though of something like this
void recursiveFunction(Object *input_obj) {
#pragma omp parallel for
for(int idx =0; idx < input_obj->numChildren;i++) {
// TODO: some code to replace the numValues > 100 condition
Object * loop_obj = obj + i;
recursiveFunction(loop_obj);
}
}
But I think OpenMP tasks will limit the number of threads during the recursion, while the parallel for construct spawns for each loop reached one process per processor (or the number of threads configured).
So what is the most elegant and efficient way to replace the original construct?