blob: be7f37cb6815264a37f6060068c575553ccca48f [file] [log] [blame]
Stanislav Mekhanoshin1c538422018-05-25 17:25:12 +00001//===- AMDGPUPerfHintAnalysis.h - analysis of functions memory traffic ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10/// \file
11/// \brief Analyzes if a function potentially memory bound and if a kernel
12/// kernel may benefit from limiting number of waves to reduce cache thrashing.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
17#define LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
18#include "llvm/IR/ValueMap.h"
19#include "llvm/Pass.h"
20
21namespace llvm {
22
23struct AMDGPUPerfHintAnalysis : public FunctionPass {
24 static char ID;
25
26public:
27 AMDGPUPerfHintAnalysis() : FunctionPass(ID) {}
28
29 bool runOnFunction(Function &F) override;
30
Reid Klecknercb48efd2018-05-25 17:46:24 +000031 void getAnalysisUsage(AnalysisUsage &AU) const override {
Stanislav Mekhanoshin1c538422018-05-25 17:25:12 +000032 AU.setPreservesAll();
33 }
34
35 bool isMemoryBound(const Function *F) const;
36
37 bool needsWaveLimiter(const Function *F) const;
38
39 struct FuncInfo {
40 unsigned MemInstCount;
41 unsigned InstCount;
42 unsigned IAMInstCount; // Indirect access memory instruction count
43 unsigned LSMInstCount; // Large stride memory instruction count
44 FuncInfo() : MemInstCount(0), InstCount(0), IAMInstCount(0),
45 LSMInstCount(0) {}
46 };
47
48 typedef ValueMap<const Function*, FuncInfo> FuncInfoMap;
49
50private:
51
52 FuncInfoMap FIM;
53};
54} // namespace llvm
55#endif // LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H