http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55251
Bug #: 55251 Summary: inconsistent OpenMP tasks scheduling Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp AssignedTo: unassig...@gcc.gnu.org ReportedBy: alfredo.butt...@gmail.com I have problems when executing a standard OpenMP tasks example from the OpenMP 3.1 API document (Example A.15.2c): struct node { struct node *left; struct node *right; }; extern void process(struct node *); void postorder_traverse( struct node *p ) { if (p->left) #pragma omp task // p is firstprivate by default postorder_traverse(p->left); if (p->right) #pragma omp task // p is firstprivate by default postorder_traverse(p->right); #pragma omp taskwait process(p); } int main(){ ... #pragma omp parallel { #pragma omp master { postorder_traverse(root); } } ... The problem is related to the scheduling of tasks. I want to count the number of tasks executed by each OpenMP thread to check whether the workload distribution is balanced. Now, if I use two threads then the tasks are pretty much equally distributed. If I use 3 or 4 threads, the master thread always executes only one task (corresponding to the root, topmost node of the tree). With more than 4 threads the behavior is inconsistent in the sense that sometimes the tasks are well distributed, sometimes the master does only one task. Is this a bug? This happens with different versions of gcc from 4.4 up to 4.7 but not with the intel compiler. Thanks Alfredo