refactor: extract methods to setup SCM state per context
per context properties are now set explicitly Related-To: NEO-12803, NEO-13632 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
f762516900
commit
165c294590
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -292,7 +292,7 @@ void CommandListImp::enableCopyOperationOffload(uint32_t productFamily, Device *
|
|||
|
||||
void CommandListImp::setStreamPropertiesDefaultSettings(NEO::StreamProperties &streamProperties) {
|
||||
if (this->stateComputeModeTracking) {
|
||||
streamProperties.stateComputeMode.setPropertiesCoherencyDevicePreemption(cmdListDefaultCoherency, this->commandListPreemptionMode, true);
|
||||
streamProperties.stateComputeMode.setPropertiesPerContext(cmdListDefaultCoherency, this->commandListPreemptionMode, true);
|
||||
}
|
||||
|
||||
streamProperties.frontEndState.setPropertiesDisableOverdispatch(cmdListDefaultDisableOverdispatch, true);
|
||||
|
|
|
@ -35,8 +35,8 @@ struct StateComputeModeProperties {
|
|||
void resetState();
|
||||
|
||||
void setPropertiesAll(bool requiresCoherency, uint32_t numGrfRequired, int32_t threadArbitrationPolicy, PreemptionMode devicePreemptionMode);
|
||||
void setPropertiesPerContext(bool requiresCoherency, PreemptionMode devicePreemptionMode, bool clearDirtyState);
|
||||
void setPropertiesGrfNumberThreadArbitration(uint32_t numGrfRequired, int32_t threadArbitrationPolicy);
|
||||
void setPropertiesCoherencyDevicePreemption(bool requiresCoherency, PreemptionMode devicePreemptionMode, bool clearDirtyState);
|
||||
|
||||
void copyPropertiesAll(const StateComputeModeProperties &properties);
|
||||
void copyPropertiesGrfNumberThreadArbitration(const StateComputeModeProperties &properties);
|
||||
|
@ -45,6 +45,7 @@ struct StateComputeModeProperties {
|
|||
void clearIsDirty();
|
||||
|
||||
protected:
|
||||
void clearIsDirtyPerContext();
|
||||
void clearIsDirtyExtraPerContext();
|
||||
bool isDirtyExtra() const;
|
||||
void resetStateExtra();
|
||||
|
|
|
@ -20,7 +20,6 @@ void StateComputeModeProperties::setPropertiesAll(bool requiresCoherency, uint32
|
|||
DEBUG_BREAK_IF(!this->propertiesSupportLoaded);
|
||||
clearIsDirty();
|
||||
|
||||
setCoherencyProperty(requiresCoherency);
|
||||
setGrfNumberProperty(numGrfRequired);
|
||||
setThreadArbitrationProperty(threadArbitrationPolicy);
|
||||
|
||||
|
@ -39,7 +38,6 @@ void StateComputeModeProperties::setPropertiesAll(bool requiresCoherency, uint32
|
|||
if (pixelAsyncComputeThreadLimit != -1 && this->scmPropertiesSupport.pixelAsyncComputeThreadLimit) {
|
||||
this->pixelAsyncComputeThreadLimit.set(pixelAsyncComputeThreadLimit);
|
||||
}
|
||||
setDevicePreemptionProperty(devicePreemptionMode);
|
||||
|
||||
int32_t memoryAllocationForScratchAndMidthreadPreemptionBuffers = -1;
|
||||
if (debugManager.flags.ForceScratchAndMTPBufferSizeMode.get() != -1) {
|
||||
|
@ -49,7 +47,7 @@ void StateComputeModeProperties::setPropertiesAll(bool requiresCoherency, uint32
|
|||
this->memoryAllocationForScratchAndMidthreadPreemptionBuffers.set(memoryAllocationForScratchAndMidthreadPreemptionBuffers);
|
||||
}
|
||||
|
||||
setPropertiesExtraPerContext();
|
||||
setPropertiesPerContext(requiresCoherency, devicePreemptionMode, false);
|
||||
}
|
||||
|
||||
void StateComputeModeProperties::copyPropertiesAll(const StateComputeModeProperties &properties) {
|
||||
|
@ -77,19 +75,30 @@ void StateComputeModeProperties::copyPropertiesGrfNumberThreadArbitration(const
|
|||
}
|
||||
|
||||
bool StateComputeModeProperties::isDirty() const {
|
||||
return isCoherencyRequired.isDirty || largeGrfMode.isDirty || zPassAsyncComputeThreadLimit.isDirty ||
|
||||
pixelAsyncComputeThreadLimit.isDirty || threadArbitrationPolicy.isDirty || devicePreemptionMode.isDirty || memoryAllocationForScratchAndMidthreadPreemptionBuffers.isDirty || isDirtyExtra();
|
||||
return isCoherencyRequired.isDirty ||
|
||||
largeGrfMode.isDirty ||
|
||||
zPassAsyncComputeThreadLimit.isDirty ||
|
||||
pixelAsyncComputeThreadLimit.isDirty ||
|
||||
threadArbitrationPolicy.isDirty ||
|
||||
devicePreemptionMode.isDirty ||
|
||||
memoryAllocationForScratchAndMidthreadPreemptionBuffers.isDirty ||
|
||||
isDirtyExtra();
|
||||
}
|
||||
|
||||
void StateComputeModeProperties::clearIsDirty() {
|
||||
isCoherencyRequired.isDirty = false;
|
||||
largeGrfMode.isDirty = false;
|
||||
zPassAsyncComputeThreadLimit.isDirty = false;
|
||||
pixelAsyncComputeThreadLimit.isDirty = false;
|
||||
threadArbitrationPolicy.isDirty = false;
|
||||
devicePreemptionMode.isDirty = false;
|
||||
memoryAllocationForScratchAndMidthreadPreemptionBuffers.isDirty = false;
|
||||
|
||||
clearIsDirtyPerContext();
|
||||
}
|
||||
|
||||
void StateComputeModeProperties::clearIsDirtyPerContext() {
|
||||
isCoherencyRequired.isDirty = false;
|
||||
devicePreemptionMode.isDirty = false;
|
||||
|
||||
clearIsDirtyExtraPerContext();
|
||||
}
|
||||
|
||||
|
@ -152,21 +161,17 @@ void StateComputeModeProperties::resetState() {
|
|||
resetStateExtra();
|
||||
}
|
||||
|
||||
void StateComputeModeProperties::setPropertiesCoherencyDevicePreemption(bool requiresCoherency, PreemptionMode devicePreemptionMode, bool clearDirtyState) {
|
||||
void StateComputeModeProperties::setPropertiesPerContext(bool requiresCoherency, PreemptionMode devicePreemptionMode, bool clearDirtyState) {
|
||||
DEBUG_BREAK_IF(!this->propertiesSupportLoaded);
|
||||
|
||||
if (!clearDirtyState) {
|
||||
this->isCoherencyRequired.isDirty = false;
|
||||
this->devicePreemptionMode.isDirty = false;
|
||||
clearIsDirtyExtraPerContext();
|
||||
clearIsDirtyPerContext();
|
||||
}
|
||||
setCoherencyProperty(requiresCoherency);
|
||||
setDevicePreemptionProperty(devicePreemptionMode);
|
||||
setPropertiesExtraPerContext();
|
||||
if (clearDirtyState) {
|
||||
this->isCoherencyRequired.isDirty = false;
|
||||
this->devicePreemptionMode.isDirty = false;
|
||||
clearIsDirtyExtraPerContext();
|
||||
clearIsDirtyPerContext();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -293,62 +293,87 @@ TEST(StreamPropertiesTests, givenOtherPipelineSelectPropertiesStructWhenSetPrope
|
|||
verifySettingPropertiesFromOtherStruct<PipelineSelectProperties, getAllPipelineSelectProperties>();
|
||||
}
|
||||
|
||||
TEST(StreamPropertiesTests, givenCoherencyStateAndDevicePreemptionComputeModePropertiesWhenSettingPropertyAndCheckIfSupportedThenExpectCorrectState) {
|
||||
TEST(StreamPropertiesTests, givenVariousDevicePreemptionComputeModesWhenSettingPropertyPerContextAndCheckIfSupportedThenExpectCorrectState) {
|
||||
bool clearDirtyState = false;
|
||||
MockStateComputeModeProperties scmProperties{};
|
||||
scmProperties.propertiesSupportLoaded = true;
|
||||
scmProperties.scmPropertiesSupport.coherencyRequired = false;
|
||||
scmProperties.scmPropertiesSupport.devicePreemptionMode = false;
|
||||
|
||||
bool coherencyRequired = false;
|
||||
PreemptionMode devicePreemptionMode = PreemptionMode::Disabled;
|
||||
scmProperties.setPropertiesCoherencyDevicePreemption(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(-1, scmProperties.isCoherencyRequired.value);
|
||||
EXPECT_EQ(-1, scmProperties.devicePreemptionMode.value);
|
||||
|
||||
scmProperties.scmPropertiesSupport.coherencyRequired = true;
|
||||
scmProperties.scmPropertiesSupport.devicePreemptionMode = true;
|
||||
scmProperties.setPropertiesCoherencyDevicePreemption(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_TRUE(scmProperties.isDirty());
|
||||
EXPECT_EQ(0, scmProperties.isCoherencyRequired.value);
|
||||
EXPECT_EQ(static_cast<int32_t>(devicePreemptionMode), scmProperties.devicePreemptionMode.value);
|
||||
|
||||
devicePreemptionMode = PreemptionMode::Initial;
|
||||
scmProperties.setPropertiesAll(coherencyRequired, -1, -1, devicePreemptionMode);
|
||||
EXPECT_TRUE(scmProperties.isDirty());
|
||||
EXPECT_EQ(0, scmProperties.isCoherencyRequired.value);
|
||||
EXPECT_EQ(static_cast<int32_t>(devicePreemptionMode), scmProperties.devicePreemptionMode.value);
|
||||
|
||||
scmProperties.setPropertiesCoherencyDevicePreemption(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(0, scmProperties.isCoherencyRequired.value);
|
||||
EXPECT_EQ(static_cast<int32_t>(devicePreemptionMode), scmProperties.devicePreemptionMode.value);
|
||||
|
||||
scmProperties.setPropertiesCoherencyDevicePreemption(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(0, scmProperties.isCoherencyRequired.value);
|
||||
EXPECT_EQ(static_cast<int32_t>(devicePreemptionMode), scmProperties.devicePreemptionMode.value);
|
||||
|
||||
coherencyRequired = true;
|
||||
devicePreemptionMode = PreemptionMode::MidThread;
|
||||
scmProperties.setPropertiesCoherencyDevicePreemption(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_TRUE(scmProperties.isDirty());
|
||||
EXPECT_EQ(1, scmProperties.isCoherencyRequired.value);
|
||||
EXPECT_EQ(static_cast<int32_t>(devicePreemptionMode), scmProperties.devicePreemptionMode.value);
|
||||
|
||||
scmProperties.setPropertiesCoherencyDevicePreemption(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(1, scmProperties.isCoherencyRequired.value);
|
||||
EXPECT_EQ(static_cast<int32_t>(devicePreemptionMode), scmProperties.devicePreemptionMode.value);
|
||||
|
||||
clearDirtyState = true;
|
||||
coherencyRequired = false;
|
||||
devicePreemptionMode = PreemptionMode::ThreadGroup;
|
||||
scmProperties.setPropertiesCoherencyDevicePreemption(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(static_cast<int32_t>(devicePreemptionMode), scmProperties.devicePreemptionMode.value);
|
||||
}
|
||||
|
||||
TEST(StreamPropertiesTests, givenVariousCoherencyRequirementsWhenSettingPropertyPerContextAndCheckIfSupportedThenExpectCorrectState) {
|
||||
bool clearDirtyState = false;
|
||||
MockStateComputeModeProperties scmProperties{};
|
||||
scmProperties.propertiesSupportLoaded = true;
|
||||
scmProperties.scmPropertiesSupport.coherencyRequired = false;
|
||||
|
||||
bool coherencyRequired = false;
|
||||
PreemptionMode devicePreemptionMode = PreemptionMode::Disabled;
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(-1, scmProperties.isCoherencyRequired.value);
|
||||
|
||||
scmProperties.scmPropertiesSupport.coherencyRequired = true;
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_TRUE(scmProperties.isDirty());
|
||||
EXPECT_EQ(0, scmProperties.isCoherencyRequired.value);
|
||||
|
||||
scmProperties.setPropertiesAll(coherencyRequired, -1, -1, devicePreemptionMode);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(0, scmProperties.isCoherencyRequired.value);
|
||||
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(0, scmProperties.isCoherencyRequired.value);
|
||||
|
||||
coherencyRequired = true;
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_TRUE(scmProperties.isDirty());
|
||||
EXPECT_EQ(1, scmProperties.isCoherencyRequired.value);
|
||||
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(1, scmProperties.isCoherencyRequired.value);
|
||||
|
||||
clearDirtyState = true;
|
||||
coherencyRequired = false;
|
||||
scmProperties.setPropertiesPerContext(coherencyRequired, devicePreemptionMode, clearDirtyState);
|
||||
EXPECT_FALSE(scmProperties.isDirty());
|
||||
EXPECT_EQ(0, scmProperties.isCoherencyRequired.value);
|
||||
EXPECT_EQ(static_cast<int32_t>(devicePreemptionMode), scmProperties.devicePreemptionMode.value);
|
||||
}
|
||||
|
||||
TEST(StreamPropertiesTests, givenGrfNumberAndThreadArbitrationStateComputeModePropertiesWhenSettingPropertyAndCheckIfSupportedThenExpectCorrectState) {
|
||||
|
|
Loading…
Reference in New Issue