feature: create InOrderExecInfo for standalone CB Event

Related-To: NEO-8145

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2024-01-12 16:27:50 +00:00
committed by Compute-Runtime-Automation
parent cc1e3965ce
commit dfc69c746a
13 changed files with 247 additions and 164 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2023-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,8 @@
#include "shared/source/helpers/in_order_cmd_helpers.h"
#include "shared/source/device/device.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/memory_manager/memory_manager.h"
#include <cstdint>
@@ -15,13 +17,43 @@
namespace NEO {
std::shared_ptr<InOrderExecInfo> InOrderExecInfo::create(NEO::Device &device, uint32_t partitionCount, bool regularCmdList, bool atomicDeviceSignalling, bool duplicatedHostStorage) {
NEO::AllocationProperties allocationProperties{device.getRootDeviceIndex(), MemoryConstants::pageSize64k, NEO::AllocationType::timestampPacketTagBuffer, device.getDeviceBitfield()};
auto inOrderDependencyCounterAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties(allocationProperties);
NEO::GraphicsAllocation *hostCounterAllocation = nullptr;
if (duplicatedHostStorage) {
NEO::AllocationProperties hostAllocationProperties{device.getRootDeviceIndex(), MemoryConstants::pageSize64k, NEO::AllocationType::bufferHostMemory, device.getDeviceBitfield()};
hostCounterAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties(hostAllocationProperties);
UNRECOVERABLE_IF(!hostCounterAllocation);
}
UNRECOVERABLE_IF(!inOrderDependencyCounterAllocation);
return std::make_shared<NEO::InOrderExecInfo>(inOrderDependencyCounterAllocation, hostCounterAllocation, *device.getMemoryManager(), partitionCount, regularCmdList, atomicDeviceSignalling);
}
std::shared_ptr<InOrderExecInfo> InOrderExecInfo::createFromExternalAllocation(NEO::Device &device, uint64_t deviceAddress, uint64_t *hostAddress, uint64_t counterValue) {
auto inOrderExecInfo = std::make_shared<NEO::InOrderExecInfo>(nullptr, nullptr, *device.getMemoryManager(), 1, false, true);
inOrderExecInfo->counterValue = counterValue;
inOrderExecInfo->hostAddress = hostAddress;
inOrderExecInfo->deviceAddress = deviceAddress;
inOrderExecInfo->duplicatedHostStorage = true;
return inOrderExecInfo;
}
InOrderExecInfo::~InOrderExecInfo() {
memoryManager.freeGraphicsMemory(&deviceCounterAllocation);
memoryManager.freeGraphicsMemory(deviceCounterAllocation);
memoryManager.freeGraphicsMemory(hostCounterAllocation);
}
InOrderExecInfo::InOrderExecInfo(NEO::GraphicsAllocation &deviceCounterAllocation, NEO::GraphicsAllocation *hostCounterAllocation, NEO::MemoryManager &memoryManager, uint32_t partitionCount, bool regularCmdList, bool atomicDeviceSignalling)
: deviceCounterAllocation(deviceCounterAllocation), memoryManager(memoryManager), hostCounterAllocation(hostCounterAllocation), regularCmdList(regularCmdList), atomicDeviceSignalling(atomicDeviceSignalling) {
InOrderExecInfo::InOrderExecInfo(NEO::GraphicsAllocation *deviceCounterAllocation, NEO::GraphicsAllocation *hostCounterAllocation, NEO::MemoryManager &memoryManager, uint32_t partitionCount, bool regularCmdList, bool atomicDeviceSignalling)
: memoryManager(memoryManager), deviceCounterAllocation(deviceCounterAllocation), hostCounterAllocation(hostCounterAllocation), regularCmdList(regularCmdList), atomicDeviceSignalling(atomicDeviceSignalling) {
numDevicePartitionsToWait = atomicDeviceSignalling ? 1 : partitionCount;
numHostPartitionsToWait = partitionCount;
@@ -29,8 +61,12 @@ InOrderExecInfo::InOrderExecInfo(NEO::GraphicsAllocation &deviceCounterAllocatio
if (hostCounterAllocation) {
hostAddress = reinterpret_cast<uint64_t *>(hostCounterAllocation->getUnderlyingBuffer());
duplicatedHostStorage = true;
} else {
hostAddress = reinterpret_cast<uint64_t *>(deviceCounterAllocation.getUnderlyingBuffer());
} else if (deviceCounterAllocation) {
hostAddress = reinterpret_cast<uint64_t *>(deviceCounterAllocation->getUnderlyingBuffer());
}
if (deviceCounterAllocation) {
deviceAddress = deviceCounterAllocation->getGpuAddress();
}
reset();
@@ -41,7 +77,11 @@ void InOrderExecInfo::reset() {
regularCmdListSubmissionCounter = 0;
allocationOffset = 0;
memset(deviceCounterAllocation.getUnderlyingBuffer(), 0, deviceCounterAllocation.getUnderlyingBufferSize());
if (deviceCounterAllocation) {
memset(deviceCounterAllocation->getUnderlyingBuffer(), 0, deviceCounterAllocation->getUnderlyingBufferSize());
} else {
DEBUG_BREAK_IF(true);
}
if (hostCounterAllocation) {
memset(hostCounterAllocation->getUnderlyingBuffer(), 0, hostCounterAllocation->getUnderlyingBufferSize());

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2023-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -17,6 +17,7 @@
namespace NEO {
class GraphicsAllocation;
class MemoryManager;
class Device;
class InOrderExecInfo : public NEO::NonCopyableClass {
public:
@@ -24,11 +25,15 @@ class InOrderExecInfo : public NEO::NonCopyableClass {
InOrderExecInfo() = delete;
InOrderExecInfo(NEO::GraphicsAllocation &deviceCounterAllocation, NEO::GraphicsAllocation *hostCounterAllocation, NEO::MemoryManager &memoryManager, uint32_t partitionCount, bool regularCmdList, bool atomicDeviceSignalling);
static std::shared_ptr<InOrderExecInfo> create(NEO::Device &device, uint32_t partitionCount, bool regularCmdList, bool atomicDeviceSignalling, bool duplicatedHostStorage);
static std::shared_ptr<InOrderExecInfo> createFromExternalAllocation(NEO::Device &device, uint64_t deviceAddress, uint64_t *hostAddress, uint64_t counterValue);
NEO::GraphicsAllocation &getDeviceCounterAllocation() const { return deviceCounterAllocation; }
InOrderExecInfo(NEO::GraphicsAllocation *deviceCounterAllocation, NEO::GraphicsAllocation *hostCounterAllocation, NEO::MemoryManager &memoryManager, uint32_t partitionCount, bool regularCmdList, bool atomicDeviceSignalling);
NEO::GraphicsAllocation *getDeviceCounterAllocation() const { return deviceCounterAllocation; }
NEO::GraphicsAllocation *getHostCounterAllocation() const { return hostCounterAllocation; }
uint64_t *getBaseHostAddress() const { return hostAddress; }
uint64_t getBaseDeviceAddress() const { return deviceAddress; }
uint64_t getCounterValue() const { return counterValue; }
void addCounterValue(uint64_t addValue) { counterValue += addValue; }
@@ -50,11 +55,12 @@ class InOrderExecInfo : public NEO::NonCopyableClass {
void reset();
protected:
NEO::GraphicsAllocation &deviceCounterAllocation;
NEO::MemoryManager &memoryManager;
NEO::GraphicsAllocation *deviceCounterAllocation = nullptr;
NEO::GraphicsAllocation *hostCounterAllocation = nullptr;
uint64_t counterValue = 0;
uint64_t regularCmdListSubmissionCounter = 0;
uint64_t deviceAddress = 0;
uint64_t *hostAddress = nullptr;
uint32_t numDevicePartitionsToWait = 0;
uint32_t numHostPartitionsToWait = 0;