Page 1 of 1

final tasks

PostPosted: Tue Dec 22, 2015 12:20 am
by fohry
Hi,

I've a question on Example 13c (p. 62) of OpenMP Examples Version 4.0.2:

According to the OpenMP 4.5 (or 4.0) specification, a task is final if
it enforces its CHILDREN to become included tasks. As to my
understanding of the standard (and confirmed by experiments with g++
4.9.0), the task itself is not included, though.

In Example 13c, let's set LIMIT=-1, such that the condition in final
always evaluates to true. Then, in the topmost call of bin_search, the
tasks in lines S-11 and S-21 are final, but these two tasks may still be
run in parallel (only their children are included).

So omp_in_final() evaluates to true, and lines S-15-16 and S-25/26 are
NOT executed. The state variable is firstprivate by default, but to my
understanding only the pointer is copied, and not the memory area it
points to. Consequently, it seems as that lines S-18 and S-28 of the two
parallel tasks write concurrently to the same memory location.

Have I misunderstood something, or how can the problem be resolved?

Best regards,

Claudia