[PATCH] Adding support for NoDuplicate function attribute in CLang

Pekka Jääskeläinen pekka.jaaskelainen at tut.fi
Thu Nov 21 01:55:07 PST 2013


On 11/21/2013 11:23 AM, David Tweed wrote:
> My understanding of what was happening was that a _particular implementation_ of
> OpenCL would have the ability to add the noduplicate attribute on its
> declaration of
> barriers if that's necessary given their implementation of the barrier; if an
> implementation
> doesn't need it it can declare barrier without the qualifier.

Alright. noduplicate is a safe assumption for the current opt passes in
LLVM, but it could be loosened if the optimization knows what it's doing and
it knows it's dealing with a barrier or other call with work-group
level semantics. Function name matching should be enough here to find it's
a barrier (or other WG-level function).

> If the first example was written such that the inner condition was actually
> based upon
> an unknowable-but-uniform variable, then I can't see an issue with that. The
> question is how often
> one gets a condition which is a uniform variable which doesn't turn out to be
> trivially determined
> so that dead code elimination which means the end code has only one barrier.

Should not be common as such code should be avoided in OpenCL kernels to
improve the performance portability, but as it might not be so bad for SPMD
machines with program counters in processing elements or other runtime
lane masking, the coder might not think about it before trying to port
the performance to another machine, e.g., with static width SIMD
instructions.

-- 
Pekka



More information about the cfe-commits mailing list