Skip to content

Commit 8266ce1

Browse files
jfuentesigcbot
authored andcommitted
Update GRF number based on kernel attribute before verification
1 parent 981506e commit 8266ce1

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

visa/BuildCISAIRImpl.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,9 @@ int CISA_IR_Builder::Compile(const char *isaasmFileName, bool emit_visa_only) {
16481648

16491649
int status = VISA_SUCCESS;
16501650
for (auto func : m_kernelsAndFunctions) {
1651-
func->finalizeAttributes();
1651+
bool attrWithoutError = func->finalizeAttributes();
1652+
if (!attrWithoutError)
1653+
return VISA_FAILURE;
16521654
}
16531655

16541656
if (m_options.getOption(vISA_GenerateISAASM) ||
@@ -1718,7 +1720,9 @@ int CISA_IR_Builder::Compile(const char *isaasmFileName, bool emit_visa_only) {
17181720
}
17191721

17201722
mainKernel = (kernel->getIsKernel()) ? kernel : mainKernel;
1721-
kernel->finalizeAttributes();
1723+
bool attrWithoutError = kernel->finalizeAttributes();
1724+
if (!attrWithoutError)
1725+
return VISA_FAILURE;
17221726
kernel->getIRBuilder()->setType(kernel->getType());
17231727
if (kernel->getIsKernel() == false) {
17241728
if (kernel->getIRBuilder()->getArgSize() <

visa/VISAKernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class VISAKernelImpl : public VISAFunction {
123123

124124
vISA::Attributes *getKernelAttributes() { return m_kernelAttrs; }
125125
// Temporary function to move options to attributes!
126-
void finalizeAttributes();
126+
bool finalizeAttributes();
127127

128128
void setName(const char *n);
129129
const char *getName() const { return m_name.c_str(); }

visa/VISAKernelImpl.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,6 @@ int VISAKernelImpl::compileFastPath() {
126126
m_kernelAttrs->isKernelAttrSet(Attributes::ATTR_RetValSize))),
127127
"vISA: input for function must have attributes ArgSize and RetValSize!");
128128

129-
if (getIsKernel() &&
130-
m_kernelAttrs->isKernelAttrSet(Attributes::ATTR_NumGRF)) {
131-
if (!m_kernel->updateKernelFromNumGRFAttr()) {
132-
m_builder->criticalMsgStream()
133-
<< "vISA: wrong value for .kernel_attr NumGRF";
134-
return VISA_FAILURE;
135-
}
136-
}
137-
138129
if (getIsKernel()) {
139130
status = calculateTotalInputSize();
140131
}
@@ -8423,16 +8414,23 @@ void VISAKernelImpl::setGenxDebugInfoBuffer(char *buffer, unsigned long size) {
84238414

84248415
/**
84258416
* finalizeAttributes() sets attributes based on options, etc.
8426-
* This is a temporary solution to move some options to attributes.
8427-
* Once clients set attributes directily without using options, this
8428-
* function shall be removed.
8417+
* Also, updates GRF configuration based on kernel attribute.
8418+
* Returns true if no error is found, false otherwise.
84298419
*/
8430-
void VISAKernelImpl::finalizeAttributes() {
8420+
bool VISAKernelImpl::finalizeAttributes() {
84318421
if (!m_kernelAttrs->isKernelAttrSet(Attributes::ATTR_Target)) {
84328422
VISATarget target = m_options->getTarget();
84338423
uint8_t val = (uint8_t)target;
84348424
AddKernelAttribute("Target", sizeof(val), &val);
84358425
}
8426+
if (m_kernelAttrs->isKernelAttrSet(Attributes::ATTR_NumGRF)) {
8427+
if (!m_kernel->updateKernelFromNumGRFAttr()) {
8428+
m_builder->criticalMsgStream()
8429+
<< "vISA: wrong value for .kernel_attr NumGRF";
8430+
return false;
8431+
}
8432+
}
8433+
return true;
84368434
}
84378435

84388436
VISA_LabelOpnd *

0 commit comments

Comments
 (0)