jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8332163: C2 SuperWord: refactor PacksetGraph and SuperWord::output into VTransformGraph

Open eme64 opened this issue 8 months ago • 6 comments

The original PR was here, it got too chaotic.

I added some extra tests for this in: https://github.com/openjdk/jdk/pull/19558 I extracted some refactorings to: https://github.com/openjdk/jdk/pull/19573

We used to have:

  • PacksetGraph: this detects cycles introduces by packs, and schedules/reorders the memops.
  • SuperWord::apply_vectorization: creates VectorNodes directly from the PackSet.

In my blog, I have published lots of ideas for SuperWord / AutoVectorization improvements: https://eme64.github.io/blog/2023/11/03/C2-AutoVectorizer-Improvement-Ideas.html

Many ideas are based on the "VectorTransform IR": cost-model, if-conversion, direct widening of scalars to vectors, additional optimizations/features with shuffle/pack/extract, handling more reduction patterns, etc.

I now decided to name it VTransform, which is essencially a graph VtransformGraph of nodes VTransformNodes that resemble the C2 Node on purpose, because the VTransform models the C2 graph after vectorization. We can now model the transformation from scalar-loop to vectorized-loop without modifying the C2 graph yet.

The new code has these steps:

  • Given the PackSet from SuperWord, we create a VTransformGraph with SuperWordVTransformBuilder.
  • [Not yet: all sorts of optimizations / checks on the VTransformGraph, in future RFE's]
  • We then schedule the VTransformGraph, and check for cycles.
  • Once we are ready to commit to vectorization, we call VTransformGraph::apply_vectorization which lets each individual VTransformNode::apply generate the new vectorized C2 nodes.

Testing

Regression testing passed.

Performance testing: no significant change in performance (as expected).


Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Issue

  • JDK-8332163: C2 SuperWord: refactor PacksetGraph and SuperWord::output into VTransformGraph (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19719/head:pull/19719
$ git checkout pull/19719

Update a local copy of the PR:
$ git checkout pull/19719
$ git pull https://git.openjdk.org/jdk.git pull/19719/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19719

View PR using the GUI difftool:
$ git pr show -t 19719

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19719.diff

Webrev

Link to Webrev Comment

eme64 avatar Jun 14 '24 10:06 eme64