(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
task-detach-2.c
       1  /* { dg-do run } */
       2  
       3  #include <omp.h>
       4  #include <assert.h>
       5  
       6  /* Test handling of detach clause with only a single thread.  The runtime
       7     should not block when a task with an unfulfilled event finishes
       8     running.  */
       9  
      10  int main (void)
      11  {
      12    omp_event_handle_t detach_event1, detach_event2;
      13    int x = 0, y = 0, z = 0;
      14  
      15    #pragma omp parallel num_threads (1)
      16      #pragma omp single
      17      {
      18        #pragma omp task detach (detach_event1)
      19  	x++;
      20  
      21        #pragma omp task detach (detach_event2)
      22        {
      23  	y++;
      24  	omp_fulfill_event (detach_event1);
      25        }
      26  
      27        #pragma omp task
      28        {
      29  	z++;
      30  	omp_fulfill_event (detach_event2);
      31        }
      32      }
      33  
      34    assert (x == 1);
      35    assert (y == 1);
      36    assert (z == 1);
      37  }