Skip to content

Commit 618a407

Browse files
srividyakarumuriigcbot
authored andcommitted
Support for uniform typed read
1 parent b889c99 commit 618a407

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11171,7 +11171,7 @@ void EmitPass::JoinSIMD(CVariable* (&tempdst)[N], uint responseLength, SIMDMode
1117111171
}
1117211172
}
1117311173

11174-
CVariable* EmitPass::BroadcastIfUniform(CVariable* pVar)
11174+
CVariable* EmitPass::BroadcastIfUniform(CVariable* pVar, bool nomask)
1117511175
{
1117611176
IGC_ASSERT_MESSAGE(nullptr != pVar, "pVar is null");
1117711177
VISA_Type VarT = pVar->GetType();
@@ -11204,12 +11204,16 @@ CVariable* EmitPass::BroadcastIfUniform(CVariable* pVar)
1120411204

1120511205
for (uint i = 0; i < elts; ++i)
1120611206
{
11207+
if (nomask)
11208+
m_encoder->SetNoMask();
1120711209
m_encoder->SetSrcSubReg(0, i * Stride);
1120811210
if (Stride != 1) m_encoder->SetDstRegion(Stride);
1120911211
m_encoder->SetDstSubReg((i * Stride) * width);
1121011212
m_encoder->Copy(Dst, ImmLo ? ImmLo : Src);
1121111213
m_encoder->Push();
1121211214
if (Need64BitEmu) {
11215+
if (nomask)
11216+
m_encoder->SetNoMask();
1121311217
m_encoder->SetSrcSubReg(0, i * Stride + 1);
1121411218
if (Stride != 1) m_encoder->SetDstRegion(Stride);
1121511219
m_encoder->SetDstSubReg((i * Stride) * width + 1);
@@ -13341,18 +13345,42 @@ void EmitPass::emitTypedRead(llvm::Instruction* pInsn)
1334113345
CVariable* pV = (pR == nullptr && isUndefOrConstInt0(pllV)) ? nullptr : GetSymbol(pllV);
1334213346
CVariable* pU = GetSymbol(pllU);
1334313347

13344-
pU = BroadcastIfUniform(pU);
13345-
pV = pV ? BroadcastIfUniform(pV) : nullptr;
13346-
pR = pR ? BroadcastIfUniform(pR) : nullptr;
13347-
pLOD = pLOD ? BroadcastIfUniform(pLOD) : nullptr;
13348+
pU = BroadcastIfUniform(pU, m_currShader->GetIsUniform(pInsn));
13349+
pV = pV ? BroadcastIfUniform(pV, m_currShader->GetIsUniform(pInsn)) : nullptr;
13350+
pR = pR ? BroadcastIfUniform(pR, m_currShader->GetIsUniform(pInsn)) : nullptr;
13351+
pLOD = pLOD ? BroadcastIfUniform(pLOD, m_currShader->GetIsUniform(pInsn)) : nullptr;
1334813352

1334913353
ResourceDescriptor resource = GetResourceVariable(pllSrcBuffer);
1335013354

1335113355
uint numChannels = iSTD::BitCount(writeMask);
1335213356

1335313357
if (m_currShader->GetIsUniform(pInsn))
1335413358
{
13355-
IGC_ASSERT_MESSAGE(0, "Uniform ld_uav_typed not implemented yet");
13359+
SIMDMode nativeDispatchMode = m_currShader->m_Platform->getMinDispatchMode();
13360+
CVariable* tempdst = nullptr;
13361+
tempdst = m_currShader->GetNewVariable(
13362+
numChannels * numLanes(nativeDispatchMode),
13363+
ISA_TYPE_F,
13364+
EALIGN_GRF,
13365+
CName("tyReadDest"));
13366+
m_encoder->SetSimdSize(nativeDispatchMode);
13367+
m_encoder->SetPredicate(nullptr);
13368+
m_encoder->SetNoMask();
13369+
m_encoder->TypedRead4(resource, pU, pV, pR, pLOD, tempdst, writeMask);
13370+
13371+
m_encoder->Push();
13372+
13373+
// Mov the required channel values to m_destination
13374+
m_encoder->SetSimdSize(SIMDMode::SIMD1);
13375+
m_encoder->SetNoMask();
13376+
13377+
for (uint i = 0; i < numChannels; ++i)
13378+
{
13379+
m_encoder->SetSrcSubReg(0, i * numLanes(nativeDispatchMode));
13380+
m_encoder->SetDstSubReg(i);
13381+
m_encoder->Copy(m_destination, tempdst);
13382+
m_encoder->Push();
13383+
}
1335613384
}
1335713385
else
1335813386
{

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class EmitPass : public llvm::FunctionPass
461461
void SplitSIMD(llvm::Instruction* inst, uint numSources, uint headerSize, CVariable* payload, SIMDMode mode, uint half);
462462
template<size_t N>
463463
void JoinSIMD(CVariable* (&tempdst)[N], uint responseLength, SIMDMode mode);
464-
CVariable* BroadcastIfUniform(CVariable* pVar);
464+
CVariable* BroadcastIfUniform(CVariable* pVar, bool nomask = false);
465465
uint DecideInstanceAndSlice(const llvm::BasicBlock& blk, SDAG& sdag, bool& slicing);
466466
bool IsUndefOrZeroImmediate(const llvm::Value* value);
467467
inline bool isUndefOrConstInt0(const llvm::Value* val)

IGC/Compiler/CISACodeGen/WIAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ WIAnalysis::WIDependancy WIAnalysisRunner::calculate_dep(const CallInst* inst)
12521252
intrinsic_name == llvm_waveAll ||
12531253
intrinsic_name == llvm_waveClustered ||
12541254
intrinsic_name == llvm_ld_ptr ||
1255+
(IGC_IS_FLAG_DISABLED(DisableUniformTypedAccess) && intrinsic_name == llvm_typed_read) ||
12551256
intrinsic_name == llvm_add_pair ||
12561257
intrinsic_name == llvm_sub_pair ||
12571258
intrinsic_name == llvm_mul_pair ||

IGC/common/igc_flags.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ DECLARE_IGC_REGKEY(bool, DisableConstantCoalescing, false, "Setting this to
111111
DECLARE_IGC_REGKEY(bool, DisableConstantCoalescingOutOfBoundsCheck, false, "Setting this to 1/true adds a compiler switch to disable constant coalesing out of bounds check", false)
112112
DECLARE_IGC_REGKEY(bool, UseHDCTypedReadForAllTextures, false, "Setting this to use HDC message rather than sampler ld for texture read", false)
113113
DECLARE_IGC_REGKEY(bool, UseHDCTypedReadForAllTypedBuffers, false, "Setting this to use HDC message rather than sampler ld for buffer read", false)
114+
DECLARE_IGC_REGKEY(bool, DisableUniformTypedAccess, true, "Setting this will disable uniform typed access handling", false)
114115
DECLARE_IGC_REGKEY(bool, DisableURBWriteMerge, false, "Setting this to 1/true adds a compiler switch to disable URB write merge", false)
115116
DECLARE_IGC_REGKEY(bool, DisableEmptyBlockRemoval, false, "Setting this to 1/true adds a compiler switch to disable empty block optimization", false)
116117
DECLARE_IGC_REGKEY(bool, DisableSIMD32Slicing, false, "Setting this to 1/true adds a compiler switch to disable emitting SIMD32 VISA code in slices", false)

0 commit comments

Comments
 (0)