Skip to content

Commit 4816988

Browse files
Add helper function to check if fence allocation is required
Related-To: NEO-3216 Change-Id: I19d7142052a2191f7c7086ba06ca6f5930652a8c Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
1 parent 541e161 commit 4816988

File tree

7 files changed

+44
-10
lines changed

7 files changed

+44
-10
lines changed

core/helpers/hw_helper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class HwHelper {
4040
virtual SipKernelType getSipKernelType(bool debuggingActive) = 0;
4141
virtual bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) const = 0;
4242
virtual bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const = 0;
43+
virtual bool isFenceAllocationRequired(const HardwareInfo &hwInfo) const = 0;
4344
virtual const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const = 0;
4445
virtual bool hvAlign4Required() const = 0;
4546
virtual bool obtainRenderBufferCompressionPreference(const HardwareInfo &hwInfo, const size_t size) const = 0;
@@ -155,6 +156,8 @@ class HwHelperHw : public HwHelper {
155156

156157
bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const override;
157158

159+
bool isFenceAllocationRequired(const HardwareInfo &hwInfo) const override;
160+
158161
void setRenderSurfaceStateForBuffer(ExecutionEnvironment &executionEnvironment,
159162
void *surfaceStateBuffer,
160163
size_t bufferSize,

core/helpers/hw_helper_base.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ bool HwHelperHw<Family>::isPageTableManagerSupported(const HardwareInfo &hwInfo)
7777
return false;
7878
}
7979

80+
template <typename Family>
81+
bool HwHelperHw<Family>::isFenceAllocationRequired(const HardwareInfo &hwInfo) const {
82+
return false;
83+
}
84+
8085
template <typename GfxFamily>
8186
inline bool HwHelperHw<GfxFamily>::checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) {
8287
return true;

runtime/command_stream/command_stream_receiver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,11 @@ bool CommandStreamReceiver::initializeTagAllocation() {
385385
}
386386

387387
bool CommandStreamReceiver::createGlobalFenceAllocation() {
388-
if (!localMemoryEnabled) {
388+
auto hwInfo = executionEnvironment.getHardwareInfo();
389+
if (!HwHelper::get(hwInfo->platform.eRenderCoreFamily).isFenceAllocationRequired(*hwInfo)) {
389390
return true;
390391
}
392+
391393
DEBUG_BREAK_IF(this->globalFenceAllocation != nullptr);
392394
this->globalFenceAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::GLOBAL_FENCE});
393395
return this->globalFenceAllocation != nullptr;

unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
#include "test.h"
1818
#include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h"
1919
#include "unit_tests/helpers/dispatch_flags_helper.h"
20+
#include "unit_tests/helpers/raii_hw_helper.h"
2021
#include "unit_tests/helpers/unit_test_helper.h"
2122
#include "unit_tests/mocks/mock_allocation_properties.h"
2223
#include "unit_tests/mocks/mock_buffer.h"
2324
#include "unit_tests/mocks/mock_command_queue.h"
2425
#include "unit_tests/mocks/mock_csr.h"
2526
#include "unit_tests/mocks/mock_event.h"
27+
#include "unit_tests/mocks/mock_hw_helper.h"
2628
#include "unit_tests/mocks/mock_kernel.h"
2729
#include "unit_tests/mocks/mock_submissions_aggregator.h"
2830

@@ -444,9 +446,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, handleTagAndScratchAllocationsResi
444446
EXPECT_TRUE(commandStreamReceiver->isMadeNonResident(scratchAllocation));
445447
}
446448

