Is there any way I could use openMP to parallelize a loop with a list that might have more elements added each iteration? As far as I understand openMP can parallelize a for loop by diving the range in chunks for each thread, but in this case the range changes, for one case the loop might have 10 iterations and for another one 100, the thing is that in the list I will usually have around 10-20 elements.
Here's an example of what I'd like to parallelize (note that the order in which things are inserted into the vectorOfResults doesn't matter)
while(!list.empty()) {
vectorOfResults.push_back(performExpensiveFunction());
if (conditions) {
add new elements to the list;
}
}
I've been thinking about doing something like, inside the while loop, have a for loop with the current "batch" of elements in the list (copy them in a temporary list) and then the next while iteration will use the newly added elements, but I was thinking if there was a way to do this using other openmp constructs. (I only now a little bit about openmp).
Thanks for your help.