@@ -58,13 +58,6 @@ using namespace llvm;
58
58
namespace IGC
59
59
{
60
60
61
- unsigned int getGRFSize ()
62
- {
63
- unsigned int byteSize = 32 ;
64
-
65
- return byteSize;
66
- }
67
-
68
61
Common_ISA_Exec_Size getExecSize (SIMDMode width)
69
62
{
70
63
switch (width)
@@ -209,10 +202,11 @@ visaBlockNum(unsigned numElems) {
209
202
return static_cast <Common_ISA_SVM_Block_Num>(~0U );
210
203
}
211
204
212
- static unsigned
213
- GetRawOpndSplitOffset (Common_ISA_Exec_Size fromExecSize,
214
- Common_ISA_Exec_Size toExecSize,
215
- unsigned thePart, CVariable *var) {
205
+ unsigned
206
+ CEncoder::GetRawOpndSplitOffset (Common_ISA_Exec_Size fromExecSize,
207
+ Common_ISA_Exec_Size toExecSize,
208
+ unsigned thePart, CVariable *var) const
209
+ {
216
210
if (!var || var->IsUniform ())
217
211
return 0 ;
218
212
@@ -226,9 +220,9 @@ GetRawOpndSplitOffset(Common_ISA_Exec_Size fromExecSize,
226
220
227
221
switch (elemSize) {
228
222
case 4 :
229
- return thePart * SIZE_GRF * 1 ;
223
+ return thePart * getGRFSize () * 1 ;
230
224
case 8 :
231
- return thePart * SIZE_GRF * 2 ;
225
+ return thePart * getGRFSize () * 2 ;
232
226
}
233
227
234
228
assert (false && " Unknown data type to split!" );
@@ -278,6 +272,8 @@ CEncoder::~CEncoder()
278
272
{
279
273
}
280
274
275
+ uint32_t CEncoder::getGRFSize () const { return m_program->getGRFSize (); }
276
+
281
277
void CEncoder::SetProgram (CShader* program)
282
278
{
283
279
m_program = program;
@@ -429,8 +425,7 @@ void CEncoder::Cmp(e_predicate p, CVariable* dst, CVariable* src0, CVariable* sr
429
425
// that is, if the execution size is 16 and the comparison type
430
426
// is QW.
431
427
bool bNeedSplitting = false ;
432
- if (flagDst &&
433
- (GetAluExecSize (dst) == EXEC_SIZE_16) &&
428
+ if (flagDst && needsSplitting (GetAluExecSize (dst)) &&
434
429
(src0->GetElemSize () > 4 || src1->GetElemSize () > 4 ))
435
430
{
436
431
bNeedSplitting = true ;
@@ -1003,7 +998,8 @@ bool CEncoder::NeedSplitting(CVariable *var, const SModifier &mod,
1003
998
return false ;
1004
999
// If the data type has more than 4 bytes, i.e. 32 bits, it already crosses
1005
1000
// 2+ GRFs by itself. There's no need to check further.
1006
- if (elemSize > 4 ) {
1001
+ if (elemSize > 4 )
1002
+ {
1007
1003
assert (elemSize == 8 && " Only QWORD is supported so far!" );
1008
1004
assert ((isSource || !mod.specialRegion ) &&
1009
1005
" It's expected that there's no special region associated with "
@@ -1193,7 +1189,7 @@ void CEncoder::SplitMDP16To8(CVariable* MDP, uint32_t MDPOfst, uint32_t NumBlks,
1193
1189
1194
1190
if (eltBytes > 0 )
1195
1191
{
1196
- const uint32_t GRFElts = SIZE_GRF / eltBytes;
1192
+ uint32_t GRFElts = getGRFSize () / eltBytes;
1197
1193
1198
1194
if (GRFElts > 0 )
1199
1195
{
@@ -1243,7 +1239,7 @@ void CEncoder::MergeMDP8To16(CVariable* V0, CVariable* V1, uint32_t NumBlks, CVa
1243
1239
if (eltBytes > 0 )
1244
1240
{
1245
1241
// Number of elements per GRF
1246
- const uint32_t GRFElts = SIZE_GRF / eltBytes;
1242
+ const uint32_t GRFElts = getGRFSize () / eltBytes;
1247
1243
1248
1244
if (GRFElts > 0 )
1249
1245
{
@@ -1675,7 +1671,8 @@ void CEncoder::AddPair(CVariable *Lo, CVariable *Hi, CVariable *L0, CVariable *H
1675
1671
ExecSize == EXEC_SIZE_4 || ExecSize == EXEC_SIZE_2 ||
1676
1672
ExecSize == EXEC_SIZE_1);
1677
1673
1678
- if (ExecSize == EXEC_SIZE_16) {
1674
+ if (needsSplitting (ExecSize))
1675
+ {
1679
1676
// Have to split it because `acc0` has only 8 elements for 32-bit
1680
1677
// integer types.
1681
1678
unsigned NumParts = 2 ;
@@ -1780,7 +1777,8 @@ void CEncoder::SubPair(CVariable *Lo, CVariable *Hi, CVariable *L0, CVariable *H
1780
1777
if (L1->GetType () != ISA_TYPE_UD && L1->GetType () != ISA_TYPE_UV) L1 = m_program->BitCast (L1, ISA_TYPE_UD);
1781
1778
if (H1->GetType () != ISA_TYPE_UD && H1->GetType () != ISA_TYPE_UV) H1 = m_program->BitCast (H1, ISA_TYPE_UD);
1782
1779
1783
- if (ExecSize == EXEC_SIZE_16) {
1780
+ if (needsSplitting (ExecSize))
1781
+ {
1784
1782
// Have to split it because `acc0` has only 8 elements for 32-bit
1785
1783
// integer types.
1786
1784
unsigned NumParts = 2 ;
@@ -2023,7 +2021,7 @@ VISA_RawOpnd* CEncoder::GetRawDestination(CVariable* var, unsigned offset)
2023
2021
{
2024
2022
V (vKernel->CreateVISARawOperand (
2025
2023
dstOpnd, GetVISAVariable (var),
2026
- m_encoderState.m_dstOperand .subVar *SIZE_GRF + offset + var->GetAliasOffset ()));
2024
+ m_encoderState.m_dstOperand .subVar *getGRFSize () + offset + var->GetAliasOffset ()));
2027
2025
}
2028
2026
else
2029
2027
{
@@ -2039,8 +2037,8 @@ void CEncoder::Send(CVariable* dst, CVariable* src, uint exDesc, CVariable* mess
2039
2037
m_encoderState.m_simdSize = m_encoderState.m_uniformSIMDSize ;
2040
2038
}
2041
2039
unsigned char sendc = isSendc ? 1 : 0 ;
2042
- unsigned char srcSize = src->GetSize ()/SIZE_GRF ;
2043
- unsigned char dstSize = dst ? dst->GetSize ()/SIZE_GRF : 0 ;
2040
+ unsigned char srcSize = src->GetSize ()/getGRFSize () ;
2041
+ unsigned char dstSize = dst ? dst->GetSize ()/getGRFSize () : 0 ;
2044
2042
VISA_PredOpnd* predOpnd = GetFlagOperand (m_encoderState.m_flag );
2045
2043
VISA_RawOpnd *srcOpnd0 = GetRawSource (src);
2046
2044
VISA_RawOpnd *dstOpnd = GetRawDestination (dst);
@@ -2076,9 +2074,9 @@ void CEncoder::Sends(CVariable* dst, CVariable* src0, CVariable* src1, uint ffid
2076
2074
m_encoderState.m_simdSize = m_encoderState.m_uniformSIMDSize ;
2077
2075
}
2078
2076
unsigned char sendc = isSendc ? 1 : 0 ;
2079
- unsigned char src0Size = src0->GetSize ()/SIZE_GRF ;
2080
- unsigned char src1Size = src1 ? src1->GetSize () / SIZE_GRF : 0 ;
2081
- unsigned char dstSize = dst ? dst->GetSize ()/SIZE_GRF : 0 ;
2077
+ unsigned char src0Size = src0->GetSize ()/getGRFSize () ;
2078
+ unsigned char src1Size = src1 ? src1->GetSize () / getGRFSize () : 0 ;
2079
+ unsigned char dstSize = dst ? dst->GetSize ()/getGRFSize () : 0 ;
2082
2080
VISA_PredOpnd* predOpnd = GetFlagOperand (m_encoderState.m_flag );
2083
2081
VISA_RawOpnd *srcOpnd0 = GetRawSource (src0);
2084
2082
VISA_RawOpnd *srcOpnd1 = GetRawSource (src1);
@@ -2875,10 +2873,10 @@ void CEncoder::TypedReadWrite(
2875
2873
VISA_StateOpndHandle* pSurfStateOpndHandle = GetVISASurfaceOpnd (resource);
2876
2874
2877
2875
// TODO unify the way we calculate offset for raw sources, maybe we shouldn't use offset at all
2878
- VISA_RawOpnd* pUOffset = GetRawSource (pU, m_encoderState.m_srcOperand [0 ].subVar *SIZE_GRF );
2879
- VISA_RawOpnd* pVOffset = GetRawSource (pV, m_encoderState.m_srcOperand [1 ].subVar *SIZE_GRF );
2880
- VISA_RawOpnd* pROffset = GetRawSource (pR, m_encoderState.m_srcOperand [2 ].subVar *SIZE_GRF );
2881
- VISA_RawOpnd* pLODOffset = GetRawSource (pLOD, m_encoderState.m_srcOperand [3 ].subVar *SIZE_GRF );
2876
+ VISA_RawOpnd* pUOffset = GetRawSource (pU, m_encoderState.m_srcOperand [0 ].subVar *getGRFSize () );
2877
+ VISA_RawOpnd* pVOffset = GetRawSource (pV, m_encoderState.m_srcOperand [1 ].subVar *getGRFSize () );
2878
+ VISA_RawOpnd* pROffset = GetRawSource (pR, m_encoderState.m_srcOperand [2 ].subVar *getGRFSize () );
2879
+ VISA_RawOpnd* pLODOffset = GetRawSource (pLOD, m_encoderState.m_srcOperand [3 ].subVar *getGRFSize () );
2882
2880
VISA_PredOpnd* predOpnd = GetFlagOperand (m_encoderState.m_flag );
2883
2881
assert (m_encoderState.m_dstOperand .subVar == 0 );
2884
2882
@@ -4621,7 +4619,7 @@ void CEncoder::GatherA64(CVariable *dst,
4621
4619
addressOpnd, dstOpnd));
4622
4620
}
4623
4621
4624
- uint32_t dstOfstBytes = dst->GetAliasOffset () + m_encoderState.m_dstOperand .subVar * SIZE_GRF ;
4622
+ uint32_t dstOfstBytes = dst->GetAliasOffset () + m_encoderState.m_dstOperand .subVar * getGRFSize () ;
4625
4623
MergeMDP8To16 (V0, V1, numElems, dst, dstOfstBytes);
4626
4624
}
4627
4625
return ;
@@ -4863,60 +4861,43 @@ void CEncoder::Gather4ScaledNd(CVariable *dst,
4863
4861
addressOpnd, dstOpnd));
4864
4862
}
4865
4863
4866
-
4867
- void CEncoder::Gather4Scaled (CVariable *dst,
4868
- const ResourceDescriptor& resource,
4869
- CVariable *offset) {
4870
- unsigned nd = dst->GetSize ();
4871
- if (dst->IsUniform ())
4864
+ uint32_t CEncoder::getNumChannels (CVariable* var) const
4865
+ {
4866
+ unsigned nd = var->GetSize ();
4867
+ if (var->IsUniform ())
4872
4868
{
4873
- if (nd > SIZE_GRF )
4869
+ if (nd > getGRFSize () )
4874
4870
{
4875
- assert (false && " Unknown DstSize!" );
4876
- return ;
4871
+ assert (false && " Unknown Variable Size!" );
4877
4872
}
4878
- nd = 1 ;
4873
+ return 1 ;
4879
4874
}
4880
4875
else
4881
4876
{
4882
- switch (m_encoderState.m_simdSize ) {
4883
- default : assert (false && " Unknown SIMD size!" ); return ;
4877
+ switch (m_encoderState.m_simdSize )
4878
+ {
4879
+ default : assert (false && " Unknown SIMD size!" ); return 1 ;
4884
4880
case SIMDMode::SIMD8:
4885
- nd = nd / (SIZE_GRF * 1 );
4886
- break ;
4881
+ return nd / (8 * SIZE_DWORD);
4887
4882
case SIMDMode::SIMD16:
4888
- nd = nd / (SIZE_GRF * 2 );
4889
- break ;
4883
+ return nd / (16 * SIZE_DWORD);
4890
4884
}
4891
4885
}
4886
+ return 1 ;
4887
+ }
4888
+
4889
+ void CEncoder::Gather4Scaled (CVariable *dst,
4890
+ const ResourceDescriptor& resource,
4891
+ CVariable *offset)
4892
+ {
4893
+ unsigned nd = getNumChannels (dst);
4892
4894
Gather4ScaledNd (dst, resource, offset, nd);
4893
4895
}
4894
4896
4895
4897
void CEncoder::Scatter4Scaled (CVariable *src,
4896
4898
const ResourceDescriptor& resource,
4897
4899
CVariable *offset) {
4898
- unsigned nd = src->GetSize ();
4899
- if (src->IsUniform ())
4900
- {
4901
- if (nd > SIZE_GRF)
4902
- {
4903
- assert (false && " Unknown SrcSize!" );
4904
- return ;
4905
- }
4906
- nd = 1 ;
4907
- }
4908
- else
4909
- {
4910
- switch (m_encoderState.m_simdSize ) {
4911
- default : assert (false && " Unknown SIMD size!" ); return ;
4912
- case SIMDMode::SIMD8:
4913
- nd = nd / (SIZE_GRF * 1 );
4914
- break ;
4915
- case SIMDMode::SIMD16:
4916
- nd = nd / (SIZE_GRF * 2 );
4917
- break ;
4918
- }
4919
- }
4900
+ unsigned nd = getNumChannels (src);
4920
4901
4921
4902
VISA_StateOpndHandle* surfaceOpnd = GetVISASurfaceOpnd (resource);
4922
4903
VISA_PredOpnd* predOpnd = GetFlagOperand (m_encoderState.m_flag );
@@ -4942,15 +4923,15 @@ void CEncoder::Scatter4Scaled(CVariable *src,
4942
4923
void CEncoder::Gather4A64 (CVariable *dst, CVariable *offset) {
4943
4924
assert (dst->GetElemSize () == 4 && " Gather4 must have 4-byte element" );
4944
4925
4945
- uint32_t dstOfstBytes = m_encoderState.m_dstOperand .subVar * SIZE_GRF + dst->GetAliasOffset ();
4926
+ uint32_t dstOfstBytes = m_encoderState.m_dstOperand .subVar * getGRFSize () + dst->GetAliasOffset ();
4946
4927
unsigned nd = dst->GetSize ();
4947
4928
switch (m_encoderState.m_simdSize ) {
4948
4929
default : assert (false && " Unknown SIMD size!" ); return ;
4949
4930
case SIMDMode::SIMD8:
4950
- nd = nd / (SIZE_GRF * 1 );
4931
+ nd = nd / (8 * SIZE_DWORD );
4951
4932
break ;
4952
4933
case SIMDMode::SIMD16:
4953
- nd = nd / (SIZE_GRF * 2 );
4934
+ nd = nd / (16 * SIZE_DWORD );
4954
4935
break ;
4955
4936
}
4956
4937
@@ -5037,10 +5018,10 @@ void CEncoder::Scatter4A64(CVariable *src, CVariable *offset) {
5037
5018
switch (m_encoderState.m_simdSize ) {
5038
5019
default : assert (false && " Unknown SIMD size!" ); return ;
5039
5020
case SIMDMode::SIMD8:
5040
- nd = nd / (SIZE_GRF * 1 );
5021
+ nd = nd / (8 * SIZE_DWORD );
5041
5022
break ;
5042
5023
case SIMDMode::SIMD16:
5043
- nd = nd / (SIZE_GRF * 2 );
5024
+ nd = nd / (16 * SIZE_DWORD );
5044
5025
break ;
5045
5026
}
5046
5027
@@ -5390,11 +5371,11 @@ void CEncoder::SetVISAWaTable(WA_TABLE const& waTable)
5390
5371
void CEncoder::GetRowAndColOffset (CVariable* var, unsigned int subVar, unsigned int subReg, unsigned char & rowOff, unsigned char & colOff)
5391
5372
{
5392
5373
unsigned int varTypeSize = GetCISADataTypeSize (var->GetType ());
5393
- unsigned int offset = var->GetAliasOffset () + subVar * SIZE_GRF + subReg * varTypeSize;
5394
- assert ((offset%SIZE_GRF ) % varTypeSize == 0 && " offset has to be aligned on element size" );
5395
- rowOff = int_cast<unsigned char >(offset / SIZE_GRF );
5374
+ unsigned int offset = var->GetAliasOffset () + subVar * getGRFSize () + subReg * varTypeSize;
5375
+ assert ((offset%getGRFSize () ) % varTypeSize == 0 && " offset has to be aligned on element size" );
5376
+ rowOff = int_cast<unsigned char >(offset / getGRFSize () );
5396
5377
assert (varTypeSize != 0 );
5397
- colOff = int_cast<unsigned char >((offset%SIZE_GRF ) / varTypeSize);
5378
+ colOff = int_cast<unsigned char >((offset%getGRFSize () ) / varTypeSize);
5398
5379
}
5399
5380
5400
5381
void CEncoder::Loc (unsigned int line)
0 commit comments