https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97649

            Bug ID: 97649
           Summary: OpenMP: 'target teams' with host-fallback: race
                    condition according to TSAN
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: openmp
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Created attachment 49474
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49474&action=edit
Test case - run with: -fopenmp -fsanitize=thread -foffload=disable

Based on https://github.com/SOLLVE/sollve_vv/pull/226/files

If I use
  #pragma omp teams distribute parallel for ...
TSAN is happy.

However, if I nest this in 'target'
  #pragma omp target teams distribute parallel for ...

and run it with host fallback (here: compiler not configured for offloading)
TSAN complains that
- one thread is already reading the value in loop 3
- while another one is writing to it in loop 2.

(If I don't use TSAN, it passes on the host and also with nvptx offloading,
but does does not rule out any race condition, either.)


With -O0, I get one error:

WARNING: ThreadSanitizer: data race (pid=2194215)
  Read of size 4 at 0x7ffc78d34718 by main thread:
    #0 test_target_teams_distribute_parallel_for_collapse <null>
(a.out+0x40239f)
    #1 main <null> (a.out+0x401144)

  Previous write of size 4 at 0x7ffc78d34718 by thread T1:
    #0 test_target_teams_distribute_parallel_for_collapse._omp_fn.1 <null>
(a.out+0x401572)
    #1 gomp_thread_start ../../../repos/gcc/libgomp/team.c:123
(libgomp.so.1+0x1ce05)


With -O3, I get plenty.

Reply via email to