Skip to content

Commit f9315fa

Browse files
pmochocksys_zuul
authored andcommitted
Changes in code.
Change-Id: I0a44674c39dfb31369427abde0ba896215d8e35e
1 parent 75544e7 commit f9315fa

File tree

4 files changed

+19
-53
lines changed

4 files changed

+19
-53
lines changed

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,6 @@ namespace IGC
321321
ctx.m_instrTypes.numSample = numSample;
322322
ctx.m_instrTypes.numInsts = numInsts;
323323
ctx.m_instrTypes.hasLoadStore = true;
324-
325-
// Always allocate private as global stateless when there are calls
326-
ctx.setForceGlobalMemoryAllocation(ctx.m_instrTypes.hasCall);
327324
}
328325

329326
// forward declaration

IGC/Compiler/CodeGenContext.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,6 @@ namespace IGC
526526
return m_InternalOptions.IntelForceGlobalMemoryAllocation;
527527
}
528528

529-
void OpenCLProgramContext::setForceGlobalMemoryAllocation(bool value)
530-
{
531-
// This flag can be updated by other conditions apart from user input
532-
// e.g. presence of stack calls
533-
m_InternalOptions.IntelForceGlobalMemoryAllocation |= value;
534-
}
535-
536529
bool OpenCLProgramContext::hasNoLocalToGenericCast() const
537530
{
538531
return m_InternalOptions.hasNoLocalToGeneric;

IGC/Compiler/CodeGenPublic.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,6 @@ namespace IGC
865865
virtual uint32_t getNumThreadsPerEU() const;
866866
virtual uint32_t getNumGRFPerThread() const;
867867
virtual bool forceGlobalMemoryAllocation() const;
868-
virtual void setForceGlobalMemoryAllocation(bool value) {};
869868
virtual bool hasNoLocalToGenericCast() const;
870869
virtual int16_t getVectorCoalescingControl() const;
871870
bool isPOSH() const;
@@ -1197,7 +1196,7 @@ namespace IGC
11971196
// output: shader information
11981197
iOpenCL::CGen8OpenCLProgram m_programOutput;
11991198
SOpenCLProgramInfo m_programInfo;
1200-
InternalOptions m_InternalOptions;
1199+
const InternalOptions m_InternalOptions;
12011200
const Options m_Options;
12021201
bool isSpirV;
12031202
float m_ProfilingTimerResolution;
@@ -1226,7 +1225,6 @@ namespace IGC
12261225
uint32_t getNumGRFPerThread() const override;
12271226
uint32_t getNumThreadsPerEU() const override;
12281227
bool forceGlobalMemoryAllocation() const override;
1229-
void setForceGlobalMemoryAllocation(bool value) override;
12301228
bool hasNoLocalToGenericCast() const override;
12311229
int16_t getVectorCoalescingControl() const override;
12321230
private:

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GenericAddressDynamicResolution.cpp

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -269,24 +269,21 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
269269

270270

271271
// Private branch
272-
if (!m_ctx->forceGlobalMemoryAllocation())
272+
privateBlock = BasicBlock::Create(I.getContext(), "PrivateBlock", convergeBlock->getParent(), convergeBlock);
273273
{
274-
privateBlock = BasicBlock::Create(I.getContext(), "PrivateBlock", convergeBlock->getParent(), convergeBlock);
275-
{
276-
IRBuilder<> privateBuilder(privateBlock);
277-
PointerType* ptrType = pointerType->getElementType()->getPointerTo(ADDRESS_SPACE_PRIVATE);
278-
Value* privatePtr = privateBuilder.CreateAddrSpaceCast(pointerOperand, ptrType);
274+
IRBuilder<> privateBuilder(privateBlock);
275+
PointerType* ptrType = pointerType->getElementType()->getPointerTo(ADDRESS_SPACE_PRIVATE);
276+
Value* privatePtr = privateBuilder.CreateAddrSpaceCast(pointerOperand, ptrType);
279277

280-
if (LoadInst* LI = dyn_cast<LoadInst>(&I))
281-
{
282-
privateLoad = privateBuilder.CreateAlignedLoad(privatePtr, LI->getAlignment(), LI->isVolatile(), "privateLoad");
283-
}
284-
else if (StoreInst* SI = dyn_cast<StoreInst>(&I))
285-
{
286-
privateBuilder.CreateAlignedStore(I.getOperand(0), privatePtr, SI->getAlignment(), SI->isVolatile());
287-
}
288-
privateBuilder.CreateBr(convergeBlock);
278+
if (LoadInst* LI = dyn_cast<LoadInst>(&I))
279+
{
280+
privateLoad = privateBuilder.CreateAlignedLoad(privatePtr, LI->getAlignment(), LI->isVolatile(), "privateLoad");
281+
}
282+
else if (StoreInst* SI = dyn_cast<StoreInst>(&I))
283+
{
284+
privateBuilder.CreateAlignedStore(I.getOperand(0), privatePtr, SI->getAlignment(), SI->isVolatile());
289285
}
286+
privateBuilder.CreateBr(convergeBlock);
290287
}
291288

292289
// Local Branch
@@ -314,14 +311,12 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
314311
globalBlock = BasicBlock::Create(I.getContext(), "GlobalBlock", convergeBlock->getParent(), convergeBlock);
315312
{
316313
IRBuilder<> globalBuilder(globalBlock);
317-
PointerType* ptrType = pointerType->getElementType()->getPointerTo(
318-
m_ctx->forceGlobalMemoryAllocation() ? ADDRESS_SPACE_GLOBAL_OR_PRIVATE : ADDRESS_SPACE_GLOBAL);
314+
PointerType* ptrType = pointerType->getElementType()->getPointerTo(ADDRESS_SPACE_GLOBAL);
319315
Value* globalPtr = globalBuilder.CreateAddrSpaceCast(pointerOperand, ptrType);
320316

321317
if (LoadInst* LI = dyn_cast<LoadInst>(&I))
322318
{
323-
globalLoad = globalBuilder.CreateAlignedLoad(globalPtr, LI->getAlignment(), LI->isVolatile(),
324-
m_ctx->forceGlobalMemoryAllocation() ? "privateOrGlobalLoad" : "globalLoad");
319+
globalLoad = globalBuilder.CreateAlignedLoad(globalPtr, LI->getAlignment(), LI->isVolatile(), "globalLoad");
325320
}
326321
else if (StoreInst* SI = dyn_cast<StoreInst>(&I))
327322
{
@@ -333,26 +328,9 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
333328
currentBlock->getTerminator()->eraseFromParent();
334329
builder.SetInsertPoint(currentBlock);
335330

336-
337-
// Private branch can be saved if private mem is allocated in global stateless
338-
if (m_ctx->forceGlobalMemoryAllocation())
339-
{
340-
SwitchInst* switchTag = builder.CreateSwitch(tag, globalBlock, 1);
341-
// Based on tag there are two cases 010: local, 000/111: global
342-
switchTag->addCase(localTag, localBlock);
343-
344-
if ((localLoad != nullptr) && (globalLoad != nullptr))
345-
{
346-
IRBuilder<> phiBuilder(&(*convergeBlock->begin()));
347-
PHINode* phi = phiBuilder.CreatePHI(I.getType(), 2, I.getName());
348-
phi->addIncoming(localLoad, localBlock);
349-
phi->addIncoming(globalLoad, globalBlock);
350-
I.replaceAllUsesWith(phi);
351-
}
352-
}
353-
else if (m_ctx->hasNoLocalToGenericCast())
331+
// Local branch can be saved if there are no local to generic casts
332+
if (m_ctx->hasNoLocalToGenericCast())
354333
{
355-
// Local branch can be saved if there are no local to generic casts
356334
SwitchInst* switchTag = builder.CreateSwitch(tag, globalBlock, 1);
357335
// Based on tag there are two cases 001: private, 000/111: global
358336
switchTag->addCase(privateTag, privateBlock);
@@ -369,7 +347,7 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
369347
else
370348
{
371349
SwitchInst* switchTag = builder.CreateSwitch(tag, globalBlock, 2);
372-
// Based on tag there are three cases 001: private, 010: local, 000/111: global
350+
// Based on tag there are two cases 001: private, 010: local, 000/111: global
373351
switchTag->addCase(privateTag, privateBlock);
374352
switchTag->addCase(localTag, localBlock);
375353

@@ -394,7 +372,7 @@ void GenericAddressDynamicResolution::resolveGASWithoutBranches(Instruction& I,
394372

395373
Value* nonLocalLoad = nullptr;
396374

397-
PointerType* ptrType = pointerType->getElementType()->getPointerTo(ADDRESS_SPACE_GLOBAL_OR_PRIVATE);
375+
PointerType* ptrType = pointerType->getElementType()->getPointerTo(ADDRESS_SPACE_GLOBAL);
398376
Value* globalPtr = builder.CreateAddrSpaceCast(pointerOperand, ptrType);
399377

400378
if (LoadInst* LI = dyn_cast<LoadInst>(&I))

0 commit comments

Comments
 (0)