Skip to content

Commit b0e4a95

Browse files
mbelickisys_zuul
authored andcommitted
Experimental SYCL unmasked call feature.
Change-Id: Iaaee3a6626a64faa83fa746a9d048f758b396340
1 parent cf446fe commit b0e4a95

File tree

14 files changed

+406
-1
lines changed

14 files changed

+406
-1
lines changed

IGC/AdaptorOCL/UnifyIROCL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9797
#include "Compiler/Optimizer/OpenCLPasses/SubGroupFuncs/SubGroupFuncsResolution.hpp"
9898
#include "Compiler/Optimizer/OpenCLPasses/BIFTransforms/BIFTransforms.hpp"
9999
#include "Compiler/Optimizer/OpenCLPasses/BreakdownIntrinsic.h"
100+
#include "Compiler/Optimizer/OpenCLPasses/TransformUnmaskedFunctionsPass.h"
100101
#include "Compiler/Optimizer/OpenCLPasses/StatelessToStatefull/StatelessToStatefull.hpp"
101102
#include "Compiler/Optimizer/OpenCLPasses/KernelFunctionCloning.h"
102103
#include "Compiler/Legalizer/TypeLegalizerPass.h"
@@ -279,6 +280,8 @@ static void CommonOCLBasedPasses(
279280
mpm.add(new MetaDataUtilsWrapper(pMdUtils, pContext->getModuleMetaData()));
280281
mpm.add(new CodeGenContextWrapper(pContext));
281282

283+
mpm.add(new TransformUnmaskedFunctionsPass());
284+
282285
mpm.add(new ClampLoopUnroll(256));
283286

284287
mpm.add(new MoveStaticAllocas());

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ namespace IGC
344344
m_encoderState.m_noMask = false;
345345
m_encoderState.m_simdSize = m_program->m_SIMDSize;
346346
m_encoderState.m_uniformSIMDSize = SIMDMode::SIMD1;
347+
348+
if (m_insideForcedNoMaskRegion) {
349+
m_encoderState.m_noMask = true;
350+
}
347351
}
348352

349353
CEncoder::CEncoder()
@@ -4332,6 +4336,7 @@ namespace IGC
43324336
CodeGenContext* context = m_program->GetContext();
43334337
m_encoderState.m_secondHalf = false;
43344338
m_enableVISAdump = false;
4339+
m_insideForcedNoMaskRegion = false;
43354340
labelMap.clear();
43364341
labelMap.resize(m_program->entry->size(), nullptr);
43374342
labelCounter = 0;

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ namespace IGC
348348
inline void SetSecondHalf(bool secondHalf);
349349
inline bool IsSecondHalf();
350350

351+
inline void BeginForcedNoMaskRegion();
352+
inline void EndForcedNoMaskRegion();
353+
351354
void Wait();
352355

353356
VISAKernel* GetVISAKernel() { return vKernel; }
@@ -561,6 +564,8 @@ namespace IGC
561564
VISABuilder* vbuilder;
562565
VISABuilder* vAsmTextBuilder;
563566

567+
bool m_insideForcedNoMaskRegion;
568+
564569
bool m_enableVISAdump;
565570
bool m_hasInlineAsm;
566571
std::vector<VISA_LabelOpnd*> labelMap;
@@ -873,6 +878,17 @@ namespace IGC
873878
Arithmetic(ISA_DP4A, dst, src0, src1, src2);
874879
}
875880

