[Omp] repeated encounters of work-sharing constructs
Richard Henderson
rth at twiddle.net
Sat Mar 26 13:56:30 PST 2005
I'm thinking of the following toy,
int main()
{
#pragma omp parallel num_threads(6)
{
int nthr = omp_get_num_threads ();
int iam = omp_get_thread_num ();
for (int i = 0; i < 5; i++)
{
#pragma omp for nowait schedule(dynamic,2)
for (int j = 0; j < nthr * 2; ++j)
sleep (iam + 1);
}
}
}
The idea being that thread 0 will complete the inner loop in 2 seconds,
and the entire parallel in 10 seconds. While thread 5 will take 12
seconds to complete the inner loop and 60 seconds to entire parallel.
So thread 0 will have completed all 5 iterations of the inner loop and
block at the implicit barrier at the end of the parallel before thread 5
has completed its first iteration.
My question is whether or not this is a legal use of the nowait clause.
It doesn't *appear* to violate the execution model in section 1.3, in
that all threads do encounter the 5 iterations of the for work-share
in the same order.
I guess I am merely hoping that the answer is no such that I do not in
fact need to do the bookkeeping required to track N simultaneous
instantiations of the same (i.e. lexically same) work-share construct...
r~
More information about the Omp
mailing list