2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-01-08 22:58:02 +08:00
|
|
|
* Copyright (c) 2018, Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
2018-07-13 20:11:04 +08:00
|
|
|
#include "runtime/command_stream/linear_stream.h"
|
2018-01-08 22:58:02 +08:00
|
|
|
#include "runtime/command_stream/preemption.h"
|
2018-07-13 20:11:04 +08:00
|
|
|
#include "runtime/helpers/cache_policy.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/mem_obj/buffer.h"
|
2018-07-13 20:11:04 +08:00
|
|
|
#include "runtime/memory_manager/graphics_allocation.h"
|
|
|
|
#include "runtime/memory_manager/memory_manager.h"
|
|
|
|
#include "test.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/fixtures/device_fixture.h"
|
2018-07-31 20:27:26 +08:00
|
|
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
2018-07-13 20:11:04 +08:00
|
|
|
#include "unit_tests/mocks/mock_buffer.h"
|
2018-01-08 22:58:02 +08:00
|
|
|
#include "unit_tests/mocks/mock_builtins.h"
|
2018-07-13 20:11:04 +08:00
|
|
|
#include "unit_tests/mocks/mock_context.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/mocks/mock_csr.h"
|
2018-03-06 22:29:06 +08:00
|
|
|
#include "unit_tests/mocks/mock_program.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-09 06:57:07 +08:00
|
|
|
#include "gmock/gmock.h"
|
2018-01-08 22:58:02 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
using namespace OCLRT;
|
|
|
|
|
|
|
|
struct CommandStreamReceiverTest : public DeviceFixture,
|
|
|
|
public ::testing::Test {
|
|
|
|
void SetUp() override {
|
|
|
|
DeviceFixture::SetUp();
|
|
|
|
|
|
|
|
commandStreamReceiver = &pDevice->getCommandStreamReceiver();
|
|
|
|
ASSERT_NE(nullptr, commandStreamReceiver);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
DeviceFixture::TearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
CommandStreamReceiver *commandStreamReceiver;
|
|
|
|
};
|
|
|
|
|
|
|
|
HWTEST_F(CommandStreamReceiverTest, testCtor) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
EXPECT_EQ(0u, csr.peekTaskLevel());
|
|
|
|
EXPECT_EQ(0u, csr.peekTaskCount());
|
|
|
|
EXPECT_FALSE(csr.isPreambleSent);
|
|
|
|
}
|
|
|
|
|
2018-06-13 02:33:03 +08:00
|
|
|
HWTEST_F(CommandStreamReceiverTest, testInitProgrammingFlags) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
csr.initProgrammingFlags();
|
|
|
|
EXPECT_FALSE(csr.isPreambleProgrammed());
|
|
|
|
EXPECT_FALSE(csr.isGSBAFor32BitProgrammed());
|
|
|
|
EXPECT_TRUE(csr.isMediaVfeStateDirty());
|
|
|
|
EXPECT_FALSE(csr.isLastVmeSubslicesConfig());
|
|
|
|
EXPECT_EQ(0u, csr.getLastSentL3Config());
|
|
|
|
EXPECT_EQ(-1, csr.getLastSentCoherencyRequest());
|
|
|
|
EXPECT_EQ(-1, csr.getLastMediaSamplerConfig());
|
|
|
|
EXPECT_EQ(PreemptionMode::Initial, csr.getLastPreemptionMode());
|
|
|
|
EXPECT_EQ(0u, csr.getLatestSentStatelessMocsConfig());
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
TEST_F(CommandStreamReceiverTest, makeResident_setsBufferResidencyFlag) {
|
|
|
|
MockContext context;
|
|
|
|
float srcMemory[] = {1.0f};
|
|
|
|
|
|
|
|
auto retVal = CL_INVALID_VALUE;
|
|
|
|
auto buffer = Buffer::create(
|
|
|
|
&context,
|
|
|
|
CL_MEM_USE_HOST_PTR,
|
|
|
|
sizeof(srcMemory),
|
|
|
|
srcMemory,
|
|
|
|
retVal);
|
|
|
|
ASSERT_NE(nullptr, buffer);
|
|
|
|
EXPECT_FALSE(buffer->getGraphicsAllocation()->isResident());
|
|
|
|
|
|
|
|
commandStreamReceiver->makeResident(*buffer->getGraphicsAllocation());
|
|
|
|
|
|
|
|
EXPECT_TRUE(buffer->getGraphicsAllocation()->isResident());
|
|
|
|
|
|
|
|
delete buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CommandStreamReceiverTest, commandStreamReceiverFromDeviceHasATagValue) {
|
|
|
|
EXPECT_NE(nullptr, const_cast<uint32_t *>(commandStreamReceiver->getTagAddress()));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CommandStreamReceiverTest, GetCommandStreamReturnsValidObject) {
|
|
|
|
auto &cs = commandStreamReceiver->getCS();
|
|
|
|
EXPECT_NE(nullptr, &cs);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CommandStreamReceiverTest, getCommandStreamContainsMemoryForRequest) {
|
|
|
|
size_t requiredSize = 16384;
|
|
|
|
const auto &commandStream = commandStreamReceiver->getCS(requiredSize);
|
|
|
|
ASSERT_NE(nullptr, &commandStream);
|
|
|
|
EXPECT_GE(commandStream.getAvailableSpace(), requiredSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CommandStreamReceiverTest, getCsReturnsCsWithCsOverfetchSizeIncludedInGraphicsAllocation) {
|
|
|
|
size_t sizeRequested = 560;
|
|
|
|
const auto &commandStream = commandStreamReceiver->getCS(sizeRequested);
|
|
|
|
ASSERT_NE(nullptr, &commandStream);
|
|
|
|
auto *allocation = commandStream.getGraphicsAllocation();
|
|
|
|
ASSERT_NE(nullptr, allocation);
|
|
|
|
|
|
|
|
size_t expectedTotalSize = alignUp(sizeRequested + MemoryConstants::cacheLineSize, MemoryConstants::pageSize) + CSRequirements::csOverfetchSize;
|
|
|
|
|
|
|
|
EXPECT_LT(commandStream.getAvailableSpace(), expectedTotalSize);
|
|
|
|
EXPECT_LE(commandStream.getAvailableSpace(), expectedTotalSize - CSRequirements::csOverfetchSize);
|
|
|
|
EXPECT_EQ(expectedTotalSize, allocation->getUnderlyingBufferSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CommandStreamReceiverTest, getCommandStreamCanRecycle) {
|
|
|
|
auto &commandStreamInitial = commandStreamReceiver->getCS();
|
|
|
|
size_t requiredSize = commandStreamInitial.getMaxAvailableSpace() + 42;
|
|
|
|
|
|
|
|
const auto &commandStream = commandStreamReceiver->getCS(requiredSize);
|
|
|
|
ASSERT_NE(nullptr, &commandStream);
|
|
|
|
EXPECT_GE(commandStream.getMaxAvailableSpace(), requiredSize);
|
|
|
|
}
|
|
|
|
|
2018-03-23 04:13:45 +08:00
|
|
|
TEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenGetCSIsCalledThenCommandStreamAllocationTypeShouldBeSetToLinearStream) {
|
|
|
|
const auto &commandStream = commandStreamReceiver->getCS();
|
|
|
|
auto commandStreamAllocation = commandStream.getGraphicsAllocation();
|
|
|
|
ASSERT_NE(nullptr, commandStreamAllocation);
|
|
|
|
|
2018-07-05 22:31:57 +08:00
|
|
|
EXPECT_EQ(GraphicsAllocation::AllocationType::LINEAR_STREAM, commandStreamAllocation->getAllocationType());
|
2018-03-23 04:13:45 +08:00
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
TEST_F(CommandStreamReceiverTest, createAllocationAndHandleResidency) {
|
|
|
|
void *host_ptr = (void *)0x1212341;
|
|
|
|
auto size = 17262u;
|
|
|
|
|
|
|
|
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(host_ptr, size);
|
|
|
|
ASSERT_NE(nullptr, graphicsAllocation);
|
|
|
|
|
|
|
|
EXPECT_EQ(host_ptr, graphicsAllocation->getUnderlyingBuffer());
|
|
|
|
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
|
|
|
|
}
|
|
|
|
|
2018-02-09 05:52:58 +08:00
|
|
|
TEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenAllocationIsNotAddedToListThenCallerMustFreeAllocation) {
|
|
|
|
void *hostPtr = reinterpret_cast<void *>(0x1212341);
|
|
|
|
auto size = 17262u;
|
|
|
|
|
|
|
|
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size, false);
|
|
|
|
ASSERT_NE(nullptr, graphicsAllocation);
|
|
|
|
|
|
|
|
EXPECT_EQ(hostPtr, graphicsAllocation->getUnderlyingBuffer());
|
|
|
|
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
|
|
|
|
|
|
|
|
commandStreamReceiver->getMemoryManager()->freeGraphicsMemory(graphicsAllocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenPtrAndSizeMeetL3CriteriaThenCsrEnableL3) {
|
|
|
|
void *hostPtr = reinterpret_cast<void *>(0xF000);
|
|
|
|
auto size = 0x2000u;
|
|
|
|
|
|
|
|
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size);
|
|
|
|
ASSERT_NE(nullptr, graphicsAllocation);
|
|
|
|
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
|
|
|
|
EXPECT_FALSE(csr.disableL3Cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenPtrAndSizeDoNotMeetL3CriteriaThenCsrDisableL3) {
|
|
|
|
void *hostPtr = reinterpret_cast<void *>(0xF001);
|
|
|
|
auto size = 0x2001u;
|
|
|
|
|
|
|
|
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size);
|
|
|
|
ASSERT_NE(nullptr, graphicsAllocation);
|
|
|
|
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
|
|
|
|
EXPECT_TRUE(csr.disableL3Cache);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
TEST_F(CommandStreamReceiverTest, memoryManagerHasAccessToCSR) {
|
|
|
|
auto *memoryManager = commandStreamReceiver->getMemoryManager();
|
|
|
|
EXPECT_EQ(commandStreamReceiver, memoryManager->csr);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(CommandStreamReceiverTest, storedAllocationsHaveCSRtaskCount) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
auto *memoryManager = csr.getMemoryManager();
|
|
|
|
void *host_ptr = (void *)0x1234;
|
|
|
|
auto allocation = memoryManager->allocateGraphicsMemory(1, host_ptr);
|
|
|
|
|
|
|
|
csr.taskCount = 2u;
|
|
|
|
|
|
|
|
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
|
|
|
|
|
|
|
EXPECT_EQ(csr.peekTaskCount(), allocation->taskCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(CommandStreamReceiverTest, dontReuseSurfaceIfStillInUse) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
auto *memoryManager = csr.getMemoryManager();
|
|
|
|
void *host_ptr = (void *)0x1234;
|
|
|
|
auto allocation = memoryManager->allocateGraphicsMemory(1, host_ptr);
|
|
|
|
|
|
|
|
csr.taskCount = 2u;
|
|
|
|
|
|
|
|
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
|
|
|
|
|
|
|
auto *hwTag = csr.getTagAddress();
|
|
|
|
|
|
|
|
*hwTag = 1;
|
|
|
|
|
2018-04-17 00:01:38 +08:00
|
|
|
auto newAllocation = memoryManager->obtainReusableAllocation(1, false);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(nullptr, newAllocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenCheckedForInitialStatusOfStatelessMocsIndexThenUnknownMocsIsReturend) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
EXPECT_EQ(CacheSettings::unknownMocs, csr.latestSentStatelessMocsConfig);
|
|
|
|
EXPECT_FALSE(csr.disableL3Cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CommandStreamReceiverTest, makeResidentPushesAllocationToMemoryManagerResidencyList) {
|
|
|
|
auto *memoryManager = commandStreamReceiver->getMemoryManager();
|
|
|
|
|
2018-07-09 20:12:32 +08:00
|
|
|
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(0x1000);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
ASSERT_NE(nullptr, graphicsAllocation);
|
|
|
|
|
|
|
|
commandStreamReceiver->makeResident(*graphicsAllocation);
|
|
|
|
|
|
|
|
auto &residencyAllocations = memoryManager->getResidencyAllocations();
|
|
|
|
|
|
|
|
ASSERT_EQ(1u, residencyAllocations.size());
|
|
|
|
EXPECT_EQ(graphicsAllocation, residencyAllocations[0]);
|
|
|
|
|
|
|
|
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CommandStreamReceiverTest, makeResidentWithoutParametersDoesNothing) {
|
|
|
|
auto *memoryManager = commandStreamReceiver->getMemoryManager();
|
2018-08-27 21:48:29 +08:00
|
|
|
commandStreamReceiver->processResidency(nullptr, *pDevice->getOsContext());
|
2017-12-21 07:45:38 +08:00
|
|
|
auto &residencyAllocations = memoryManager->getResidencyAllocations();
|
|
|
|
EXPECT_EQ(0u, residencyAllocations.size());
|
|
|
|
}
|
|
|
|
|
2018-03-21 19:58:30 +08:00
|
|
|
TEST_F(CommandStreamReceiverTest, givenForced32BitAddressingWhenDebugSurfaceIsAllocatedThenRegularAllocationIsReturned) {
|
|
|
|
auto *memoryManager = commandStreamReceiver->getMemoryManager();
|
|
|
|
memoryManager->setForce32BitAllocations(true);
|
|
|
|
auto allocation = commandStreamReceiver->allocateDebugSurface(1024);
|
|
|
|
EXPECT_FALSE(allocation->is32BitAllocation);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
HWTEST_F(CommandStreamReceiverTest, givenDefaultCommandStreamReceiverThenDefaultDispatchingPolicyIsImmediateSubmission) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
2018-04-04 17:34:46 +08:00
|
|
|
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
|
2018-03-30 03:26:25 +08:00
|
|
|
}
|
2018-04-03 18:23:14 +08:00
|
|
|
|
2018-04-26 16:01:01 +08:00
|
|
|
HWTEST_F(CommandStreamReceiverTest, givenCsrWhenGetIndirectHeapIsCalledThenHeapIsReturned) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
auto &heap = csr.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 10u);
|
|
|
|
EXPECT_NE(nullptr, heap.getGraphicsAllocation());
|
|
|
|
EXPECT_NE(nullptr, csr.indirectHeap[IndirectHeap::DYNAMIC_STATE]);
|
|
|
|
EXPECT_EQ(&heap, csr.indirectHeap[IndirectHeap::DYNAMIC_STATE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(CommandStreamReceiverTest, givenCsrWhenReleaseIndirectHeapIsCalledThenHeapAllocationIsNull) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
auto &heap = csr.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 10u);
|
|
|
|
csr.releaseIndirectHeap(IndirectHeap::DYNAMIC_STATE);
|
|
|
|
EXPECT_EQ(nullptr, heap.getGraphicsAllocation());
|
|
|
|
EXPECT_EQ(0u, heap.getMaxAvailableSpace());
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(CommandStreamReceiverTest, givenCsrWhenAllocateHeapMemoryIsCalledThenHeapMemoryIsAllocated) {
|
|
|
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
IndirectHeap *dsh = nullptr;
|
|
|
|
csr.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
|
|
|
|
EXPECT_NE(nullptr, dsh);
|
|
|
|
ASSERT_NE(nullptr, dsh->getGraphicsAllocation());
|
|
|
|
csr.getMemoryManager()->freeGraphicsMemory(dsh->getGraphicsAllocation());
|
|
|
|
delete dsh;
|
|
|
|
}
|
|
|
|
|
2018-04-03 18:23:14 +08:00
|
|
|
TEST(CommandStreamReceiverSimpleTest, givenCSRWithoutTagAllocationWhenGetTagAllocationIsCalledThenNullptrIsReturned) {
|
|
|
|
MockCommandStreamReceiver csr;
|
|
|
|
EXPECT_EQ(nullptr, csr.getTagAllocation());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommandStreamReceiverSimpleTest, givenCSRWithTagAllocationSetWhenGetTagAllocationIsCalledThenCorrectAllocationIsReturned) {
|
|
|
|
MockCommandStreamReceiver csr;
|
|
|
|
GraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
|
|
|
csr.setTagAllocation(&allocation);
|
|
|
|
EXPECT_EQ(&allocation, csr.getTagAllocation());
|
2018-05-09 06:57:07 +08:00
|
|
|
}
|
2018-07-03 23:56:55 +08:00
|
|
|
|
2018-07-13 20:11:04 +08:00
|
|
|
TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroyedThenItDestroysTagAllocation) {
|
|
|
|
struct MockGraphicsAllocation : public GraphicsAllocation {
|
|
|
|
using GraphicsAllocation::GraphicsAllocation;
|
|
|
|
~MockGraphicsAllocation() override { *destructorCalled = true; }
|
|
|
|
bool *destructorCalled = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool destructorCalled = false;
|
|
|
|
|
|
|
|
auto mockGraphicsAllocation = new MockGraphicsAllocation(nullptr, 1u);
|
|
|
|
mockGraphicsAllocation->destructorCalled = &destructorCalled;
|
|
|
|
std::unique_ptr<MockCommandStreamReceiver> csr(new MockCommandStreamReceiver);
|
|
|
|
std::unique_ptr<OsAgnosticMemoryManager> memoryManager(new OsAgnosticMemoryManager);
|
|
|
|
csr->setMemoryManager(memoryManager.get());
|
|
|
|
csr->setTagAllocation(mockGraphicsAllocation);
|
|
|
|
EXPECT_FALSE(destructorCalled);
|
|
|
|
csr.reset(nullptr);
|
|
|
|
EXPECT_TRUE(destructorCalled);
|
|
|
|
}
|
|
|
|
|
2018-07-16 23:11:43 +08:00
|
|
|
TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTagAllocationIsCalledThenTagAllocationIsBeingAllocated) {
|
|
|
|
std::unique_ptr<OsAgnosticMemoryManager> memoryManager(new OsAgnosticMemoryManager);
|
|
|
|
std::unique_ptr<MockCommandStreamReceiver> csr(new MockCommandStreamReceiver);
|
|
|
|
csr->setMemoryManager(memoryManager.get());
|
|
|
|
EXPECT_EQ(nullptr, csr->getTagAllocation());
|
|
|
|
EXPECT_TRUE(csr->getTagAddress() == nullptr);
|
|
|
|
csr->initializeTagAllocation();
|
|
|
|
EXPECT_NE(nullptr, csr->getTagAllocation());
|
|
|
|
EXPECT_TRUE(csr->getTagAddress() != nullptr);
|
2018-07-31 20:27:26 +08:00
|
|
|
EXPECT_EQ(*csr->getTagAddress(), initialHardwareTag);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommandStreamReceiverSimpleTest, givenNullHardwareDebugModeWhenInitializeTagAllocationIsCalledThenTagAllocationIsBeingAllocatedAndinitialValueIsMinusOne) {
|
|
|
|
DebugManagerStateRestore dbgRestore;
|
|
|
|
DebugManager.flags.EnableNullHardware.set(true);
|
|
|
|
std::unique_ptr<OsAgnosticMemoryManager> memoryManager(new OsAgnosticMemoryManager);
|
|
|
|
std::unique_ptr<MockCommandStreamReceiver> csr(new MockCommandStreamReceiver);
|
|
|
|
csr->setMemoryManager(memoryManager.get());
|
|
|
|
EXPECT_EQ(nullptr, csr->getTagAllocation());
|
|
|
|
EXPECT_TRUE(csr->getTagAddress() == nullptr);
|
|
|
|
csr->initializeTagAllocation();
|
|
|
|
EXPECT_NE(nullptr, csr->getTagAllocation());
|
|
|
|
EXPECT_TRUE(csr->getTagAddress() != nullptr);
|
|
|
|
EXPECT_EQ(*csr->getTagAddress(), static_cast<uint32_t>(-1));
|
2018-07-16 23:11:43 +08:00
|
|
|
}
|
|
|
|
|
2018-07-03 23:56:55 +08:00
|
|
|
TEST(CommandStreamReceiverSimpleTest, givenCSRWhenWaitBeforeMakingNonResidentWhenRequiredIsCalledWithBlockingFlagSetThenItReturnsImmediately) {
|
|
|
|
MockCommandStreamReceiver csr;
|
|
|
|
uint32_t tag = 0;
|
|
|
|
GraphicsAllocation allocation(&tag, sizeof(tag));
|
|
|
|
csr.latestFlushedTaskCount = 3;
|
|
|
|
csr.setTagAllocation(&allocation);
|
2018-08-02 21:17:58 +08:00
|
|
|
csr.waitBeforeMakingNonResidentWhenRequired();
|
2018-07-03 23:56:55 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(0u, tag);
|
2018-07-13 20:11:04 +08:00
|
|
|
}
|