LLVM: include/llvm/MCA/HardwareUnits/Scheduler.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_MCA_HARDWAREUNITS_SCHEDULER_H

15#define LLVM_MCA_HARDWAREUNITS_SCHEDULER_H

16

24

25namespace llvm {

26namespace mca {

27

29public:

32

33

34

35

36

38};

39

40

42

43

44 int computeRank(const InstRef &Lhs) const {

46 }

47

48public:

51

53 int LhsRank = computeRank(Lhs);

54 int RhsRank = computeRank(Rhs);

55

56

57

58 if (LhsRank == RhsRank)

60 return LhsRank < RhsRank;

61 }

62};

63

64

65

66

67

68

69

70

73

74

75 std::unique_ptr Strategy;

76

77

78 std::unique_ptr Resources;

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112 std::vector WaitSet;

113 std::vector PendingSet;

114 std::vector ReadySet;

115 std::vector IssuedSet;

116

117

118

119

120

121

123

124

125

126 unsigned NumDispatchedToThePendingSet;

127

128

129

130 bool HadTokenStall;

131

132

133

134

135 LLVM_ABI void initializeStrategy(std::unique_ptr S);

136

137

138 void issueInstructionImpl(

140 SmallVectorImpl<std::pair<ResourceRef, ReleaseAtCycles>> &Pipes);

141

142

143

144

146

147

148

149

151

152

153

154

156

157public:

160

162 std::unique_ptr SelectStrategy)

164 std::move(SelectStrategy)) {}

165

167 std::unique_ptr SelectStrategy)

168 : LSU(Lsu), Resources(std::move(RM)), BusyResourceUnits(0),

169 NumDispatchedToThePendingSet(0), HadTokenStall(false) {

170 initializeStrategy(std::move(SelectStrategy));

171 }

172

173

181

182

183

184

185

186

188

189

190

191

192

193

194

195

196

197

198

200

201

202

203

206 SmallVectorImpl<std::pair<ResourceRef, ReleaseAtCycles>> &Used,

208

209

210

212

213

214

215

216

217

218

219

220

221

222

223

224

229

230

231

232

233

235 return Resources->resolveResourceMask(Mask);

236 }

237

238

239

240

242

245

246

247

248

249

250

253

254

255

256

258

259

260

262

263#ifndef NDEBUG

264

265 void dump() const;

266

267

268

269

275#endif

276};

277}

278}

279

280#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file defines a base class for describing a simulated hardware unit.

A Load/Store unit class that models load/store queues and that implements a simple weak memory consis...

Legalize the Machine IR a function s Machine IR

The classes here represent processor resource units and their management strategy.

This file defines the SmallVector class.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

DefaultSchedulerStrategy()=default

bool compare(const InstRef &Lhs, const InstRef &Rhs) const override

Returns true if Lhs should take priority over Rhs.

Definition Scheduler.h:52

~DefaultSchedulerStrategy() override

An InstRef contains both a SourceMgr index and Instruction pair.

Instruction * getInstruction()

unsigned getSourceIndex() const

unsigned getNumUsers() const

Abstract base interface for LS (load/store) units in llvm-mca.

SchedulerStrategy()=default

virtual ~SchedulerStrategy()

virtual bool compare(const InstRef &Lhs, const InstRef &Rhs) const =0

Returns true if Lhs should take priority over Rhs.

Status

Definition Scheduler.h:174

@ SC_LOAD_QUEUE_FULL

Definition Scheduler.h:176

@ SC_AVAILABLE

Definition Scheduler.h:175

@ SC_STORE_QUEUE_FULL

Definition Scheduler.h:177

@ SC_DISPATCH_GROUP_STALL

Definition Scheduler.h:179

@ SC_BUFFERS_FULL

Definition Scheduler.h:178

LLVM_ABI InstRef select()

Select the next instruction to issue from the ReadySet.

unsigned getResourceID(uint64_t Mask) const

Convert a resource mask into a valid llvm processor resource identifier.

Definition Scheduler.h:234

LLVM_ABI void issueInstruction(InstRef &IR, SmallVectorImpl< std::pair< ResourceRef, ReleaseAtCycles > > &Used, SmallVectorImpl< InstRef > &Pending, SmallVectorImpl< InstRef > &Ready)

Issue an instruction and populates a vector of used pipeline resources, and a vector of instructions ...

Scheduler(std::unique_ptr< ResourceManager > RM, LSUnitBase &Lsu, std::unique_ptr< SchedulerStrategy > SelectStrategy)

Definition Scheduler.h:166

LLVM_ABI Status isAvailable(const InstRef &IR)

Check if the instruction in 'IR' can be dispatched during this cycle.

LLVM_ABI void analyzeDataDependencies(SmallVectorImpl< InstRef > &RegDeps, SmallVectorImpl< InstRef > &MemDeps)

This method is called by the ExecuteStage at the end of each cycle to identify bottlenecks caused by ...

Scheduler(const MCSchedModel &Model, LSUnitBase &Lsu, std::unique_ptr< SchedulerStrategy > SelectStrategy)

Definition Scheduler.h:161

LLVM_ABI bool dispatch(InstRef &IR)

Reserves buffer and LSUnit queue resources that are necessary to issue this instruction.

LLVM_ABI void cycleEvent(SmallVectorImpl< ResourceRef > &Freed, SmallVectorImpl< InstRef > &Executed, SmallVectorImpl< InstRef > &Pending, SmallVectorImpl< InstRef > &Ready)

This routine notifies the Scheduler that a new cycle just started.

LLVM_ABI bool mustIssueImmediately(const InstRef &IR) const

Returns true if IR has to be issued immediately, or if IR is a zero latency instruction.

LLVM_ABI uint64_t analyzeResourcePressure(SmallVectorImpl< InstRef > &Insts)

Returns a mask of busy resources, and populates vector Insts with instructions that could not be issu...

bool isReadySetEmpty() const

Definition Scheduler.h:243

void instructionCheck(const InstRef &IR) const

Definition Scheduler.h:270

Scheduler(const MCSchedModel &Model, LSUnitBase &Lsu)

Definition Scheduler.h:158

bool hadTokenStall() const

Definition Scheduler.h:261

bool isWaitSetEmpty() const

Definition Scheduler.h:244

Helper functions used by various pipeline components.

This is an optimization pass for GlobalISel generic memory operations.

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

bool is_contained(R &&Range, const E &Element)

Returns true if Element is found in Range.

Implement std::hash so that hash_code can be used in STL containers.

Machine model for scheduling, bundling, and heuristics.