Skip to content

Commit 2976cc3

Browse files
AnBodrovaArtem Gindinson
authored andcommitted
Changes in code.
1 parent 58f28ac commit 2976cc3

File tree

7 files changed

+25
-44
lines changed

7 files changed

+25
-44
lines changed

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ namespace IGC
306306
IntelHasPositivePointerOffset = true;
307307
}
308308

309+
// -cl-intel-has-subDW-aligned-ptr-arg, -ze-opt-has-subDW-aligned-ptr-arg
310+
else if (suffix.equals("-has-subDW-aligned-ptr-arg"))
311+
{
312+
IntelHasSubDWAlignedPtrArg = true;
313+
}
314+
309315
// -cl-intel-disable-a64WA
310316
else if (suffix.equals("-disable-a64WA"))
311317
{

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace IGC
3434
IntelHasPositivePointerOffset(false),
3535
IntelHasBufferOffsetArg(false),
3636
IntelBufferOffsetArgOptional(true),
37+
IntelHasSubDWAlignedPtrArg(false),
3738
LargeGRFKernels(),
3839
RegularGRFKernels()
3940
{
@@ -71,6 +72,10 @@ namespace IGC
7172
bool IntelHasPositivePointerOffset; // default: false
7273
bool IntelHasBufferOffsetArg; // default: false
7374
bool IntelBufferOffsetArgOptional; // default: true
75+
bool IntelHasSubDWAlignedPtrArg;
76+
// default: false, meaning kernel's sub-DW ptrArgs (char*, short*) are DW-aligned.
77+
// This default is stronger than the natural alignment implied by char*/short*. But
78+
// for historical reason, we have this.
7479

7580
bool replaceGlobalOffsetsByZero = false;
7681
bool IntelEnablePreRAScheduling = true;

IGC/Compiler/Optimizer/OpenCLPasses/StatelessToStateful/StatelessToStateful.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ StatelessToStateful::StatelessToStateful()
132132
: FunctionPass(ID),
133133
m_hasBufferOffsetArg(false),
134134
m_hasOptionalBufferOffsetArg(false),
135+
m_hasSubDWAlignedPtrArg(false),
135136
m_hasPositivePointerOffset(false),
136137
m_ACT(nullptr),
137138
m_pImplicitArgs(nullptr),
@@ -174,6 +175,8 @@ bool StatelessToStateful::runOnFunction(llvm::Function& F)
174175
m_hasOptionalBufferOffsetArg = (m_hasBufferOffsetArg &&
175176
(IGC_IS_FLAG_ENABLED(EnableOptionalBufferOffset) || modMD->compOpt.BufferOffsetArgOptional));
176177

178+
m_hasSubDWAlignedPtrArg = (IGC_IS_FLAG_ENABLED(UseSubDWAlignedPtrArg) || modMD->compOpt.HasSubDWAlignedPtrArg);
179+
177180
m_hasPositivePointerOffset = (IGC_IS_FLAG_ENABLED(SToSProducesPositivePointer) || modMD->compOpt.HasPositivePointerOffset);
178181

179182
m_pImplicitArgs = new ImplicitArgs(F, pMdUtils);
@@ -424,7 +427,10 @@ bool StatelessToStateful::pointerIsPositiveOffsetFromKernelArgument(
424427
// guarantted to be DW-aligned.)
425428
//
426429
// Note that implicit arg is always aligned.
427-
bool isAlignedPointee = arg->isImplicitArg() ? true : (getPointeeAlign(DL, base) >= 4);
430+
bool isAlignedPointee =
431+
(!m_hasSubDWAlignedPtrArg || arg->isImplicitArg())
432+
? true
433+
: (getPointeeAlign(DL, base) >= 4);
428434

429435
// special handling
430436
if (m_supportNonGEPPtr && gep == nullptr && !arg->isImplicitArg())

IGC/Compiler/Optimizer/OpenCLPasses/StatelessToStateful/StatelessToStateful.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ namespace IGC
151151
// can be on or off, which is indicated by this boolean flag.
152152
bool m_hasOptionalBufferOffsetArg;
153153

154+
// For historic reason, kernel ptrArgs, such as char*, short*, are assumed to
155+
// be aligned on DW (which is stronger than what OCL's natural alignment) in this
156+
// stateful optimization. If this is not a case, this arg should be set to true!
157+
bool m_hasSubDWAlignedPtrArg;
158+
154159
// When true, every messages that are in ptrArg + offset will have offset >= 0.
155160
bool m_hasPositivePointerOffset;
156161

IGC/Compiler/tests/StatelessToStateful/bufferOffset/char_pointer_argument.ll

Lines changed: 0 additions & 43 deletions
This file was deleted.

IGC/common/MDFrameWork.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ namespace IGC
392392
bool HasPositivePointerOffset = false;
393393
bool HasBufferOffsetArg = false;
394394
bool BufferOffsetArgOptional = true;
395+
bool HasSubDWAlignedPtrArg = false;
395396
bool replaceGlobalOffsetsByZero = false;
396397
unsigned forcePixelShaderSIMDMode = 0;
397398
bool pixelShaderDoNotAbortOnSpill = false;

IGC/common/igc_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ DECLARE_IGC_REGKEY(DWORD, DebugInternalSwitch, 0, "Code pass select
287287
DECLARE_IGC_REGKEY(bool, SToSProducesPositivePointer, false, "This key is for StatelessToStateful optimization if the user knows the pointer offset is postive to the kernel argument.", false)
288288
DECLARE_IGC_REGKEY(bool, EnableSupportBufferOffset, false, "[debugging]For StatelessToStateful optimization [OCL], support implicit buffer offset argument (same as -cl-intel-has-buffer-offset-arg).", false)
289289
DECLARE_IGC_REGKEY(bool, EnableOptionalBufferOffset, true, "For StatelessToStateful optimization [OCL], if true, make buffer offset optional. Valid only if buffer offset is supported.", true)
290+
DECLARE_IGC_REGKEY(bool, UseSubDWAlignedPtrArg, false, "[OCL]If set, for kernel pointer arg such as ptr to char or short, the arg is not necessarily DW aligned", false)
290291
DECLARE_IGC_REGKEY(bool, EnableTestIGCBuiltin, false, "Enable testing igc builtin (precompiled kernels) using OCL.", false)
291292
DECLARE_IGC_REGKEY(bool, EnableCSSIMD32, false, "Enable computer shader SIMD32 mode, and fall back to lower SIMD when spill", false)
292293
DECLARE_IGC_REGKEY(bool, ForceCSSIMD32, false, "Force computer shader SIMD32 mode", false)

0 commit comments

Comments
 (0)