20

Graal Autovectorization

 4 years ago
source link: https://www.tuicool.com/articles/fYFziaM
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Graal Autovectorization

Here's our first prototype for Autovectorization in Graal, as mentioned in our email to the graal-dev mailing list in July .

The feature can be enabled using the -Dgraal.Autovectorize=true flag. It's disabled by default.

Current status

  • Implementation of the SLP algorithm .
  • Operand packing and extraction.
  • Code generation for AMD64.
  • Not limited to loops.
    The current implementation vectorizes everything to stress-test the implementation.
  • Vector stamps.
  • We're passing all mx unittest tests.
  • Scimark 2.0 (but it's currently significantly slower, due to loop unrolling limitations & lack of a heuristic).
  • Support for arbitrary vector lengths (within the vector register limit).

Caveats

  • Unrolling/ bounds elimination
    The CE LoopPartialUnrollPhase does not unroll loops containing array accesses due to guard lowering. We've explored several alternatives to this, like a separate unroll phase that runs before lowering, but this is also not ideal. Right now we have chosen to use one LoopPartialUnrollPhase so the implementation currently does not leverage SLP in loops.
  • Heuristic
    We need to develop a heuristic to restrict vectorization to cases where it is beneficial. Right now we vectorize everything and performance takes a hit as a result. Heuristics that we need are: A loop unrolling heuristic, pair packing savings heuristic, pack filtering heuristic.

There are a few areas where we're unsure of the approach to take, as we don't want to break anything on the EE side. We'll explicitly call out areas in the patch in places where we think there might be a better approach.

@nvgrw @ddegazio @usrinivasan @christhalinger


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK