Skip to content

Commit

Permalink
[VPlan] Document current status. (#85689)
Browse files Browse the repository at this point in the history
Update VectorizationPlan.rst to include a section about the current
status of VPlan and its use in LoopVectorize, based on "VPlan: Status
Update and Future Roadmap", LLVM Developers’ Meeting 2023,
https://www.youtube.com/watch?v=SzGP4PgMuLE

PR: #85689
  • Loading branch information
fhahn committed May 16, 2024
1 parent 03d8e61 commit 99de3a6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
63 changes: 53 additions & 10 deletions llvm/docs/VectorizationPlan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,49 @@ candidates. It serves for both optimizing candidates including estimating their
cost reliably, and for performing their final translation into IR. This
facilitates dealing with multiple vectorization candidates.

Current Status
==============
VPlan is currently used to drive code-generation in LoopVectorize. VPlans are
constructed after all cost-based and most legality-related decisions have been
taken. As def-use chains between recipes are now fully modeled in VPlan,
VPlan-based analyses and transformations are used to simplify and modularize
the vectorization process [10]_. Those include transformations to

1. Legalize the initial VPlan, e.g. by introducing specialized recipes for
reductions and interleave groups.

2. Optimize the legalized VPlan, e.g. by removing redundant recipes or
introducing active-lane-masks.

3. Apply unroll- and vectorization-factor specific optimizations, e.g. removing
the backedge to reiterate the vector loop based on VF & UF.

Refer to :numref:`fig-vplan-transform-pipeline` for an overview of the current
transformation pipeline.

Note that some legality checks are already done in VPlan, including checking if
all users of a fixed-order recurrence can be re-ordered. This is implemented as
a VPlan-to-VPlan transformation that either applies a valid re-ordering or
bails out marking the VPlan as invalid.

.. _fig-vplan-transform-pipeline:
.. figure:: ./vplan-transform-pipeline.png
:width: 800 px

VPlan Transformation Pipeline in 2024


VPlan currently models the complete vector loop, as well as additional parts of
the vectorization skeleton. Refer to :numref:`fig-vplan-scope` for an overview
of the scope covered by VPlan.

.. _fig-vplan-scope:
.. figure:: ./vplan-scope.png
:width: 800 px

Scope modeled in VPlan in 2024


High-level Design
=================

Expand Down Expand Up @@ -160,13 +203,10 @@ The low-level design of VPlan comprises of the following classes.
VPValues.

:VPInstruction:
A VPInstruction is both a VPRecipe and a VPUser. It models a single
VPlan-level instruction to be generated if the VPlan is executed, including
its opcode and possibly additional characteristics. It is the basis for
writing instruction-level analyses and optimizations in VPlan as creating,
replacing or moving VPInstructions record both def-use and scheduling
decisions. VPInstructions also extend LLVM IR's opcodes with idiomatic
operations that enrich the Vectorizer's semantics.
A VPInstruction is a recipe characterized by a single opcode and optional
flags, free of ingredients or other meta-data. VPInstructions also extend
LLVM IR's opcodes with idiomatic operations that enrich the Vectorizer's
semantics.

:VPTransformState:
Stores information used for generating output IR, passed from
Expand All @@ -177,9 +217,9 @@ The Planning Process and VPlan Roadmap
======================================

Transforming the Loop Vectorizer to use VPlan follows a staged approach. First,
VPlan is used to record the final vectorization decisions, and to execute them:
the Hierarchical CFG models the planned control-flow, and Recipes capture
decisions taken inside basic-blocks. Next, VPlan will be used also as the basis
VPlan was only used to record the final vectorization decisions, and to execute
them: the Hierarchical CFG models the planned control-flow, and Recipes capture
decisions taken inside basic-blocks. Currently, VPlan is used also as the basis
for taking these decisions, effectively turning them into a series of
VPlan-to-VPlan algorithms. Finally, VPlan will support the planning process
itself including cost-based analyses for making these decisions, to fully
Expand Down Expand Up @@ -248,3 +288,6 @@ References
.. [9] "Extending LoopVectorizer: OpenMP4.5 SIMD and Outer Loop
Auto-Vectorization", Intel Vectorizer Team, LLVM Developers' Meeting 2016.
.. [10] "VPlan: Status Update and Future Roadmap", Florian Hahn, LLVM
Developers' Meeting 2023, https://www.youtube.com/watch?v=SzGP4PgMuLE
1 change: 1 addition & 0 deletions llvm/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
# If false, no module index is generated.
# latex_domain_indices = True

numfig = True

# -- Options for manual page output --------------------------------------------

Expand Down
Binary file added llvm/docs/vplan-scope.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added llvm/docs/vplan-transform-pipeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 99de3a6

Please sign in to comment.