[22/n] Internal 4GB allocator.

- Finalize Instruction Heap removal.

Change-Id: Idd7df94a228238a5157c3251180fc3c8d3a189df
This commit is contained in:
Mrozek, Michal
2018-03-29 07:31:09 +02:00
parent 2be5934096
commit 7f3c4d3d70
12 changed files with 2 additions and 170 deletions

View File

@@ -421,8 +421,6 @@ TEST_P(CommandQueueIndirectHeapTest, IndirectHeapContainsAtLeast64KB) {
auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), sizeof(uint32_t));
if (this->GetParam() == IndirectHeap::SURFACE_STATE) {
EXPECT_EQ(64 * KB - MemoryConstants::pageSize, indirectHeap.getAvailableSpace());
} else if (this->GetParam() == IndirectHeap::INSTRUCTION) {
EXPECT_EQ(optimalInstructionHeapSize, indirectHeap.getAvailableSpace());
} else {
EXPECT_EQ(64 * KB, indirectHeap.getAvailableSpace());
}
@@ -478,9 +476,6 @@ TEST_P(CommandQueueIndirectHeapTest, MemoryManagerWithReusableAllocationsWhenAsk
auto memoryManager = pDevice->getMemoryManager();
auto allocationSize = defaultHeapSize * 2;
if (this->GetParam() == IndirectHeap::INSTRUCTION) {
allocationSize = optimalInstructionHeapSize * 2;
}
auto allocation = memoryManager->allocateGraphicsMemory(allocationSize);
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
@@ -627,7 +622,6 @@ INSTANTIATE_TEST_CASE_P(
IndirectHeap::DYNAMIC_STATE,
IndirectHeap::GENERAL_STATE,
IndirectHeap::INDIRECT_OBJECT,
IndirectHeap::INSTRUCTION,
IndirectHeap::SURFACE_STATE));
typedef Test<DeviceFixture> CommandQueueCSTest;
@@ -733,40 +727,6 @@ HWTEST_F(WaitForQueueCompletionTests, whenFinishIsCalledThenCallWaitWithoutQuick
EXPECT_FALSE(cmdQ->requestedUseQuickKmdSleep);
}
constexpr char sipPattern[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 39, 41};
static_assert(false == isAligned<MemoryConstants::cacheLineSize>(sizeof(sipPattern)),
"Will be checking for automatic cacheline alignment, so pattern length must not be a multiple of cacheline");
constexpr size_t alignedPatternSize = alignUp(sizeof(sipPattern), MemoryConstants::cacheLineSize);
TEST(CommandQueueGetIndirectHeap, whenNewInstructionHeapIsBeingCreatedThenCommandStreamReceiverCanReserveAMemoryBlockAtItsBegining) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr));
MockCommandStreamReceiver *csr = new MockCommandStreamReceiver;
mockDevice->resetCommandStreamReceiver(csr);
csr->instructionHeapReserveredData.assign(sipPattern, sipPattern + sizeof(sipPattern));
MockCommandQueue cmdQ{nullptr, mockDevice.get(), nullptr};
IndirectHeap &heap = cmdQ.getIndirectHeap(OCLRT::IndirectHeap::INSTRUCTION, 8192);
EXPECT_LE(8192U, heap.getAvailableSpace());
EXPECT_EQ(alignedPatternSize, heap.getUsed());
ASSERT_LE(sizeof(sipPattern), heap.getMaxAvailableSpace());
char *reservedBlock = reinterpret_cast<char *>(heap.getCpuBase());
auto dataFoundInReservedBlock = ArrayRef<char>(reservedBlock, sizeof(sipPattern));
auto expectedData = ArrayRef<char>(csr->instructionHeapReserveredData);
EXPECT_THAT(dataFoundInReservedBlock, testing::ContainerEq(expectedData));
}
TEST(CommandQueueGetIndirectHeap, whenCheckingForCsrInstructionHeapReservedBlockSizeThenCachelineAlignmentIsExpected) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr));
MockCommandStreamReceiver *csr = new MockCommandStreamReceiver;
mockDevice->resetCommandStreamReceiver(csr);
csr->instructionHeapReserveredData.assign(sipPattern, sipPattern + sizeof(sipPattern));
MockCommandQueue cmdQ{nullptr, mockDevice.get(), nullptr};
EXPECT_GE(alignedPatternSize, csr->getInstructionHeapCmdStreamReceiverReservedSize());
EXPECT_EQ(alignedPatternSize, cmdQ.getInstructionHeapReservedBlockSize());
}
TEST(CommandQueue, givenEnqueueAcquireSharedObjectsWhenNoObjectsThenReturnSuccess) {
MockContext context;
CommandQueue cmdQ(&context, nullptr, 0);

View File

@@ -2763,6 +2763,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenSusbsequ
dispatchFlags);
EXPECT_EQ(expectedUsed + additionalSize, mockCsr->peekTotalMemoryUsed());
mockCsr->flushBatchedSubmissions();
}
struct MockedMemoryManager : public OsAgnosticMemoryManager {

View File

@@ -260,36 +260,4 @@ TEST_F(CommandStreamReceiverTest, givenForced32BitAddressingWhenDebugSurfaceIsAl
HWTEST_F(CommandStreamReceiverTest, givenDefaultCommandStreamReceiverThenDefaultDispatchingPolicyIsImmediateSubmission) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_EQ(CommandStreamReceiver::DispatchMode::ImmediateDispatch, csr.dispatchMode);
}
TEST(CommandStreamReceiver, cmdStreamReceiverReservedBlockInInstructionHeapIsBasedOnPreemptionHelper) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr));
mockDevice->setPreemptionMode(PreemptionMode::MidThread);
{
MockBuiltins mockBuiltins;
mockBuiltins.overrideGlobalBuiltins();
{
auto sipOverride = std::unique_ptr<OCLRT::SipKernel>(new OCLRT::SipKernel(OCLRT::SipKernelType::Csr, getSipProgramWithCustomBinary()));
mockBuiltins.overrideSipKernel(std::move(sipOverride));
}
size_t reservedSize = mockDevice->getCommandStreamReceiver().getInstructionHeapCmdStreamReceiverReservedSize();
size_t expectedSize = OCLRT::PreemptionHelper::getInstructionHeapSipKernelReservedSize(*mockDevice);
EXPECT_NE(0U, expectedSize);
EXPECT_EQ(expectedSize, reservedSize);
ASSERT_LE(expectedSize, reservedSize);
StackVec<char, 4096> cmdStreamIhBuffer;
cmdStreamIhBuffer.resize(reservedSize);
LinearStream cmdStreamReceiverInstrucionHeap{cmdStreamIhBuffer.begin(), cmdStreamIhBuffer.size()};
mockDevice->getCommandStreamReceiver().initializeInstructionHeapCmdStreamReceiverReservedBlock(cmdStreamReceiverInstrucionHeap);
StackVec<char, 4096> preemptionHelperIhBuffer;
preemptionHelperIhBuffer.resize(expectedSize);
LinearStream preemptionHelperInstrucionHeap{preemptionHelperIhBuffer.begin(), preemptionHelperIhBuffer.size()};
PreemptionHelper::initializeInstructionHeapSipKernelReservedBlock(preemptionHelperInstrucionHeap, *mockDevice);
cmdStreamIhBuffer.resize(expectedSize);
EXPECT_THAT(preemptionHelperIhBuffer, testing::ContainerEq(cmdStreamIhBuffer));
}
}
}

