Skip to content

Commit b46d1c2

Browse files
scottp101igcbot
authored andcommitted
refactor preemption check into function
refactor preemption check into function
1 parent d047fc5 commit b46d1c2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,10 +1465,8 @@ bool EmitPass::runOnFunction(llvm::Function& F)
14651465

14661466
if ((m_currShader->GetShaderType() == ShaderType::COMPUTE_SHADER ||
14671467
m_currShader->GetShaderType() == ShaderType::OPENCL_SHADER) &&
1468-
m_currShader->m_Platform->supportDisableMidThreadPreemptionSwitch() &&
1469-
IGC_IS_FLAG_ENABLED(EnableDisableMidThreadPreemptionOpt) &&
1470-
(m_currShader->GetContext()->m_instrTypes.numLoopInsts == 0) &&
1471-
(m_currShader->ProgramOutput()->m_InstructionCount < IGC_GET_FLAG_VALUE(MidThreadPreemptionDisableThreshold)))
1468+
m_currShader->m_State.shouldDisablePreemption(
1469+
m_currShader->ProgramOutput()->m_InstructionCount))
14721470
{
14731471

14741472
{

IGC/Compiler/CISACodeGen/GenericShaderState.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ namespace IGC
107107
CodeGenContext& Ctx;
108108

109109
CodeGenContext& GetContext() const { return Ctx; }
110+
111+
bool shouldDisablePreemption(unsigned NumInst) const
112+
{
113+
return (Ctx.platform.supportDisableMidThreadPreemptionSwitch() &&
114+
IGC_IS_FLAG_ENABLED(EnableDisableMidThreadPreemptionOpt) &&
115+
(Ctx.m_instrTypes.numLoopInsts == 0) &&
116+
(NumInst < IGC_GET_FLAG_VALUE(MidThreadPreemptionDisableThreshold)));
117+
}
110118
private:
111119
bool m_HasSample = false;
112120
int m_BarrierNumber = 0;

0 commit comments

Comments
 (0)