fix: ensure memory info is queried before querying engine info

initialization of engine info relies on memory info data

Related-To: NEO-12073
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-07-25 15:30:26 +00:00
committed by Compute-Runtime-Automation
parent ace883ca55
commit e24acc6155
9 changed files with 20 additions and 2 deletions

View File

@@ -97,6 +97,7 @@ class DrmMockTime : public DrmMockSuccess {
};
struct DrmMockCustom : public Drm {
using Drm::memoryInfoQueried;
static constexpr NEO::DriverModelType driverModelType = NEO::DriverModelType::drm;
static std::unique_ptr<DrmMockCustom> create(RootDeviceEnvironment &rootDeviceEnvironment);

View File

@@ -32,6 +32,7 @@ TEST(DrmTest, givenEngineQuerySupportedWhenQueryingEngineInfoThenEngineInfoIsIni
auto drm = std::make_unique<DrmQueryMock>(*executionEnvironment->rootDeviceEnvironments[0]);
auto hwInfo = drm->rootDeviceEnvironment.getHardwareInfo();
ASSERT_NE(nullptr, drm);
drm->memoryInfoQueried = true;
drm->queryEngineInfo();
auto haveLocalMemory = hwInfo->gtSystemInfo.MultiTileArchInfo.IsValid;
EXPECT_EQ(haveLocalMemory ? 3u : 2u, drm->ioctlCallsCount);
@@ -817,6 +818,7 @@ TEST(DrmTest, whenQueryingEngineInfoThenMultiTileArchInfoIsUnchanged) {
auto drm = std::make_unique<DrmQueryMock>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->memoryInfoQueried = true;
drm->queryEngineInfo();
EXPECT_NE(nullptr, drm->engineInfo);

View File

@@ -23,6 +23,7 @@ TEST(DrmTest, whenQueryingEngineInfoThenSingleIoctlIsCalled) {
std::unique_ptr<DrmMock> drm = std::make_unique<DrmMock>(*executionEnvironment->rootDeviceEnvironments[0]);
EXPECT_NE(nullptr, drm);
auto ioctlCount = drm->ioctlCount.total.load();
drm->memoryInfoQueried = true;
drm->queryEngineInfo();
EXPECT_EQ(1 + ioctlCount, drm->ioctlCount.total.load());
}
@@ -35,6 +36,7 @@ TEST(EngineInfoTest, givenEngineInfoQuerySupportedWhenQueryingEngineInfoThenEngi
std::vector<MemoryRegion> memRegions{
{{0, 0}, 0, 0}};
drm->memoryInfo.reset(new MemoryInfo(memRegions, *drm));
drm->memoryInfoQueried = true;
drm->queryEngineInfo();
EXPECT_EQ(2u + drm->getBaseIoctlCalls(), drm->ioctlCallsCount);
auto engineInfo = drm->getEngineInfo();
@@ -48,6 +50,7 @@ TEST(EngineInfoTest, whenQueryingEngineInfoWithoutMemoryInfoThenEngineInfoCreate
auto drm = std::make_unique<DrmMockEngine>(*executionEnvironment->rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, drm);
drm->memoryInfoQueried = true;
drm->queryEngineInfo();
EXPECT_EQ(2u + drm->getBaseIoctlCalls(), drm->ioctlCallsCount);
auto engineInfo = drm->getEngineInfo();

View File

@@ -1110,6 +1110,7 @@ TEST_F(DrmMemoryManagerTest, GivenDeviceSharedAllocationWhichRequiresHostMapThen
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
this->mock->memoryInfo.reset(new MemoryInfo(regionInfo, *mock));
this->mock->memoryInfoQueried = true;
this->mock->queryEngineInfo();
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::gpuTimestampDeviceBuffer, false, {});
@@ -1136,6 +1137,7 @@ TEST_F(DrmMemoryManagerTest, GivenDeviceSharedAllocationWhenSetCacheRegionFailsT
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0};
this->mock->memoryInfo.reset(new MemoryInfo(regionInfo, *mock));
this->mock->memoryInfoQueried = true;
this->mock->queryEngineInfo();
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::gpuTimestampDeviceBuffer, false, {});
properties.cacheRegion = std::numeric_limits<uint32_t>::max();
@@ -7941,4 +7943,4 @@ TEST_F(DrmMemoryManagerTest, givenUsmCompressionSupportedThenReturnFalse) {
debugManager.flags.RenderCompressedBuffersEnabled.set(1);
EXPECT_TRUE(memoryManager->usmCompressionSupported(device));
}
}

View File

@@ -670,6 +670,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoWithDeviceMemoryT
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 1}, 1024, 0},
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 2}, 1024, 0}};
drm->memoryInfo.reset(new MemoryInfo(memRegions, *drm));
drm->memoryInfoQueried = true;
EXPECT_TRUE(drm->queryEngineInfo());
EXPECT_EQ(3u, drm->ioctlCallsCount);
auto hwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
@@ -700,6 +701,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoThenCorrectCCSFla
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}, 1024, 0},
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 1}, 1024, 0}};
drm->memoryInfo.reset(new MemoryInfo(memRegions, *drm));
drm->memoryInfoQueried = true;
EXPECT_TRUE(drm->queryEngineInfo());
EXPECT_EQ(3u, drm->ioctlCallsCount);
auto hwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
@@ -740,6 +742,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoAndFailIoctlThenF
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 1}, 1024, 0},
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 2}, 1024, 0}};
drm->memoryInfo.reset(new MemoryInfo(memRegions, *drm));
drm->memoryInfoQueried = true;
EXPECT_FALSE(drm->queryEngineInfo());
EXPECT_EQ(3u, drm->ioctlCallsCount);

View File

@@ -586,6 +586,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenQueryEngineInfoWithoutDeviceMemo
std::vector<MemoryRegion> memRegions{
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 0}, 1024, 0}};
drm->memoryInfo.reset(new MemoryInfo(memRegions, *drm));
drm->memoryInfoQueried = true;
EXPECT_TRUE(drm->queryEngineInfo());
EXPECT_EQ(2u, drm->ioctlCallsCount);
@@ -608,6 +609,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenQueryEngineInfoWithDeviceMemoryA
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}, 1024, 0},
{{drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 1}, 1024, 0}};
drm->memoryInfo.reset(new MemoryInfo(memRegions, *drm));
drm->memoryInfoQueried = true;
EXPECT_TRUE(drm->queryEngineInfo());
EXPECT_EQ(2u, drm->ioctlCallsCount);

View File

@@ -1863,6 +1863,7 @@ TEST(IoctlHelperXeTest, whenBindingDrmContextWithoutVirtualEnginesThenProperEngi
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
ioctlHelper->initialize();
drm->memoryInfoQueried = true;
drm->queryEngineInfo();
unsigned int expectedValue = DRM_XE_ENGINE_CLASS_COMPUTE;
@@ -1886,6 +1887,7 @@ TEST(IoctlHelperXeTest, whenBindingDrmContextWithVirtualEnginesThenProperEngines
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
ioctlHelper->initialize();
drm->memoryInfoQueried = true;
drm->queryEngineInfo();
executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 2;
@@ -2093,6 +2095,7 @@ TEST(IoctlHelperXeTest, givenLowPriorityContextWhenCreatingDrmContextThenExtProp
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
drm->memoryInfoQueried = true;
drm->queryEngineInfo();
executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1;