2019-04-10 18:44:02 +08:00
|
|
|
/*
|
2020-01-28 00:28:10 +08:00
|
|
|
* Copyright (C) 2017-2020 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"
|
2019-04-10 18:44:02 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2019-04-16 20:07:50 +08:00
|
|
|
template <typename TagType = TimestampPacketStorage>
|
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;
|
|
|
|
|
2019-12-02 15:37:42 +08:00
|
|
|
MockTagAllocator(uint32_t rootDeviceIndex, MemoryManager *memoryManager, size_t tagCount = 10)
|
|
|
|
: BaseClass(rootDeviceIndex, memoryManager, tagCount, MemoryConstants::cacheLineSize, sizeof(TagType), false) {}
|
2019-04-10 18:44:02 +08:00
|
|
|
|
|
|
|
void returnTag(NodeType *node) override {
|
|
|
|
releaseReferenceNodes.push_back(node);
|
|
|
|
BaseClass::returnTag(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void returnTagToFreePool(NodeType *node) override {
|
|
|
|
returnedToFreePoolNodes.push_back(node);
|
|
|
|
BaseClass::returnTagToFreePool(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<NodeType *> releaseReferenceNodes;
|
|
|
|
std::vector<NodeType *> returnedToFreePoolNodes;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MockTimestampPacketContainer : public TimestampPacketContainer {
|
|
|
|
public:
|
|
|
|
using TimestampPacketContainer::timestampPacketNodes;
|
|
|
|
|
2019-04-16 20:07:50 +08:00
|
|
|
MockTimestampPacketContainer(TagAllocator<TimestampPacketStorage> &tagAllocator, size_t numberOfPreallocatedTags) {
|
2019-04-10 18:44:02 +08:00
|
|
|
for (size_t i = 0; i < numberOfPreallocatedTags; i++) {
|
|
|
|
add(tagAllocator.getTag());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-16 20:07:50 +08:00
|
|
|
TagNode<TimestampPacketStorage> *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
|