[PATCH] D27249: [LoopVectorize] Use OpenMP vector routines.

Francesco Petrogalli via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 02:49:58 PST 2016


fpetrogalli added a comment.

In https://reviews.llvm.org/D27249#610351, @rengolin wrote:

> Just a high level question: why can't this extend the same insert mechanism we already use for the other vectorised functions, instead of creating a new one for OpenMP?


Hi Renato,

I am preparing a RFC email for the dev channel explaining my view on
this change. My short answer here is that the mapping ("scalar name" ,
"vectorization factor (VF)") into "vector name" that is currently
implemented in the TLI does not cover all the signatures of the
multiple vector variants that can be associated to a scalar function
by means of attaching "declare simd" directive to the function
declaration or definition.

Consider this example:

  #pragma omp declare simd
  #pragma omp declare simd uniform(y)
  double pow(double x, double y)

In this case the user is asking the compiler to be aware of two vector
version available. With the current mapping it would generate two
entries for each VF (assuming VF = 4):

  ("pow", 4) -> "pow_vector_vector"
  ("pow", 4) -> "pow_vector_uniform_vector"

I made up the vector names, but you can see that with this mapping the
vectorizer doesn't have a way to choose the vector_vector version over
the vector_uniform_vector one. Of course, one could implement a "name
generation" in the vectorizer and search over the full triple
(scalar_name, VF, vector_name) until a match is found, but such
vector_name generator in the vectorizer should be target dependent, as
each architecture will come up with it's own vector ABI that mangle
the scalar name into the vector name.

With this solution one could rely in the vector signature of the
function using the multimap that maps scalar names into (vector names,
vector signatures).

In this case, the "pow" example before would generates this item in
the multimap:

  "pow" -> [(pow_vector_vector, <double x 4>(<double x 4>,<double x 4>)),
            (pow_vector_uniform_vector, <double x 4>(<double x 4>, double))]

The "pow_vector_uniform_vector" here is clearly different because the
uniform parameter is kept as a scalar. This is just an example, things
can get even more complicated when both "linear" (and associated
modifiers "var", "uval", "val" and "ref") are used in directive.

With this multimap, the vectorizer wouldn't have to make up the vector
name for the matching. I think this is better because it skips the
need to write a target-dependent vector ABI name mangling method in
the vectorizer.

I am aware that	the signature mapping method is not complete -
e.g. how do distinguish a step=2 from a step=3 in a linear clause of
the same parameter in the function signature. Nevertheless, even in
this situation using the function signature has the advantage of
providing a structure (the FunctionType) that can be used to attach
linear/uniform descriptors to vector or scalar parameters without
introducing new structures holding the parameter position.

I'll add this comment to the RFC, and extend it	with more examples.

Cheers,

Francesco


https://reviews.llvm.org/D27249





More information about the llvm-commits mailing list