Commit 4ea2494
Jonathan Peyton
[OpenMP] Fix nested parallel with tasking (#87309)
When a nested parallel region ends, the runtime calls __kmp_join_call().
During this call, the primary thread of the nested parallel region will
reset its tid (retval of omp_get_thread_num()) to what it was in the
outer parallel region. A data race occurs with the current code when
another worker thread from the nested inner parallel region tries to
steal tasks from the primary thread's task deque. The worker thread
reads the tid value directly from the primary thread's data structure
and may read the wrong value.
This change just uses the calculated victim_tid from execute_tasks()
directly in the steal_task() routine rather than reading tid from the
data structure.
Fixes: #873071 parent f119a4f commit 4ea2494
2 files changed
Lines changed: 52 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3219 | 3219 | | |
3220 | 3220 | | |
3221 | 3221 | | |
3222 | | - | |
| 3222 | + | |
3223 | 3223 | | |
3224 | 3224 | | |
3225 | 3225 | | |
| |||
3229 | 3229 | | |
3230 | 3230 | | |
3231 | 3231 | | |
3232 | | - | |
| 3232 | + | |
3233 | 3233 | | |
3234 | 3234 | | |
3235 | 3235 | | |
3236 | 3236 | | |
3237 | 3237 | | |
| 3238 | + | |
| 3239 | + | |
3238 | 3240 | | |
3239 | | - | |
3240 | 3241 | | |
| 3242 | + | |
| 3243 | + | |
3241 | 3244 | | |
3242 | 3245 | | |
3243 | 3246 | | |
| |||
3452 | 3455 | | |
3453 | 3456 | | |
3454 | 3457 | | |
3455 | | - | |
3456 | | - | |
3457 | | - | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
3458 | 3461 | | |
3459 | 3462 | | |
3460 | 3463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments