I would like to know if there is a way to parallelize this piece of code in openmp. This loop needs to find next element that must be analyzed in another algorithm. So this loop analyze two vectors visited and used, if it finds an element that is visited but not used, next is equal to k and exit from loop setting k equal to dimension+1, if there aren't elements visited and not used, loop try to find elements not visited and not used and set next=k.
It's important that the statments inside else if don't break loop because there can be element visited in vectors.
for (k=0;k<dimension;k++){
if (visited[k] == 1 && used[k]==0){
next = k;
fail =0;
k=dimension+1;
}
else if (visited[k] == 0 && used[k]==0) {
next = k;
fail = 1;
}
}
How Can I parallelize it with pragma omp for?