blob: 88b9c96a914829affc366c91cd751794ed3a6eb7 [file] [log] [blame]
Stanislav Mekhanoshin1c538422018-05-25 17:25:12 +00001//===- AMDGPUPerfHintAnalysis.h - analysis of functions memory traffic ----===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Stanislav Mekhanoshin1c538422018-05-25 17:25:12 +00006//
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_MDGPUPERFHINTANALYSIS_H
16#define LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
17#include "llvm/IR/ValueMap.h"
18#include "llvm/Pass.h"
19
20namespace llvm {
21
22struct AMDGPUPerfHintAnalysis : public FunctionPass {
23 static char ID;
24
25public:
26 AMDGPUPerfHintAnalysis() : FunctionPass(ID) {}
27
28 bool runOnFunction(Function &F) override;
29
Reid Klecknercb48efd2018-05-25 17:46:24 +000030 void getAnalysisUsage(AnalysisUsage &AU) const override {
Stanislav Mekhanoshin1c538422018-05-25 17:25:12 +000031 AU.setPreservesAll();
32 }
33
34 bool isMemoryBound(const Function *F) const;
35
36 bool needsWaveLimiter(const Function *F) const;
37
38 struct FuncInfo {
39 unsigned MemInstCount;
40 unsigned InstCount;
41 unsigned IAMInstCount; // Indirect access memory instruction count
42 unsigned LSMInstCount; // Large stride memory instruction count
43 FuncInfo() : MemInstCount(0), InstCount(0), IAMInstCount(0),
44 LSMInstCount(0) {}
45 };
46
47 typedef ValueMap<const Function*, FuncInfo> FuncInfoMap;
48
49private:
50
51 FuncInfoMap FIM;
52};
53} // namespace llvm
54#endif // LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H