2018-10-02 14:37:30 -07:00
|
|
|
/*
|
2019-02-08 10:27:48 +01:00
|
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
2018-10-02 14:37:30 -07:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "runtime/helpers/timestamp_packet.h"
|
|
|
|
|
|
2019-08-22 16:51:02 +02:00
|
|
|
#include "core/command_stream/linear_stream.h"
|
2018-10-02 14:37:30 -07:00
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
2018-10-05 12:51:57 -07:00
|
|
|
#include "runtime/event/event.h"
|
2019-06-12 09:13:06 +02:00
|
|
|
#include "runtime/helpers/hardware_commands_helper.h"
|
2018-10-02 14:37:30 -07:00
|
|
|
#include "runtime/utilities/tag_allocator.h"
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
using namespace NEO;
|
2018-10-02 14:37:30 -07:00
|
|
|
|
|
|
|
|
void TimestampPacketContainer::add(Node *timestampPacketNode) {
|
|
|
|
|
timestampPacketNodes.push_back(timestampPacketNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimestampPacketContainer::~TimestampPacketContainer() {
|
2018-11-27 13:07:41 +01:00
|
|
|
for (auto node : timestampPacketNodes) {
|
|
|
|
|
node->returnTag();
|
2018-10-02 14:37:30 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimestampPacketContainer::swapNodes(TimestampPacketContainer ×tampPacketContainer) {
|
|
|
|
|
timestampPacketNodes.swap(timestampPacketContainer.timestampPacketNodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimestampPacketContainer::resolveDependencies(bool clearAllDependencies) {
|
|
|
|
|
std::vector<Node *> pendingNodes;
|
|
|
|
|
|
2018-11-27 13:07:41 +01:00
|
|
|
for (auto node : timestampPacketNodes) {
|
2019-02-08 10:27:48 +01:00
|
|
|
if (node->tagForCpuAccess->canBeReleased() || clearAllDependencies) {
|
2018-11-27 13:07:41 +01:00
|
|
|
node->returnTag();
|
2018-10-02 14:37:30 -07:00
|
|
|
} else {
|
|
|
|
|
pendingNodes.push_back(node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::swap(timestampPacketNodes, pendingNodes);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 13:07:41 +01:00
|
|
|
void TimestampPacketContainer::assignAndIncrementNodesRefCounts(const TimestampPacketContainer &inputTimestampPacketContainer) {
|
2018-10-05 12:51:57 -07:00
|
|
|
auto &inputNodes = inputTimestampPacketContainer.peekNodes();
|
|
|
|
|
std::copy(inputNodes.begin(), inputNodes.end(), std::back_inserter(timestampPacketNodes));
|
|
|
|
|
|
2018-11-27 13:07:41 +01:00
|
|
|
for (auto node : inputNodes) {
|
2018-10-02 14:37:30 -07:00
|
|
|
node->incRefCount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimestampPacketContainer::makeResident(CommandStreamReceiver &commandStreamReceiver) {
|
2018-11-27 13:07:41 +01:00
|
|
|
for (auto node : timestampPacketNodes) {
|
2019-02-08 10:27:48 +01:00
|
|
|
commandStreamReceiver.makeResident(*node->getBaseGraphicsAllocation());
|
2018-10-02 14:37:30 -07:00
|
|
|
}
|
|
|
|
|
}
|
2019-07-10 10:52:03 +02:00
|
|
|
|
|
|
|
|
bool TimestampPacketContainer::isCompleted() const {
|
|
|
|
|
for (auto node : timestampPacketNodes) {
|
|
|
|
|
if (!node->tagForCpuAccess->isCompleted()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|