mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Unify StreamProperties structs
Introduce functions allowing to copy values from one struct to another, while correctly setting values of isDirty field. Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
899af98240
commit
7eb81e9d85
@@ -1852,14 +1852,14 @@ void CommandListCoreFamily<gfxCoreFamily>::updateStreamProperties(Kernel &kernel
|
||||
using VFE_STATE_TYPE = typename GfxFamily::VFE_STATE_TYPE;
|
||||
|
||||
if (!containsAnyKernel) {
|
||||
requiredStreamState.setCooperativeKernelProperties(kernel.usesSyncBuffer(), device->getHwInfo());
|
||||
requiredStreamState.frontEndState.setProperties(kernel.usesSyncBuffer(), device->getHwInfo());
|
||||
finalStreamState = requiredStreamState;
|
||||
containsAnyKernel = true;
|
||||
}
|
||||
|
||||
auto &hwInfo = device->getHwInfo();
|
||||
auto programVfe = finalStreamState.setCooperativeKernelProperties(kernel.usesSyncBuffer(), hwInfo);
|
||||
if (programVfe) {
|
||||
finalStreamState.frontEndState.setProperties(kernel.usesSyncBuffer(), hwInfo);
|
||||
if (finalStreamState.frontEndState.isDirty()) {
|
||||
auto pVfeStateAddress = NEO::PreambleHelper<GfxFamily>::getSpaceForVfeState(commandContainer.getCommandStream(), hwInfo, engineGroupType);
|
||||
auto pVfeState = new VFE_STATE_TYPE;
|
||||
NEO::PreambleHelper<GfxFamily>::programVfeState(pVfeState, hwInfo, 0, 0, device->getMaxNumHwThreads(),
|
||||
@@ -1869,7 +1869,7 @@ void CommandListCoreFamily<gfxCoreFamily>::updateStreamProperties(Kernel &kernel
|
||||
|
||||
auto &kernelAttributes = kernel.getKernelDescriptor().kernelAttributes;
|
||||
auto &neoDevice = *device->getNEODevice();
|
||||
finalStreamState.setStateComputeModeProperties(false, kernelAttributes.numGrfRequired, isMultiOsContextCapable,
|
||||
finalStreamState.stateComputeMode.setProperties(false, kernelAttributes.numGrfRequired, isMultiOsContextCapable,
|
||||
kernelAttributes.flags.useGlobalAtomics,
|
||||
(neoDevice.getNumAvailableDevices() > 1));
|
||||
if (finalStreamState.stateComputeMode.isDirty()) {
|
||||
|
||||
@@ -330,7 +330,8 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
|
||||
|
||||
if (!isCopyOnlyCommandQueue) {
|
||||
auto &requiredStreamState = commandList->getRequiredStreamState();
|
||||
auto programVfe = streamProperties.setCooperativeKernelProperties(requiredStreamState.getCooperativeKernelProperties(), hwInfo);
|
||||
streamProperties.frontEndState.setProperties(requiredStreamState.frontEndState);
|
||||
auto programVfe = streamProperties.frontEndState.isDirty();
|
||||
if (frontEndStateDirty) {
|
||||
programVfe = true;
|
||||
frontEndStateDirty = false;
|
||||
@@ -339,7 +340,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
|
||||
programFrontEnd(scratchSpaceController->getScratchPatchAddress(), scratchSpaceController->getPerThreadScratchSpaceSize(), child);
|
||||
}
|
||||
auto &finalStreamState = commandList->getFinalStreamState();
|
||||
streamProperties.setCooperativeKernelProperties(finalStreamState.getCooperativeKernelProperties(), hwInfo);
|
||||
streamProperties.frontEndState.setProperties(finalStreamState.frontEndState);
|
||||
}
|
||||
|
||||
patchCommands(*commandList, scratchSpaceController->getScratchPatchAddress());
|
||||
@@ -462,13 +463,13 @@ size_t CommandQueueHw<gfxCoreFamily>::estimateFrontEndCmdSizeForMultipleCommandL
|
||||
|
||||
auto streamPropertiesCopy = streamProperties;
|
||||
auto singleFrontEndCmdSize = estimateFrontEndCmdSize();
|
||||
auto &hwInfo = device->getHwInfo();
|
||||
size_t estimatedSize = 0;
|
||||
|
||||
for (size_t i = 0; i < numCommandLists; i++) {
|
||||
auto commandList = CommandList::fromHandle(phCommandLists[i]);
|
||||
auto &requiredStreamState = commandList->getRequiredStreamState();
|
||||
auto isVfeRequired = streamPropertiesCopy.setCooperativeKernelProperties(requiredStreamState.getCooperativeKernelProperties(), hwInfo);
|
||||
streamPropertiesCopy.frontEndState.setProperties(requiredStreamState.frontEndState);
|
||||
auto isVfeRequired = streamPropertiesCopy.frontEndState.isDirty();
|
||||
if (isFrontEndStateDirty) {
|
||||
isVfeRequired = true;
|
||||
isFrontEndStateDirty = false;
|
||||
@@ -477,7 +478,7 @@ size_t CommandQueueHw<gfxCoreFamily>::estimateFrontEndCmdSizeForMultipleCommandL
|
||||
estimatedSize += singleFrontEndCmdSize;
|
||||
}
|
||||
auto &finalStreamState = commandList->getFinalStreamState();
|
||||
streamPropertiesCopy.setCooperativeKernelProperties(finalStreamState.getCooperativeKernelProperties(), hwInfo);
|
||||
streamPropertiesCopy.frontEndState.setProperties(finalStreamState.frontEndState);
|
||||
}
|
||||
|
||||
return estimatedSize;
|
||||
|
||||
@@ -14,7 +14,7 @@ template <typename Family>
|
||||
void EncodeStates<Family>::adjustStateComputeMode(LinearStream &csr, uint32_t numGrfRequired, void *const stateComputeModePtr,
|
||||
bool isMultiOsContextCapable, bool requiresCoherency, bool useGlobalAtomics, bool areMultipleSubDevicesInContext) {
|
||||
StreamProperties properties{};
|
||||
properties.setStateComputeModeProperties(requiresCoherency, numGrfRequired, isMultiOsContextCapable, useGlobalAtomics, areMultipleSubDevicesInContext);
|
||||
properties.stateComputeMode.setProperties(requiresCoherency, numGrfRequired, isMultiOsContextCapable, useGlobalAtomics, areMultipleSubDevicesInContext);
|
||||
EncodeComputeMode<Family>::adjustComputeMode(csr, stateComputeModePtr, properties.stateComputeMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -913,7 +913,7 @@ inline void CommandStreamReceiverHw<GfxFamily>::programVFEState(LinearStream &cs
|
||||
auto engineGroupType = hwHelper.getEngineGroupType(getOsContext().getEngineType(), hwInfo);
|
||||
auto pVfeState = PreambleHelper<GfxFamily>::getSpaceForVfeState(&csr, hwInfo, engineGroupType);
|
||||
StreamProperties streamProperties{};
|
||||
streamProperties.setCooperativeKernelProperties(lastKernelExecutionType == KernelExecutionType::Concurrent, hwInfo);
|
||||
streamProperties.frontEndState.setProperties(lastKernelExecutionType == KernelExecutionType::Concurrent, hwInfo);
|
||||
PreambleHelper<GfxFamily>::programVfeState(
|
||||
pVfeState, hwInfo, requiredScratchSize, getScratchPatchAddress(),
|
||||
maxFrontEndThreads, lastAdditionalKernelExecInfo, streamProperties);
|
||||
|
||||
@@ -12,11 +12,18 @@ namespace NEO {
|
||||
struct StateComputeModeProperties {
|
||||
StreamProperty isCoherencyRequired{};
|
||||
|
||||
void setProperties(bool requiresCoherency, uint32_t numGrfRequired, bool isMultiOsContextCapable,
|
||||
bool useGlobalAtomics, bool areMultipleSubDevicesInContext);
|
||||
void setProperties(const StateComputeModeProperties &properties);
|
||||
bool isDirty();
|
||||
void clearIsDirty();
|
||||
};
|
||||
|
||||
struct FrontEndProperties {
|
||||
void setProperties(bool isCooperativeKernel, const HardwareInfo &hwInfo);
|
||||
void setProperties(const FrontEndProperties &properties);
|
||||
bool isDirty();
|
||||
void clearIsDirty();
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -9,20 +9,18 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
bool StreamProperties::setCooperativeKernelProperties(int32_t cooperativeKernelProperties, const HardwareInfo &hwInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t StreamProperties::getCooperativeKernelProperties() const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void StreamProperties::setStateComputeModeProperties(bool requiresCoherency, uint32_t numGrfRequired, bool isMultiOsContextCapable,
|
||||
void StateComputeModeProperties::setProperties(bool requiresCoherency, uint32_t numGrfRequired, bool isMultiOsContextCapable,
|
||||
bool useGlobalAtomics, bool areMultipleSubDevicesInContext) {
|
||||
stateComputeMode.clearIsDirty();
|
||||
clearIsDirty();
|
||||
|
||||
int32_t isCoherencyRequired = (requiresCoherency ? 1 : 0);
|
||||
stateComputeMode.isCoherencyRequired.set(isCoherencyRequired);
|
||||
this->isCoherencyRequired.set(isCoherencyRequired);
|
||||
}
|
||||
|
||||
void StateComputeModeProperties::setProperties(const StateComputeModeProperties &properties) {
|
||||
clearIsDirty();
|
||||
|
||||
isCoherencyRequired.set(properties.isCoherencyRequired.value);
|
||||
}
|
||||
|
||||
bool StateComputeModeProperties::isDirty() {
|
||||
@@ -32,3 +30,16 @@ bool StateComputeModeProperties::isDirty() {
|
||||
void StateComputeModeProperties::clearIsDirty() {
|
||||
isCoherencyRequired.isDirty = false;
|
||||
}
|
||||
|
||||
void FrontEndProperties::setProperties(bool isCooperativeKernel, const HardwareInfo &hwInfo) {
|
||||
}
|
||||
|
||||
void FrontEndProperties::setProperties(const FrontEndProperties &properties) {
|
||||
}
|
||||
|
||||
bool FrontEndProperties::isDirty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void FrontEndProperties::clearIsDirty() {
|
||||
}
|
||||
|
||||
@@ -15,12 +15,6 @@
|
||||
namespace NEO {
|
||||
|
||||
struct StreamProperties {
|
||||
bool setCooperativeKernelProperties(int32_t cooperativeKernelProperties, const HardwareInfo &hwInfo);
|
||||
int32_t getCooperativeKernelProperties() const;
|
||||
|
||||
void setStateComputeModeProperties(bool requiresCoherency, uint32_t numGrfRequired, bool isMultiOsContextCapable,
|
||||
bool useGlobalAtomics, bool areMultipleSubDevicesInContext);
|
||||
|
||||
StateComputeModeProperties stateComputeMode{};
|
||||
FrontEndProperties frontEndState{};
|
||||
};
|
||||
|
||||
@@ -42,11 +42,6 @@ enum class LocalMemoryAccessMode {
|
||||
CpuAccessDisallowed = 3
|
||||
};
|
||||
|
||||
enum class FrontEndType {
|
||||
Video,
|
||||
Compute
|
||||
};
|
||||
|
||||
class HwHelper {
|
||||
public:
|
||||
using EngineInstancesContainer = StackVec<EngineTypeUsage, 32>;
|
||||
@@ -74,7 +69,6 @@ class HwHelper {
|
||||
virtual bool preferSmallWorkgroupSizeForKernel(const size_t size, const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isBufferSizeSuitableForRenderCompression(const size_t size) const = 0;
|
||||
virtual bool obtainBlitterPreference(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual FrontEndType getFrontEndType(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) = 0;
|
||||
virtual bool allowRenderCompression(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const = 0;
|
||||
@@ -244,8 +238,6 @@ class HwHelperHw : public HwHelper {
|
||||
|
||||
bool obtainBlitterPreference(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
FrontEndType getFrontEndType(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) override;
|
||||
|
||||
bool timestampPacketWriteSupported() const override;
|
||||
|
||||
@@ -55,11 +55,6 @@ bool HwHelperHw<Family>::obtainBlitterPreference(const HardwareInfo &hwInfo) con
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
FrontEndType HwHelperHw<Family>::getFrontEndType(const HardwareInfo &hwInfo) const {
|
||||
return FrontEndType::Video;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
const HwHelper::EngineInstancesContainer HwHelperHw<GfxFamily>::getGpgpuEngineInstances(const HardwareInfo &hwInfo) const {
|
||||
return {
|
||||
|
||||
@@ -16,4 +16,8 @@ std::vector<StreamProperty *> getAllStateComputeModeProperties(StateComputeModeP
|
||||
return allProperties;
|
||||
}
|
||||
|
||||
std::vector<StreamProperty *> getAllFrontEndProperties(FrontEndProperties &properties) {
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -44,32 +44,90 @@ TEST(StreamPropertiesTests, whenPropertyValueIsChangedThenProperStateIsSet) {
|
||||
TEST(StreamPropertiesTests, whenSettingStateComputeModePropertiesThenCorrectValuesAreSet) {
|
||||
StreamProperties properties;
|
||||
for (auto requiresCoherency : ::testing::Bool()) {
|
||||
properties.setStateComputeModeProperties(requiresCoherency, 0u, false, false, false);
|
||||
properties.stateComputeMode.setProperties(requiresCoherency, 0u, false, false, false);
|
||||
EXPECT_EQ(requiresCoherency, properties.stateComputeMode.isCoherencyRequired.value);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(StreamPropertiesTests, givenVariousStatesOfThePropertiesWhenIsStateComputeModeDirtyIsQueriedThenCorrectValueIsReturned) {
|
||||
struct MockStateComputeModeProperties : StateComputeModeProperties {
|
||||
using StateComputeModeProperties::clearIsDirty;
|
||||
template <typename PropertiesT>
|
||||
using getAllPropertiesFunctionPtr = std::vector<StreamProperty *> (*)(PropertiesT &properties);
|
||||
|
||||
template <typename PropertiesT, getAllPropertiesFunctionPtr<PropertiesT> getAllProperties>
|
||||
void verifyIsDirty() {
|
||||
struct MockPropertiesT : PropertiesT {
|
||||
using PropertiesT::clearIsDirty;
|
||||
};
|
||||
MockStateComputeModeProperties properties;
|
||||
MockPropertiesT properties;
|
||||
auto allProperties = getAllProperties(properties);
|
||||
|
||||
EXPECT_FALSE(properties.isDirty());
|
||||
for (auto pProperty : getAllStateComputeModeProperties(properties)) {
|
||||
for (auto pProperty : allProperties) {
|
||||
pProperty->isDirty = true;
|
||||
EXPECT_TRUE(properties.isDirty());
|
||||
pProperty->isDirty = false;
|
||||
EXPECT_FALSE(properties.isDirty());
|
||||
}
|
||||
for (auto pProperty : getAllStateComputeModeProperties(properties)) {
|
||||
for (auto pProperty : allProperties) {
|
||||
pProperty->isDirty = true;
|
||||
}
|
||||
EXPECT_TRUE(properties.isDirty());
|
||||
|
||||
EXPECT_EQ(!allProperties.empty(), properties.isDirty());
|
||||
|
||||
properties.clearIsDirty();
|
||||
for (auto pProperty : getAllStateComputeModeProperties(properties)) {
|
||||
for (auto pProperty : allProperties) {
|
||||
EXPECT_FALSE(pProperty->isDirty);
|
||||
}
|
||||
EXPECT_FALSE(properties.isDirty());
|
||||
}
|
||||
|
||||
TEST(StreamPropertiesTests, givenVariousStatesOfStateComputeModePropertiesWhenIsDirtyIsQueriedThenCorrectValueIsReturned) {
|
||||
verifyIsDirty<StateComputeModeProperties, &getAllStateComputeModeProperties>();
|
||||
}
|
||||
|
||||
TEST(StreamPropertiesTests, givenVariousStatesOfFrontEndPropertiesWhenIsDirtyIsQueriedThenCorrectValueIsReturned) {
|
||||
verifyIsDirty<FrontEndProperties, getAllFrontEndProperties>();
|
||||
}
|
||||
|
||||
template <typename PropertiesT, getAllPropertiesFunctionPtr<PropertiesT> getAllProperties>
|
||||
void verifySettingPropertiesFromOtherStruct() {
|
||||
PropertiesT propertiesDestination;
|
||||
PropertiesT propertiesSource;
|
||||
|
||||
auto allPropertiesDestination = getAllProperties(propertiesDestination);
|
||||
auto allPropertiesSource = getAllProperties(propertiesSource);
|
||||
|
||||
int valueToSet = 1;
|
||||
for (auto pProperty : allPropertiesSource) {
|
||||
pProperty->value = valueToSet;
|
||||
valueToSet++;
|
||||
}
|
||||
EXPECT_FALSE(propertiesSource.isDirty());
|
||||
|
||||
propertiesDestination.setProperties(propertiesSource);
|
||||
EXPECT_EQ(!allPropertiesDestination.empty(), propertiesDestination.isDirty());
|
||||
|
||||
int expectedValue = 1;
|
||||
for (auto pProperty : allPropertiesDestination) {
|
||||
EXPECT_EQ(expectedValue, pProperty->value);
|
||||
EXPECT_TRUE(pProperty->isDirty);
|
||||
expectedValue++;
|
||||
}
|
||||
|
||||
propertiesDestination.setProperties(propertiesSource);
|
||||
EXPECT_FALSE(propertiesDestination.isDirty());
|
||||
|
||||
expectedValue = 1;
|
||||
for (auto pProperty : allPropertiesDestination) {
|
||||
EXPECT_EQ(expectedValue, pProperty->value);
|
||||
EXPECT_FALSE(pProperty->isDirty);
|
||||
expectedValue++;
|
||||
}
|
||||
}
|
||||
|
||||
TEST(StreamPropertiesTests, givenOtherStateComputeModePropertiesStructWhenSetPropertiesIsCalledThenCorrectValuesAreSet) {
|
||||
verifySettingPropertiesFromOtherStruct<StateComputeModeProperties, &getAllStateComputeModeProperties>();
|
||||
}
|
||||
|
||||
TEST(StreamPropertiesTests, givenOtherFrontEndPropertiesStructWhenSetPropertiesIsCalledThenCorrectValuesAreSet) {
|
||||
verifySettingPropertiesFromOtherStruct<FrontEndProperties, getAllFrontEndProperties>();
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct FrontEndProperties;
|
||||
struct StateComputeModeProperties;
|
||||
struct StreamProperty;
|
||||
|
||||
std::vector<StreamProperty *> getAllStateComputeModeProperties(StateComputeModeProperties &properties);
|
||||
std::vector<StreamProperty *> getAllFrontEndProperties(FrontEndProperties &properties);
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user