@@ -234,6 +234,77 @@ class BinaryEncodingIGA
234
234
}
235
235
}
236
236
237
+ // get IGA type from GenPrecision
238
+ iga::Type getIGAPrecisionType (GenPrecision p) const
239
+ {
240
+ switch (p)
241
+ {
242
+ case GenPrecision::U1: return iga::Type::U1;
243
+ case GenPrecision::U2: return iga::Type::U2;
244
+ case GenPrecision::U4: return iga::Type::U4;
245
+ case GenPrecision::U8: return iga::Type::UB;
246
+ case GenPrecision::S2: return iga::Type::S2;
247
+ case GenPrecision::S4: return iga::Type::S4;
248
+ case GenPrecision::S8: return iga::Type::B;
249
+ case GenPrecision::FP16: return iga::Type::HF;
250
+ case GenPrecision::BF16: return iga::Type::BF;
251
+ default :
252
+ assert (false && " illegal Operand Precision" );
253
+ return iga::Type::INVALID;
254
+ }
255
+ }
256
+
257
+ iga::Type getIGADpasType (G4_InstDpas* DpasInst, int SrcOprdIx) const
258
+ {
259
+ iga::Type ty;
260
+ switch (SrcOprdIx) {
261
+ default :
262
+ MUST_BE_TRUE (false , " Invalid SrcOprdIx!" );
263
+ break ;
264
+ case 0 :
265
+ {
266
+ G4_Operand* src0 = DpasInst->getSrc (0 );
267
+ if (src0->isNullReg ()) {
268
+ ty = getIGAType (DpasInst->getDst ()->getType (), platform);
269
+ }
270
+ else
271
+ {
272
+ ty = getIGAType (src0->getType (), platform);
273
+ }
274
+ break ;
275
+ }
276
+ case 1 :
277
+ ty = getIGAPrecisionType (DpasInst->getSrc1Precision ());
278
+ break ;
279
+ case 2 :
280
+ ty = getIGAPrecisionType (DpasInst->getSrc2Precision ());
281
+ break ;
282
+ }
283
+ return ty;
284
+ }
285
+
286
+ iga::RegRef getIGADpasRegRef (G4_InstDpas* DpasInst, int SrcOprdIx) const
287
+ {
288
+ G4_Operand* src = DpasInst->getSrc (SrcOprdIx);
289
+ iga::RegRef regref = getIGARegRef (src);
290
+ if (SrcOprdIx == 2 ) {
291
+ // By default, subRegNum is in terms of operand's type (D/UD for
292
+ // dpas's src1/2). IGA needs it to be in terms of precision type.
293
+ // Note that no need to do it for src1 as it must be grf-aligned!
294
+ assert ((regref.subRegNum % 2 ) == 0 &&
295
+ " Minimum alignemnt of dpas's src2 must be QW" );
296
+ uint32_t bitOffsets = regref.subRegNum * src->getTypeSize () * 8 ;
297
+ uint32_t PBits = G4_InstDpas::GetPrecisionSizeInBits (DpasInst->getSrc2Precision ());
298
+ regref.subRegNum = bitOffsets / PBits;
299
+ }
300
+ return regref;
301
+ }
302
+
303
+ static iga::BfnFC getBfnFC (const G4_INST *inst)
304
+ {
305
+ uint8_t funcCtrl = inst->asBfnInst ()->getBooleanFuncCtrl ();
306
+ return iga::BfnFC (funcCtrl);
307
+ }
237
308
static iga::SFID getSFID (const G4_INST* inst);
238
309
static iga::MathFC getMathFC (const G4_INST *inst);
239
310
iga::Type getIGAType (const G4_INST* I, Gen4_Operand_Number O, TARGET_PLATFORM P);
@@ -264,6 +335,9 @@ Platform BinaryEncodingIGA::getIGAInternalPlatform(TARGET_PLATFORM genxPlatform)
264
335
case GENX_TGLLP:
265
336
platform = Platform::XE;
266
337
break ;
338
+ case GENX_XE_HP:
339
+ platform = Platform::XE_HP;
340
+ break ;
267
341
default :
268
342
break ;
269
343
}
@@ -553,6 +627,21 @@ std::pair<const iga::OpSpec *,iga::Subfunction> BinaryEncodingIGA::getIgaOpInfo(
553
627
case G4_dp3: igaOp = iga::Op::DP3; break ;
554
628
case G4_dp2: igaOp = iga::Op::DP2; break ;
555
629
case G4_dp4a: igaOp = iga::Op::DP4A; break ;
630
+ case G4_dpas:
631
+ case G4_dpasw:
632
+ {
633
+ igaOp = inst->opcode () == G4_dpasw ? iga::Op::DPASW : iga::Op::DPAS;
634
+ G4_InstDpas* dpasInst = inst->asDpasInst ();
635
+ uint8_t D = dpasInst->getSystolicDepth ();
636
+ uint8_t C = dpasInst->getRepeatCount ();
637
+ sf = iga::GetDpasFC (D, C);
638
+ break ;
639
+ }
640
+ case G4_add3: igaOp = iga::Op::ADD3; break ;
641
+ case G4_bfn:
642
+ igaOp = iga::Op::BFN;
643
+ sf = getBfnFC (inst);
644
+ break ;
556
645
case G4_line: igaOp = iga::Op::LINE; break ;
557
646
case G4_pln: igaOp = iga::Op::PLN; break ;
558
647
case G4_mad: igaOp = iga::Op::MAD; break ;
@@ -619,8 +708,35 @@ void BinaryEncodingIGA::SetSWSB(G4_INST *inst, iga::SWSB &sw)
619
708
sw.sbid = inst->getToken ();
620
709
}
621
710
711
+ // Set distance, e.g. A@1
712
+ using DistanceType = vISA::G4_INST::DistanceType;
622
713
if ((unsigned )inst->getDistance ())
623
714
{
715
+ // check the distance type for multi-dist-pipes
716
+ if (kernel.fg .builder ->hasThreeALUPipes () ||
717
+ kernel.fg .builder ->hasFourALUPipes ()) {
718
+ switch (inst->getDistanceTypeXe ())
719
+ {
720
+ case DistanceType::DIST:
721
+ sw.distType = SWSB::DistType::REG_DIST;
722
+ break ;
723
+ case DistanceType::DISTALL:
724
+ sw.distType = SWSB::DistType::REG_DIST_ALL;
725
+ break ;
726
+ case DistanceType::DISTINT:
727
+ sw.distType = SWSB::DistType::REG_DIST_INT;
728
+ break ;
729
+ case DistanceType::DISTFLOAT:
730
+ sw.distType = SWSB::DistType::REG_DIST_FLOAT;
731
+ break ;
732
+ case DistanceType::DISTLONG:
733
+ sw.distType = SWSB::DistType::REG_DIST_LONG;
734
+ break ;
735
+ default :
736
+ break ;
737
+ }
738
+ }
739
+ else
624
740
{
625
741
// there is only one pipe on single-dist-pipe platform,
626
742
// must be REG_DIST
@@ -765,6 +881,8 @@ void BinaryEncodingIGA::Encode()
765
881
SWSB::InstType instTy = SWSB::InstType::UNKNOWN;
766
882
if (inst->isMath ())
767
883
instTy = SWSB::InstType::MATH;
884
+ else if (inst->isDpas ())
885
+ instTy = SWSB::InstType::DPAS;
768
886
else if (inst->isSend ())
769
887
instTy = SWSB::InstType::SEND;
770
888
else
@@ -1157,6 +1275,22 @@ void BinaryEncodingIGA::translateInstructionSrcs(
1157
1275
region,
1158
1276
type);
1159
1277
}
1278
+ else if (inst->isDpas ())
1279
+ {
1280
+ assert (srcRegion->getRegAccess () == Direct &&
1281
+ " dpas does not support indirect GRF operands" );
1282
+ G4_InstDpas* dpasInst = inst->asDpasInst ();
1283
+ RegRef regRef = getIGADpasRegRef (dpasInst, i);
1284
+ type = getIGADpasType (dpasInst, i);
1285
+
1286
+ igaInst->setDirectSource (
1287
+ opIx,
1288
+ srcMod,
1289
+ getIGARegName (srcRegion),
1290
+ regRef,
1291
+ region,
1292
+ type);
1293
+ }
1160
1294
else if (srcRegion->getRegAccess () == Direct)
1161
1295
{
1162
1296
igaInst->setDirectSource (
@@ -1201,7 +1335,6 @@ void BinaryEncodingIGA::translateInstructionSrcs(
1201
1335
} // for
1202
1336
}
1203
1337
1204
-
1205
1338
SendDesc BinaryEncodingIGA::getIGASendDesc (G4_INST* sendInst) const
1206
1339
{
1207
1340
SendDesc desc;
@@ -1319,8 +1452,19 @@ iga::SendDesc BinaryEncodingIGA::encodeExDescRegA0(
1319
1452
(uint16_t )exDescG4->asSrcRegRegion ()->ExSubRegNum (valid);
1320
1453
assert (valid && " invalid subreg" );
1321
1454
1455
+ if (kernel.fg .builder ->useNewExtDescFormat () && descG4->isCPSEnabled ()) {
1456
+ // CPS is an instruction option if using RegDesc+ExBSO
1457
+ extraOpts.add (InstOpt::CPS);
1458
+ }
1459
+
1460
+ // By default all RegDesc in the new descriptor format will use
1461
+ // the ExBSO model if at all possible
1462
+ bool encodeExBso = kernel.fg .builder ->useNewExtDescFormat ();
1463
+ if (encodeExBso)
1464
+ extraOpts.add (InstOpt::EXBSO);
1322
1465
1323
1466
// G4 IR keeps Src1.Length (xlen) separate. So it's known,
1467
+ // (even with a reg desc in nonExBSO mode)
1324
1468
xlen = (int )descG4->extMessageLength ();
1325
1469
1326
1470
return exDescIga;
@@ -1463,6 +1607,7 @@ iga::Type BinaryEncodingIGA::getIGAType(G4_Type type, TARGET_PLATFORM genxPlatfo
1463
1607
case Type_V: return iga::Type::V;
1464
1608
case Type_VF: return iga::Type::VF;
1465
1609
case Type_NF: return iga::Type::NF;
1610
+ case Type_BF: return iga::Type::BF;
1466
1611
default :
1467
1612
assert (false && " illegal type" );
1468
1613
return iga::Type::INVALID;
0 commit comments