Skip to content

Commit 9378db8

Browse files
weiyu-chensys_zuul
authored andcommitted
Refactor SendMsgDescriptor related code.
Change-Id: I3469094b0d27924851166d2245f00219a6e21f18
1 parent d5cc742 commit 9378db8

10 files changed

+136
-396
lines changed

visa/BuildIR.h

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,12 +1323,11 @@ class IR_Builder {
13231323
unsigned regs2rcv,
13241324
unsigned regs2snd,
13251325
SFID funcID,
1326-
bool eot,
13271326
unsigned extMsgLength,
13281327
uint16_t extFuncCtrl,
13291328
SendAccess access,
1330-
G4_Operand *bti = nullptr,
1331-
G4_Operand *sti = nullptr);
1329+
G4_Operand* bti = nullptr,
1330+
G4_Operand* sti = nullptr);
13321331

13331332
G4_Operand* emitSampleIndexGE16(
13341333
G4_Operand* sampler, G4_Declare* headerDecl);
@@ -1862,32 +1861,31 @@ class IR_Builder {
18621861
unsigned option);
18631862

18641863
G4_InstSend* Create_Send_Inst_For_CISA(
1865-
G4_Predicate* pred,
1866-
G4_DstRegRegion *postDst,
1867-
G4_SrcRegRegion *payload,
1868-
unsigned regs2snd,
1869-
unsigned regs2rcv,
1870-
unsigned execsize,
1871-
unsigned fc,
1872-
SFID tf_id,
1873-
bool eot,
1874-
bool head_present,
1875-
SendAccess access,
1876-
G4_Operand *bti,
1877-
G4_Operand *sti,
1878-
unsigned int option,
1879-
bool is_sendc);
1880-
1881-
G4_InstSend* Create_SplitSend_Inst_For_CISA(G4_Predicate* pred, G4_DstRegRegion *dst,
1882-
G4_SrcRegRegion *src1, unsigned regs2snd1,
1883-
G4_SrcRegRegion *src2, unsigned regs2snd2,
1864+
G4_Predicate* pred,
1865+
G4_DstRegRegion* postDst,
1866+
G4_SrcRegRegion* payload,
1867+
unsigned regs2snd,
1868+
unsigned regs2rcv,
1869+
unsigned execsize,
1870+
unsigned fc,
1871+
SFID tf_id,
1872+
bool head_present,
1873+
SendAccess access,
1874+
G4_Operand* bti,
1875+
G4_Operand* sti,
1876+
unsigned int option,
1877+
bool is_sendc);
1878+
1879+
G4_InstSend* Create_SplitSend_Inst_For_CISA(G4_Predicate* pred, G4_DstRegRegion* dst,
1880+
G4_SrcRegRegion* src1, unsigned regs2snd1,
1881+
G4_SrcRegRegion* src2, unsigned regs2snd2,
18841882
unsigned regs2rcv,
18851883
unsigned execsize,
1886-
unsigned fc, unsigned exFuncCtrl,
1887-
SFID tf_id, bool eot,
1884+
unsigned fc,
1885+
SFID tf_id,
18881886
bool head_present,
18891887
SendAccess access,
1890-
G4_Operand *bti, G4_Operand *sti,
1888+
G4_Operand* bti, G4_Operand* sti,
18911889
unsigned option,
18921890
bool is_sendc);
18931891

