[LLVMdev] parallel loop awareness to the LoopVectorizer

Preston Briggs preston.briggs at gmail.com
Mon Jan 28 10:41:00 PST 2013


About these disclaimers associated with ivdep and such...
You guys are overthinking it. They're just saying you cannot force the
compiler to vectorize or parallelize a loop that it knows (can prove!) is
not a parallel loop. They are not obliging the compiler to do dependence
analysis or alias analysis or anything.

For example

len = 0;
while (A[i]) {
  i++;
  len++;
}


Assert all you want; the compiler won't parallelize the loop, and a good
thing too.

Preston




> > From: "Pekka Jääskeläinen" <pekka.jaaskelainen at tut.fi>
> > To: "Hal Finkel" <hfinkel at anl.gov>
> > Cc: "Nadav Rotem" <nrotem at apple.com>, "LLVM Developers Mailing List" <
> llvmdev at cs.uiuc.edu>
> > Sent: Monday, January 28, 2013 11:36:21 AM
> > Subject: Re: [LLVMdev] [PATCH] parallel loop awareness to the
> LoopVectorizer
> >
> > On 01/28/2013 06:51 PM, Hal Finkel wrote:
> > > Is this sufficient to implement #pragma ivdep in clang?
> >
> > I'm not completely sure of this:
> >
> > "Note: The proven dependencies that prevent vectorization are not
> > ignored,
> > only assumed dependencies are ignored."
> >
> >
> http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/cref_cls/common/cppref_pragma_ivdep.htm
> >
> > Thus, there's a slight difference. It cannot be used to disable
> > dependency
> > checking altogether (and just blame a sloppy programmer if there
> > actually
> > are dependencies), but it just converts the "unknown alias" to "no
> > alias".
> > If there's a "yes" from the analyzer it still prevents the
> > vectorization.
> > So, sort of a softened programmer-friendlier version of the
> > semantics.
> >
> > The vagueness comes from that it depends on the intelligence
> > of the dependency analysis implementation whether a dependency can be
> > "proven"
> > or not, doesn't it? Thus, #pragma ivdep with a non-existing
> > loop dependence analyzer is equivalent to the semantics of the
> > proposed
> > metadata.
>
> And the user has no way of knowing which dependencies are proven and which
> are assumed, right? It seems like the user just needs to assume that
> nothing is proven ;) Nevertheless, based on this, we probably do need
> something with slightly weaker semantics for ivdep.
>
> >
> > Also, it's a bit unclear what is the real difference to the #pragma
> > parallel:
> >
> http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/cref_cls/common/cppref_pragma_parallel.htm
> >
> > It similarly states: "However, if dependencies are proven, they are
> > not
> > ignored." So conversely, if the compiler cannot prove a dependency
> > for
> > some reason, they *are* ignored?
>
> Interesting.
>
> >
> > OpenMP's 'omp for', on the other hand, can be used to mark a truly
> > parallel
> > loop where this metadata could be used if one wants to parallelize
> > those
> > loops using a finer-granularity mechanism than threads.
>
> Agreed; we should make sure to incorporate this into the upcoming OpenMP
> support. The loops will be outlined, but the outlined pieces can then be
> marked with this 'parallel' metadata.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130128/b7d916ed/attachment.html>


More information about the llvm-dev mailing list