mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-31 03:20:47 +08:00
Move GTPin notifications out from CSR
Change-Id: I4209fc18017c694d71848c3fecd8c3d7440f151b Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
be41b3b30a
commit
0aedea1ae2
68
core/command_stream/experimental_command_buffer.cpp
Normal file
68
core/command_stream/experimental_command_buffer.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/command_stream/experimental_command_buffer.h"
|
||||
|
||||
#include "core/command_stream/linear_stream.h"
|
||||
#include "core/memory_manager/internal_allocation_storage.h"
|
||||
#include "core/memory_manager/memory_constants.h"
|
||||
#include "core/memory_manager/memory_manager.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
ExperimentalCommandBuffer::ExperimentalCommandBuffer(CommandStreamReceiver *csr, double profilingTimerResolution) : commandStreamReceiver(csr),
|
||||
currentStream(nullptr),
|
||||
timestampsOffset(0),
|
||||
experimentalAllocationOffset(0),
|
||||
defaultPrint(true),
|
||||
timerResolution(profilingTimerResolution) {
|
||||
auto rootDeviceIndex = csr->getRootDeviceIndex();
|
||||
timestamps = csr->getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY});
|
||||
memset(timestamps->getUnderlyingBuffer(), 0, timestamps->getUnderlyingBufferSize());
|
||||
experimentalAllocation = csr->getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY});
|
||||
memset(experimentalAllocation->getUnderlyingBuffer(), 0, experimentalAllocation->getUnderlyingBufferSize());
|
||||
}
|
||||
|
||||
ExperimentalCommandBuffer::~ExperimentalCommandBuffer() {
|
||||
auto timestamp = static_cast<uint64_t *>(timestamps->getUnderlyingBuffer());
|
||||
for (uint32_t i = 0; i < timestampsOffset / (2 * sizeof(uint64_t)); i++) {
|
||||
auto stop = static_cast<uint64_t>(*(timestamp + 1) * timerResolution);
|
||||
auto start = static_cast<uint64_t>(*timestamp * timerResolution);
|
||||
auto delta = stop - start;
|
||||
printDebugString(defaultPrint, stdout, "#%u: delta %llu start %llu stop %llu\n", i, delta, start, stop);
|
||||
timestamp += 2;
|
||||
}
|
||||
MemoryManager *memoryManager = commandStreamReceiver->getMemoryManager();
|
||||
memoryManager->freeGraphicsMemory(timestamps);
|
||||
memoryManager->freeGraphicsMemory(experimentalAllocation);
|
||||
|
||||
if (currentStream.get()) {
|
||||
memoryManager->freeGraphicsMemory(currentStream->getGraphicsAllocation());
|
||||
currentStream->replaceGraphicsAllocation(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) {
|
||||
if (!currentStream) {
|
||||
currentStream.reset(new LinearStream(nullptr));
|
||||
}
|
||||
minRequiredSize += CSRequirements::minCommandQueueCommandStreamSize;
|
||||
constexpr static auto additionalAllocationSize = CSRequirements::minCommandQueueCommandStreamSize + CSRequirements::csOverfetchSize;
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(*currentStream, minRequiredSize, additionalAllocationSize);
|
||||
}
|
||||
|
||||
void ExperimentalCommandBuffer::makeResidentAllocations() {
|
||||
commandStreamReceiver->makeResident(*currentStream->getGraphicsAllocation());
|
||||
commandStreamReceiver->makeResident(*timestamps);
|
||||
commandStreamReceiver->makeResident(*experimentalAllocation);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user