Timestamp Packet ownership

- Tag allocator: reference count tracking
- Obtain tag by command queue and pass to Event if exist during enqueue
- Handle Timestamp Packet lifetime on Event and CmdQueue destruction

Change-Id: I9a5969830ea7a9d729e6f70519d8c28ff70fcf06
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2018-08-28 14:11:25 +02:00
committed by sys_ocldev
parent b49101803c
commit da0f9381dc
11 changed files with 174 additions and 27 deletions

View File

@@ -36,6 +36,7 @@
#include "runtime/helpers/mipmap.h"
#include "runtime/helpers/options.h"
#include "runtime/helpers/ptr_math.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/mem_obj/image.h"
#include "runtime/helpers/surface_formats.h"
@@ -43,6 +44,7 @@
#include "runtime/helpers/string.h"
#include "CL/cl_ext.h"
#include "runtime/utilities/api_intercept.h"
#include "runtime/utilities/tag_allocator.h"
#include "runtime/helpers/convert_color.h"
#include "runtime/helpers/queue_helpers.h"
#include <map>
@@ -102,6 +104,10 @@ CommandQueue::~CommandQueue() {
auto memoryManager = device->getMemoryManager();
DEBUG_BREAK_IF(nullptr == memoryManager);
if (timestampPacketNode) {
memoryManager->getTimestampPacketAllocator()->returnTag(timestampPacketNode);
}
if (commandStream && commandStream->getGraphicsAllocation()) {
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream->getGraphicsAllocation()), REUSABLE_ALLOCATION);
commandStream->replaceGraphicsAllocation(nullptr);
@@ -604,4 +610,13 @@ void CommandQueue::dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo,
builder.buildDispatchInfos(multiDispatchInfo, dispatchParams);
}
void CommandQueue::obtainNewTimestampPacketNode() {
auto allocator = device->getMemoryManager()->getTimestampPacketAllocator();
if (timestampPacketNode) {
allocator->returnTag(timestampPacketNode);
}
timestampPacketNode = allocator->getTag();
}
} // namespace OCLRT

View File

@@ -40,6 +40,7 @@ class Image;
class IndirectHeap;
class Kernel;
class MemObj;
class TimestampPacket;
struct CompletionStamp;
enum class QueuePriority {
@@ -418,6 +419,8 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
MOCKABLE_VIRTUAL void dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo, BuffersForAuxTranslation &buffersForAuxTranslation,
AuxTranslationDirection auxTranslationDirection);
void obtainNewTimestampPacketNode();
Context *context;
Device *device;
@@ -438,6 +441,8 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
bool mapDcFlushRequired = false;
bool isSpecialCommandQueue = false;
TagNode<TimestampPacket> *timestampPacketNode = nullptr;
private:
void providePerformanceHint(TransferProperties &transferProperties);
};

View File

@@ -240,13 +240,22 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
}
}
if ((this->isProfilingEnabled() && (eventBuilder.getEvent() != nullptr))) {
// Get allocation for timestamps
hwTimeStamps = eventBuilder.getEvent()->getHwTimeStamp();
if (this->isPerfCountersEnabled()) {
hwPerfCounter = eventBuilder.getEvent()->getHwPerfCounter();
//PERF COUNTER: copy current configuration from queue to event
eventBuilder.getEvent()->copyPerfCounters(this->getPerfCountersConfigData());
if (DebugManager.flags.EnableTimestampPacket.get()) {
obtainNewTimestampPacketNode();
}
if (eventBuilder.getEvent()) {
if (timestampPacketNode) {
eventBuilder.getEvent()->setTimestampPacketNode(timestampPacketNode);
}
if (this->isProfilingEnabled()) {
// Get allocation for timestamps
hwTimeStamps = eventBuilder.getEvent()->getHwTimeStamp();
if (this->isPerfCountersEnabled()) {
hwPerfCounter = eventBuilder.getEvent()->getHwPerfCounter();
// PERF COUNTER: copy current configuration from queue to event
eventBuilder.getEvent()->copyPerfCounters(this->getPerfCountersConfigData());
}
}
}

View File

@@ -610,7 +610,7 @@ void GpgpuWalkerHelper<GfxFamily>::dispatchWalker(
// Implement enabling special WA DisableLSQCROPERFforOCL if needed
GpgpuWalkerHelper<GfxFamily>::applyWADisableLSQCROPERFforOCL(commandStream, kernel, true);
bool setupTimestampPacket = (DebugManager.flags.EnableTimestampPacket.get()) && (currentDispatchIndex == numDispatches - 1);
bool setupTimestampPacket = (timestampPacket && (currentDispatchIndex == numDispatches - 1));
if (setupTimestampPacket) {
GpgpuWalkerHelper<GfxFamily>::setupTimestampPacket(commandStream, nullptr, timestampPacket, TimestampPacket::WriteOperationType::Start);
}