[llvm-dev] AMDGPU and support for the new pass manager
Sharma, Reshabh Kumar via llvm-dev
llvm-dev at lists.llvm.org
Thu Jan 7 21:18:58 PST 2021
[AMD Official Use Only - Internal Distribution Only]
Hi Arthur,
I was looking into porting the IR passes in to the NPM more than a year ago. Let me get back to you with more concrete answers.
Many thanks,
Reshabh
From: Arthur Eubanks via llvm-dev<mailto:llvm-dev at lists.llvm.org>
Sent: Friday, January 8, 2021 1:58 AM
To: Matt Arsenault<mailto:arsenm2 at gmail.com>; llvm-dev<mailto:llvm-dev at lists.llvm.org>; nhaehnle at gmail.com<mailto:nhaehnle at gmail.com>
Subject: Re: [llvm-dev] AMDGPU and support for the new pass manager
[CAUTION: External Email]
We're sorting out the custom inliner in https://reviews.llvm.org/D94153<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD94153&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000259582%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=wESrgfOchjmGwMu4wl553fTymdbPnvoasjcF%2B9Q%2Fpnk%3D&reserved=0>.
As for LegacyDivergenceAnalysis and Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll, if there's no response, I'll just pin the test to the legacy PM, since it's testing an AMDGPU-specific optimization setting (disabling loop unswitching on divergent loop conditions). If there are noticeable performance regressions related to this due to the NPM switch, the AMDGPU community can temporarily use the legacy PM and then port the relevant analysis passes and fix up loop unswitching for AMDGPU.
Then we should be good to go for turning on the new PM for opt when it's specified on the CMake command line.
On Mon, Jan 4, 2021 at 2:16 PM Arthur Eubanks <aeubanks at google.com<mailto:aeubanks at google.com>> wrote:
I've ported most of the IR passes and added them to AMDGPU's opt pipeline.
There are 2 issues remaining:
1) LegacyDivergenceAnalysis is used in LoopUnswitch to avoid unswitching loops with divergent condition Values. I'm not sure what the state of the LegacyDivergenceAnalysis vs DivergenceAnalysis is. (Also the new PM only has SimpleLoopUnswitch instead of LoopUnswitch).
Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll.
2) The AMDGPU backend has its own inliner<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fblob%2Fmain%2Fllvm%2Flib%2FTarget%2FAMDGPU%2FAMDGPUInline.cpp&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000269575%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Y52BAjZbnZxzTYnMNpAzFh5A8GsC9AJcgxqR9xwYqT8%3D&reserved=0> (set here<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fblob%2F92be640bd7d4fbc8e032a0aa81381a0246efa0be%2Fllvm%2Flib%2FTarget%2FAMDGPU%2FAMDGPUTargetMachine.cpp%23L438&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000279572%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=AKsWY951zKzuz6YfLpbBEoywQQWh1SMqu38HbOPIX4I%3D&reserved=0>). Any ideas for how to do custom inliner cost modeling in the new PM pipelines? Allow targets to override an analysis pass that the inliner uses to get an InlineAdvisor?
CodeGen/AMDGPU/amdgpu-inline.ll
On Fri, Dec 4, 2020 at 4:44 PM Arthur Eubanks <aeubanks at google.com<mailto:aeubanks at google.com>> wrote:
Some indicative failing tests are under the llvm/test/CodeGen/AMDGPU directory when opt's -enable-new-pm flag is set to true by default. They should also be repro'able by adding a corresponding NPM RUN line, e.g. "opt -S -O1 -mtriple=amdgcn-- ..." -> "opt -S -passes='default<O1>' -mtriple=amdgcn-- ...".
I see the following AMDGPU-specific failures:
LLVM :: CodeGen/AMDGPU/amdgpu-inline.ll
LLVM :: CodeGen/AMDGPU/infer-addrpace-pipeline.ll
LLVM :: CodeGen/AMDGPU/internalize.ll
LLVM :: CodeGen/AMDGPU/llvm.amdgcn.wavefrontsize.ll
LLVM :: CodeGen/AMDGPU/opt-pipeline.ll
LLVM :: CodeGen/AMDGPU/propagate-attributes-clone.ll
LLVM :: CodeGen/AMDGPU/propagate-attributes-single-set.ll
LLVM :: CodeGen/AMDGPU/simplify-libcalls.ll
LLVM :: CodeGen/AMDGPU/sroa-before-unroll.ll
LLVM :: Transforms/LoopUnswitch/AMDGPU/divergent-unswitch.ll
(Also I took a closer look, actually it looks like NVPTX also needs updating, but NVPTXTargetMachine only adds two passes)
On Fri, Dec 4, 2020 at 3:48 PM Arthur Eubanks <aeubanks at google.com<mailto:aeubanks at google.com>> wrote:
Currently AMDGPU is the last target which injects passes into the pipeline but hasn't been updated to work with the new pass manager.
Recently there was added support for the NPM's equivalent of TargetMachine::adjustPassManager(). (Bug<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.llvm.org%2Fshow_bug.cgi%3Fid%3D47244&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000279572%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=KrpH97uBBJkHUdP8vwCBE1N9Dfr7gcPvJ2sniJ%2F1byE%3D&reserved=0>, Phab<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD88138&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000289565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=lPG91RO7BATJFI8fkQ7XYSq5OavGhsUpjtRHT0uHwQ4%3D&reserved=0>). BPF<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fblob%2F99f79cbf31cc6ccdfa1aed253a64c5e8012f4ef7%2Fllvm%2Flib%2FTarget%2FBPF%2FBPFTargetMachine.cpp%23L126&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000289565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Uh3RM2sPGz7%2BFF5o3pG60CqRAchFbq%2FtsEbkjkS%2F1TU%3D&reserved=0> and Hexagon have their NPM equivalents implemented already, but AMDGPU has a lot of custom passes added by adjustPassManager<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fblob%2F99f79cbf31cc6ccdfa1aed253a64c5e8012f4ef7%2Fllvm%2Flib%2FTarget%2FAMDGPU%2FAMDGPUTargetMachine.cpp%23L420&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000299565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=zODbjrSVrFMHXrckrECafNIrmaNWLdjqtHlVOatUgwQ%3D&reserved=0> and hasn't been updated to work with the NPM.
Could the maintainers of AMDGPU port the necessary passes to the new pass manager add them to AMDGPUTargetMachine::registerPassBuilderCallbacks()? I'm happy to provide any guidance if necessary. Here's<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD91990&data=04%7C01%7Creshabhkumar.sharma%40amd.com%7C02872c91be3148db82c508d8b34ac4a2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637456481000309558%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=M0WS7ZEG14yyfKghrwFkEgba6If7QsLnLZnjUIyIsgs%3D&reserved=0> an example of porting a pass and adding it to the pipeline.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210108/29d6f3fe/attachment-0001.html>
More information about the llvm-dev
mailing list