[llvm-dev] [RFC] Goals for VPlan-based cost modelling

Sjoerd Meijer via llvm-dev
Fri, 30 Oct 2020 11:39:55 -0000

Hello Anna,

There was a VPlan round-table at the US LLVM dev conference just a few weeks
ago, and I have linked in the people who were involved in this as cost-modeling
was one of the topics that was discussed. You may have seen this already, but
Dave started doing some work in this area recently:

https://reviews.llvm.org/D89322
https://reviews.llvm.org/D89323

Just some first high-level remarks on your proposal: I think work in this area
would be very valuable and solve a real problem that we currently have. If you
plan to choose this as a subject for a master's thesis, you probably need to
think about how big of a task this is and having some motivating examples would
be good too (but you mentioned some already). To me it sounds like a big task
that needs a lot of plumbing in VPlan, but that's why having this discussion
here is interesting and hopefully people with more VPlan experience can provide
insights.

Cheers,
Sjoerd.


________________________________
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Anna
Sophia Welker via llvm-dev <llvm-dev at lists.llvm.org>
Sent: 30 October 2020 10:08
To: llvm-dev at lists.llvm.org <llvm-dev at lists.llvm.org>
Subject: [llvm-dev] [RFC] Goals for VPlan-based cost modelling

Hi all,

I am looking into the benefits of a VPlan-based cost model, and into how such a
cost model should be implemented to make the most out of these benefits.

Over the last year I have been working with LLVM, mainly focused on the ARM
backend, in the course of a one-year internship at Arm Ltd. My main project from
December 2019 to August 2020 was to introduce gather/scatters for MVE
auto-vectorization. One of the recurring challenges during this work was to get
things right in the cost model.
For example, gathers can extend the data they load, while scatters can truncate
their input, meaning that an extend following the load, or a truncate preceding
the store, is for free if it meets certain type conditions. As the current cost
model is not designed for context-based analysis, this was a pain to model.

I have done some research and found out that one of the proposed benefits of
VPlan is that a new cost model making use of it would be able to better support
context-dependent decisions like this.
However, there does not exist much specification about what such a cost model
should look like.

Also, I have read through the respective code to understand how loop
vectorization is currently done and how far the introduction of VPlan has
progressed and have realised that the only recipe that actually handles more
than one instruction from the input IR is the one for interleaved groups. When
the VPlan is generated on the VPlan-native path, every IR instruction is
considered and transformed into a recipe separately, ignoring its context (to
give a code location, I am looking at
VPlanTransforms::VPInstructionsToVPRecipes).
And maybe there are architectures that for some cases do not have the same
vector instructions, so a pattern that works great for one could be useless for
others. So I am wondering: Is there any plan to have target-dependent flavours
of recipes, or how will those things be handled?
Right now it makes sense that nothing like this has been implemented yet, as
there is no cost model that could guide the transformation. But if recipes are a
general thing, should the cost model be the component actually providing the
target-specific pattern for a recipe, together with its cost?

I am considering choosing a topic related to VPlan, possibly cost modelling, for
my Master thesis, with the goal to present a solution and implement a prototype.

What I would like to ask the community is

(1) what goals there are or should be for VPlan-based cost modelling,
(2) whether there have been any discussions on target-dependent patterns yet,
and
(3) which examples of inefficiencies and shortcomings of the current cost model
they have come across.

I am looking forward to your feedback.

Many thanks,
Anna Welker

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20201030/a786ff54/attachment.html>