Skip to content

Commit c24bbac

Browse files
Refactor scratch offset programming.
- no need for virtual functions and helpers, this is just a constant that is the same everywhere. Change-Id: Id0ebfd2eed26e26f90f104ec456dcc997be70211 Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
1 parent 84d1461 commit c24bbac

File tree

6 files changed

+19
-26
lines changed

6 files changed

+19
-26
lines changed

runtime/command_stream/scratch_space_controller.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class InternalAllocationStorage;
2020
class MemoryManager;
2121
struct HardwareInfo;
2222

23+
namespace ScratchSpaceConstants {
24+
constexpr size_t scratchSpaceOffsetFor64Bit = 4096u;
25+
}
26+
2327
class ScratchSpaceController {
2428
public:
2529
ScratchSpaceController(ExecutionEnvironment &environment, InternalAllocationStorage &allocationStorage);

runtime/command_stream/scratch_space_controller_base.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ void ScratchSpaceControllerBase::createScratchSpaceAllocation() {
5252
uint64_t ScratchSpaceControllerBase::calculateNewGSH() {
5353
uint64_t gsh = 0;
5454
if (scratchAllocation) {
55-
auto &hwHelper = HwHelper::get(executionEnvironment.getHardwareInfo()->platform.eRenderCoreFamily);
56-
auto scratchSpaceOffsetFor64bit = hwHelper.getScratchSpaceOffsetFor64bit();
57-
gsh = scratchAllocation->getGpuAddress() - scratchSpaceOffsetFor64bit;
55+
gsh = scratchAllocation->getGpuAddress() - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit;
5856
}
5957
return gsh;
6058
}
@@ -66,10 +64,8 @@ uint64_t ScratchSpaceControllerBase::getScratchPatchAddress() {
6664
if (scratchAllocation) {
6765
scratchAddress = scratchAllocation->getGpuAddressToPatch();
6866
if (is64bit && !getMemoryManager()->peekForce32BitAllocations()) {
69-
auto &hwHelper = HwHelper::get(executionEnvironment.getHardwareInfo()->platform.eRenderCoreFamily);
70-
auto scratchSpaceOffsetFor64bit = hwHelper.getScratchSpaceOffsetFor64bit();
7167
//this is to avoid scractch allocation offset "0"
72-
scratchAddress = scratchSpaceOffsetFor64bit;
68+
scratchAddress = ScratchSpaceConstants::scratchSpaceOffsetFor64Bit;
7369
}
7470
}
7571
return scratchAddress;

runtime/helpers/hw_helper.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class HwHelper {
6060
cl_mem_flags flags,
6161
uint32_t surfaceType,
6262
bool forceNonAuxMode) = 0;
63-
virtual size_t getScratchSpaceOffsetFor64bit() = 0;
6463
virtual const std::vector<aub_stream::EngineType> getGpgpuEngineInstances() const = 0;
6564
virtual bool getEnableLocalMemory(const HardwareInfo &hwInfo) const = 0;
6665
virtual std::string getExtensions() const = 0;
@@ -151,8 +150,6 @@ class HwHelperHw : public HwHelper {
151150
uint32_t surfaceType,
152151
bool forceNonAuxMode) override;
153152

154-
size_t getScratchSpaceOffsetFor64bit() override;
155-
156153
const std::vector<aub_stream::EngineType> getGpgpuEngineInstances() const override;
157154

158155
bool getEnableLocalMemory(const HardwareInfo &hwInfo) const override;

runtime/helpers/hw_helper_base.inl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ void HwHelperHw<Family>::setRenderSurfaceStateForBuffer(ExecutionEnvironment &ex
132132
}
133133
}
134134

135-
template <typename Family>
136-
size_t HwHelperHw<Family>::getScratchSpaceOffsetFor64bit() {
137-
return 4096;
138-
}
139-
140135
template <typename Family>
141136
bool HwHelperHw<Family>::getEnableLocalMemory(const HardwareInfo &hwInfo) const {
142137
if (DebugManager.flags.EnableLocalMemory.get() != -1) {

unit_tests/command_queue/enqueue_kernel_2_tests.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
9+
#include "runtime/command_stream/scratch_space_controller.h"
910
#include "runtime/helpers/hw_helper.h"
1011
#include "runtime/memory_manager/allocations_list.h"
1112
#include "unit_tests/command_queue/enqueue_fixture.h"
@@ -344,8 +345,8 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
344345
EXPECT_NE(0u, cmd->getScratchSpaceBasePointer());
345346
EXPECT_EQ(0u, GSHaddress);
346347
} else {
347-
EXPECT_EQ(HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), cmd->getScratchSpaceBasePointer());
348-
EXPECT_EQ(GSHaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), graphicsAllocation->getGpuAddress());
348+
EXPECT_EQ(ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, cmd->getScratchSpaceBasePointer());
349+
EXPECT_EQ(GSHaddress + ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, graphicsAllocation->getGpuAddress());
349350
}
350351

351352
auto allocationSize = scratchSize * pDevice->getDeviceInfo().computeUnitsUsedForScratch;
@@ -397,7 +398,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
397398
auto *sba2 = (STATE_BASE_ADDRESS *)*itorCmdForStateBase;
398399
auto GSHaddress2 = sba2->getGeneralStateBaseAddress();
399400
EXPECT_NE(0u, GSHaddress2);
400-
EXPECT_EQ(HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), cmd2->getScratchSpaceBasePointer());
401+
EXPECT_EQ(ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, cmd2->getScratchSpaceBasePointer());
401402
EXPECT_NE(GSHaddress2, GSHaddress);
402403
}
403404
EXPECT_EQ(graphicsAllocation->getUnderlyingBufferSize(), allocationSize);
@@ -418,7 +419,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
418419
if (is32bit) {
419420
EXPECT_EQ(0u, GSBaddress);
420421
} else if (is64bit) {
421-
EXPECT_EQ(graphicsAllocation2->getGpuAddress(), GSBaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit());
422+
EXPECT_EQ(graphicsAllocation2->getGpuAddress(), GSBaddress + ScratchSpaceConstants::scratchSpaceOffsetFor64Bit);
422423
}
423424

