Skip to content

Commit 72c4df4

Browse files
weiyu-chengfxbot
authored andcommitted
add 16 OWord block r/w support for some platforms
Change-Id: I3c1689138b1e346a5bc310207e1022984d1c6cc3
1 parent dd7d369 commit 72c4df4

File tree

7 files changed

+73
-112
lines changed

7 files changed

+73
-112
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,6 +3168,8 @@ Common_ISA_Oword_Num ConvertSizeToVisaType(uint size)
31683168
return OWORD_NUM_4;
31693169
case 8:
31703170
return OWORD_NUM_8;
3171+
case 16:
3172+
return OWORD_NUM_16;
31713173
default:
31723174
assert( 0 && "unreachable" );
31733175
return OWORD_NUM_ILLEGAL;

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 49 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -4569,6 +4569,35 @@ void EmitPass::emitSimdShuffleDown( llvm::Instruction* inst )
45694569
m_encoder->Push();
45704570
}
45714571

4572+
static uint32_t getBlockMsgSize(uint32_t bytesRemaining, bool do256Byte)
4573+
{
4574+
if (do256Byte && bytesRemaining >= 256)
4575+
{
4576+
return 256;
4577+
}
4578+
else if (bytesRemaining >= 128)
4579+
{
4580+
return 128;
4581+
}
4582+
else if (bytesRemaining >= 64)
4583+
{
4584+
return 64;
4585+
}
4586+
else if (bytesRemaining >= 32)
4587+
{
4588+
return 32;
4589+
}
4590+
else if (bytesRemaining >= 16)
4591+
{
4592+
return 16;
4593+
}
4594+
else
4595+
{
4596+
assert(0);
4597+
return 0;
4598+
}
4599+
}
4600+
45724601
void EmitPass::emitSimdBlockWrite( llvm::Instruction* inst, llvm::Value* ptrVal )
45734602
{
45744603
Value* llPtr = inst->getOperand( 0 );
@@ -4677,30 +4706,8 @@ void EmitPass::emitSimdBlockWrite( llvm::Instruction* inst, llvm::Value* ptrVal
46774706

46784707
while ( bytesRemaining )
46794708
{
4680-
if ( bytesRemaining >= 128 )
4681-
{
4682-
bytesRemaining -= 128;
4683-
bytesToRead = 128;
4684-
}
4685-
else if ( bytesRemaining >= 64 )
4686-
{
4687-
bytesRemaining -= 64;
4688-
bytesToRead = 64;
4689-
}
4690-
else if ( bytesRemaining >= 32 )
4691-
{
4692-
bytesRemaining -= 32;
4693-
bytesToRead = 32;
4694-
}
4695-
else if (bytesRemaining >= 16)
4696-
{
4697-
bytesRemaining -= 16;
4698-
bytesToRead = 16;
4699-
}
4700-
else
4701-
{
4702-
assert( 0 );
4703-
}
4709+
bytesToRead = getBlockMsgSize(bytesRemaining, false);
4710+
bytesRemaining -= bytesToRead;
47044711

47054712
m_encoder->OWStoreA64( data, pTempVar, bytesToRead, srcOffset );
47064713
srcOffset = srcOffset + bytesToRead;
@@ -4751,30 +4758,10 @@ void EmitPass::emitSimdBlockWrite( llvm::Instruction* inst, llvm::Value* ptrVal
47514758
uint32_t bytesToRead = 0;
47524759
while ( bytesRemaining )
47534760
{
4754-
if ( bytesRemaining >= 128 )
4755-
{
4756-
bytesRemaining -= 128;
4757-
bytesToRead = 128;
4758-
}
4759-
else if ( bytesRemaining >= 64 )
4760-
{
4761-
bytesRemaining -= 64;
4762-
bytesToRead = 64;
4763-
}
4764-
else if ( bytesRemaining >= 32 )
4765-
{
4766-
bytesRemaining -= 32;
4767-
bytesToRead = 32;
4768-
}
4769-
else if (bytesRemaining >= 16)
4770-
{
4771-
bytesRemaining -= 16;
4772-
bytesToRead = 16;
4773-
}
4774-
else
4775-
{
4776-
assert( 0 );
4777-
}
4761+
bool canDo256Byte = false;
4762+
4763+
bytesToRead = getBlockMsgSize(bytesRemaining, canDo256Byte);
4764+
bytesRemaining -= bytesToRead;
47784765

47794766
m_encoder->OWStore( data, resource.m_surfaceType, resource.m_resource, src0shifted, bytesToRead, srcOffset );
47804767
srcOffset = srcOffset + bytesToRead;
@@ -4881,8 +4868,8 @@ void EmitPass::emitSimdBlockRead( llvm::Instruction* inst, llvm::Value* ptrVal )
48814868
{
48824869
assert(!isToSLM && "SLM's ptr size should be 32!");
48834870

4871+
uint32_t dstOffset = 0;
48844872
uint32_t bytesRemaining = totalBytes;
4885-
uint32_t dstSubReg = 0;
48864873
uint32_t bytesToRead = 0;
48874874

48884875
// Emits instructions generating one or more A64 OWORD block read instructions
@@ -4900,35 +4887,12 @@ void EmitPass::emitSimdBlockRead( llvm::Instruction* inst, llvm::Value* ptrVal )
49004887

49014888
while ( bytesRemaining )
49024889
{
4903-
if ( bytesRemaining >= 128 )
4904-
{
4905-
bytesRemaining -= 128;
4906-
bytesToRead = 128;
4907-
}
4908-
else if ( bytesRemaining >= 64 )
4909-
{
4910-
bytesRemaining -= 64;
4911-
bytesToRead = 64;
4912-
}
4913-
else if ( bytesRemaining >= 32 )
4914-
{
4915-
bytesRemaining -= 32;
4916-
bytesToRead = 32;
4917-
}
4918-
else if ( bytesRemaining >= 16 )
4919-
{
4920-
bytesRemaining -= 16;
4921-
bytesToRead = 16;
4922-
}
4923-
else
4924-
{
4925-
assert( 0 );
4926-
}
4890+
bytesToRead = getBlockMsgSize(bytesRemaining, false);
4891+
bytesRemaining -= bytesToRead;
49274892

4928-
m_encoder->SetDstSubVar( dstSubReg );
4929-
dstSubReg = dstSubReg + 4;
4930-
m_encoder->OWLoadA64( m_destination, pTempVar, bytesToRead );
4893+
m_encoder->OWLoadA64( m_destination, pTempVar, bytesToRead, dstOffset);
49314894
m_encoder->Push();
4895+
dstOffset += bytesToRead;
49324896

49334897
if ( bytesRemaining )
49344898
{
@@ -4962,49 +4926,29 @@ void EmitPass::emitSimdBlockRead( llvm::Instruction* inst, llvm::Value* ptrVal )
49624926
ISA_TYPE_UD,
49634927
EALIGN_DWORD );
49644928

4965-
if (isToSLM) {
4929+
if (isToSLM)
4930+
{
49664931
// It is OW-aligned OW address
49674932
m_encoder->Shr(pTempVar, src, m_currShader->ImmToVariable(4, ISA_TYPE_UD));
49684933
}
49694934

49704935
m_encoder->Push();
49714936

4972-
uint32_t dstSubReg = 0;
4937+
uint32_t dstOffset = 0;
49734938
uint32_t bytesToRead = 0;
49744939
uint32_t bytesRemaining = totalBytes;
49754940
bool isFirstIter = true;
49764941
while ( bytesRemaining )
49774942
{
4978-
if ( bytesRemaining >= 128 )
4979-
{
4980-
bytesRemaining -= 128;
4981-
bytesToRead = 128;
4982-
}
4983-
else if ( bytesRemaining >= 64 )
4984-
{
4985-
bytesRemaining -= 64;
4986-
bytesToRead = 64;
4987-
}
4988-
else if ( bytesRemaining >= 32 )
4989-
{
4990-
bytesRemaining -= 32;
4991-
bytesToRead = 32;
4992-
}
4993-
else if (bytesRemaining >= 16)
4994-
{
4995-
bytesRemaining -= 16;
4996-
bytesToRead = 16;
4997-
}
4998-
else
4999-
{
5000-
assert( 0 );
5001-
}
4943+
bool canDo256Byte = false;
4944+
4945+
bytesToRead = getBlockMsgSize(bytesRemaining, canDo256Byte);
4946+
bytesRemaining -= bytesToRead;
50024947

50034948
bool useSrc = isFirstIter && !isToSLM;
5004-
m_encoder->SetDstSubVar( dstSubReg );
5005-
dstSubReg = dstSubReg+4;
5006-
m_encoder->OWLoad( m_destination, resource, useSrc ? src : pTempVar, isToSLM, bytesToRead );
4949+
m_encoder->OWLoad( m_destination, resource, useSrc ? src : pTempVar, isToSLM, bytesToRead, dstOffset );
50074950
m_encoder->Push();
4951+
dstOffset += bytesToRead;
50084952

50094953
if ( bytesRemaining )
50104954
{

visa/BuildIR.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,8 @@ class IR_Builder {
24402440
uint32_t getSamplerResponseLength(int numChannels, bool isFP16, int execSize,
24412441
bool pixelNullMask, bool nullDst);
24422442

2443+
uint32_t setOwordForDesc(uint32_t desc, int numOword, bool isSLM = false) const;
2444+
24432445
};
24442446
}
24452447

visa/Common_ISA_util.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ unsigned Get_Common_ISA_Oword_Num( Common_ISA_Oword_Num num )
592592
return 4;
593593
case OWORD_NUM_8:
594594
return 8;
595+
case OWORD_NUM_16:
596+
return 16;
595597
default:
596598
MUST_BE_TRUE( false, "illegal Oword number (should be 0..3)." );
597599
return 0;
@@ -1412,8 +1414,10 @@ Common_ISA_Oword_Num Get_Common_ISA_Oword_Num_From_Number( unsigned num )
14121414
return OWORD_NUM_4;
14131415
case 8:
14141416
return OWORD_NUM_8;
1417+
case 16:
1418+
return OWORD_NUM_16;
14151419
default:
1416-
MUST_BE_TRUE( false, "illegal Oword number (should be 0..3)." );
1420+
MUST_BE_TRUE( false, "illegal Oword number." );
14171421
return OWORD_NUM_ILLEGAL;
14181422
}
14191423
}

visa/HWCapsOpen.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,9 @@
410410
return false;
411411
}
412412

413+
bool has16OWordSLMBlockRW() const
414+
{
415+
return false;
416+
}
417+
413418
// end HW capabilities

visa/TranslationInterface.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,7 +2558,7 @@ static G4_Operand* lowerSurface255To253(G4_Operand* surface, IR_Builder& builder
25582558
}
25592559
}
25602560

2561-
static uint32_t setOwordForDesc(uint32_t desc, int numOword)
2561+
uint32_t IR_Builder::setOwordForDesc(uint32_t desc, int numOword, bool isSLM) const
25622562
{
25632563
switch (numOword)
25642564
{
@@ -2570,6 +2570,9 @@ static uint32_t setOwordForDesc(uint32_t desc, int numOword)
25702570
return desc | (0x3 << MESSAGE_SPECIFIC_CONTROL);
25712571
case 8:
25722572
return desc | (0x4 << MESSAGE_SPECIFIC_CONTROL);
2573+
case 16:
2574+
assert(isSLM && has16OWordSLMBlockRW() && "16OWord block r/w not supported");
2575+
return desc | (0x5 << MESSAGE_SPECIFIC_CONTROL);
25732576
default:
25742577
/// TODO(move to verifier): default: ASSERT_USER(false, "OWord block size must be 1/2/4/8.");
25752578
return desc;
@@ -2618,7 +2621,7 @@ int IR_Builder::translateVISAOwordLoadInst(
26182621

26192622
surface = lowerSurface255To253(surface, *this);
26202623

2621-
unsigned num_oword = Get_Common_ISA_Oword_Num( (Common_ISA_Oword_Num)size );
2624+
unsigned num_oword = Get_Common_ISA_Oword_Num( size );
26222625
bool unaligned = (opcode == ISA_OWORD_LD_UNALIGNED);
26232626

26242627
// create dcl for VX
@@ -2668,7 +2671,7 @@ int IR_Builder::translateVISAOwordLoadInst(
26682671
}
26692672

26702673
// Set bit 12-8 for the message descriptor
2671-
temp = setOwordForDesc(temp, num_oword);
2674+
temp = setOwordForDesc(temp, num_oword, IsSLMSurface(surface));
26722675

26732676
// !!!WHY???
26742677
if (num_oword > 2)
@@ -2785,13 +2788,13 @@ int IR_Builder::translateVISAOwordStoreInst(
27852788

27862789
surface = lowerSurface255To253(surface, *this);
27872790

2788-
unsigned num_oword = Get_Common_ISA_Oword_Num( (Common_ISA_Oword_Num)size );
2791+
unsigned num_oword = Get_Common_ISA_Oword_Num(size);
27892792
unsigned obj_size = num_oword * 16; // size of obj in bytes
27902793

27912794
unsigned funcCtrl = DC_OWORD_BLOCK_WRITE << 14;
27922795

27932796
// Set bit 12-8 for the message descriptor
2794-
funcCtrl = setOwordForDesc(funcCtrl, num_oword);
2797+
funcCtrl = setOwordForDesc(funcCtrl, num_oword, IsSLMSurface(surface));
27952798

27962799
if (useSends())
27972800
{

visa/include/visa_igc_common_header.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ typedef enum {
203203
OWORD_NUM_2 = 0x1,
204204
OWORD_NUM_4 = 0x2,
205205
OWORD_NUM_8 = 0x3,
206-
OWORD_NUM_ILLEGAL = 0x4
206+
OWORD_NUM_16 = 0x4,
207+
OWORD_NUM_ILLEGAL = 0x5
207208
} Common_ISA_Oword_Num;
208209

209210
// media load inst modifiers

0 commit comments

Comments
 (0)