Hi!

The second part of the cancel-taskgroup-3.c ICEs on hosts that have more
than 64 CPUs (cores or threads).  The problem is that the cancellation of
the taskgroup happens in the worksharing loop that iterates 64 times only,
so if each thread invokes just a single iteration, threads 64 and above
don't have their taskgroup cancelled.

The following patch checks this through a threadprivate variable, records in
each thread if the corresponding taskgroup has been cancelled and asserts
the following task is not executed only if the taskgroup should have been
cancelled.

Tested on powerpc64le-linux and bootstrapped/regtested on x86_64-linux and
i686-linux, committed to trunk.

2018-12-08  Jakub Jelinek  <ja...@redhat.com>

        PR libgomp/87995
        * testsuite/libgomp.c-c++-common/cancel-taskgroup-3.c: Require
        tls_runtime effective target.
        (t): New threadprivate variable.
        (main): Set t in threads which execute iterations of the worksharing
        loop.  Propagate that to the task after the loop and don't abort
        if the current taskgroup hasn't been cancelled.

--- libgomp/testsuite/libgomp.c-c++-common/cancel-taskgroup-3.c.jj      
2018-11-08 18:08:04.074943776 +0100
+++ libgomp/testsuite/libgomp.c-c++-common/cancel-taskgroup-3.c 2018-12-07 
18:14:49.663319896 +0100
@@ -1,9 +1,12 @@
-/* { dg-do run } */
+/* { dg-do run { target tls_runtime } } */
 /* { dg-set-target-env-var OMP_CANCELLATION "true" } */
 
 #include <stdlib.h>
 #include <omp.h>
 
+int t;
+#pragma omp threadprivate (t)
+
 int
 main ()
 {
@@ -42,11 +45,12 @@ main ()
   #pragma omp parallel
   #pragma omp taskgroup
   {
-    #pragma omp taskwait
+    int p;
     #pragma omp for reduction (task, +: a)
     for (i = 0; i < 64; ++i)
       {
        a++;
+       t = 1;
        #pragma omp task in_reduction (+: a)
        {
          volatile int zero = 0;
@@ -58,9 +62,10 @@ main ()
       }
     if (a != 64)
       abort ();
-    #pragma omp task
+    p = t;
+    #pragma omp task firstprivate (p)
     {
-      if (omp_get_cancellation ())
+      if (p && omp_get_cancellation ())
        abort ();
     }
   }

        Jakub

Reply via email to