424425
EXPECT_TRUE(csr.getAllocationsForReuse().peekIsEmpty());

unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
595595
EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation());
596596
EXPECT_EQ(GmmHelper::decanonize(graphicsAllocationScratch->getGpuAddress()) - GSHaddress, graphicsAddress);
597597
} else if (!deviceInfo.svmCapabilities && is64bit) {
598-
EXPECT_EQ(HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), mediaVfeState->getScratchSpaceBasePointer());
599-
EXPECT_EQ(GSHaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), graphicsAllocationScratch->getGpuAddressToPatch());
598+
EXPECT_EQ(ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, mediaVfeState->getScratchSpaceBasePointer());
599+
EXPECT_EQ(GSHaddress + ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, graphicsAllocationScratch->getGpuAddressToPatch());
600600
} else {
601601
EXPECT_EQ((uint64_t)graphicsAllocationScratch->getUnderlyingBuffer(), graphicsAddress);
602602
}
@@ -608,7 +608,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
608608
uint64_t scratchBaseHighPart = (uint64_t)mediaVfeState->getScratchSpaceBasePointerHigh();
609609

610610
if (is64bit && !deviceInfo.force32BitAddressess) {
611-
uint64_t expectedAddress = HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit();
611+
uint64_t expectedAddress = ScratchSpaceConstants::scratchSpaceOffsetFor64Bit;
612612
EXPECT_EQ(expectedAddress, scratchBaseLowPart);
613613
EXPECT_EQ(0u, scratchBaseHighPart);
614614
} else {
@@ -620,7 +620,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
620620
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(), GSHaddress);
621621
} else {
622622
if (is64bit) {
623-
EXPECT_EQ(graphicsAddress - HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), GSHaddress);
623+
EXPECT_EQ(graphicsAddress - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, GSHaddress);
624624
} else {
625625
EXPECT_EQ(0u, GSHaddress);
626626
}
@@ -709,8 +709,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
709709
EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation());
710710
EXPECT_EQ(GmmHelper::decanonize(graphicsAllocationScratch->getGpuAddress()) - GSHaddress, graphicsAddress);
711711
} else if (!deviceInfo.svmCapabilities && is64bit) {
712-
EXPECT_EQ(HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), mediaVfeState->getScratchSpaceBasePointer());
713-
EXPECT_EQ(GSHaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), graphicsAllocationScratch->getGpuAddressToPatch());
712+
EXPECT_EQ(ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, mediaVfeState->getScratchSpaceBasePointer());
713+
EXPECT_EQ(GSHaddress + ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, graphicsAllocationScratch->getGpuAddressToPatch());
714714
} else {
715715
EXPECT_EQ((uint64_t)graphicsAllocationScratch->getUnderlyingBuffer(), graphicsAddress);
716716
}
@@ -722,7 +722,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
722722
uint64_t scratchBaseHighPart = (uint64_t)mediaVfeState->getScratchSpaceBasePointerHigh();
723723

724724
if (is64bit && !deviceInfo.force32BitAddressess) {
725-
lowPartGraphicsAddress = HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit();
725+
lowPartGraphicsAddress = ScratchSpaceConstants::scratchSpaceOffsetFor64Bit;
726726
highPartGraphicsAddress = 0u;
727727
}
728728

@@ -733,7 +733,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
733733
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(), GSHaddress);
734734
} else {
735735
if (is64bit) {
736-
EXPECT_EQ(graphicsAddress - HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), GSHaddress);
736+
EXPECT_EQ(graphicsAddress - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, GSHaddress);
737737
} else {
738738
EXPECT_EQ(0u, GSHaddress);
739739
}

0 commit comments

Comments
 (0)