This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Fix tasking + parallel bug
ClosedPublic

Authored by jlpeyton on Jul 30 2018, 11:12 AM.

Details

Summary

From the bug report, the runtime needs to initialize the nproc variables (inside middle init) for each root when the task is encountered, otherwise, a segfault can occur.

Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=36720

Diff Detail

Repository
rL LLVM

Event Timeline

jlpeyton created this revision.Jul 30 2018, 11:12 AM
Hahnfeld requested changes to this revision.Jul 30 2018, 11:53 AM

This doesn't seem to work with GOMP interface. I think the initialization should be moved to __kmp_task_alloc (or __kmp_omp_task, is there a reason this has to happen when allocating?)?

This revision now requires changes to proceed.Jul 30 2018, 11:53 AM

This doesn't seem to work with GOMP interface. I think the initialization should be moved to __kmp_task_alloc (or __kmp_omp_task, is there a reason this has to happen when allocating?)?

Yes, should be fine to move it to __kmp_task_alloc. An alternative would be to change middle initialization to initialize nproc not only for current task, but for all its parents, that looks a bit trickier to write at first glance...

Regarding __kmp_omp_task - this looks worse, because it may be skipped. E.g. Intel compiler can skip it for "task if(0)". So the allocation routine looks preferable.

Regarding __kmp_omp_task - this looks worse, because it may be skipped. E.g. Intel compiler can skip it for "task if(0)". So the allocation routine looks preferable.

Ah yes, that makes sense.

jlpeyton updated this revision to Diff 158040.Jul 30 2018, 12:30 PM

Moved middle init to __kmp_task_alloc()

Hahnfeld accepted this revision.Jul 30 2018, 12:58 PM

LGTM, fixes the provided test case. Thanks for the fast fix!

This revision is now accepted and ready to land.Jul 30 2018, 12:58 PM
This revision was automatically updated to reflect the committed changes.