View File

@@ -236,25 +236,6 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
}
void setOSInterface(OSInterface *osInterface);
size_t getInstructionHeapCmdStreamReceiverReservedSize() const override {
if (instructionHeapReserveredData.size() == 0) {
return CommandStreamReceiver::getInstructionHeapCmdStreamReceiverReservedSize();
}
return instructionHeapReserveredData.size();
}
void initializeInstructionHeapCmdStreamReceiverReservedBlock(LinearStream &ih) const override {
if (instructionHeapReserveredData.size() == 0) {
CommandStreamReceiver::initializeInstructionHeapCmdStreamReceiverReservedBlock(ih);
return;
}
void *block = ih.getSpace(instructionHeapReserveredData.size());
memcpy_s(block, instructionHeapReserveredData.size(),
instructionHeapReserveredData.data(), instructionHeapReserveredData.size());
}
};
#if defined(__clang__)

View File

@@ -313,27 +313,6 @@ TEST(PreemptionTest, defaultMode) {
EXPECT_EQ(-1, preemptionModeFromDebugManager);
}
TEST(PreemptionTest, whenPreemptionModeIsNotMidThreadThenInstructionHeapSipKernelReservedSizeIsEmpty) {
char buffer[4096];
LinearStream instructionHeap(buffer, sizeof(buffer));
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr));
mockDevice->setPreemptionMode(PreemptionMode::Disabled);
EXPECT_EQ(0U, PreemptionHelper::getInstructionHeapSipKernelReservedSize(*mockDevice));
PreemptionHelper::initializeInstructionHeapSipKernelReservedBlock(instructionHeap, *mockDevice);
ASSERT_EQ(0U, instructionHeap.getUsed());
mockDevice->setPreemptionMode(PreemptionMode::MidBatch);
EXPECT_EQ(0U, PreemptionHelper::getInstructionHeapSipKernelReservedSize(*mockDevice));
PreemptionHelper::initializeInstructionHeapSipKernelReservedBlock(instructionHeap, *mockDevice);
ASSERT_EQ(0U, instructionHeap.getUsed());
mockDevice->setPreemptionMode(PreemptionMode::ThreadGroup);
EXPECT_EQ(0U, PreemptionHelper::getInstructionHeapSipKernelReservedSize(*mockDevice));
PreemptionHelper::initializeInstructionHeapSipKernelReservedBlock(instructionHeap, *mockDevice);
ASSERT_EQ(0U, instructionHeap.getUsed());
}
struct PreemptionHwTest : ::testing::Test, ::testing::WithParamInterface<PreemptionMode> {
};