2019-07-05 22:26:13 +02:00
|
|
|
//===- AMDGPUPerfHintAnalysis.h ---- analysis of memory traffic -*- C++ -*-===//
|
2018-05-25 19:25:12 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-05-25 19:25:12 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// \brief Analyzes if a function potentially memory bound and if a kernel
|
|
|
|
/// kernel may benefit from limiting number of waves to reduce cache thrashing.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
|
2019-07-05 22:26:13 +02:00
|
|
|
|
|
|
|
#include "llvm/Analysis/CallGraphSCCPass.h"
|
2018-05-25 19:25:12 +02:00
|
|
|
#include "llvm/IR/ValueMap.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2019-07-05 22:26:13 +02:00
|
|
|
struct AMDGPUPerfHintAnalysis : public CallGraphSCCPass {
|
2018-05-25 19:25:12 +02:00
|
|
|
static char ID;
|
|
|
|
|
|
|
|
public:
|
2019-07-05 22:26:13 +02:00
|
|
|
AMDGPUPerfHintAnalysis() : CallGraphSCCPass(ID) {}
|
2018-05-25 19:25:12 +02:00
|
|
|
|
2019-07-05 22:26:13 +02:00
|
|
|
bool runOnSCC(CallGraphSCC &SCC) override;
|
2018-05-25 19:25:12 +02:00
|
|
|
|
2018-05-25 19:46:24 +02:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
2018-05-25 19:25:12 +02:00
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isMemoryBound(const Function *F) const;
|
|
|
|
|
|
|
|
bool needsWaveLimiter(const Function *F) const;
|
|
|
|
|
|
|
|
struct FuncInfo {
|
2021-07-08 21:23:52 +02:00
|
|
|
unsigned MemInstCost;
|
|
|
|
unsigned InstCost;
|
|
|
|
unsigned IAMInstCost; // Indirect access memory instruction count
|
|
|
|
unsigned LSMInstCost; // Large stride memory instruction count
|
|
|
|
FuncInfo() : MemInstCost(0), InstCost(0), IAMInstCost(0), LSMInstCost(0) {}
|
2018-05-25 19:25:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef ValueMap<const Function*, FuncInfo> FuncInfoMap;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
FuncInfoMap FIM;
|
|
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
#endif // LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
|