mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Create wrapper for drm_i915_gem_exec_object2
Related-To: NEO-6852 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0b68fdbe52
commit
268393d776
@@ -9,6 +9,7 @@
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_wrappers.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_helper.h"
|
||||
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
|
||||
@@ -25,7 +26,7 @@ TEST_F(DrmBufferObjectTest, WhenCallingExecThenReturnIsCorrect) {
|
||||
mock->ioctl_expected.total = 1;
|
||||
mock->ioctl_res = 0;
|
||||
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
ExecObject execObjectsStorage = {};
|
||||
auto ret = bo->exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, 0, 0);
|
||||
EXPECT_EQ(mock->ioctl_res, ret);
|
||||
EXPECT_EQ(0u, mock->execBuffer.flags);
|
||||
@@ -35,7 +36,7 @@ TEST_F(DrmBufferObjectTest, GivenInvalidParamsWhenCallingExecThenEfaultIsReturne
|
||||
mock->ioctl_expected.total = 3;
|
||||
mock->ioctl_res = -1;
|
||||
mock->errnoValue = EFAULT;
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
ExecObject execObjectsStorage = {};
|
||||
EXPECT_EQ(EFAULT, bo->exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, 0, 0));
|
||||
}
|
||||
|
||||
@@ -46,7 +47,7 @@ TEST_F(DrmBufferObjectTest, GivenDetectedGpuHangDuringEvictUnusedAllocationsWhen
|
||||
|
||||
bo->callBaseEvictUnusedAllocations = false;
|
||||
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
ExecObject execObjectsStorage = {};
|
||||
const auto result = bo->exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, 0, 0);
|
||||
|
||||
EXPECT_EQ(BufferObject::gpuHangDetected, result);
|
||||
@@ -80,25 +81,25 @@ TEST_F(DrmBufferObjectTest, givenBindAvailableWhenCallWaitThenNoIoctlIsCalled) {
|
||||
}
|
||||
|
||||
TEST_F(DrmBufferObjectTest, givenAddressThatWhenSizeIsAddedCrosses32BitBoundaryWhenExecIsCalledThen48BitFlagIsSet) {
|
||||
drm_i915_gem_exec_object2 execObject;
|
||||
MockExecObject execObject{};
|
||||
|
||||
memset(&execObject, 0, sizeof(execObject));
|
||||
bo->setAddress(((uint64_t)1u << 32) - 0x1000u);
|
||||
bo->setSize(0x1000);
|
||||
bo->fillExecObject(execObject, osContext.get(), 0, 1);
|
||||
//base address + size > size of 32bit address space
|
||||
EXPECT_TRUE(execObject.flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS);
|
||||
EXPECT_TRUE(execObject.has48BAddressSupportFlag());
|
||||
}
|
||||
|
||||
TEST_F(DrmBufferObjectTest, givenAddressThatWhenSizeIsAddedWithin32BitBoundaryWhenExecIsCalledThen48BitFlagSet) {
|
||||
drm_i915_gem_exec_object2 execObject;
|
||||
MockExecObject execObject{};
|
||||
|
||||
memset(&execObject, 0, sizeof(execObject));
|
||||
bo->setAddress(((uint64_t)1u << 32) - 0x1000u);
|
||||
bo->setSize(0xFFF);
|
||||
bo->fillExecObject(execObject, osContext.get(), 0, 1);
|
||||
//base address + size < size of 32bit address space
|
||||
EXPECT_TRUE(execObject.flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS);
|
||||
EXPECT_TRUE(execObject.has48BAddressSupportFlag());
|
||||
}
|
||||
|
||||
TEST_F(DrmBufferObjectTest, whenExecFailsThenPinFails) {
|
||||
@@ -179,7 +180,7 @@ TEST_F(DrmBufferObjectTest, whenPrintExecutionBufferIsSetToTrueThenMessageFoundI
|
||||
mock->ioctl_expected.total = 1;
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.PrintExecutionBuffer.set(true);
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
ExecObject execObjectsStorage = {};
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto ret = bo->exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, 0, 0);
|
||||
@@ -369,7 +370,7 @@ TEST(DrmBufferObject, givenDrmIoctlReturnsErrorNotSupportedThenBufferObjectRetur
|
||||
std::unique_ptr<OsContextLinux> osContext;
|
||||
osContext.reset(new OsContextLinux(*drm, 0u, EngineDescriptorHelper::getDefaultDescriptor()));
|
||||
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
ExecObject execObjectsStorage = {};
|
||||
auto ret = bo.exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, 0, 0);
|
||||
EXPECT_NE(0, ret);
|
||||
}
|
||||
@@ -538,7 +539,7 @@ TEST(DrmBufferObject, whenMarkForCapturedCalledThenIsMarkedForCaptureReturnsTrue
|
||||
}
|
||||
|
||||
TEST_F(DrmBufferObjectTest, givenBoMarkedForCaptureWhenFillingExecObjectThenCaptureFlagIsSet) {
|
||||
drm_i915_gem_exec_object2 execObject;
|
||||
MockExecObject execObject{};
|
||||
|
||||
memset(&execObject, 0, sizeof(execObject));
|
||||
bo->markForCapture();
|
||||
@@ -546,11 +547,11 @@ TEST_F(DrmBufferObjectTest, givenBoMarkedForCaptureWhenFillingExecObjectThenCapt
|
||||
bo->setSize(0x1000);
|
||||
bo->fillExecObject(execObject, osContext.get(), 0, 1);
|
||||
|
||||
EXPECT_TRUE(execObject.flags & EXEC_OBJECT_CAPTURE);
|
||||
EXPECT_TRUE(execObject.hasCaptureFlag());
|
||||
}
|
||||
|
||||
TEST_F(DrmBufferObjectTest, givenAsyncDebugFlagWhenFillingExecObjectThenFlagIsSet) {
|
||||
drm_i915_gem_exec_object2 execObject;
|
||||
MockExecObject execObject{};
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseAsyncDrmExec.set(1);
|
||||
|
||||
@@ -559,7 +560,7 @@ TEST_F(DrmBufferObjectTest, givenAsyncDebugFlagWhenFillingExecObjectThenFlagIsSe
|
||||
bo->setSize(0x1000);
|
||||
bo->fillExecObject(execObject, osContext.get(), 0, 1);
|
||||
|
||||
EXPECT_TRUE(execObject.flags & EXEC_OBJECT_ASYNC);
|
||||
EXPECT_TRUE(execObject.hasAsyncFlag());
|
||||
}
|
||||
|
||||
TEST_F(DrmBufferObjectTest, given47bitAddressWhenSetThenIsAddressNotCanonized) {
|
||||
|
||||
@@ -25,7 +25,7 @@ TEST_F(DrmBufferObjectPrelimTest, GivenCompletionAddressWhenCallingExecThenRetur
|
||||
constexpr uint32_t completionValue = 33;
|
||||
constexpr uint64_t expectedCompletionValue = completionValue;
|
||||
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
ExecObject execObjectsStorage = {};
|
||||
auto ret = bo->exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, completionAddress, completionValue);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_EQ(completionAddress, mock->context.completionAddress);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "shared/test/common/helpers/dispatch_flags_helper.h"
|
||||
#include "shared/test/common/helpers/execution_environment_helper.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_wrappers.h"
|
||||
#include "shared/test/common/mocks/mock_allocation_properties.h"
|
||||
#include "shared/test/common/mocks/mock_gmm.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_page_table_mngr.h"
|
||||
@@ -72,7 +73,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenCommandStreamWhenItIsFlush
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenTaskThatRequiresLargeResourceCountWhenItIsFlushedThenExecStorageIsResized) {
|
||||
std::vector<GraphicsAllocation *> graphicsAllocations;
|
||||
|
||||
auto &execStorage = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->getExecStorage();
|
||||
auto &execStorage = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->execObjectsStorage;
|
||||
execStorage.resize(0);
|
||||
|
||||
for (auto id = 0; id < 10; id++) {
|
||||
@@ -1585,18 +1586,19 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocInMemoryOperationsInt
|
||||
|
||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
|
||||
const auto boRequirments = [&allocation](const auto &bo) {
|
||||
return (static_cast<int>(bo.handle) == static_cast<DrmAllocation *>(allocation)->getBO()->peekHandle() &&
|
||||
bo.offset == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||
const auto execObjectRequirements = [&allocation](const auto &execObject) {
|
||||
auto mockExecObject = static_cast<const MockExecObject &>(execObject);
|
||||
return (static_cast<int>(mockExecObject.getHandle()) == static_cast<DrmAllocation *>(allocation)->getBO()->peekHandle() &&
|
||||
mockExecObject.getOffset() == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||
};
|
||||
|
||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->getExecStorage();
|
||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->execObjectsStorage;
|
||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), execObjectRequirements) != residency.end());
|
||||
EXPECT_EQ(residency.size(), 2u);
|
||||
residency.clear();
|
||||
|
||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), execObjectRequirements) != residency.end());
|
||||
EXPECT_EQ(residency.size(), 2u);
|
||||
residency.clear();
|
||||
|
||||
@@ -1605,7 +1607,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocInMemoryOperationsInt
|
||||
|
||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
|
||||
EXPECT_FALSE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
||||
EXPECT_FALSE(std::find_if(residency.begin(), residency.end(), execObjectRequirements) != residency.end());
|
||||
EXPECT_EQ(residency.size(), 1u);
|
||||
|
||||
mm->freeGraphicsMemory(allocation);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "shared/test/common/libult/linux/drm_mock_helper.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock_prelim_context.h"
|
||||
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_wrappers.h"
|
||||
#include "shared/test/common/mocks/mock_allocation_properties.h"
|
||||
#include "shared/test/common/mocks/mock_gfx_partition.h"
|
||||
#include "shared/test/common/mocks/mock_gmm.h"
|
||||
@@ -2086,13 +2087,14 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedPrelimTest, givenUseVmBindSetWhenFlus
|
||||
|
||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
|
||||
const auto boRequirments = [&allocation](const auto &bo) {
|
||||
return (static_cast<int>(bo.handle) == 0u &&
|
||||
bo.offset == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||
const auto execObjectRequirements = [&allocation](const auto &execObject) {
|
||||
auto mockExecObject = static_cast<const MockExecObject &>(execObject);
|
||||
return (mockExecObject.getHandle() == 0 &&
|
||||
mockExecObject.getOffset() == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||
};
|
||||
|
||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->getExecStorage();
|
||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), boRequirments) == residency.end());
|
||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->execObjectsStorage;
|
||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), execObjectRequirements) == residency.end());
|
||||
EXPECT_EQ(residency.size(), 1u);
|
||||
|
||||
residency.clear();
|
||||
@@ -2115,13 +2117,14 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedPrelimTest, givenUseVmBindAndPassBoun
|
||||
|
||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
|
||||
const auto boRequirments = [&allocation](const auto &bo) {
|
||||
return (static_cast<int>(bo.handle) == 0 &&
|
||||
bo.offset == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||
const auto execObjectRequirements = [&allocation](const auto &execObject) {
|
||||
auto mockExecObject = static_cast<const MockExecObject &>(execObject);
|
||||
return (mockExecObject.getHandle() == 0 &&
|
||||
mockExecObject.getOffset() == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||
};
|
||||
|
||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->getExecStorage();
|
||||
EXPECT_FALSE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->execObjectsStorage;
|
||||
EXPECT_FALSE(std::find_if(residency.begin(), residency.end(), execObjectRequirements) != residency.end());
|
||||
EXPECT_EQ(residency.size(), 1u);
|
||||
|
||||
residency.clear();
|
||||
@@ -2144,13 +2147,14 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedPrelimTest, givenUseVmBindAndPassBoun
|
||||
|
||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
|
||||
const auto boRequirments = [&allocation](const auto &bo) {
|
||||
return (static_cast<int>(bo.handle) == 0 &&
|
||||
bo.offset == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||
const auto execObjectRequirements = [&allocation](const auto &execObject) {
|
||||
auto mockExecObject = static_cast<const MockExecObject &>(execObject);
|
||||
return (mockExecObject.getHandle() == 0 &&
|
||||
mockExecObject.getOffset() == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||
};
|
||||
|
||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->getExecStorage();
|
||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->execObjectsStorage;
|
||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), execObjectRequirements) != residency.end());
|
||||
EXPECT_EQ(residency.size(), 2u);
|
||||
|
||||
residency.clear();
|
||||
|
||||
Reference in New Issue
Block a user