New method to return TimestampPacket alignment

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-04-01 10:15:17 +00:00
committed by Compute-Runtime-Automation
parent e93dc9c61a
commit da9d039dd6
5 changed files with 36 additions and 18 deletions

View File

@ -640,27 +640,13 @@ TEST_F(CommandStreamReceiverTest, whenGettingEventPerfCountAllocatorThenSameTagA
EXPECT_EQ(allocator2, allocator);
}
HWTEST_F(CommandStreamReceiverTest, givenTimestampPacketAllocatorWhenAskingForTagThenReturnValidObject) {
HWTEST_F(CommandStreamReceiverTest, givenCsrWhenAskingForTimestampPacketAlignmentThenReturnFourCachelines) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_EQ(nullptr, csr.timestampPacketAllocator.get());
auto allocator = static_cast<TagAllocator<TimestampPackets<uint32_t>> *>(csr.getTimestampPacketAllocator());
EXPECT_NE(nullptr, csr.timestampPacketAllocator.get());
EXPECT_EQ(allocator, csr.timestampPacketAllocator.get());
constexpr auto expectedAlignment = MemoryConstants::cacheLineSize * 4;
auto allocator2 = static_cast<TagAllocator<TimestampPackets<uint32_t>> *>(csr.getTimestampPacketAllocator());
EXPECT_EQ(allocator, allocator2);
auto node1 = allocator->getTag();
auto node2 = allocator->getTag();
EXPECT_NE(nullptr, node1);
EXPECT_NE(nullptr, node2);
EXPECT_NE(node1, node2);
constexpr auto tagAlignment = MemoryConstants::cacheLineSize * 4;
EXPECT_TRUE(isAligned(node1->getGpuAddress(), tagAlignment));
EXPECT_TRUE(isAligned(node2->getGpuAddress(), tagAlignment));
EXPECT_EQ(expectedAlignment, csr.getTimestampPacketAllocatorAlignment());
}
HWTEST_F(CommandStreamReceiverTest, givenUltCommandStreamReceiverWhenAddAubCommentIsCalledThenCallAddAubCommentOnCsr) {

View File

@ -358,6 +358,30 @@ HWTEST_F(TimestampPacketTests, givenCommandStreamReceiverHwWhenObtainingPreferre
EXPECT_EQ(2048u, csr.getPreferredTagPoolSize());
}
HWTEST_F(TimestampPacketTests, givenTagAlignmentWhenCreatingAllocatorThenGpuAddressIsAligned) {
class MyCsr : public CommandStreamReceiverHw<FamilyType> {
public:
using CommandStreamReceiverHw<FamilyType>::CommandStreamReceiverHw;
size_t getTimestampPacketAllocatorAlignment() const override {
return alignment;
}
size_t alignment = 4096;
};
OsContext &osContext = *executionEnvironment->memoryManager->getRegisteredEngines()[0].osContext;
MyCsr csr(*executionEnvironment, 0, osContext.getDeviceBitfield());
csr.setupContext(osContext);
auto allocator = csr.getTimestampPacketAllocator();
auto tag1 = allocator->getTag();
auto tag2 = allocator->getTag();
EXPECT_TRUE(isAligned(tag1->getGpuAddress(), csr.alignment));
EXPECT_TRUE(isAligned(tag2->getGpuAddress(), csr.alignment));
}
HWTEST_F(TimestampPacketTests, givenDebugFlagSetWhenCreatingTimestampPacketAllocatorThenDisableReusingAndLimitPoolSize) {
DebugManagerStateRestore restore;
DebugManager.flags.DisableTimestampPacketOptimizations.set(true);

View File

@ -37,6 +37,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
using BaseClass::getCmdSizeForPrologue;
using BaseClass::getScratchPatchAddress;
using BaseClass::getScratchSpaceController;
using BaseClass::getTimestampPacketAllocatorAlignment;
using BaseClass::indirectHeap;
using BaseClass::iohState;
using BaseClass::isBlitterDirectSubmissionEnabled;

View File

@ -155,6 +155,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
bool checkPlatformSupportsNewResourceImplicitFlush() const;
bool checkPlatformSupportsGpuIdleImplicitFlush() const;
MOCKABLE_VIRTUAL size_t getTimestampPacketAllocatorAlignment() const;
HeapDirtyState dshState;
HeapDirtyState iohState;
HeapDirtyState sshState;

View File

@ -1282,10 +1282,15 @@ TagAllocatorBase *CommandStreamReceiverHw<GfxFamily>::getTimestampPacketAllocato
using TimestampPacketsT = TimestampPackets<typename GfxFamily::TimestampPacketType>;
timestampPacketAllocator = std::make_unique<TagAllocator<TimestampPacketsT>>(
rootDeviceIndex, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize * 4,
rootDeviceIndex, getMemoryManager(), getPreferredTagPoolSize(), getTimestampPacketAllocatorAlignment(),
sizeof(TimestampPacketsT), doNotReleaseNodes, osContext->getDeviceBitfield());
}
return timestampPacketAllocator.get();
}
template <typename GfxFamily>
size_t CommandStreamReceiverHw<GfxFamily>::getTimestampPacketAllocatorAlignment() const {
return MemoryConstants::cacheLineSize * 4;
}
} // namespace NEO