881+
inline void CEncoder::BeginForcedNoMaskRegion()
882+
{
883+
m_insideForcedNoMaskRegion = true;
884+
m_encoderState.m_noMask = true;
885+
}
886+
887+
inline void CEncoder::EndForcedNoMaskRegion()
888+
{
889+
m_insideForcedNoMaskRegion = false;
890+
}
891+
876892
inline void CEncoder::SetNoMask()
877893
{
878894
m_encoderState.m_noMask = true;

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16817,6 +16817,15 @@ void EmitPass::emitDP4A(GenIntrinsicInst* GII) {
1681716817
m_encoder->Push();
1681816818
}
1681916819

16820+
void EmitPass::emitUnmaskedRegionBoundary(bool start)
16821+
{
16822+
if (start) {
16823+
m_encoder->BeginForcedNoMaskRegion();
16824+
} else {
16825+
m_encoder->EndForcedNoMaskRegion();
16826+
}
16827+
}
16828+
1682016829
void EmitPass::emitDebugPlaceholder(llvm::GenIntrinsicInst* I)
1682116830
{
1682216831
m_encoder->Loc(I->getDebugLoc().getLine());

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ namespace IGC
428428

429429
void emitLLVMbswap(llvm::IntrinsicInst* inst);
430430
void emitDP4A(llvm::GenIntrinsicInst* GII);
431+
void emitUnmaskedRegionBoundary(bool start);
431432
// Debug Built-Ins
432433
void emitStateRegID(uint64_t and_imm, uint64_t shr_imm);
433434
void emitThreadPause(llvm::GenIntrinsicInst* inst);

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,12 @@ namespace IGC
11261126
match = MatchURBRead(*CI) ||
11271127
MatchSingleInstruction(*CI);
11281128
break;
1129+
case GenISAIntrinsic::GenISA_UnmaskedRegionBegin:
1130+
match = MatchUnmaskedRegionBoundary(I, true);
1131+
break;
1132+
case GenISAIntrinsic::GenISA_UnmaskedRegionEnd:
1133+
match = MatchUnmaskedRegionBoundary(I, false);
1134+
break;
11291135
default:
11301136
match = MatchSingleInstruction(I);
11311137
// no pattern for the rest of the intrinsics
@@ -3725,6 +3731,24 @@ namespace IGC
37253731
return true;
37263732
}
37273733

3734+
bool CodeGenPatternMatch::MatchUnmaskedRegionBoundary(Instruction &I, bool start)
3735+
{
3736+
struct UnmaskedBoundaryPattern : public Pattern
3737+
{
3738+
bool start;
3739+
virtual void Emit(EmitPass* pass, const DstModifier& modifier)
3740+
{
3741+
(void) modifier;
3742+
pass->emitUnmaskedRegionBoundary(start);
3743+
}
3744+
};
3745+
3746+
UnmaskedBoundaryPattern* pattern = new (m_allocator) UnmaskedBoundaryPattern();
3747+
pattern->start = start;
3748+
AddPattern(pattern);
3749+
return true;
3750+
}
3751+
37283752

37293753
bool CodeGenPatternMatch::MatchLogicAlu(llvm::BinaryOperator& I)
37303754
{

IGC/Compiler/CISACodeGen/PatternMatchPass.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ namespace IGC
242242
bool MatchCopyToStruct(llvm::InsertValueInst*);
243243
bool MatchCopyFromStruct(llvm::ExtractValueInst*);
244244

245+
bool MatchUnmaskedRegionBoundary(llvm::Instruction& I, bool start);
246+
245247
void AddPattern(Pattern* P)
246248
{
247249
m_currentPattern = P;

IGC/Compiler/CISACodeGen/opCode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,6 @@ DECLARE_OPCODE(GenISA_WavePrefix, GenISAIntrinsic, llvm_wavePrefix, false, false
256256
DECLARE_OPCODE(GenISA_QuadPrefix, GenISAIntrinsic, llvm_quadPrefix, false, false, false, false, false, false, false)
257257
DECLARE_OPCODE(GenISA_WaveShuffleIndex, GenISAIntrinsic, llvm_waveShuffleIndex, false, false, false, false, false, false, false)
258258

259+
// Unmasked region
260+
DECLARE_OPCODE(GenISA_UnmaskedRegionBegin, GenISAIntrinsic, llvm_unmaskedBegin, false, false, false, false, false, false, false)
261+
DECLARE_OPCODE(GenISA_UnmaskedRegionEnd, GenISAIntrinsic, llvm_unmaskedEnd, false, false, false, false, false, false, false)

IGC/Compiler/Optimizer/OpenCLPasses/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ add_subdirectory(UnreachableHandling)
3939
set(IGC_BUILD__SRC__OpenCLPasses
4040
"${CMAKE_CURRENT_SOURCE_DIR}/KernelArgs.cpp"
4141
"${CMAKE_CURRENT_SOURCE_DIR}/BreakdownIntrinsic.cpp"
42+
"${CMAKE_CURRENT_SOURCE_DIR}/TransformUnmaskedFunctionsPass.cpp"
4243
"${CMAKE_CURRENT_SOURCE_DIR}/KernelFunctionCloning.cpp"
4344
"${CMAKE_CURRENT_SOURCE_DIR}/ErrorCheckPass.cpp"
4445
)
@@ -86,6 +87,7 @@ set(IGC_BUILD__SRC__Optimizer_OpenCLPasses
8687
set(IGC_BUILD__HDR__OpenCLPasses
8788
"${CMAKE_CURRENT_SOURCE_DIR}/KernelArgs.hpp"
8889
"${CMAKE_CURRENT_SOURCE_DIR}/BreakdownIntrinsic.h"
90+
"${CMAKE_CURRENT_SOURCE_DIR}/TransformUnmaskedFunctionsPass.h"
8991
"${CMAKE_CURRENT_SOURCE_DIR}/KernelFunctionCloning.h"
9092
"${CMAKE_CURRENT_SOURCE_DIR}/ErrorCheckPass.h"
9193
)

0 commit comments

Comments
 (0)