How does variable "not_findable" change from line 28 to 30, sometimes.
# g++ -fopenmp a.cppCode:using namespace std; #include <vector> typedef size_t T; #include <assert.h> #include <omp.h> #include <iostream> void foo(T& F_count) { T I=0; bool not_findable=false; bool found=false; #pragma omp parallel { bool finder=false; while(true) { { bool break_out; #pragma omp critica() { if(!not_findable) { if(!(I<F_count)) not_findable=true; ++I; } cerr << not_findable << endl; break_out=not_findable; cerr << not_findable << endl; } if(break_out) break; } { #pragma omp critica() { if(true && !found) { found=true; finder=true; } } if(found) break; } } #pragma omp barrier if(finder) --F_count; } } int main() { T F_count=0; for(T I_count=0;I_count<4;++I_count) { ++F_count; foo(F_count); assert(2<I_count || 0==F_count); } return 0; }
# false;while [ $? != 0 ]; do echo 4 | ./a.out; done