fix: re-add switch case for once writable query

A change related to the tbx fault manager
incorrectly removed a switch case from
`AubHelper::isOneTimeAubWritableAllocationType`.

This fixes that and refactors some APIs to prevent
similar mistakes from happening again by cleaning
up logic.

Addresses show stopper for pre-si pytorch workflows.

Resolves: NEO-14399
Signed-off-by: Jack Myers <jack.myers@intel.com>
This commit is contained in:
Jack Myers
2025-03-18 20:46:23 +00:00
committed by Compute-Runtime-Automation
parent 2e729bcb4c
commit 0e25970853
4 changed files with 12 additions and 6 deletions

View File

@@ -41,8 +41,10 @@ bool AubHelper::isOneTimeAubWritableAllocationType(const AllocationType &type) {
case AllocationType::assertBuffer:
case AllocationType::tagBuffer:
case AllocationType::syncDispatchToken:
return true;
case AllocationType::bufferHostMemory:
return (NEO::debugManager.flags.SetBufferHostMemoryAlwaysAubWritable.get() ? false : true) || (NEO::debugManager.flags.EnableTbxPageFaultManager.get() == 1);
return NEO::debugManager.isTbxPageFaultManagerEnabled() ||
(NEO::debugManager.flags.SetBufferHostMemoryAlwaysAubWritable.get() == false);
default:
return false;
}

View File

@@ -85,7 +85,9 @@ TbxCommandStreamReceiverHw<GfxFamily>::~TbxCommandStreamReceiverHw() {
template <typename GfxFamily>
bool TbxCommandStreamReceiverHw<GfxFamily>::isAllocTbxFaultable(GraphicsAllocation *gfxAlloc) {
// indicates host memory not managed by the driver
if (gfxAlloc->getDriverAllocatedCpuPtr() == nullptr || !debugManager.isTbxPageFaultManagerEnabled() || this->getTbxPageFaultManager() == nullptr) {
if ((gfxAlloc->getDriverAllocatedCpuPtr() == nullptr) ||
(debugManager.isTbxPageFaultManagerEnabled() == false) ||
(this->getTbxPageFaultManager() == nullptr)) {
return false;
}
auto allocType = gfxAlloc->getAllocationType();

View File

@@ -162,9 +162,10 @@ class DebugSettingsManager : NEO::NonCopyableAndNonMovableClass {
inline bool isTbxPageFaultManagerEnabled() {
auto setCsr = flags.SetCommandStreamReceiver.get();
auto tbxMngrFlag = flags.EnableTbxPageFaultManager.get();
auto isTbxMode = (setCsr == static_cast<int32_t>(CommandStreamReceiverType::tbx)) || (setCsr == static_cast<int32_t>(CommandStreamReceiverType::tbxWithAub));
return tbxMngrFlag && isTbxMode;
auto isTbxMode = (setCsr == static_cast<int32_t>(CommandStreamReceiverType::tbx)) ||
(setCsr == static_cast<int32_t>(CommandStreamReceiverType::tbxWithAub));
auto isFaultManagerEnabledInEnvVars = flags.EnableTbxPageFaultManager.get();
return isFaultManagerEnabledInEnvVars && isTbxMode;
}
protected:

View File

@@ -129,9 +129,10 @@ TEST(AubHelper, givenAllocationTypeWhenAskingIfOneTimeWritableThenReturnCorrectR
}
}
TEST(AubHelper, givenSetBufferHostMemoryAlwaysAubWritableAndDisabledTbxFaultMngrWhenAskingIfBufferHostMemoryAllocationIsOneTimeAubWritableThenReturnCorrectResult) {
TEST(AubHelper, givenAlwaysAubWritableAndEnableTbxFaultManagerSetExternallyThenAllocationIsOneTimeAubWritableShouldReturnCorrectResult) {
DebugManagerStateRestore stateRestore;
NEO::debugManager.flags.EnableTbxPageFaultManager.set(0);
NEO::debugManager.flags.SetCommandStreamReceiver.set(2);
for (auto isAlwaysAubWritable : {false, true}) {
for (auto isTbxFaultManagerEnabled : {false, true}) {