Skip to content

Commit 98d2d86

Browse files
jgu222sys_zuul
authored andcommitted
Continue to refactor attributes.
1. SurfaceUsage is var's attribute, not kernel's 2. Use attribute's enum instead of hard-coded string name. Remove uneeded code. Change-Id: Ie13a5f7673c6ab95d66ac5983ee1d28776961420
1 parent 82f2034 commit 98d2d86

File tree

8 files changed

+23
-32
lines changed

8 files changed

+23
-32
lines changed

visa/Attributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Attributes::SAttrInfo Attributes::AttrsInfo[Attributes::ATTR_TOTAL_NUM] =
4343
/////////////////////////////////////
4444
ATTR_ENTRY("Target", VISA_CM) , /* ATTR_Target */
4545
ATTR_ENTRY("SLMSIZE", 0 ) , /* ATTR_SLMSize */
46-
ATTR_ENTRY("SurfaceUsage", 0) , /* ATTR_SurfaceUsage */
4746
ATTR_ENTRY("SpillMemOffset", 0) , /* ATTR_SpillMemOffset */
4847
ATTR_ENTRY("ArgSize", 0) , /* ATTR_ArgSize */
4948
ATTR_ENTRY("RetValSize", 0) , /* ATTR_RetValSize */
@@ -66,6 +65,7 @@ Attributes::SAttrInfo Attributes::AttrsInfo[Attributes::ATTR_TOTAL_NUM] =
6665
ATTR_ENTRY("Scope", -1) , /* ATTR_Scope */
6766
ATTR_ENTRY("Input_Output", -1) , /* ATTR_Input_Output */
6867
ATTR_ENTRY("NoWidening", -1) , /* ATTR_NoWidening */
68+
ATTR_ENTRY("SurfaceUsage", 0) , /* ATTR_SurfaceUsage */
6969

7070
////////////////////////////////////////////
7171
///// string non-Kernel Attributes ////

visa/Attributes.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ namespace vISA
6363
ATTR_START_INT_KERNEL_ATTR,
6464
ATTR_Target = ATTR_START_INT_KERNEL_ATTR,
6565
ATTR_SLMSize,
66-
ATTR_SurfaceUsage,
6766
ATTR_SpillMemOffset, // Offset at which spill/fill starts
6867
ATTR_ArgSize,
6968
ATTR_RetValSize,
@@ -93,6 +92,7 @@ namespace vISA
9392
ATTR_Scope,
9493
ATTR_Input_Output,
9594
ATTR_NoWidening,
95+
ATTR_SurfaceUsage,
9696

9797
/********************************************************/
9898
/* string non-kernel attributes, such as variables' */

