2019-04-10 18:44:02 +08:00
|
|
|
/*
|
2024-07-22 23:46:14 +08:00
|
|
|
* Copyright (C) 2019-2024 Intel Corporation
|
2019-04-10 18:44:02 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/timestamp_packet.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
2020-06-03 18:31:33 +08:00
|
|
|
|
2019-04-10 18:44:02 +08:00
|
|
|
namespace NEO {
|
|
|
|
|
2023-09-25 15:45:36 +08:00
|
|
|
template <typename TagType = TimestampPackets<uint32_t, TimestampPacketConstants::preferredPacketCount>>
|
2019-04-10 18:44:02 +08:00
|
|
|
class MockTagAllocator : public TagAllocator<TagType> {
|
|
|
|
public:
|
|
|
|
using BaseClass = TagAllocator<TagType>;
|
|
|
|
using BaseClass::freeTags;
|
|
|
|
using BaseClass::usedTags;
|
|
|
|
using NodeType = typename BaseClass::NodeType;
|
|
|
|
|
2021-05-13 02:48:41 +08:00
|
|
|
MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount,
|
|
|
|
size_t tagAlignment, size_t tagSize, bool doNotReleaseNodes, DeviceBitfield deviceBitfield)
|
2024-12-16 19:01:27 +08:00
|
|
|
: BaseClass(RootDeviceIndicesContainer({rootDeviceIndex}), memoryManager, tagCount, tagAlignment, tagSize, NEO::TimestampPacketConstants::initValue, doNotReleaseNodes, true, deviceBitfield) {
|
2021-05-13 02:48:41 +08:00
|
|
|
}
|
|
|
|
|
2019-12-02 15:37:42 +08:00
|
|
|
MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount = 10)
|
2021-05-13 02:48:41 +08:00
|
|
|
: MockTagAllocator(rootDeviceIndex, memoryManager, tagCount, MemoryConstants::cacheLineSize, sizeof(TagType), false, mockDeviceBitfield) {
|
|
|
|
}
|
|
|
|
|
2022-04-07 21:09:40 +08:00
|
|
|
MockTagAllocator(const RootDeviceIndicesContainer &rootDeviceIndices, MemoryManager *memoryManager, size_t tagCount = 10)
|
2024-12-16 19:01:27 +08:00
|
|
|
: BaseClass(rootDeviceIndices, memoryManager, tagCount, MemoryConstants::cacheLineSize, sizeof(TagType), NEO::TimestampPacketConstants::initValue, false, true, mockDeviceBitfield) {}
|
2019-04-10 18:44:02 +08:00
|
|
|
|
2021-03-25 02:21:13 +08:00
|
|
|
void returnTag(TagNodeBase *node) override {
|
|
|
|
releaseReferenceNodes.push_back(static_cast<NodeType *>(node));
|
2019-04-10 18:44:02 +08:00
|
|
|
BaseClass::returnTag(node);
|
|
|
|
}
|
|
|
|
|
2021-03-25 02:21:13 +08:00
|
|
|
void returnTagToFreePool(TagNodeBase *node) override {
|
|
|
|
returnedToFreePoolNodes.push_back(static_cast<NodeType *>(node));
|
2019-04-10 18:44:02 +08:00
|
|
|
BaseClass::returnTagToFreePool(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<NodeType *> releaseReferenceNodes;
|
|
|
|
std::vector<NodeType *> returnedToFreePoolNodes;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MockTimestampPacketContainer : public TimestampPacketContainer {
|
|
|
|
public:
|
|
|
|
using TimestampPacketContainer::timestampPacketNodes;
|
|
|
|
|
2021-03-25 02:21:13 +08:00
|
|
|
MockTimestampPacketContainer(TagAllocatorBase &tagAllocator, size_t numberOfPreallocatedTags) {
|
2019-04-10 18:44:02 +08:00
|
|
|
for (size_t i = 0; i < numberOfPreallocatedTags; i++) {
|
|
|
|
add(tagAllocator.getTag());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-25 02:21:13 +08:00
|
|
|
TagNodeBase *getNode(size_t position) {
|
2019-04-10 18:44:02 +08:00
|
|
|
return timestampPacketNodes.at(position);
|
|
|
|
}
|
|
|
|
};
|
2019-12-02 15:37:42 +08:00
|
|
|
} // namespace NEO
|