Skip to content

Commit 2a13bc4

Browse files
iwwuigcbot
authored andcommitted
Extend morton walk order to loads
IGC marks a shader as "HasSample" to use Morton walk order for the increased sampler cache hit rates. Currently, only sampler messages and gather4 are supported. This PR expands to include loads, except for buffers/1D textures.
1 parent 9cbd41b commit 2a13bc4

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5331,6 +5331,7 @@ void EmitPass::emitLdInstruction(llvm::Instruction* inst)
53315331
IGC_ASSERT_MESSAGE(numOperands < 11, "Wrong number of operands");
53325332

53335333
EOPCODE opCode = GetOpCode(inst);
5334+
m_currShader->m_State.SetHasLoadInst();
53345335
//Subtract the offsets, resource sources to get
53355336
//the number of texture coordinates and index to texture source
53365337
uint numSources = numOperands - 6;
@@ -8786,6 +8787,7 @@ void EmitPass::emitLdmsInstruction(llvm::Instruction* inst)
87868787
{
87878788
uint numOperands = inst->getNumOperands();
87888789
EOPCODE opCode = GetOpCode(inst);
8790+
m_currShader->m_State.SetHasLoadInst();
87898791
//Subtract the offsets, and texture resource, lod to get
87908792
//the number of texture coordinates and index to texture source
87918793
uint numSources = numOperands - 5;

IGC/Compiler/CISACodeGen/GenericShaderState.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ namespace IGC
5050
void SetBarrierNumber(int BarrierNumber) { m_BarrierNumber = BarrierNumber; }
5151
int GetBarrierNumber() const { return m_BarrierNumber; }
5252

53-
bool GetHasSample() const { return m_HasSample; }
54-
void SetHasSampleInst() { m_HasSampleInst = true; m_HasSample = true; }
55-
void SetHasGather4Inst() { m_HasGather4Inst = true; m_HasSample = true; }
53+
bool GetHasSampleLoadGather4() const
54+
{
55+
return (m_HasSampleInst || m_HasGather4Inst || m_HasLoadInst);
56+
}
57+
void SetHasSampleInst() { m_HasSampleInst = true; }
58+
void SetHasGather4Inst() { m_HasGather4Inst = true; }
59+
void SetHasLoadInst() { m_HasLoadInst = true; }
5660

5761
bool GetHasDPAS() const { return m_HasDPAS; }
5862
void SetHasDPAS() { m_HasDPAS = true; }
@@ -115,9 +119,9 @@ namespace IGC
115119
(NumInst < IGC_GET_FLAG_VALUE(MidThreadPreemptionDisableThreshold)));
116120
}
117121
private:
118-
bool m_HasSample = false;
119122
bool m_HasSampleInst = false;
120123
bool m_HasGather4Inst = false;
124+
bool m_HasLoadInst = false;
121125
int m_BarrierNumber = 0;
122126
bool m_HasDPAS = false;
123127
// Shader has LSC store messages with non-default L1 cache control

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,7 @@ namespace IGC
28732873

28742874
// TODO: need to change misleading HasBarriers to NumberofBarriers
28752875
m_kernelInfo.m_executionEnvironment.HasBarriers = m_State.GetBarrierNumber();
2876-
m_kernelInfo.m_executionEnvironment.HasSample = m_State.GetHasSample();
2876+
m_kernelInfo.m_executionEnvironment.HasSample = m_State.GetHasSampleLoadGather4();
28772877
m_kernelInfo.m_executionEnvironment.DisableMidThreadPreemption = GetDisableMidThreadPreemption();
28782878
m_kernelInfo.m_executionEnvironment.SubgroupIndependentForwardProgressRequired =
28792879
m_Context->getModuleMetaData()->compOpt.SubgroupIndependentForwardProgressRequired;

0 commit comments

Comments
 (0)