[Bug middle-end/100144] [OpenMP] Data race with "omp parallel master taskloop ... shared(scalar)"

2021-04-20 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100144

--- Comment #2 from Tobias Burnus  ---
Sollve_vv's testcase has been fixed:

Issue: https://github.com/SOLLVE/sollve_vv/issues/324
Patch test_parallel_master_taskloop.c:
https://github.com/SOLLVE/sollve_vv/pull/325
Patch test_parallel_master_taskloop_device.c:
https://github.com/SOLLVE/sollve_vv/pull/326

[Bug middle-end/100144] [OpenMP] Data race with "omp parallel master taskloop ... shared(scalar)"

2021-04-19 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100144

--- Comment #1 from Jakub Jelinek  ---
This looks just like a bogus assumption in the testcase.
The taskloop directive says that the iterations are split into some tasks.  As
neither num_tasks nor graintsize clauses are specified, it is implementation
defined into how many tasks it is split.
But even when those would be specified, there is still no guarantee that the
master thread will execute any of those explicit threads, it can easily happen
that while the master thread creates the tasks other threads pick those tasks
already and there is no task left for the master thread.
The test should better use if (i == 0) num_threads = omp_get_num_threads();
then it has a guarantee that it will be executed exactly once.