TSP: Move packetsUsed member out of GraphicsAllocation

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-07-22 15:27:05 +00:00
committed by Compute-Runtime-Automation
parent f22251f68a
commit 31250b343f
8 changed files with 24 additions and 45 deletions

View File

@@ -92,8 +92,19 @@ struct Event : _ze_event_handle_t {
bool isTimestampEvent = false;
};
template <typename TagSizeT>
class KernelTimestampsData : public NEO::TimestampPackets<TagSizeT> {
public:
uint32_t getPacketsUsed() const { return packetsUsed; }
void setPacketsUsed(uint32_t value) { packetsUsed = value; }
protected:
uint32_t packetsUsed = 1;
};
template <typename TagSizeT>
struct EventImp : public Event {
EventImp(EventPool *eventPool, int index, Device *device)
: device(device), index(index), eventPool(eventPool) {}
@@ -124,7 +135,7 @@ struct EventImp : public Event {
size_t getGlobalEndOffset() const override { return NEO::TimestampPackets<TagSizeT>::getGlobalEndOffset(); }
size_t getSinglePacketSize() const override { return NEO::TimestampPackets<TagSizeT>::getSinglePacketSize(); };
std::unique_ptr<NEO::TimestampPackets<TagSizeT>[]> kernelTimestampsData;
std::unique_ptr<KernelTimestampsData<TagSizeT>[]> kernelTimestampsData;
Device *device;
int index;

View File

@@ -15,7 +15,7 @@ Event *Event::create(EventPool *eventPool, const ze_event_desc_t *desc, Device *
if (eventPool->isEventPoolTimestampFlagSet()) {
event->setEventTimestampFlag(true);
event->kernelTimestampsData = std::make_unique<NEO::TimestampPackets<TagSizeT>[]>(EventPacketsCount::maxKernelSplit);
event->kernelTimestampsData = std::make_unique<KernelTimestampsData<TagSizeT>[]>(EventPacketsCount::maxKernelSplit);
}
auto alloc = eventPool->getAllocation().getGraphicsAllocation(device->getNEODevice()->getRootDeviceIndex());

View File

@@ -48,10 +48,10 @@ HWTEST_F(TimestampPacketTests, givenTagNodeWithPacketsUsed2WhenSemaphoreIsProgra
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
TimestampPackets<uint32_t> tag;
tag.setPacketsUsed(2);
MockTagNode mockNode;
mockNode.tagForCpuAccess = &tag;
mockNode.gpuAddress = 0x1230000;
mockNode.setPacketsUsed(2);
auto &cmdStream = mockCmdQ->getCS(0);
TimestampPacketHelper::programSemaphore<FamilyType>(cmdStream, mockNode);
@@ -59,7 +59,7 @@ HWTEST_F(TimestampPacketTests, givenTagNodeWithPacketsUsed2WhenSemaphoreIsProgra
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(cmdStream, 0);
auto it = hwParser.cmdList.begin();
for (uint32_t packetId = 0; packetId < tag.getPacketsUsed(); packetId++) {
for (uint32_t packetId = 0; packetId < mockNode.getPacketsUsed(); packetId++) {
verifySemaphore(genCmdCast<MI_SEMAPHORE_WAIT *>(*it++), &mockNode, packetId);
}
}
@@ -137,7 +137,7 @@ TEST_F(TimestampPacketSimpleTests, whenNewTagIsTakenThenReinitialize) {
EXPECT_EQ(1u, packet.contextEnd);
EXPECT_EQ(1u, packet.globalEnd);
}
EXPECT_EQ(1u, firstNode->tagForCpuAccess->getPacketsUsed());
EXPECT_EQ(1u, firstNode->getPacketsUsed());
}
TEST_F(TimestampPacketSimpleTests, whenObjectIsCreatedThenInitializeAllStamps) {
@@ -150,7 +150,6 @@ TEST_F(TimestampPacketSimpleTests, whenObjectIsCreatedThenInitializeAllStamps) {
EXPECT_EQ(1u, packet.contextEnd);
EXPECT_EQ(1u, packet.globalEnd);
}
EXPECT_EQ(1u, timestampPacketStorage.getPacketsUsed());
}
HWTEST_F(TimestampPacketTests, givenCommandStreamReceiverHwWhenObtainingPreferredTagPoolSizeThenReturnCorrectValue) {
@@ -421,7 +420,7 @@ HWTEST_F(TimestampPacketTests, whenEstimatingSizeForNodeDependencyThenReturnCorr
size_t sizeForNodeDependency = 0;
sizeForNodeDependency += TimestampPacketHelper::getRequiredCmdStreamSizeForNodeDependency<FamilyType>(mockNode);
size_t expectedSize = mockNode.tagForCpuAccess->getPacketsUsed() * sizeof(typename FamilyType::MI_SEMAPHORE_WAIT);
size_t expectedSize = mockNode.getPacketsUsed() * sizeof(typename FamilyType::MI_SEMAPHORE_WAIT);
EXPECT_EQ(expectedSize, sizeForNodeDependency);
}

View File

@@ -1142,9 +1142,9 @@ struct ProfilingTimestampPacketsTest : public ::testing::Test {
void addTimestampNodeMultiOsContext(uint32_t globalStart[16], uint32_t globalEnd[16], uint32_t contextStart[16], uint32_t contextEnd[16], uint32_t size) {
auto node = new MockTagNode<TimestampPackets<uint32_t>>();
auto timestampPacketStorage = new TimestampPackets<uint32_t>();
timestampPacketStorage->setPacketsUsed(size);
node->setPacketsUsed(size);
for (uint32_t i = 0u; i < timestampPacketStorage->getPacketsUsed(); ++i) {
for (uint32_t i = 0u; i < node->getPacketsUsed(); ++i) {
uint32_t values[4] = {contextStart[i], globalStart[i], contextEnd[i], globalEnd[i]};
timestampPacketStorage->assignDataToAllTimestamps(i, values);

View File

@@ -25,7 +25,6 @@ struct TagAllocatorTest : public Test<MemoryAllocatorFixture> {
class MockTimestampPackets32 : public TimestampPackets<uint32_t> {
public:
void setTagToReadyState() {
auto packetsUsed = getPacketsUsed();
initialize();
uint32_t zeros[4] = {};
@@ -33,7 +32,6 @@ struct TagAllocatorTest : public Test<MemoryAllocatorFixture> {
for (uint32_t i = 0; i < TimestampPacketSizeControl::preferredPacketCount; i++) {
assignDataToAllTimestamps(i, zeros);
}
setPacketsUsed(packetsUsed);
}
void setToNonReadyState() {
@@ -553,8 +551,6 @@ TEST_F(TagAllocatorTest, givenNotSupportedTagTypeWhenCallingMethodThenAbortOrRet
EXPECT_ANY_THROW(perfCounterNode.getGlobalEndValue(0));
EXPECT_ANY_THROW(perfCounterNode.getContextCompleteRef());
EXPECT_ANY_THROW(perfCounterNode.getGlobalEndRef());
EXPECT_ANY_THROW(perfCounterNode.setPacketsUsed(0));
EXPECT_ANY_THROW(perfCounterNode.getPacketsUsed());
EXPECT_ANY_THROW(perfCounterNode.getSinglePacketSize());
EXPECT_ANY_THROW(perfCounterNode.assignDataToAllTimestamps(0, nullptr));
}
@@ -566,8 +562,6 @@ TEST_F(TagAllocatorTest, givenNotSupportedTagTypeWhenCallingMethodThenAbortOrRet
EXPECT_ANY_THROW(hwTimestampNode.getContextStartOffset());
EXPECT_ANY_THROW(hwTimestampNode.getContextEndOffset());
EXPECT_ANY_THROW(hwTimestampNode.getGlobalEndOffset());
EXPECT_ANY_THROW(hwTimestampNode.setPacketsUsed(0));
EXPECT_ANY_THROW(hwTimestampNode.getPacketsUsed());
EXPECT_ANY_THROW(hwTimestampNode.getSinglePacketSize());
EXPECT_ANY_THROW(hwTimestampNode.assignDataToAllTimestamps(0, nullptr));
EXPECT_ANY_THROW(hwTimestampNode.getQueryHandleRef());

View File

@@ -55,7 +55,6 @@ class TimestampPackets : public TagTypeBase {
packet.contextEnd = 1u;
packet.globalEnd = 1u;
}
packetsUsed = 1;
}
void assignDataToAllTimestamps(uint32_t packetIndex, void *source) {
@@ -72,16 +71,12 @@ class TimestampPackets : public TagTypeBase {
uint64_t getContextEndValue(uint32_t packetIndex) const { return static_cast<uint64_t>(packets[packetIndex].contextEnd); }
uint64_t getGlobalEndValue(uint32_t packetIndex) const { return static_cast<uint64_t>(packets[packetIndex].globalEnd); }
void setPacketsUsed(uint32_t used) { packetsUsed = used; }
uint32_t getPacketsUsed() const { return packetsUsed; }
protected:
Packet packets[TimestampPacketSizeControl::preferredPacketCount];
uint32_t packetsUsed = 1;
};
#pragma pack()
static_assert(((4 * TimestampPacketSizeControl::preferredPacketCount + 1) * sizeof(uint32_t)) == sizeof(TimestampPackets<uint32_t>),
static_assert(((4 * TimestampPacketSizeControl::preferredPacketCount) * sizeof(uint32_t)) == sizeof(TimestampPackets<uint32_t>),
"This structure is consumed by GPU and has to follow specific restrictions for padding and size");
class TimestampPacketContainer : public NonCopyableClass {

View File

@@ -72,8 +72,8 @@ class TagNodeBase : public NonCopyableOrMovableClass {
virtual uint64_t &getGlobalEndRef() const = 0;
virtual uint64_t &getContextCompleteRef() const = 0;
virtual void setPacketsUsed(uint32_t used) = 0;
virtual uint32_t getPacketsUsed() const = 0;
void setPacketsUsed(uint32_t used) { packetsUsed = used; };
uint32_t getPacketsUsed() const { return packetsUsed; };
virtual size_t getSinglePacketSize() const = 0;
@@ -87,6 +87,7 @@ class TagNodeBase : public NonCopyableOrMovableClass {
MultiGraphicsAllocation *gfxAllocation = nullptr;
uint64_t gpuAddress = 0;
std::atomic<uint32_t> refCount{0};
uint32_t packetsUsed = 1;
bool doNotReleaseNodes = false;
bool profilingCapable = true;
@@ -104,6 +105,7 @@ class TagNode : public TagNodeBase, public IDNode<TagNode<TagType>> {
void initialize() override {
tagForCpuAccess->initialize();
packetsUsed = 1;
setProfilingCapable(true);
}
@@ -124,9 +126,6 @@ class TagNode : public TagNodeBase, public IDNode<TagNode<TagType>> {
uint64_t &getGlobalEndRef() const override;
uint64_t &getContextCompleteRef() const override;
void setPacketsUsed(uint32_t used) override;
uint32_t getPacketsUsed() const override;
size_t getSinglePacketSize() const override;
MetricsLibraryApi::QueryHandle_1_0 &getQueryHandleRef() const override;

View File

@@ -222,25 +222,6 @@ uint64_t &TagNode<TagType>::getGlobalEndRef() const {
}
}
template <typename TagType>
void TagNode<TagType>::setPacketsUsed(uint32_t used) {
if constexpr (TagType::getTagNodeType() == TagNodeType::TimestampPacket) {
return tagForCpuAccess->setPacketsUsed(used);
} else {
UNUSED_VARIABLE(used);
UNRECOVERABLE_IF(true);
}
}
template <typename TagType>
uint32_t TagNode<TagType>::getPacketsUsed() const {
if constexpr (TagType::getTagNodeType() == TagNodeType::TimestampPacket) {
return tagForCpuAccess->getPacketsUsed();
} else {
UNRECOVERABLE_IF(true);
}
}
template <typename TagType>
size_t TagNode<TagType>::getSinglePacketSize() const {
if constexpr (TagType::getTagNodeType() == TagNodeType::TimestampPacket) {