mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Return SubmissionStatus from printBOsForSubmit method
it allows to return non-binary status to API layer Related-To: NEO-7412 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
1d4240a0c8
commit
bddf1bbe76
@ -544,49 +544,6 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, WhenFlushNotCalledThenClearResi
|
|||||||
mm->freeGraphicsMemory(allocation2);
|
mm->freeGraphicsMemory(allocation2);
|
||||||
}
|
}
|
||||||
|
|
||||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenPrintBOsForSubmitWhenPrintThenProperValuesArePrinted) {
|
|
||||||
DebugManagerStateRestore restorer;
|
|
||||||
DebugManager.flags.PrintBOsForSubmit.set(true);
|
|
||||||
|
|
||||||
auto allocation1 = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
|
||||||
auto allocation2 = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
|
||||||
auto buffer = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
|
||||||
ASSERT_NE(nullptr, allocation1);
|
|
||||||
ASSERT_NE(nullptr, allocation2);
|
|
||||||
ASSERT_NE(nullptr, buffer);
|
|
||||||
|
|
||||||
csr->makeResident(*allocation1);
|
|
||||||
csr->makeResident(*allocation2);
|
|
||||||
|
|
||||||
ResidencyContainer residency;
|
|
||||||
residency.push_back(allocation1);
|
|
||||||
residency.push_back(allocation2);
|
|
||||||
|
|
||||||
testing::internal::CaptureStdout();
|
|
||||||
|
|
||||||
static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->printBOsForSubmit(residency, *buffer);
|
|
||||||
|
|
||||||
std::string output = testing::internal::GetCapturedStdout();
|
|
||||||
|
|
||||||
std::vector<BufferObject *> bos;
|
|
||||||
allocation1->makeBOsResident(&csr->getOsContext(), 0, &bos, true);
|
|
||||||
allocation2->makeBOsResident(&csr->getOsContext(), 0, &bos, true);
|
|
||||||
buffer->makeBOsResident(&csr->getOsContext(), 0, &bos, true);
|
|
||||||
|
|
||||||
std::stringstream expected;
|
|
||||||
expected << "Buffer object for submit\n";
|
|
||||||
for (const auto &bo : bos) {
|
|
||||||
expected << "BO-" << bo->peekHandle() << ", range: " << std::hex << bo->peekAddress() << " - " << ptrOffset(bo->peekAddress(), bo->peekSize()) << ", size: " << std::dec << bo->peekSize() << "\n";
|
|
||||||
}
|
|
||||||
expected << "\n";
|
|
||||||
|
|
||||||
EXPECT_FALSE(output.compare(expected.str()));
|
|
||||||
|
|
||||||
mm->freeGraphicsMemory(allocation1);
|
|
||||||
mm->freeGraphicsMemory(allocation2);
|
|
||||||
mm->freeGraphicsMemory(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenFlushMultipleTimesThenSucceeds) {
|
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenFlushMultipleTimesThenSucceeds) {
|
||||||
auto &cs = csr->getCS();
|
auto &cs = csr->getCS();
|
||||||
auto commandBuffer = static_cast<DrmAllocation *>(cs.getGraphicsAllocation());
|
auto commandBuffer = static_cast<DrmAllocation *>(cs.getGraphicsAllocation());
|
||||||
|
@ -61,7 +61,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
|
|||||||
gemCloseWorkerOperationMode = gemCloseWorkerMode::gemCloseWorkerInactive;
|
gemCloseWorkerOperationMode = gemCloseWorkerMode::gemCloseWorkerInactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printBOsForSubmit(ResidencyContainer &allocationsForResidency, GraphicsAllocation &cmdBufferAllocation);
|
SubmissionStatus printBOsForSubmit(ResidencyContainer &allocationsForResidency, GraphicsAllocation &cmdBufferAllocation);
|
||||||
|
|
||||||
using CommandStreamReceiver::pageTableManager;
|
using CommandStreamReceiver::pageTableManager;
|
||||||
|
|
||||||
|
@ -114,7 +114,10 @@ SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBu
|
|||||||
lock = memoryOperationsInterface->lockHandlerIfUsed();
|
lock = memoryOperationsInterface->lockHandlerIfUsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->printBOsForSubmit(allocationsForResidency, *batchBuffer.commandBufferAllocation);
|
auto submissionStatus = this->printBOsForSubmit(allocationsForResidency, *batchBuffer.commandBufferAllocation);
|
||||||
|
if (submissionStatus != SubmissionStatus::SUCCESS) {
|
||||||
|
return submissionStatus;
|
||||||
|
}
|
||||||
|
|
||||||
if (this->drm->isVmBindAvailable()) {
|
if (this->drm->isVmBindAvailable()) {
|
||||||
allocationsForResidency.push_back(batchBuffer.commandBufferAllocation);
|
allocationsForResidency.push_back(batchBuffer.commandBufferAllocation);
|
||||||
@ -174,17 +177,23 @@ void DrmCommandStreamReceiver<GfxFamily>::readBackAllocation(void *source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename GfxFamily>
|
template <typename GfxFamily>
|
||||||
void DrmCommandStreamReceiver<GfxFamily>::printBOsForSubmit(ResidencyContainer &allocationsForResidency, GraphicsAllocation &cmdBufferAllocation) {
|
SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::printBOsForSubmit(ResidencyContainer &allocationsForResidency, GraphicsAllocation &cmdBufferAllocation) {
|
||||||
if (DebugManager.flags.PrintBOsForSubmit.get()) {
|
if (DebugManager.flags.PrintBOsForSubmit.get()) {
|
||||||
std::vector<BufferObject *> bosForSubmit;
|
std::vector<BufferObject *> bosForSubmit;
|
||||||
for (auto drmIterator = 0u; drmIterator < osContext->getDeviceBitfield().size(); drmIterator++) {
|
for (auto drmIterator = 0u; drmIterator < osContext->getDeviceBitfield().size(); drmIterator++) {
|
||||||
if (osContext->getDeviceBitfield().test(drmIterator)) {
|
if (osContext->getDeviceBitfield().test(drmIterator)) {
|
||||||
for (auto gfxAllocation = allocationsForResidency.begin(); gfxAllocation != allocationsForResidency.end(); gfxAllocation++) {
|
for (auto gfxAllocation = allocationsForResidency.begin(); gfxAllocation != allocationsForResidency.end(); gfxAllocation++) {
|
||||||
auto drmAllocation = static_cast<DrmAllocation *>(*gfxAllocation);
|
auto drmAllocation = static_cast<DrmAllocation *>(*gfxAllocation);
|
||||||
drmAllocation->makeBOsResident(osContext, drmIterator, &bosForSubmit, true);
|
auto retCode = drmAllocation->makeBOsResident(osContext, drmIterator, &bosForSubmit, true);
|
||||||
|
if (retCode) {
|
||||||
|
return Drm::getSubmissionStatusFromReturnCode(retCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto drmCmdBufferAllocation = static_cast<DrmAllocation *>(&cmdBufferAllocation);
|
auto drmCmdBufferAllocation = static_cast<DrmAllocation *>(&cmdBufferAllocation);
|
||||||
drmCmdBufferAllocation->makeBOsResident(osContext, drmIterator, &bosForSubmit, true);
|
auto retCode = drmCmdBufferAllocation->makeBOsResident(osContext, drmIterator, &bosForSubmit, true);
|
||||||
|
if (retCode) {
|
||||||
|
return Drm::getSubmissionStatusFromReturnCode(retCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("Buffer object for submit\n");
|
printf("Buffer object for submit\n");
|
||||||
@ -193,6 +202,7 @@ void DrmCommandStreamReceiver<GfxFamily>::printBOsForSubmit(ResidencyContainer &
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
return SubmissionStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename GfxFamily>
|
template <typename GfxFamily>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "shared/source/os_interface/linux/drm_allocation.h"
|
#include "shared/source/os_interface/linux/drm_allocation.h"
|
||||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||||
|
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
@ -60,6 +61,8 @@ class MockDrmAllocation : public DrmAllocation {
|
|||||||
return bindBOsRetValue;
|
return bindBOsRetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ADDMETHOD_NOBASE(makeBOsResident, int, 0, (OsContext * osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind));
|
||||||
|
|
||||||
bool registerBOBindExtHandleCalled = false;
|
bool registerBOBindExtHandleCalled = false;
|
||||||
bool markedForCapture = false;
|
bool markedForCapture = false;
|
||||||
bool bindBOsCalled = false;
|
bool bindBOsCalled = false;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "shared/test/common/helpers/execution_environment_helper.h"
|
#include "shared/test/common/helpers/execution_environment_helper.h"
|
||||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||||
#include "shared/test/common/libult/linux/drm_mock.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_command_stream_receiver.h"
|
#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
|
||||||
#include "shared/test/common/mocks/mock_allocation_properties.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.h"
|
||||||
@ -950,3 +951,89 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPageTableManagerAndMapFalseWhenUpd
|
|||||||
EXPECT_TRUE(result);
|
EXPECT_TRUE(result);
|
||||||
EXPECT_EQ(1u, mockMngr->updateAuxTableCalled);
|
EXPECT_EQ(1u, mockMngr->updateAuxTableCalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenPrintBOsForSubmitWhenPrintThenProperValuesArePrinted) {
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
DebugManager.flags.PrintBOsForSubmit.set(true);
|
||||||
|
|
||||||
|
MockDrmAllocation allocation1(AllocationType::BUFFER, MemoryPool::System4KBPages);
|
||||||
|
MockDrmAllocation allocation2(AllocationType::BUFFER, MemoryPool::System4KBPages);
|
||||||
|
MockDrmAllocation cmdBuffer(AllocationType::COMMAND_BUFFER, MemoryPool::System4KBPages);
|
||||||
|
|
||||||
|
csr->makeResident(allocation1);
|
||||||
|
csr->makeResident(allocation2);
|
||||||
|
|
||||||
|
ResidencyContainer residency;
|
||||||
|
residency.push_back(&allocation1);
|
||||||
|
residency.push_back(&allocation2);
|
||||||
|
|
||||||
|
testing::internal::CaptureStdout();
|
||||||
|
|
||||||
|
EXPECT_EQ(SubmissionStatus::SUCCESS, static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->printBOsForSubmit(residency, cmdBuffer));
|
||||||
|
|
||||||
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
std::vector<BufferObject *> bos;
|
||||||
|
allocation1.makeBOsResident(&csr->getOsContext(), 0, &bos, true);
|
||||||
|
allocation2.makeBOsResident(&csr->getOsContext(), 0, &bos, true);
|
||||||
|
cmdBuffer.makeBOsResident(&csr->getOsContext(), 0, &bos, true);
|
||||||
|
|
||||||
|
std::stringstream expected;
|
||||||
|
expected << "Buffer object for submit\n";
|
||||||
|
for (const auto &bo : bos) {
|
||||||
|
expected << "BO-" << bo->peekHandle() << ", range: " << std::hex << bo->peekAddress() << " - " << ptrOffset(bo->peekAddress(), bo->peekSize()) << ", size: " << std::dec << bo->peekSize() << "\n";
|
||||||
|
}
|
||||||
|
expected << "\n";
|
||||||
|
|
||||||
|
EXPECT_FALSE(output.compare(expected.str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenPrintBOsForSubmitAndFailureOnMakeResidentForCmdBufferWhenPrintThenErrorIsReturnedAndNothingIsPrinted) {
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
DebugManager.flags.PrintBOsForSubmit.set(true);
|
||||||
|
|
||||||
|
MockDrmAllocation allocation1(AllocationType::BUFFER, MemoryPool::System4KBPages);
|
||||||
|
MockDrmAllocation allocation2(AllocationType::BUFFER, MemoryPool::System4KBPages);
|
||||||
|
MockDrmAllocation cmdBuffer(AllocationType::COMMAND_BUFFER, MemoryPool::System4KBPages);
|
||||||
|
|
||||||
|
cmdBuffer.makeBOsResidentResult = ENOSPC;
|
||||||
|
|
||||||
|
csr->makeResident(allocation1);
|
||||||
|
csr->makeResident(allocation2);
|
||||||
|
|
||||||
|
ResidencyContainer residency;
|
||||||
|
residency.push_back(&allocation1);
|
||||||
|
residency.push_back(&allocation2);
|
||||||
|
|
||||||
|
testing::internal::CaptureStdout();
|
||||||
|
|
||||||
|
EXPECT_EQ(SubmissionStatus::OUT_OF_HOST_MEMORY, static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->printBOsForSubmit(residency, cmdBuffer));
|
||||||
|
|
||||||
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
|
EXPECT_TRUE(output.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenPrintBOsForSubmitAndFailureOnMakeResidentForAllocationToResidencyWhenPrintThenErrorIsReturnedAndNothingIsPrinted) {
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
DebugManager.flags.PrintBOsForSubmit.set(true);
|
||||||
|
|
||||||
|
MockDrmAllocation allocation1(AllocationType::BUFFER, MemoryPool::System4KBPages);
|
||||||
|
MockDrmAllocation allocation2(AllocationType::BUFFER, MemoryPool::System4KBPages);
|
||||||
|
MockDrmAllocation cmdBuffer(AllocationType::COMMAND_BUFFER, MemoryPool::System4KBPages);
|
||||||
|
|
||||||
|
allocation1.makeBOsResidentResult = ENOSPC;
|
||||||
|
|
||||||
|
csr->makeResident(allocation1);
|
||||||
|
csr->makeResident(allocation2);
|
||||||
|
|
||||||
|
ResidencyContainer residency;
|
||||||
|
residency.push_back(&allocation1);
|
||||||
|
residency.push_back(&allocation2);
|
||||||
|
|
||||||
|
testing::internal::CaptureStdout();
|
||||||
|
|
||||||
|
EXPECT_EQ(SubmissionStatus::OUT_OF_HOST_MEMORY, static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->printBOsForSubmit(residency, cmdBuffer));
|
||||||
|
|
||||||
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
|
EXPECT_TRUE(output.empty());
|
||||||
|
}
|
Reference in New Issue
Block a user