mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Enable zeDeviceCanAccessPeer
- Propagate return value up from Batch Buffer exec - Add zeDeviceCanAccessPeer functionality Signed-off-by: Raiyan Latif <raiyan.latif@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
2441f0660d
commit
0859f99d64
@@ -104,9 +104,33 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
|
||||
|
||||
bool callHwFlush = true;
|
||||
|
||||
void flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
|
||||
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
|
||||
if (callHwFlush) {
|
||||
DrmCommandStreamReceiver<GfxFamily>::flushInternal(batchBuffer, allocationsForResidency);
|
||||
return DrmCommandStreamReceiver<GfxFamily>::flushInternal(batchBuffer, allocationsForResidency);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
class TestedDrmCommandStreamReceiverWithFailingExec : public TestedDrmCommandStreamReceiver<GfxFamily> {
|
||||
public:
|
||||
TestedDrmCommandStreamReceiverWithFailingExec(gemCloseWorkerMode mode,
|
||||
ExecutionEnvironment &executionEnvironment,
|
||||
const DeviceBitfield deviceBitfield)
|
||||
: TestedDrmCommandStreamReceiver<GfxFamily>(mode,
|
||||
executionEnvironment,
|
||||
deviceBitfield) {
|
||||
}
|
||||
TestedDrmCommandStreamReceiverWithFailingExec(ExecutionEnvironment &executionEnvironment,
|
||||
uint32_t rootDeviceIndex,
|
||||
const DeviceBitfield deviceBitfield)
|
||||
: TestedDrmCommandStreamReceiver<GfxFamily>(executionEnvironment,
|
||||
rootDeviceIndex,
|
||||
deviceBitfield) {
|
||||
}
|
||||
|
||||
int exec(const BatchBuffer &batchBuffer, uint32_t vmHandleId, uint32_t drmContextId) override {
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -384,6 +384,32 @@ TEST(DrmBufferObject, givenPerContextVmRequiredWhenBoCreatedThenBindInfoIsInitia
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DrmBufferObject, givenDrmIoctlReturnsErrorNotSupportedThenBufferObjectReturnsError) {
|
||||
auto executionEnvironment = new ExecutionEnvironment;
|
||||
executionEnvironment->setDebuggingEnabled();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
executionEnvironment->calculateMaxOsContextCount();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||
|
||||
DrmMockReturnErrorNotSupported *drm = new DrmMockReturnErrorNotSupported(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
|
||||
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u);
|
||||
|
||||
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
|
||||
|
||||
auto osContextCount = device->getExecutionEnvironment()->memoryManager->getRegisteredEnginesCount();
|
||||
MockBufferObject bo(drm, 0, 0, osContextCount);
|
||||
|
||||
std::unique_ptr<OsContextLinux> osContext;
|
||||
osContext.reset(new OsContextLinux(*drm, 0u, EngineDescriptorHelper::getDefaultDescriptor()));
|
||||
|
||||
drm_i915_gem_exec_object2 execObjectsStorage = {};
|
||||
auto ret = bo.exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage);
|
||||
EXPECT_NE(0, ret);
|
||||
}
|
||||
|
||||
TEST(DrmBufferObject, givenPerContextVmRequiredWhenBoBoundAndUnboundThenCorrectBindInfoIsUpdated) {
|
||||
auto executionEnvironment = new ExecutionEnvironment;
|
||||
executionEnvironment->setDebuggingEnabled();
|
||||
|
||||
@@ -163,3 +163,83 @@ class DrmCommandStreamEnhancedTemplate : public ::testing::Test {
|
||||
};
|
||||
|
||||
using DrmCommandStreamEnhancedTest = DrmCommandStreamEnhancedTemplate<DrmMockCustom>;
|
||||
|
||||
template <typename T>
|
||||
class DrmCommandStreamEnhancedWithFailingExecTemplate : public ::testing::Test {
|
||||
public:
|
||||
std::unique_ptr<DebugManagerStateRestore> dbgState;
|
||||
MockExecutionEnvironment *executionEnvironment;
|
||||
T *mock;
|
||||
CommandStreamReceiver *csr = nullptr;
|
||||
const uint32_t rootDeviceIndex = 0u;
|
||||
|
||||
DrmMemoryManager *mm = nullptr;
|
||||
std::unique_ptr<MockDevice> device;
|
||||
|
||||
template <typename GfxFamily>
|
||||
void SetUpT() {
|
||||
executionEnvironment = new MockExecutionEnvironment();
|
||||
executionEnvironment->incRefInternal();
|
||||
executionEnvironment->initGmm();
|
||||
this->dbgState = std::make_unique<DebugManagerStateRestore>();
|
||||
//make sure this is disabled, we don't want to test this now
|
||||
DebugManager.flags.EnableForcePin.set(false);
|
||||
|
||||
mock = new T();
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, rootDeviceIndex);
|
||||
|
||||
csr = new TestedDrmCommandStreamReceiverWithFailingExec<GfxFamily>(*executionEnvironment, rootDeviceIndex, 1);
|
||||
ASSERT_NE(nullptr, csr);
|
||||
mm = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive,
|
||||
DebugManager.flags.EnableForcePin.get(),
|
||||
true,
|
||||
*executionEnvironment);
|
||||
ASSERT_NE(nullptr, mm);
|
||||
executionEnvironment->memoryManager.reset(mm);
|
||||
constructPlatform()->peekExecutionEnvironment()->prepareRootDeviceEnvironments(1u);
|
||||
constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
constructPlatform()->peekExecutionEnvironment()->initializeMemoryManager();
|
||||
device.reset(MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex));
|
||||
device->resetCommandStreamReceiver(csr);
|
||||
ASSERT_NE(nullptr, device);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void TearDownT() {
|
||||
executionEnvironment->decRefInternal();
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void makeResidentBufferObjects(OsContext *osContext, DrmAllocation *drmAllocation) {
|
||||
drmAllocation->bindBOs(osContext, 0u, &static_cast<TestedDrmCommandStreamReceiver<GfxFamily> *>(csr)->residency, false);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool isResident(BufferObject *bo) const {
|
||||
auto &residency = this->getResidencyVector<GfxFamily>();
|
||||
return std::find(residency.begin(), residency.end(), bo) != residency.end();
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
const std::vector<BufferObject *> &getResidencyVector() const {
|
||||
return static_cast<const TestedDrmCommandStreamReceiver<GfxFamily> *>(csr)->residency;
|
||||
}
|
||||
|
||||
protected:
|
||||
class MockBufferObject : public BufferObject {
|
||||
friend DrmCommandStreamEnhancedTemplate<T>;
|
||||
|
||||
protected:
|
||||
MockBufferObject(Drm *drm, size_t size) : BufferObject(drm, 1, 0, 16u) {
|
||||
this->size = alignUp(size, 4096);
|
||||
}
|
||||
};
|
||||
|
||||
MockBufferObject *createBO(size_t size) {
|
||||
return new MockBufferObject(this->mock, size);
|
||||
}
|
||||
};
|
||||
|
||||
using DrmCommandStreamEnhancedWithFailingExec = DrmCommandStreamEnhancedWithFailingExecTemplate<DrmMockCustom>;
|
||||
@@ -626,6 +626,20 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenNotEmptyNotPaddedBbWhenFlu
|
||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedWithFailingExec, GivenFailingExecThenCSRFlushFails) {
|
||||
int bbUsed = 15 * sizeof(uint32_t);
|
||||
|
||||
auto &cs = csr->getCS();
|
||||
|
||||
cs.getSpace(bbUsed);
|
||||
|
||||
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
|
||||
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
|
||||
bool ret = csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenNotAlignedWhenFlushingThenSucceeds) {
|
||||
auto &cs = csr->getCS();
|
||||
auto commandBuffer = static_cast<DrmAllocation *>(cs.getGraphicsAllocation());
|
||||
@@ -1191,10 +1205,11 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenNoAllocsInMemoryOperationH
|
||||
|
||||
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
|
||||
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
|
||||
void flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
|
||||
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
|
||||
auto memoryOperationsInterface = static_cast<MockDrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
ASSERT_TRUE(memoryOperationsInterface->mutex.try_lock());
|
||||
EXPECT_TRUE(memoryOperationsInterface->mutex.try_lock());
|
||||
memoryOperationsInterface->mutex.unlock();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1222,9 +1237,10 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocsInMemoryOperationHan
|
||||
|
||||
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
|
||||
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
|
||||
void flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
|
||||
int flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
|
||||
auto memoryOperationsInterface = static_cast<MockDrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
|
||||
EXPECT_FALSE(memoryOperationsInterface->mutex.try_lock());
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user