visa/BuildCISAIRImpl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,6 @@ int CISA_IR_Builder::Compile(const char* nameInput, std::ostream* os, bool emit_
861861
for( iter = m_kernels.begin(), i = 0; iter != end; iter++, i++ )
862862
{
863863
VISAKernelImpl* kernel = (*iter);
864-
kernel->processAttributes();
865864
kernel->getIRBuilder()->setIsKernel(kernel->getIsKernel());
866865
if( kernel->getIsKernel() == false )
867866
{

visa/BuildIR.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ class IR_Builder {
515515
G4_Declare* predefinedVars[static_cast<int>(PreDefinedVarsInternal::VAR_LAST)];
516516
};
517517

518-
bool use64BitFEStackVars;
519518
bool hasNullReturnSampler = false;
520519

521520
bool hasPerThreadProlog = false;
@@ -886,7 +885,7 @@ class IR_Builder {
886885
isKernel(false), parentBuilder(parent),
887886
builtinSamplerHeaderInitialized(false), m_pWaTable(pWaTable), m_options(options), CanonicalRegionStride0(0, 1, 0),
888887
CanonicalRegionStride1(1, 1, 0), CanonicalRegionStride2(2, 1, 0), CanonicalRegionStride4(4, 1, 0),
889-
use64BitFEStackVars(false), mem(m), phyregpool(m, k.getNumRegTotal()), hashtable(m), rgnpool(m), dclpool(m),
888+
mem(m), phyregpool(m, k.getNumRegTotal()), hashtable(m), rgnpool(m), dclpool(m),
890889
instList(alloc), kernel(k)
891890
{
892891
m_inst = nullptr;
@@ -2733,9 +2732,10 @@ class IR_Builder {
27332732

27342733
void doSamplerHeaderMove(G4_Declare* header, G4_Operand* sampler);
27352734

2736-
void set64BitFEStackVars() { use64BitFEStackVars = true; }
2737-
void set32BitFEStackVars() { use64BitFEStackVars = false; }
2738-
bool is64BitFEStackVars() { return use64BitFEStackVars; }
2735+
bool is64BitFEStackVars()
2736+
{
2737+
return kernel.getIntKernelAttribute(Attributes::ATTR_FESPSize) == 64;
2738+
}
27392739

27402740
void expandFdiv(uint8_t exsize, G4_Predicate *predOpnd, bool saturate,
27412741
G4_DstRegRegion *dstOpnd, G4_Operand *src0Opnd, G4_Operand *src1Opnd, uint32_t instOpt);

visa/ByteCodeReaderNG.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6161
#include "VISAKernel.h"
6262

6363
using namespace std;
64+
using namespace vISA;
6465

6566
struct RoutineContainer
6667
{
@@ -2413,13 +2414,14 @@ static void readRoutineNG(unsigned& bytePos, const char* buf, vISA::Mem_Manager&
24132414
attribute_info_t* attribute = &var->attributes[ai];
24142415

24152416
/// TODO: Does this code even make sense anymore???
2416-
if (!strcmp(header.strings[attribute->nameIndex], "SurfaceUsage"))
2417+
const char* attrName = header.strings[attribute->nameIndex];
2418+
if (Attributes::isAttribute(Attributes::ATTR_SurfaceUsage, attrName))
24172419
{
24182420
header.surface_attrs[i] = (attribute->value.intVal == 2);
24192421
break;
24202422
}
24212423

2422-
kernelBuilderImpl->AddAttributeToVar(decl, header.strings[attribute->nameIndex], attribute->size, attribute->value.stringVal);
2424+
kernelBuilderImpl->AddAttributeToVar(decl, attrName, attribute->size, attribute->value.stringVal);
24232425
}
24242426

24252427
container.surfaceVarDecls[i] = decl;

visa/IsaVerification.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ using namespace std;
4040

4141
#include "IsaDisassembly.h"
4242
#include "PreDefinedVars.h"
43+
#include "Attributes.hpp"
4344

4445
#include "Gen4_IR.hpp"
4546
/* stdio.h portability code start */
@@ -49,7 +50,7 @@ using namespace std;
4950
snprintf(NULL, 0, __VA_ARGS__)
5051
#endif
5152

52-
53+
using namespace vISA;
5354

5455
#define REPORT_HEADER(opt, cond, ...) \
5556
do if (!(cond)) { \
@@ -2916,14 +2917,15 @@ static void verifyKernelAttributes(
29162917
{
29172918
auto attr = header->getAttr(i);
29182919
const char* attrName = header->getString(attr->nameIndex);
2919-
if (strcmp(attrName, "SLMSize") == 0)
2920+
if (Attributes::isAttribute(Attributes::ATTR_SLMSize, attrName))
29202921
{
29212922
numSLMSize++;
29222923
}
29232924
}
29242925

29252926
REPORT_HEADER(options, numSLMSize <= 1,
2926-
"More than 1 kernel attribute defined SLMSize");
2927+
"More than 1 kernel attribute defined %s",
2928+
Attributes::getAttributeName(Attributes::ATTR_SLMSize));
29272929

29282930
}
29292931

visa/VISAKernel.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ class VISAKernelImpl : public VISAFunction
229229

230230
int getVISAOffset() const;
231231

232-
void processAttributes();
233-
234232
/***************** START EXPOSED APIS *************************/
235233
VISA_BUILDER_API int CreateVISAGenVar(VISA_GenVar *& decl, const char *varName, int numberElements, VISA_Type dataType,
236234
VISA_Align varAlign, VISA_GenVar *parentDecl = NULL, int aliasOffset = 0);

visa/VISAKernelImpl.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ int VISAKernelImpl::AddKernelAttribute(const char* attrName, int size, const voi
12901290
m_builder->getFCPatchInfo()->setIsEntryKernel(true);
12911291
m_options->setOption(vISA_loadThreadPayload, true);
12921292
}
1293-
else if (strcmp(attrName, "RetValSize") == 0)
1293+
else if (attrID == Attributes::ATTR_RetValSize)
12941294
{
12951295
if (IS_GEN_BOTH_PATH)
12961296
{
@@ -1300,7 +1300,7 @@ int VISAKernelImpl::AddKernelAttribute(const char* attrName, int size, const voi
13001300
}
13011301
}
13021302
}
1303-
else if (strcmp(attrName, "ArgSize") == 0)
1303+
else if (attrID == Attributes::ATTR_ArgSize)
13041304
{
13051305
if (IS_GEN_BOTH_PATH)
13061306
{
@@ -1341,18 +1341,17 @@ int VISAKernelImpl::AddAttributeToVarGeneric(CISA_GEN_VAR *decl, const char* var
13411341
//this->m_var_info_size += Get_Size_Attribute_Info(attr);
13421342
if(IS_GEN_BOTH_PATH)
13431343
{
1344-
if (strcmp(varName, "Input") == 0 ||
1345-
strcmp(varName, "Input_Output") == 0)
1344+
if (Attributes::isAttribute(Attributes::ATTR_Input, varName) ||
1345+
Attributes::isAttribute(Attributes::ATTR_Input_Output, varName))
13461346
{
13471347
decl->genVar.dcl->getRootDeclare()->setLiveIn();
1348-
13491348
}
1350-
if (strcmp(varName, "Output") == 0 ||
1351-
strcmp(varName, "Input_Output") == 0)
1349+
if (Attributes::isAttribute(Attributes::ATTR_Output, varName) ||
1350+
Attributes::isAttribute(Attributes::ATTR_Input_Output, varName))
13521351
{
13531352
decl->genVar.dcl->getRootDeclare()->setLiveOut();
13541353
}
1355-
if (strcmp(varName, "NoWidening") == 0)
1354+
if (Attributes::isAttribute(Attributes::ATTR_NoWidening, varName))
13561355
{
13571356
decl->genVar.dcl->getRootDeclare()->setDoNotWiden();
13581357
}
@@ -8129,15 +8128,6 @@ int VISAKernelImpl::getVISAOffset() const
81298128
return -1;
81308129
}
81318130

8132-
void VISAKernelImpl::processAttributes()
8133-
{
8134-
int feSPSize = 32;
8135-
if (getIntKernelAttributeValue("FESPSize", feSPSize) && feSPSize == 64)
8136-
{
8137-
m_builder->set64BitFEStackVars();
8138-
}
8139-
}
8140-
81418131
void VISAKernelImpl::computeFCInfo(BinaryEncodingBase* binEncodingInstance)
81428132
{
81438133
// This function iterates over all instructions in kernel and sets up data

0 commit comments

Comments
 (0)