Taskwait construct ================== .. index:: taskwait Apart from implicit synchronization (task data dependences), OmpSs-2 also offers a mechanism that allow users to synchronize task execution. The ``taskwait`` construct is an stand-alone directive (with no code block associated) and specifies a wait on the deep completion of all descendant tasks, including the non-direct children tasks. The syntax of the ``taskwait`` construct is the following:: #pragma oss taskwait [clauses] The valid clauses for the ``taskwait`` construct are the following: * ``on(list-of-variables)``: It specifies to wait only for the subset (not all of them) of descendant tasks that declared a dependency on any of the variables that appear on the list of variables. .. highlight:: c The ``on`` clause allows to wait only on the tasks that produces some data in the same way as the ``inout`` clause. It suspends the current task until all previous tasks with any dependency on the expression are completed. The following example illustrates its use:: int compute1(void); int compute2(void); int main() { int result1, result2; #pragma oss task out(result1) result1 = compute1(); #pragma oss task out(result2) result2 = compute2(); #pragma oss taskwait on(result1) printf("result1 = %d\n", result1); #pragma oss taskwait on(result2) printf("result2 = %d\n", result2); return 0; }