visa/BuildIRImpl.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,14 @@ G4_SendMsgDescriptor* IR_Builder::createSendMsgDesc(
145145
unsigned regs2rcv,
146146
unsigned regs2snd,
147147
SFID funcID,
148-
bool eot,
149148
unsigned extMsgLength,
150149
uint16_t extFuncCtrl,
151150
SendAccess access,
152151
G4_Operand *bti,
153152
G4_Operand *sti)
154153
{
155154
G4_SendMsgDescriptor* msgDesc = new (mem) G4_SendMsgDescriptor(
156-
funcCtrl, regs2rcv, regs2snd, SFIDtoInt(funcID), eot, (uint16_t) extMsgLength,
155+
funcCtrl, regs2rcv, regs2snd, funcID, (uint16_t) extMsgLength,
157156
extFuncCtrl, access, bti, sti, *this);
158157
return msgDesc;
159158
}
@@ -842,7 +841,6 @@ G4_InstSend* IR_Builder::Create_Send_Inst_For_CISA(
842841
unsigned execsize,
843842
unsigned fc,
844843
SFID tf_id,
845-
bool eot,
846844
bool header_present,
847845
SendAccess access,
848846
G4_Operand* bti,
@@ -852,7 +850,7 @@ G4_InstSend* IR_Builder::Create_Send_Inst_For_CISA(
852850
{
853851
G4_SendMsgDescriptor* msgDesc =
854852
createSendMsgDesc(fc, regs2rcv, regs2snd, tf_id,
855-
eot, 0, 0, access, bti, sti);
853+
0, 0, access, bti, sti);
856854

857855
msgDesc->setHeaderPresent(header_present);
858856

@@ -997,9 +995,7 @@ G4_InstSend* IR_Builder::Create_SplitSend_Inst_For_CISA(
997995
unsigned regs2rcv,
998996
unsigned execsize,
999997
unsigned fc,
1000-
unsigned exFuncCtrl,
1001998
SFID tf_id,
1002-
bool eot,
1003999
bool header_present,
10041000
SendAccess access,
10051001
G4_Operand* bti,
@@ -1008,8 +1004,8 @@ G4_InstSend* IR_Builder::Create_SplitSend_Inst_For_CISA(
10081004
bool is_sendc)
10091005
{
10101006
G4_SendMsgDescriptor *msgDesc =
1011-
createSendMsgDesc(fc, regs2rcv, regs2snd1, tf_id, eot, regs2snd2,
1012-
(uint16_t)exFuncCtrl, access, bti, sti);
1007+
createSendMsgDesc(fc, regs2rcv, regs2snd1, tf_id, regs2snd2,
1008+
0, access, bti, sti);
10131009

10141010
msgDesc->setHeaderPresent(header_present);
10151011

visa/Gen4_IR.cpp

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ short Operand_Type_Rank( G4_Type type )
236236

237237
G4_SendMsgDescriptor::G4_SendMsgDescriptor(
238238
uint32_t fCtrl, uint32_t regs2rcv,
239-
uint32_t regs2snd, uint32_t fID, bool isEot, uint16_t extMsgLen,
239+
uint32_t regs2snd, SFID fID, uint16_t extMsgLen,
240240
uint32_t extFCtrl, SendAccess access,
241241
G4_Operand *bti, G4_Operand *sti,
242242
IR_Builder& builder)
@@ -250,14 +250,13 @@ G4_SendMsgDescriptor::G4_SendMsgDescriptor(
250250
desc.layout.msgLength = regs2snd;
251251

252252
extDesc.value = 0;
253-
extDesc.layout.funcID = fID;
254-
extDesc.layout.eot = isEot;
253+
extDesc.layout.funcID = SFIDtoInt(fID);
255254
extDesc.layout.extMsgLength = extMsgLen;
256255
extDesc.layout.extFuncCtrl = extFCtrl;
257256

258257
src1Len = extMsgLen; // [10:6]
259-
eotAfterMessage = isEot; // [5]
260-
sfid = intToSFID(fID);
258+
eotAfterMessage = false; // [5]
259+
sfid = fID;
261260

262261
accessType = access;
263262
funcCtrlValid = true;
@@ -277,11 +276,6 @@ G4_SendMsgDescriptor::G4_SendMsgDescriptor(
277276
uint32_t totalMaxLength = builder.getMaxSendMessageLength();
278277
MUST_BE_TRUE(extDesc.layout.extMsgLength + desc.layout.msgLength < totalMaxLength,
279278
"combined message length may not exceed the maximum");
280-
281-
if (extDesc.layout.extMsgLength + desc.layout.msgLength >= 16)
282-
{
283-
MUST_BE_TRUE(!isEot, "cm_sends can't set eot if message length is greater than 16");
284-
}
285279
}
286280

287281
G4_SendMsgDescriptor::G4_SendMsgDescriptor(
@@ -625,55 +619,6 @@ bool G4_SendMsgDescriptor::isHdcTypedSurfaceWrite() const
625619
getHdcMessageType() == DC1_TYPED_SURFACE_WRITE;
626620
}
627621

628-
bool G4_SendMsgDescriptor::isReadOnlyMessage(uint32_t msgDesc,
629-
uint32_t extDesc)
630-
{
631-
SFID funcID = intToSFID(extDesc & 0xF);
632-
unsigned subFuncID = (msgDesc >> 14) & 0x1F;
633-
634-
switch (funcID) {
635-
default:
636-
break;
637-
case SFID::DP_DC:
638-
switch (subFuncID) {
639-
case DC_OWORD_BLOCK_READ:
640-
case DC_ALIGNED_OWORD_BLOCK_READ:
641-
case DC_DWORD_SCATTERED_READ:
642-
case DC_BYTE_SCATTERED_READ:
643-
return true;
644-
default:
645-
return false;
646-
}
647-
case SFID::DP_DC1:
648-
switch (subFuncID) {
649-
case DC1_UNTYPED_SURFACE_READ:
650-
case DC1_MEDIA_BLOCK_READ:
651-
case DC1_TYPED_SURFACE_READ:
652-
case DC1_A64_SCATTERED_READ:
653-
case DC1_A64_UNTYPED_SURFACE_READ:
654-
case DC1_A64_BLOCK_READ:
655-
return true;
656-
default:
657-
return false;
658-
}
659-
case SFID::DP_DC2:
660-
switch (subFuncID) {
661-
case DC2_UNTYPED_SURFACE_READ:
662-
case DC2_A64_SCATTERED_READ:
663-
case DC2_A64_UNTYPED_SURFACE_READ:
664-
case DC2_BYTE_SCATTERED_READ:
665-
return true;
666-
default:
667-
return false;
668-
}
669-
case SFID::SAMPLER:
670-
return true;
671-
}
672-
673-
// Unknown.
674-
return false;
675-
}
676-
677622
const char* G4_SendMsgDescriptor::getDescType() const
678623
{
679624
// Return plain text string of type of msg, ie "oword read", "oword write",

visa/Gen4_IR.hpp

Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ class G4_SendMsgDescriptor
300300
static const int SLMIndex = 0xFE;
301301

302302
G4_SendMsgDescriptor(uint32_t fCtrl, uint32_t regs2rcv, uint32_t regs2snd,
303-
uint32_t fID, bool isEot, uint16_t extMsgLength, uint32_t extFCtrl,
304-
SendAccess access, G4_Operand *bti, G4_Operand *sti, IR_Builder& builder);
303+
SFID fID, uint16_t extMsgLength, uint32_t extFCtrl,
304+
SendAccess access, G4_Operand* bti, G4_Operand* sti, IR_Builder& builder);
305305

306306
/// Construct a object with descriptor and extended descriptor values.
307307
/// used in IR_Builder::createSendMsgDesc(uint32_t desc, uint32_t extDesc, SendAccess access)
@@ -378,16 +378,18 @@ class G4_SendMsgDescriptor
378378
}
379379

380380
/* Info methods */
381+
// common for all sends
381382
uint16_t ResponseLength() const { return desc.layout.rspLength; }
382383
uint16_t MessageLength() const { return desc.layout.msgLength; }
383384
uint16_t extMessageLength() const { return (uint16_t)src1Len; }
384-
385-
bool isCPSEnabled() const {return extDesc.layout.cps != 0;}
386385
bool isDataPortRead() const { return accessType != SendAccess::WRITE_ONLY; }
387386
bool isDataPortWrite() const { return accessType != SendAccess::READ_ONLY; }
388387
SendAccess getAccess() const { return accessType; }
389-
bool isValidFuncCtrl() const { return funcCtrlValid; }
390-
bool isSampler() const {return getFuncId() == SFID::SAMPLER;}
388+
bool isValidFuncCtrl() const { return funcCtrlValid; }
389+
bool isHeaderPresent() const;
390+
void setHeaderPresent(bool val);
391+
392+
// for HDC messages only (DC0/DC1/DC2)
391393
bool isHDC() const
392394
{
393395
auto funcID = getFuncId();
@@ -397,88 +399,66 @@ class G4_SendMsgDescriptor
397399
funcID == SFID::DP_DC2 ||
398400
funcID == SFID::DP_CC;
399401
}
400-
// isHDC() must be true
401-
uint32_t getHdcMessageType() const;
402-
403-
bool isThreadMessage() const {
404-
return getFuncId() == SFID::GATEWAY || getFuncId() == SFID::SPAWNER;
405-
}
406402

403+
uint32_t getHdcMessageType() const;
407404
bool isAtomicMessage() const;
408405
uint16_t getHdcAtomicOp() const;
409406

410407
bool isSLMMessage() const;
411408

412-
bool isBarrierMsg() const;
413-
bool isFence() const;
414-
415-
bool isSendBarrier() const {
416-
return isAtomicMessage() || isBarrierMsg(); // atomic write or explicit barrier
417-
}
418-
419-
/////////////////////////////////////////////////////////
420-
// the following may only be called on HDC messages
421409
unsigned int getEnabledChannelNum() const;
422410
unsigned int getBlockNum() const;
423411
unsigned int getBlockSize() const;
424-
// true if the message is either oword read or unaligned oword read
425412
bool isOwordLoad() const;
426413

427-
// introduced to replace direct access to desc bits
428414
bool isHdcTypedSurfaceWrite() const;
429415

430-
// TODO: this should be eliminated; it only supports a subset of messages
431-
// and can produce a false negative on newer messages; it also doesn't
432-
// support the SFID separate from the descriptor
433-
//
434-
// read-only implies that it doesn't write (e.g. an atomic)
435-
static bool isReadOnlyMessage(uint32_t msgDesc, uint32_t exDesc);
436-
437-
438416
// return offset in unit of GRF
439417
uint16_t getScratchRWOffset() const
440418
{
441419
MUST_BE_TRUE(isScratchRW(), "Message is not scratch space R/W.");
442420
return (getFuncCtrl() & 0xFFFu);
443421
}
444422

445-
// number of GRFs to read/write
446-
//
447-
// Block Size indicates the number of simd-8 registers to be read|written.
448-
// 11: 8 registers
449-
// 10: 4 registers
450-
// 01: 2 registers
451-
// 00: 1 register
452-
uint16_t getScratchRWSize() const
453-
{
454-
MUST_BE_TRUE(isScratchRW(), "Message is not scratch space R/W.");
455-
uint16_t bitV = ((getFuncCtrl() & 0x3000u) >> 12);
456-
return 0x1 << bitV;
457-
}
458423
bool isScratchRW() const
459424
{
460425
// scratch msg: DC0, bit 18 = 1
461426
return getFuncId() == SFID::DP_DC && ((getFuncCtrl() & 0x40000u) != 0);
462427
}
463428
bool isScratchRead() const
464429
{
465-
if( !isScratchRW() )
466-
return false;
467-
return ((getFuncCtrl() & 0x20000u) == 0);
430+
return isScratchRW() && (getFuncCtrl() & 0x20000u) == 0;
468431
}
469432
bool isScratchWrite() const
470433
{
471-
if( !isScratchRW() )
472-
return false;
473-
return ((getFuncCtrl ()& 0x20000u) != 0);
434+
return isScratchRW() && (getFuncCtrl() & 0x20000u) != 0;
435+
}
436+
uint16_t getScratchRWSize() const
437+
{
438+
MUST_BE_TRUE(isScratchRW(), "Message is not scratch space R/W.");
439+
uint16_t bitV = ((getFuncCtrl() & 0x3000u) >> 12);
440+
return 0x1 << bitV;
474441
}
475442

476-
bool isHeaderPresent() const;
477-
void setHeaderPresent(bool val);
443+
bool isA64Message() const;
478444

445+
// for sampler mesasges only
446+
bool isSampler() const { return getFuncId() == SFID::SAMPLER; }
447+
bool isCPSEnabled() const { return extDesc.layout.cps != 0; }
479448
bool is16BitInput() const;
480449
bool is16BitReturn() const;
481-
bool isA64Message() const;
450+
451+
bool isThreadMessage() const
452+
{
453+
return getFuncId() == SFID::GATEWAY || getFuncId() == SFID::SPAWNER;
454+
}
455+
456+
bool isBarrierMsg() const;
457+
bool isFence() const;
458+
459+
bool isSendBarrier() const {
460+
return isAtomicMessage() || isBarrierMsg(); // atomic write or explicit barrier
461+
}
482462

483463
const G4_Operand *getBti() const {return m_bti;}
484464
G4_Operand *getBti() {return m_bti;}

visa/GraphColor.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9381,12 +9381,7 @@ int GlobalRA::coloringRegAlloc()
93819381
}
93829382

93839383
scratchOffset = std::max(scratchOffset, spillGRF.getNextScratchOffset());
9384-
#ifdef FIX_SCRATCH_SPILL_MESSAGE
9385-
if (scratchOffset >= SCRATCH_MSG_LIMIT && useScratchMsgForSpill)
9386-
{
9387-
spillGRF.fixSpillFillCode(&kernel);
9388-
}
9389-
#endif
9384+
93909385
bool disableSpillCoalecse = builder.getOption(vISA_DisableSpillCoalescing) ||
93919386
builder.getOption(vISA_FastSpill) || builder.getOption(vISA_Debug) ||
93929387
!useScratchMsgForSpill;

visa/Optimizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7791,7 +7791,7 @@ void genBucket(G4_INST *send, Bucket *bucket, RW rwType) {
77917791
msgDescImm |= i;
77927792

77937793
G4_SendMsgDescriptor* desc = kernel.fg.builder->createSendMsgDesc(
7794-
msgDescImm, 0, 1, funcID, false, msgSize, extFuncCtrl, SendAccess::WRITE_ONLY);
7794+
msgDescImm, 0, 1, funcID, msgSize, extFuncCtrl, SendAccess::WRITE_ONLY);
77957795
const RegionDesc* region = kernel.fg.builder->getRegionStride1();
77967796
G4_SrcRegRegion* headerOpnd = kernel.fg.builder->Create_Src_Opnd_From_Dcl(kernel.fg.builder->getBuiltinR0(), region);
77977797
G4_Declare* tempDcl = builder.createHardwiredDeclare(msgSize * 8, Type_UD, i, 0);

0 commit comments

Comments
 (0)