Skip to content

Commit 298df15

Browse files
Add flag to determine if csr can allocate in internal heaps
Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 0c8080a commit 298df15

File tree

8 files changed

+21
-12
lines changed

8 files changed

+21
-12
lines changed

opencl/test/unit_test/command_queue/command_queue_tests.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,13 @@ TEST_P(CommandQueueIndirectHeapTest, WhenGettingIndirectHeapThenValidObjectIsRet
517517
EXPECT_NE(nullptr, &indirectHeap);
518518
}
519519

520-
TEST_P(CommandQueueIndirectHeapTest, givenIndirectObjectHeapWhenItIsQueriedForInternalAllocationThenTrueIsReturned) {
520+
HWTEST_P(CommandQueueIndirectHeapTest, givenIndirectObjectHeapWhenItIsQueriedForInternalAllocationThenTrueIsReturned) {
521521
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
522522
MockCommandQueue cmdQ(context.get(), pClDevice, props);
523+
auto &commandStreamReceiver = pClDevice->getUltCommandStreamReceiver<FamilyType>();
523524

524525
auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), 8192);
525-
if (this->GetParam() == IndirectHeap::INDIRECT_OBJECT) {
526+
if (this->GetParam() == IndirectHeap::INDIRECT_OBJECT && commandStreamReceiver.canUse4GbHeaps) {
526527
EXPECT_TRUE(indirectHeap.getGraphicsAllocation()->is32BitAllocation());
527528
} else {
528529
EXPECT_FALSE(indirectHeap.getGraphicsAllocation()->is32BitAllocation());
@@ -587,7 +588,7 @@ TEST_P(CommandQueueIndirectHeapTest, WhenGettingIndirectHeapThenSizeIsAlignedToC
587588
EXPECT_TRUE(isAligned<MemoryConstants::cacheLineSize>(indirectHeap.getAvailableSpace()));
588589
}
589590

590-
TEST_P(CommandQueueIndirectHeapTest, givenCommandStreamReceiverWithReusableAllocationsWhenAskedForHeapAllocationThenAllocationFromReusablePoolIsReturned) {
591+
HWTEST_P(CommandQueueIndirectHeapTest, givenCommandStreamReceiverWithReusableAllocationsWhenAskedForHeapAllocationThenAllocationFromReusablePoolIsReturned) {
591592
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
592593
MockCommandQueue cmdQ(context.get(), pClDevice, props);
593594

@@ -597,9 +598,9 @@ TEST_P(CommandQueueIndirectHeapTest, givenCommandStreamReceiverWithReusableAlloc
597598

598599
GraphicsAllocation *allocation = nullptr;
599600

600-
auto &commandStreamReceiver = cmdQ.getGpgpuCommandStreamReceiver();
601+
auto &commandStreamReceiver = pClDevice->getUltCommandStreamReceiver<FamilyType>();
601602
auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM;
602-
if (this->GetParam() == IndirectHeap::INDIRECT_OBJECT) {
603+
if (this->GetParam() == IndirectHeap::INDIRECT_OBJECT && commandStreamReceiver.canUse4GbHeaps) {
603604
allocationType = GraphicsAllocation::AllocationType::INTERNAL_HEAP;
604605
}
605606
allocation = memoryManager->allocateGraphicsMemoryWithProperties({pDevice->getRootDeviceIndex(), allocationSize, allocationType, pDevice->getDeviceBitfield()});
@@ -736,13 +737,14 @@ TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapWhenGraphicAllocat
736737
memoryManager->freeGraphicsMemory(allocation);
737738
}
738739

739-
TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetIndirectHeapIsCalledThenIndirectHeapAllocationTypeShouldBeSetToInternalHeapForIohAndLinearStreamForOthers) {
740+
HWTEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetIndirectHeapIsCalledThenIndirectHeapAllocationTypeShouldBeSetToInternalHeapForIohAndLinearStreamForOthers) {
740741
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
741742
MockCommandQueue cmdQ(context.get(), pClDevice, props);
743+
auto &commandStreamReceiver = pClDevice->getUltCommandStreamReceiver<FamilyType>();
742744

743745
auto heapType = this->GetParam();
744746

745-
bool requireInternalHeap = IndirectHeap::INDIRECT_OBJECT == heapType;
747+
bool requireInternalHeap = IndirectHeap::INDIRECT_OBJECT == heapType && commandStreamReceiver.canUse4GbHeaps;
746748
const auto &indirectHeap = cmdQ.getIndirectHeap(heapType, 100);
747749
auto indirectHeapAllocation = indirectHeap.getGraphicsAllocation();
748750
ASSERT_NE(nullptr, indirectHeapAllocation);

opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ HWTEST_F(HardwareCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoComme
206206
EXPECT_EQ(PatchInfoAllocationType::IndirectObjectHeap, kernel->getPatchInfoDataList()[0].targetType);
207207
}
208208

209-
HWTEST_F(HardwareCommandsTest, givenIndirectHeapNotAllocatedFromInternalPoolWhenSendCrossThreadDataIsCalledThenOffsetZeroIsReturned) {
209+
HWCMDTEST_F(IGFX_GEN8_CORE, HardwareCommandsTest, givenIndirectHeapNotAllocatedFromInternalPoolWhenSendCrossThreadDataIsCalledThenOffsetZeroIsReturned) {
210210
auto nonInternalAllocation = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
211211
IndirectHeap indirectHeap(nonInternalAllocation, false);
212212

@@ -221,7 +221,7 @@ HWTEST_F(HardwareCommandsTest, givenIndirectHeapNotAllocatedFromInternalPoolWhen
221221
pDevice->getMemoryManager()->freeGraphicsMemory(nonInternalAllocation);
222222
}
223223

224-
HWTEST_F(HardwareCommandsTest, givenIndirectHeapAllocatedFromInternalPoolWhenSendCrossThreadDataIsCalledThenHeapBaseOffsetIsReturned) {
224+
HWCMDTEST_F(IGFX_GEN8_CORE, HardwareCommandsTest, givenIndirectHeapAllocatedFromInternalPoolWhenSendCrossThreadDataIsCalledThenHeapBaseOffsetIsReturned) {
225225
auto internalAllocation = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties(pDevice->getRootDeviceIndex(), true, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::INTERNAL_HEAP, pDevice->getDeviceBitfield()));
226226
IndirectHeap indirectHeap(internalAllocation, true);
227227
auto expectedOffset = internalAllocation->getGpuAddressToPatch();
@@ -238,7 +238,7 @@ HWTEST_F(HardwareCommandsTest, givenIndirectHeapAllocatedFromInternalPoolWhenSen
238238
pDevice->getMemoryManager()->freeGraphicsMemory(internalAllocation);
239239
}
240240

241-
HWTEST_F(HardwareCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoDataOffsetsAreMoved) {
241+
HWCMDTEST_F(IGFX_GEN8_CORE, HardwareCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoDataOffsetsAreMoved) {
242242
DebugManagerStateRestore dbgRestore;
243243
DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
244244

opencl/test/unit_test/libult/ult_command_stream_receiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
5454
using BaseClass::staticWorkPartitioningEnabled;
5555
using BaseClass::wasSubmittedToSingleSubdevice;
5656
using BaseClass::CommandStreamReceiver::bindingTableBaseAddressRequired;
57+
using BaseClass::CommandStreamReceiver::canUse4GbHeaps;
5758
using BaseClass::CommandStreamReceiver::checkForNewResources;
5859
using BaseClass::CommandStreamReceiver::checkImplicitFlushForGpuIdle;
5960
using BaseClass::CommandStreamReceiver::cleanupResources;

shared/source/command_stream/command_stream_receiver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
390390
if (IndirectHeap::SURFACE_STATE == heapType) {
391391
finalHeapSize = defaultSshSize;
392392
}
393-
bool requireInternalHeap = IndirectHeap::INDIRECT_OBJECT == heapType ? true : false;
393+
bool requireInternalHeap = IndirectHeap::INDIRECT_OBJECT == heapType ? canUse4GbHeaps : false;
394394

395395
if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {
396396
requireInternalHeap = false;

shared/source/command_stream/command_stream_receiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class CommandStreamReceiver {
184184
bool peekTimestampPacketWriteEnabled() const { return timestampPacketWriteEnabled; }
185185

186186
size_t defaultSshSize;
187+
bool canUse4GbHeaps = true;
187188

188189
AllocationsList &getTemporaryAllocations();
189190
AllocationsList &getAllocationsForReuse();

shared/source/command_stream/command_stream_receiver_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
145145
void addPipeControlCmd(LinearStream &commandStream, PipeControlArgs &args);
146146
void addPipeControlBeforeStateBaseAddress(LinearStream &commandStream);
147147
size_t getSshHeapSize();
148+
bool are4GbHeapsAvailable() const;
148149

149150
uint64_t getScratchPatchAddress();
150151
void createScratchSpaceController();

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw(ExecutionEnvironment
5252
resetKmdNotifyHelper(new KmdNotifyHelper(&peekHwInfo().capabilityTable.kmdNotifyProperties));
5353
flatBatchBufferHelper.reset(new FlatBatchBufferHelperHw<GfxFamily>(executionEnvironment));
5454
defaultSshSize = getSshHeapSize();
55+
canUse4GbHeaps = are4GbHeapsAvailable();
5556

5657
timestampPacketWriteEnabled = hwHelper.timestampPacketWriteSupported();
5758
if (DebugManager.flags.EnableTimestampPacket.get() != -1) {

shared/source/command_stream/command_stream_receiver_hw_bdw_plus.inl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -14,6 +14,9 @@ size_t CommandStreamReceiverHw<GfxFamily>::getSshHeapSize() {
1414
return defaultHeapSize;
1515
}
1616

17+
template <typename GfxFamily>
18+
bool CommandStreamReceiverHw<GfxFamily>::are4GbHeapsAvailable() const { return true; }
19+
1720
template <typename GfxFamily>
1821
inline void CommandStreamReceiverHw<GfxFamily>::programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config) {
1922
typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;

0 commit comments

Comments
 (0)