447-
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenLocalMemoryIsEnabledAndFlushTaskIsCalledThenGlobalFenceAlocationIsMadeResident) {
448-
DebugManagerStateRestore dbgRestorer;
449-
DebugManager.flags.EnableLocalMemory.set(true);
449+
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCommandStreamReceiverWhenFenceAllocationIsRequiredAndFlushTaskIsCalledThenFenceAlocationIsMadeResident) {
450+
RAIIHwHelperFactory<MockHwHelperWithFenceAllocation<FamilyType>> hwHelperBackup{pDevice->getHardwareInfo().platform.eRenderCoreFamily};
450451

451452
auto commandStreamReceiver = new MockCsrHw<FamilyType>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
452453
pDevice->resetCommandStreamReceiver(commandStreamReceiver);

unit_tests/command_stream/command_stream_receiver_hw_tests.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
#include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h"
3636
#include "unit_tests/helpers/dispatch_flags_helper.h"
3737
#include "unit_tests/helpers/hw_parse.h"
38+
#include "unit_tests/helpers/raii_hw_helper.h"
3839
#include "unit_tests/helpers/unit_test_helper.h"
3940
#include "unit_tests/libult/ult_command_stream_receiver.h"
4041
#include "unit_tests/mocks/mock_buffer.h"
4142
#include "unit_tests/mocks/mock_command_queue.h"
4243
#include "unit_tests/mocks/mock_context.h"
4344
#include "unit_tests/mocks/mock_csr.h"
4445
#include "unit_tests/mocks/mock_event.h"
46+
#include "unit_tests/mocks/mock_hw_helper.h"
4547
#include "unit_tests/mocks/mock_internal_allocation_storage.h"
4648
#include "unit_tests/mocks/mock_kernel.h"
4749
#include "unit_tests/mocks/mock_memory_manager.h"
@@ -631,9 +633,8 @@ HWTEST_F(BcsTests, givenInputAllocationsWhenBlitDispatchedThenMakeAllAllocations
631633
EXPECT_EQ(5u, csr.makeResidentAllocations.size());
632634
}
633635

634-
HWTEST_F(BcsTests, givenLocalMemoryEnabledWhenBlitDispatchedThenMakeAllAllocationsResident) {
635-
DebugManagerStateRestore restore;
636-
DebugManager.flags.EnableLocalMemory.set(true);
636+
HWTEST_F(BcsTests, givenFenceAllocationIsRequiredWhenBlitDispatchedThenMakeAllAllocationsResident) {
637+
RAIIHwHelperFactory<MockHwHelperWithFenceAllocation<FamilyType>> hwHelperBackup{pDevice->getHardwareInfo().platform.eRenderCoreFamily};
637638

638639
auto bcsOsContext = std::unique_ptr<OsContext>(OsContext::create(nullptr, 0, 0, aub_stream::ENGINE_BCS, PreemptionMode::Disabled, false));
639640
auto bcsCsr = std::make_unique<UltCommandStreamReceiver<FamilyType>>(*pDevice->getExecutionEnvironment(), pDevice->getRootDeviceIndex());

unit_tests/command_stream/command_stream_receiver_tests.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
#include "unit_tests/fixtures/device_fixture.h"
2626
#include "unit_tests/fixtures/multi_root_device_fixture.h"
2727
#include "unit_tests/gen_common/matchers.h"
28+
#include "unit_tests/helpers/raii_hw_helper.h"
2829
#include "unit_tests/helpers/unit_test_helper.h"
2930
#include "unit_tests/mocks/mock_buffer.h"
3031
#include "unit_tests/mocks/mock_builtins.h"
3132
#include "unit_tests/mocks/mock_context.h"
3233
#include "unit_tests/mocks/mock_csr.h"
3334
#include "unit_tests/mocks/mock_execution_environment.h"
3435
#include "unit_tests/mocks/mock_graphics_allocation.h"
36+
#include "unit_tests/mocks/mock_hw_helper.h"
3537
#include "unit_tests/mocks/mock_memory_manager.h"
3638
#include "unit_tests/mocks/mock_program.h"
3739

@@ -363,9 +365,8 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTa
363365
EXPECT_EQ(*csr->getTagAddress(), initialHardwareTag);
364366
}
365367

366-
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenLocalMemoryIsEnabledAndCreateGlobalFenceAllocationIsCalledThenGlobalFenceAllocationIsAllocated) {
367-
DebugManagerStateRestore dbgRestore;
368-
DebugManager.flags.EnableLocalMemory.set(true);
368+
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenFenceAllocationIsRequiredAndCreateGlobalFenceAllocationIsCalledThenFenceAllocationIsAllocated) {
369+
RAIIHwHelperFactory<MockHwHelperWithFenceAllocation<FamilyType>> hwHelperBackup{pDevice->getHardwareInfo().platform.eRenderCoreFamily};
369370

370371
MockCsrHw<FamilyType> csr(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
371372
EXPECT_EQ(nullptr, csr.globalFenceAllocation);

unit_tests/mocks/mock_hw_helper.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2020 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include "core/helpers/hw_helper.h"
10+
#include "core/helpers/hw_info.h"
11+
12+
namespace NEO {
13+
14+
template <typename GfxFamily>
15+
class MockHwHelperWithFenceAllocation : public HwHelperHw<GfxFamily> {
16+
public:
17+
bool isFenceAllocationRequired(const HardwareInfo &hwInfo) const override {
18+
return true;
19+
}
20+
};
21+
} // namespace NEO

0 commit comments

Comments
 (0)