[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 19 10:48:17 PDT 2016


Anastasia added a comment.

In https://reviews.llvm.org/D25343#567374, @tstellarAMD wrote:

> In https://reviews.llvm.org/D25343#565288, @Anastasia wrote:
>
> > Do you have any code example where Clang/LLVM performs wrong optimizations with respect to the control flow of SPMD execution?
> >
> > My understanding from the earlier discussion we have had: https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that noduplicate is essentially enough for the frontend to prevent erroneous optimizations. Because in general compiler can't do much with unknown function calls.
>
>
> noduplicate is enough for correctness, but it prevents legal optimizations, like unrolling loops with barriers.  The convergent attribute was added specifically for these kinds of builtins, so we should be using it here instead of noduplicate.


Should we deprecate noduplicate then as convergent should cover both use cases for OpenCL I believe? As far as I understand noduplicate was added specifically for SPMD use cases...



================
Comment at: include/clang/Basic/AttrDocs.td:630
+  void convfunc(void) __attribute__((convergent));
+  // Setting it as a C++11 attribute is also valid in a C++ program.
+  // void convfunc(void) [[clang::convergent]];
----------------
Did you mean "in an OpenCL program"?


================
Comment at: test/CodeGenOpenCL/convergent.cl:17
+//    } else {
+//      non_conffun();
+//    }
----------------
-> non_convfun();


https://reviews.llvm.org/D25343





More information about the cfe-commits mailing list