LLVM 20.0.0git
AMDGPUPerfHintAnalysis.h
Go to the documentation of this file.
1//===- AMDGPUPerfHintAnalysis.h ---- analysis of memory traffic -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// \brief Analyzes if a function potentially memory bound and if a kernel
11/// kernel may benefit from limiting number of waves to reduce cache thrashing.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUPERFHINTANALYSIS_H
16#define LLVM_LIB_TARGET_AMDGPU_AMDGPUPERFHINTANALYSIS_H
17
18#include "llvm/IR/PassManager.h"
19#include "llvm/IR/ValueMap.h"
20
23
24namespace llvm {
25
26class AMDGPUPerfHintAnalysis;
27class CallGraphSCC;
28class GCNTargetMachine;
29class LazyCallGraph;
30
32public:
33 struct FuncInfo {
34 unsigned MemInstCost;
35 unsigned InstCost;
36 unsigned IAMInstCost; // Indirect access memory instruction count
37 unsigned LSMInstCost; // Large stride memory instruction count
38 bool HasDenseGlobalMemAcc; // Set if at least 1 basic block has relatively
39 // high global memory access
43 };
44
46
47private:
48 FuncInfoMap FIM;
49
50public:
52
53 // OldPM
54 bool runOnSCC(const GCNTargetMachine &TM, CallGraphSCC &SCC);
55
56 // NewPM
57 bool run(const GCNTargetMachine &TM, LazyCallGraph &CG);
58
59 bool isMemoryBound(const Function *F) const;
60
61 bool needsWaveLimiter(const Function *F) const;
62};
63
65 : public PassInfoMixin<AMDGPUPerfHintAnalysisPass> {
67 std::unique_ptr<AMDGPUPerfHintAnalysis> Impl;
68
70 : TM(TM), Impl(std::make_unique<AMDGPUPerfHintAnalysis>()) {}
71
73};
74
75} // namespace llvm
76#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUPERFHINTANALYSIS_H
This header provides classes for managing passes over SCCs of the call graph.
Implements a lazy call graph analysis and related passes for the new pass manager.
#define F(x, y, z)
Definition: MD5.cpp:55
const char LLVMTargetMachineRef TM
This header defines various interfaces for pass management in LLVM.
bool isMemoryBound(const Function *F) const
bool needsWaveLimiter(const Function *F) const
bool run(const GCNTargetMachine &TM, LazyCallGraph &CG)
bool runOnSCC(const GCNTargetMachine &TM, CallGraphSCC &SCC)
ValueMap< const Function *, FuncInfo > FuncInfoMap
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on.
A lazily constructed view of the call graph of a module.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
See the file comment.
Definition: ValueMap.h:84
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
AMDGPUPerfHintAnalysisPass(const GCNTargetMachine &TM)
std::unique_ptr< AMDGPUPerfHintAnalysis > Impl
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:69