refactor: move tag initialization to allocator [1/n]
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
parent
2062c13704
commit
b1dea19fbd
|
@ -39,7 +39,7 @@ NEO::TagAllocatorBase *getInOrderCounterAllocator(std::unique_ptr<NEO::TagAlloca
|
|||
DEBUG_BREAK_IF(alignUp(nodeSize, MemoryConstants::cacheLineSize) * NodeT::defaultAllocatorTagCount > MemoryConstants::pageSize64k);
|
||||
|
||||
allocator = std::make_unique<NEO::TagAllocator<NodeT>>(rootDeviceIndices, neoDevice.getMemoryManager(), NodeT::defaultAllocatorTagCount,
|
||||
MemoryConstants::cacheLineSize, nodeSize, false, false, neoDevice.getDeviceBitfield());
|
||||
MemoryConstants::cacheLineSize, nodeSize, 0, false, false, neoDevice.getDeviceBitfield());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ std::unique_ptr<NEO::TagAllocatorBase> L0GfxCoreHelperHw<Family>::getInOrderTime
|
|||
|
||||
size_t size = sizeof(TimestampPacketsT) * packetsCountPerElement;
|
||||
|
||||
return std::make_unique<NEO::TagAllocator<TimestampPacketsT>>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, size, false, false, deviceBitfield);
|
||||
return std::make_unique<NEO::TagAllocator<TimestampPacketsT>>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, size, 0, false, false, deviceBitfield);
|
||||
}
|
||||
|
||||
template <typename Family>
|
||||
|
|
|
@ -960,7 +960,7 @@ TagAllocatorBase *CommandStreamReceiver::getEventTsAllocator() {
|
|||
if (profilingTimeStampAllocator.get() == nullptr) {
|
||||
RootDeviceIndicesContainer rootDeviceIndices = {rootDeviceIndex};
|
||||
profilingTimeStampAllocator = std::make_unique<TagAllocator<HwTimeStamps>>(rootDeviceIndices, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize,
|
||||
sizeof(HwTimeStamps), false, true, osContext->getDeviceBitfield());
|
||||
sizeof(HwTimeStamps), 0, false, true, osContext->getDeviceBitfield());
|
||||
}
|
||||
return profilingTimeStampAllocator.get();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ TagAllocatorBase *CommandStreamReceiver::getEventPerfCountAllocator(const uint32
|
|||
if (perfCounterAllocator.get() == nullptr) {
|
||||
RootDeviceIndicesContainer rootDeviceIndices = {rootDeviceIndex};
|
||||
perfCounterAllocator = std::make_unique<TagAllocator<HwPerfCounter>>(
|
||||
rootDeviceIndices, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, tagSize, false, true, osContext->getDeviceBitfield());
|
||||
rootDeviceIndices, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, tagSize, 0, false, true, osContext->getDeviceBitfield());
|
||||
}
|
||||
return perfCounterAllocator.get();
|
||||
}
|
||||
|
|
|
@ -446,10 +446,12 @@ std::unique_ptr<TagAllocatorBase> GfxCoreHelperHw<GfxFamily>::createTimestampPac
|
|||
if (debugManager.flags.OverrideTimestampPacketSize.get() != -1) {
|
||||
if (debugManager.flags.OverrideTimestampPacketSize.get() == 4) {
|
||||
using TimestampPackets32T = TimestampPackets<uint32_t, GfxFamily::timestampPacketCount>;
|
||||
return std::make_unique<TagAllocator<TimestampPackets32T>>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPackets32T), doNotReleaseNodes, true, deviceBitfield);
|
||||
return std::make_unique<TagAllocator<TimestampPackets32T>>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPackets32T), NEO::TimestampPacketConstants::initValue,
|
||||
doNotReleaseNodes, true, deviceBitfield);
|
||||
} else if (debugManager.flags.OverrideTimestampPacketSize.get() == 8) {
|
||||
using TimestampPackets64T = TimestampPackets<uint64_t, GfxFamily::timestampPacketCount>;
|
||||
return std::make_unique<TagAllocator<TimestampPackets64T>>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPackets64T), doNotReleaseNodes, true, deviceBitfield);
|
||||
return std::make_unique<TagAllocator<TimestampPackets64T>>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPackets64T), NEO::TimestampPacketConstants::initValue,
|
||||
doNotReleaseNodes, true, deviceBitfield);
|
||||
} else {
|
||||
UNRECOVERABLE_IF(true);
|
||||
}
|
||||
|
@ -458,7 +460,8 @@ std::unique_ptr<TagAllocatorBase> GfxCoreHelperHw<GfxFamily>::createTimestampPac
|
|||
using TimestampPacketType = typename GfxFamily::TimestampPacketType;
|
||||
using TimestampPacketsT = TimestampPackets<TimestampPacketType, GfxFamily::timestampPacketCount>;
|
||||
|
||||
return std::make_unique<TagAllocator<TimestampPacketsT>>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPacketsT), doNotReleaseNodes, true, deviceBitfield);
|
||||
return std::make_unique<TagAllocator<TimestampPacketsT>>(rootDeviceIndices, memoryManager, initialTagCount, tagAlignment, sizeof(TimestampPacketsT), NEO::TimestampPacketConstants::initValue,
|
||||
doNotReleaseNodes, true, deviceBitfield);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
|
|
@ -26,6 +26,8 @@ class TagNodeBase;
|
|||
template <bool deviceAlloc>
|
||||
class DeviceAllocNodeType {
|
||||
public:
|
||||
using ValueT = uint64_t;
|
||||
|
||||
static constexpr size_t defaultAllocatorTagCount = 128;
|
||||
|
||||
static constexpr AllocationType getAllocationType() { return deviceAlloc ? AllocationType::timestampPacketTagBuffer : NEO::AllocationType::bufferHostMemory; }
|
||||
|
@ -34,7 +36,7 @@ class DeviceAllocNodeType {
|
|||
|
||||
static constexpr size_t getSinglePacketSize() { return sizeof(uint64_t); }
|
||||
|
||||
void initialize() { data = 0; }
|
||||
void initialize(uint64_t initValue) { data = initValue; }
|
||||
|
||||
protected:
|
||||
uint64_t data = {};
|
||||
|
|
|
@ -29,6 +29,8 @@ class LinearStream;
|
|||
template <typename TSize, uint32_t packetCount>
|
||||
class TimestampPackets : public TagTypeBase {
|
||||
public:
|
||||
using ValueT = TSize;
|
||||
|
||||
static constexpr AllocationType getAllocationType() {
|
||||
return AllocationType::timestampPacketTagBuffer;
|
||||
}
|
||||
|
@ -37,12 +39,12 @@ class TimestampPackets : public TagTypeBase {
|
|||
|
||||
static constexpr size_t getSinglePacketSize() { return sizeof(Packet); }
|
||||
|
||||
void initialize() {
|
||||
void initialize(TSize initValue) {
|
||||
for (auto &packet : packets) {
|
||||
packet.contextStart = TimestampPacketConstants::initValue;
|
||||
packet.globalStart = TimestampPacketConstants::initValue;
|
||||
packet.contextEnd = TimestampPacketConstants::initValue;
|
||||
packet.globalEnd = TimestampPacketConstants::initValue;
|
||||
packet.contextStart = initValue;
|
||||
packet.globalStart = initValue;
|
||||
packet.contextEnd = initValue;
|
||||
packet.globalEnd = initValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -14,13 +14,15 @@ namespace NEO {
|
|||
|
||||
class HwTimeStamps : public TagTypeBase {
|
||||
public:
|
||||
void initialize() {
|
||||
globalStartTS = 0;
|
||||
contextStartTS = 0;
|
||||
globalEndTS = 0;
|
||||
contextEndTS = 0;
|
||||
globalCompleteTS = 0;
|
||||
contextCompleteTS = 0;
|
||||
using ValueT = uint64_t;
|
||||
|
||||
void initialize(uint64_t initValue) {
|
||||
globalStartTS = initValue;
|
||||
contextStartTS = initValue;
|
||||
globalEndTS = initValue;
|
||||
contextEndTS = initValue;
|
||||
globalCompleteTS = initValue;
|
||||
contextCompleteTS = initValue;
|
||||
}
|
||||
|
||||
static constexpr AllocationType getAllocationType() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -14,9 +14,11 @@ namespace NEO {
|
|||
|
||||
class HwPerfCounter : public TagTypeBase {
|
||||
public:
|
||||
void initialize() {
|
||||
using ValueT = uint8_t;
|
||||
|
||||
void initialize(uint8_t initValue) {
|
||||
query = {};
|
||||
report[0] = 0;
|
||||
report[0] = initValue;
|
||||
}
|
||||
|
||||
static constexpr AllocationType getAllocationType() {
|
||||
|
|
|
@ -104,10 +104,11 @@ class TagNode : public TagNodeBase, public IDNode<TagNode<TagType>> {
|
|||
"This structure is consumed by GPU and has to follow specific restrictions for padding and size");
|
||||
|
||||
public:
|
||||
using ValueT = typename TagType::ValueT;
|
||||
TagType *tagForCpuAccess;
|
||||
|
||||
void initialize() override {
|
||||
tagForCpuAccess->initialize();
|
||||
tagForCpuAccess->initialize(static_cast<TagAllocator<TagType> *>(allocator)->getInitialValue());
|
||||
packetsUsed = 1;
|
||||
setProfilingCapable(true);
|
||||
}
|
||||
|
@ -177,13 +178,15 @@ template <typename TagType>
|
|||
class TagAllocator : public TagAllocatorBase {
|
||||
public:
|
||||
using NodeType = TagNode<TagType>;
|
||||
using ValueT = typename TagType::ValueT;
|
||||
|
||||
TagAllocator(const RootDeviceIndicesContainer &rootDeviceIndices, MemoryManager *memMngr, size_t tagCount,
|
||||
size_t tagAlignment, size_t tagSize, bool doNotReleaseNodes, bool initializeTags, DeviceBitfield deviceBitfield);
|
||||
size_t tagAlignment, size_t tagSize, ValueT initialValue, bool doNotReleaseNodes, bool initializeTags, DeviceBitfield deviceBitfield);
|
||||
|
||||
TagNodeBase *getTag() override;
|
||||
|
||||
void returnTag(TagNodeBase *node) override;
|
||||
ValueT getInitialValue() const { return initialValue; }
|
||||
|
||||
protected:
|
||||
TagAllocator() = delete;
|
||||
|
@ -202,6 +205,7 @@ class TagAllocator : public TagAllocatorBase {
|
|||
|
||||
std::vector<std::unique_ptr<NodeType[]>> tagPoolMemory;
|
||||
|
||||
const ValueT initialValue;
|
||||
bool initializeTags = true;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
namespace NEO {
|
||||
template <typename TagType>
|
||||
TagAllocator<TagType>::TagAllocator(const RootDeviceIndicesContainer &rootDeviceIndices, MemoryManager *memMngr, size_t tagCount, size_t tagAlignment,
|
||||
size_t tagSize, bool doNotReleaseNodes, bool initializeTags, DeviceBitfield deviceBitfield)
|
||||
: TagAllocatorBase(rootDeviceIndices, memMngr, tagCount, tagAlignment, tagSize, doNotReleaseNodes, deviceBitfield), initializeTags(initializeTags) {
|
||||
size_t tagSize, ValueT initialValue, bool doNotReleaseNodes, bool initializeTags, DeviceBitfield deviceBitfield)
|
||||
: TagAllocatorBase(rootDeviceIndices, memMngr, tagCount, tagAlignment, tagSize, doNotReleaseNodes, deviceBitfield), initialValue(initialValue), initializeTags(initializeTags) {
|
||||
|
||||
populateFreeTags();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class MockTagAllocator : public TagAllocator<TagType> {
|
|||
|
||||
MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount,
|
||||
size_t tagAlignment, size_t tagSize, bool doNotReleaseNodes, DeviceBitfield deviceBitfield)
|
||||
: BaseClass(RootDeviceIndicesContainer({rootDeviceIndex}), memoryManager, tagCount, tagAlignment, tagSize, doNotReleaseNodes, true, deviceBitfield) {
|
||||
: BaseClass(RootDeviceIndicesContainer({rootDeviceIndex}), memoryManager, tagCount, tagAlignment, tagSize, NEO::TimestampPacketConstants::initValue, doNotReleaseNodes, true, deviceBitfield) {
|
||||
}
|
||||
|
||||
MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount = 10)
|
||||
|
@ -29,7 +29,7 @@ class MockTagAllocator : public TagAllocator<TagType> {
|
|||
}
|
||||
|
||||
MockTagAllocator(const RootDeviceIndicesContainer &rootDeviceIndices, MemoryManager *memoryManager, size_t tagCount = 10)
|
||||
: BaseClass(rootDeviceIndices, memoryManager, tagCount, MemoryConstants::cacheLineSize, sizeof(TagType), false, true, mockDeviceBitfield) {}
|
||||
: BaseClass(rootDeviceIndices, memoryManager, tagCount, MemoryConstants::cacheLineSize, sizeof(TagType), NEO::TimestampPacketConstants::initValue, false, true, mockDeviceBitfield) {}
|
||||
|
||||
void returnTag(TagNodeBase *node) override {
|
||||
releaseReferenceNodes.push_back(static_cast<NodeType *>(node));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -16,7 +16,7 @@ class MockTimestampPackets32 : public TimestampPackets<uint32_t, TimestampPacket
|
|||
using TimestampPackets<uint32_t, TimestampPacketConstants::preferredPacketCount>::packets;
|
||||
|
||||
void setTagToReadyState() {
|
||||
initialize();
|
||||
initialize(0);
|
||||
|
||||
uint32_t zeros[4] = {};
|
||||
|
||||
|
|
|
@ -36,7 +36,8 @@ struct TagAllocatorTest : public Test<MemoryAllocatorFixture> {
|
|||
};
|
||||
|
||||
struct TimeStamps {
|
||||
void initialize() {
|
||||
using ValueT = uint64_t;
|
||||
void initialize(uint64_t initValue) {
|
||||
initializeCount++;
|
||||
start = 1;
|
||||
end = 2;
|
||||
|
@ -94,7 +95,7 @@ class MockTagAllocator : public TagAllocator<TagType> {
|
|||
|
||||
MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount,
|
||||
size_t tagAlignment, size_t tagSize, bool doNotReleaseNodes, DeviceBitfield deviceBitfield)
|
||||
: BaseClass(RootDeviceIndicesContainer{rootDeviceIndex}, memoryManager, tagCount, tagAlignment, tagSize, doNotReleaseNodes, true, deviceBitfield) {
|
||||
: BaseClass(RootDeviceIndicesContainer{rootDeviceIndex}, memoryManager, tagCount, tagAlignment, tagSize, 0, doNotReleaseNodes, true, deviceBitfield) {
|
||||
}
|
||||
|
||||
MockTagAllocator(MemoryManager *memMngr, size_t tagCount, size_t tagAlignment, bool disableCompletionCheck, DeviceBitfield deviceBitfield)
|
||||
|
@ -357,8 +358,8 @@ TEST_F(TagAllocatorTest, whenNewTagIsTakenThenItIsInitialized) {
|
|||
}
|
||||
|
||||
TEST_F(TagAllocatorTest, givenReinitializationDisabledWhenGettingNewTagThenDontInitialize) {
|
||||
MockTagAllocator<TimeStamps> tagAllocator1(RootDeviceIndicesContainer{0}, memoryManager, 1, 2, sizeof(TimeStamps), false, true, deviceBitfield);
|
||||
MockTagAllocator<TimeStamps> tagAllocator2(RootDeviceIndicesContainer{0}, memoryManager, 1, 2, sizeof(TimeStamps), false, false, deviceBitfield);
|
||||
MockTagAllocator<TimeStamps> tagAllocator1(RootDeviceIndicesContainer{0}, memoryManager, 1, 2, sizeof(TimeStamps), 0, false, true, deviceBitfield);
|
||||
MockTagAllocator<TimeStamps> tagAllocator2(RootDeviceIndicesContainer{0}, memoryManager, 1, 2, sizeof(TimeStamps), 0, false, false, deviceBitfield);
|
||||
|
||||
tagAllocator1.freeTags.peekHead()->tagForCpuAccess->initializeCount = 0;
|
||||
tagAllocator2.freeTags.peekHead()->tagForCpuAccess->initializeCount = 0;
|
||||
|
@ -500,7 +501,7 @@ TEST_F(TagAllocatorTest, givenMultipleRootDevicesWhenPopulatingTagsThenCreateMul
|
|||
const RootDeviceIndicesContainer indices = {0, 2, maxRootDeviceIndex};
|
||||
|
||||
MockTagAllocator<TimestampPackets<uint32_t, TimestampPacketConstants::preferredPacketCount>> timestampPacketAllocator(indices, testMemoryManager, 1, 1,
|
||||
sizeof(TimestampPackets<uint32_t, TimestampPacketConstants::preferredPacketCount>), false,
|
||||
sizeof(TimestampPackets<uint32_t, TimestampPacketConstants::preferredPacketCount>), 0, false,
|
||||
true, mockDeviceBitfield);
|
||||
|
||||
EXPECT_EQ(1u, timestampPacketAllocator.getGraphicsAllocationsCount());
|
||||
|
@ -532,7 +533,7 @@ HWTEST_F(TagAllocatorTest, givenMultipleRootDevicesWhenCallingMakeResidentThenUs
|
|||
const RootDeviceIndicesContainer indicesVector = {0, 1};
|
||||
|
||||
MockTagAllocator<TimestampPackets<uint32_t, FamilyType::timestampPacketCount>> timestampPacketAllocator(indicesVector, testMemoryManager, 1, 1, sizeof(TimestampPackets<uint32_t, FamilyType::timestampPacketCount>),
|
||||
false, true, mockDeviceBitfield);
|
||||
0, false, true, mockDeviceBitfield);
|
||||
|
||||
EXPECT_EQ(1u, timestampPacketAllocator.getGraphicsAllocationsCount());
|
||||
|
||||
|
|
Loading…
Reference in New Issue