performance: do not capture and mutate stateful arguments in default mode

Related-To: NEO-13916

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2025-07-18 12:04:04 +00:00
committed by Compute-Runtime-Automation
parent baab16c394
commit 259883c9c7
4 changed files with 32 additions and 18 deletions

View File

@@ -121,6 +121,7 @@ zexCommandListGetVariable(
auto outVariable = reinterpret_cast<Variable **>(phVariable);
InterfaceVariableDescriptor varDesc = {};
varDesc.api = true;
varDesc.name = pVariableDescriptor->name;
if (pVariableDescriptor->pNext != nullptr) {

View File

@@ -421,7 +421,7 @@ ze_result_t Variable::setBufferVariable(size_t size, const void *argVal) {
}
if (argValue != nullptr) {
cmdList->setBufferSurfaceState(reinterpret_cast<void *>(gpuAddress), newBufferAlloc, this);
mutateStatefulBufferArg(gpuAddress, newBufferAlloc);
desc.state = State::initialized;
}
updateAllocationResidency(oldBufferAlloc, newBufferAlloc);

View File

@@ -45,6 +45,7 @@ struct InterfaceVariableDescriptor {
bool isConstSize = false;
bool isStageCommit = false;
bool immediateValueChunks = false;
bool api = false;
};
enum VariableType : uint8_t {
@@ -84,6 +85,7 @@ struct VariableDescriptor {
bool isStageCommit = false;
bool commitRequired = false;
bool immediateValueChunks = false;
bool apiVariable = false;
};
struct Variable : public VariableHandle {
@@ -264,6 +266,7 @@ struct Variable : public VariableHandle {
void setDescExperimentalValues(const InterfaceVariableDescriptor *ifaceVarDesc);
bool hasKernelArgCorrectType(const NEO::ArgDescriptor &arg);
void mutateStatefulBufferArg(GpuAddress bufferGpuAddress, NEO::GraphicsAllocation *bufferAllocation);
ze_result_t setBufferVariable(size_t size, const void *argVal);
ze_result_t setValueVariable(size_t size, const void *argVal);

View File

@@ -32,6 +32,7 @@ Variable *Variable::createFromInfo(ze_command_list_handle_t hCmdList, Program::D
} else if (varInfo.type == VariableType::value) {
var->setValueUsages(std::move(varInfo.valueUsages));
}
desc.apiVariable = true;
return var;
}
@@ -183,6 +184,7 @@ ze_result_t Variable::selectImmediateAddKernelArgUsageHandler(const NEO::ArgDesc
void Variable::setDescExperimentalValues(const InterfaceVariableDescriptor *ifaceVarDesc) {
desc.name = ifaceVarDesc->name == nullptr ? "" : std::string(ifaceVarDesc->name);
desc.apiVariable = ifaceVarDesc->api;
if (ifaceVarDesc->isTemporary) {
desc.isTemporary = true;
@@ -196,28 +198,36 @@ void Variable::setDescExperimentalValues(const InterfaceVariableDescriptor *ifac
}
ze_result_t Variable::addKernelArgUsageStatefulBuffer(const NEO::ArgDescriptor &kernelArg, IndirectObjectHeapOffset iohOffset, SurfaceStateHeapOffset sshOffset) {
const auto &arg = kernelArg.as<NEO::ArgDescPointer>();
if (sshOffset != undefined<SurfaceStateHeapOffset>) {
if (NEO::isValidOffset(arg.bufferOffset)) {
if (NEO::isValidOffset(arg.bindful)) {
bufferUsages.bindful.push_back(sshOffset + arg.bindful);
} else if (NEO::isValidOffset(arg.bindless)) {
bufferUsages.bindless.push_back(iohOffset + arg.bindless);
if (desc.apiVariable) {
const auto &arg = kernelArg.as<NEO::ArgDescPointer>();
if (sshOffset != undefined<SurfaceStateHeapOffset>) {
if (NEO::isValidOffset(arg.bufferOffset)) {
if (NEO::isValidOffset(arg.bindful)) {
bufferUsages.bindful.push_back(sshOffset + arg.bindful);
} else if (NEO::isValidOffset(arg.bindless)) {
bufferUsages.bindless.push_back(iohOffset + arg.bindless);
} else {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
bufferUsages.bufferOffset.push_back(iohOffset + arg.bufferOffset);
} else {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
bufferUsages.bufferOffset.push_back(iohOffset + arg.bufferOffset);
} else {
if (NEO::isValidOffset(arg.bindful)) {
bufferUsages.bindfulWithoutOffset.push_back(sshOffset + arg.bindful);
} else if (NEO::isValidOffset(arg.bindless)) {
bufferUsages.bindlessWithoutOffset.push_back(iohOffset + arg.bindless);
} else {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
if (NEO::isValidOffset(arg.bindful)) {
bufferUsages.bindfulWithoutOffset.push_back(sshOffset + arg.bindful);
} else if (NEO::isValidOffset(arg.bindless)) {
bufferUsages.bindlessWithoutOffset.push_back(iohOffset + arg.bindless);
} else {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
}
}
}
return ZE_RESULT_SUCCESS;
}
void Variable::mutateStatefulBufferArg(GpuAddress bufferGpuAddress, NEO::GraphicsAllocation *bufferAllocation) {
if (desc.apiVariable) {
cmdList->setBufferSurfaceState(reinterpret_cast<void *>(bufferGpuAddress), bufferAllocation, this);
}
}
} // namespace L0::MCL