L0::Event to support dynamic size - part 2

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-05-18 16:28:14 +00:00
committed by Compute-Runtime-Automation
parent 529020c72c
commit afa461efb0
12 changed files with 226 additions and 47 deletions

View File

@@ -52,6 +52,8 @@ set(L0_RUNTIME_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/helpers/api_specific_config_l0.cpp ${CMAKE_CURRENT_SOURCE_DIR}/helpers/api_specific_config_l0.cpp
${CMAKE_CURRENT_SOURCE_DIR}/helpers/l0_populate_factory.h ${CMAKE_CURRENT_SOURCE_DIR}/helpers/l0_populate_factory.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers${BRANCH_DIR_SUFFIX}/hw_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers${BRANCH_DIR_SUFFIX}/hw_helpers.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers/l0_hw_helper_base.inl
${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers/l0_hw_helper_skl_plus.inl
${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers/l0_hw_helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers/l0_hw_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers/l0_hw_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers/l0_hw_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel/kernel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kernel/kernel.cpp

View File

@@ -24,23 +24,22 @@
#include "level_zero/core/source/device/device.h" #include "level_zero/core/source/device/device.h"
#include "level_zero/core/source/device/device_imp.h" #include "level_zero/core/source/device/device_imp.h"
#include "level_zero/core/source/driver/driver_handle_imp.h" #include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/core/source/event/event_impl.inl" #include "level_zero/core/source/hw_helpers/l0_hw_helper.h"
#include "level_zero/tools/source/metrics/metric.h" #include "level_zero/tools/source/metrics/metric.h"
#include <set> #include <set>
namespace L0 { //
#include "level_zero/core/source/event/event_impl.inl"
ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uint32_t numDevices, ze_device_handle_t *phDevices, uint32_t numEvents) { namespace L0 {
template Event *Event::create<uint64_t>(EventPool *, const ze_event_desc_t *, Device *);
template Event *Event::create<uint32_t>(EventPool *, const ze_event_desc_t *, Device *);
ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uint32_t numDevices, ze_device_handle_t *phDevices) {
std::set<uint32_t> rootDeviceIndices; std::set<uint32_t> rootDeviceIndices;
uint32_t maxRootDeviceIndex = 0u; uint32_t maxRootDeviceIndex = 0u;
void *eventPoolPtr = nullptr;
size_t alignedSize = alignUp<size_t>(numEvents * eventSize, MemoryConstants::pageSize64k);
NEO::GraphicsAllocation::AllocationType allocationType = isEventPoolUsedForTimestamp ? NEO::GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER
: NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(driver); DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(driver);
bool useDevicesFromApi = true; bool useDevicesFromApi = true;
@@ -59,7 +58,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uin
} }
if (!eventDevice) { if (!eventDevice) {
continue; return ZE_RESULT_ERROR_INVALID_ARGUMENT;
} }
devices.push_back(eventDevice); devices.push_back(eventDevice);
@@ -69,15 +68,24 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uin
} }
} }
auto &hwHelper = devices[0]->getHwHelper();
eventAlignment = static_cast<uint32_t>(hwHelper.getTimestampPacketAllocatorAlignment());
eventSize = static_cast<uint32_t>(alignUp(EventPacketsCount::eventPackets * hwHelper.getSingleTimestampPacketSize(), eventAlignment));
size_t alignedSize = alignUp<size_t>(numEvents * eventSize, MemoryConstants::pageSize64k);
NEO::GraphicsAllocation::AllocationType allocationType = isEventPoolUsedForTimestamp ? NEO::GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER
: NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
eventPoolAllocations = std::make_unique<NEO::MultiGraphicsAllocation>(maxRootDeviceIndex); eventPoolAllocations = std::make_unique<NEO::MultiGraphicsAllocation>(maxRootDeviceIndex);
NEO::AllocationProperties allocationProperties{*rootDeviceIndices.begin(), alignedSize, allocationType, systemMemoryBitfield}; NEO::AllocationProperties allocationProperties{*rootDeviceIndices.begin(), alignedSize, allocationType, systemMemoryBitfield};
allocationProperties.alignment = eventAlignment; allocationProperties.alignment = eventAlignment;
std::vector<uint32_t> rootDeviceIndicesVector = {rootDeviceIndices.begin(), rootDeviceIndices.end()}; std::vector<uint32_t> rootDeviceIndicesVector = {rootDeviceIndices.begin(), rootDeviceIndices.end()};
eventPoolPtr = driver->getMemoryManager()->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndicesVector, auto eventPoolPtr = driver->getMemoryManager()->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndicesVector,
allocationProperties, allocationProperties,
*eventPoolAllocations); *eventPoolAllocations);
if (!eventPoolPtr) { if (!eventPoolPtr) {
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
@@ -86,10 +94,12 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uin
} }
EventPoolImp::~EventPoolImp() { EventPoolImp::~EventPoolImp() {
auto graphicsAllocations = eventPoolAllocations->getGraphicsAllocations(); if (eventPoolAllocations) {
auto memoryManager = devices[0]->getDriverHandle()->getMemoryManager(); auto graphicsAllocations = eventPoolAllocations->getGraphicsAllocations();
for (auto gpuAllocation : graphicsAllocations) { auto memoryManager = devices[0]->getDriverHandle()->getMemoryManager();
memoryManager->freeGraphicsMemory(gpuAllocation); for (auto gpuAllocation : graphicsAllocations) {
memoryManager->freeGraphicsMemory(gpuAllocation);
}
} }
} }
@@ -111,7 +121,10 @@ ze_result_t EventPoolImp::createEvent(const ze_event_desc_t *desc, ze_event_hand
if (desc->index > (getNumEvents() - 1)) { if (desc->index > (getNumEvents() - 1)) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT; return ZE_RESULT_ERROR_INVALID_ARGUMENT;
} }
*phEvent = Event::create<uint32_t>(this, desc, this->getDevice());
auto &l0HwHelper = L0HwHelper::get(getDevice()->getHwInfo().platform.eRenderCoreFamily);
*phEvent = l0HwHelper.createEvent(this, desc, getDevice());
return ZE_RESULT_SUCCESS; return ZE_RESULT_SUCCESS;
} }
@@ -121,21 +134,18 @@ ze_result_t Event::destroy() {
return ZE_RESULT_SUCCESS; return ZE_RESULT_SUCCESS;
} }
EventPool *EventPool::create(DriverHandle *driver, Context *context, uint32_t numDevices, EventPool *EventPool::create(DriverHandle *driver, Context *context, uint32_t numDevices, ze_device_handle_t *phDevices, const ze_event_pool_desc_t *desc) {
ze_device_handle_t *phDevices, auto eventPool = std::make_unique<EventPoolImp>(desc);
const ze_event_pool_desc_t *desc) {
auto eventPool = new (std::nothrow) EventPoolImp(driver, numDevices, phDevices, desc->count, desc->flags);
if (!eventPool) { if (!eventPool) {
DEBUG_BREAK_IF(true); DEBUG_BREAK_IF(true);
return nullptr; return nullptr;
} }
ze_result_t result = eventPool->initialize(driver, context, numDevices, phDevices, desc->count); ze_result_t result = eventPool->initialize(driver, context, numDevices, phDevices);
if (result) { if (result) {
delete eventPool;
return nullptr; return nullptr;
} }
return eventPool; return eventPool.release();
} }
} // namespace L0 } // namespace L0

View File

@@ -145,16 +145,13 @@ struct EventPool : _ze_event_pool_handle_t {
}; };
struct EventPoolImp : public EventPool { struct EventPoolImp : public EventPool {
EventPoolImp(DriverHandle *driver, uint32_t numDevices, ze_device_handle_t *phDevices, uint32_t numEvents, ze_event_pool_flags_t flags) : numEvents(numEvents) { EventPoolImp(const ze_event_pool_desc_t *desc) : numEvents(desc->count) {
if (flags & ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP) { if (desc->flags & ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP) {
isEventPoolUsedForTimestamp = true; isEventPoolUsedForTimestamp = true;
} }
} }
ze_result_t initialize(DriverHandle *driver, Context *context, ze_result_t initialize(DriverHandle *driver, Context *context, uint32_t numDevices, ze_device_handle_t *phDevices);
uint32_t numDevices,
ze_device_handle_t *phDevices,
uint32_t numEvents);
~EventPoolImp(); ~EventPoolImp();
@@ -175,10 +172,8 @@ struct EventPoolImp : public EventPool {
size_t numEvents; size_t numEvents;
protected: protected:
const uint32_t eventAlignment = 4 * MemoryConstants::cacheLineSize; uint32_t eventAlignment = 0;
const uint32_t eventSize = static_cast<uint32_t>(alignUp(EventPacketsCount::eventPackets * uint32_t eventSize = 0;
NEO::TimestampPackets<uint32_t>::getSinglePacketSize(),
eventAlignment));
}; };
} // namespace L0 } // namespace L0

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Intel Corporation * Copyright (C) 2020-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -7,6 +7,7 @@
#include "level_zero/core/source/helpers/l0_populate_factory.h" #include "level_zero/core/source/helpers/l0_populate_factory.h"
#include "level_zero/core/source/hw_helpers/l0_hw_helper_base.inl" #include "level_zero/core/source/hw_helpers/l0_hw_helper_base.inl"
#include "level_zero/core/source/hw_helpers/l0_hw_helper_skl_plus.inl"
#include "hw_cmds.h" #include "hw_cmds.h"

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Intel Corporation * Copyright (C) 2020-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -7,6 +7,7 @@
#include "level_zero/core/source/helpers/l0_populate_factory.h" #include "level_zero/core/source/helpers/l0_populate_factory.h"
#include "level_zero/core/source/hw_helpers/l0_hw_helper_base.inl" #include "level_zero/core/source/hw_helpers/l0_hw_helper_base.inl"
#include "level_zero/core/source/hw_helpers/l0_hw_helper_skl_plus.inl"
#include "hw_cmds.h" #include "hw_cmds.h"

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Intel Corporation * Copyright (C) 2020-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -7,6 +7,7 @@
#include "level_zero/core/source/helpers/l0_populate_factory.h" #include "level_zero/core/source/helpers/l0_populate_factory.h"
#include "level_zero/core/source/hw_helpers/l0_hw_helper_base.inl" #include "level_zero/core/source/hw_helpers/l0_hw_helper_base.inl"
#include "level_zero/core/source/hw_helpers/l0_hw_helper_skl_plus.inl"
#include "hw_cmds.h" #include "hw_cmds.h"

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Intel Corporation * Copyright (C) 2020-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -14,11 +14,15 @@
namespace L0 { namespace L0 {
struct HardwareInfo; struct HardwareInfo;
struct Event;
struct Device;
struct EventPool;
class L0HwHelper { class L0HwHelper {
public: public:
static L0HwHelper &get(GFXCORE_FAMILY gfxCore); static L0HwHelper &get(GFXCORE_FAMILY gfxCore);
virtual void setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const = 0; virtual void setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const = 0;
virtual L0::Event *createEvent(L0::EventPool *eventPool, const ze_event_desc_t *desc, L0::Device *device) const = 0;
protected: protected:
L0HwHelper() = default; L0HwHelper() = default;
@@ -32,6 +36,7 @@ class L0HwHelperHw : public L0HwHelper {
return l0HwHelper; return l0HwHelper;
} }
void setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const override; void setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const override;
L0::Event *createEvent(L0::EventPool *eventPool, const ze_event_desc_t *desc, L0::Device *device) const override;
L0HwHelperHw() = default; L0HwHelperHw() = default;
}; };

View File

@@ -1,16 +1,31 @@
/* /*
* Copyright (C) 2020 Intel Corporation * Copyright (C) 2020-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
*/ */
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "level_zero/core/source/device/device.h"
#include "level_zero/core/source/event/event.h"
#include "level_zero/core/source/hw_helpers/l0_hw_helper.h" #include "level_zero/core/source/hw_helpers/l0_hw_helper.h"
namespace L0 { namespace L0 {
template <typename Family> template <typename Family>
void L0HwHelperHw<Family>::setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const { L0::Event *L0HwHelperHw<Family>::createEvent(L0::EventPool *eventPool, const ze_event_desc_t *desc, L0::Device *device) const {
if (NEO::DebugManager.flags.OverrideTimestampPacketSize.get() != -1) {
if (NEO::DebugManager.flags.OverrideTimestampPacketSize.get() == 4) {
return Event::create<uint32_t>(eventPool, desc, device);
} else if (NEO::DebugManager.flags.OverrideTimestampPacketSize.get() == 8) {
return Event::create<uint64_t>(eventPool, desc, device);
} else {
UNRECOVERABLE_IF(true);
}
}
return Event::create<typename Family::TimestampPacketType>(eventPool, desc, device);
} }
} // namespace L0 } // namespace L0

View File

@@ -0,0 +1,16 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/source/hw_helpers/l0_hw_helper.h"
namespace L0 {
template <typename Family>
void L0HwHelperHw<Family>::setAdditionalGroupProperty(ze_command_queue_group_properties_t &groupProperty, uint32_t groupType) const {
}
} // namespace L0

View File

@@ -5,6 +5,7 @@
* *
*/ */
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_memory_operations_handler.h" #include "shared/test/common/mocks/mock_memory_operations_handler.h"
#include "opencl/test/unit_test/mocks/mock_compilers.h" #include "opencl/test/unit_test/mocks/mock_compilers.h"
@@ -214,7 +215,7 @@ TEST_F(EventPoolCreate, givenCloseIpcHandleCalledReturnsNotSupported) {
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result); EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
} }
TEST_F(EventPoolCreate, GivenAtLeastOneValidDeviceHandleWhenCreatingEventPoolThenEventPoolCreated) { TEST_F(EventPoolCreate, GivenNullptrDeviceAndNumberOfDevicesWhenCreatingEventPoolThenReturnError) {
ze_event_pool_desc_t eventPoolDesc = { ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC, ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr, nullptr,
@@ -223,6 +224,18 @@ TEST_F(EventPoolCreate, GivenAtLeastOneValidDeviceHandleWhenCreatingEventPoolThe
ze_device_handle_t devices[] = {nullptr, device->toHandle()}; ze_device_handle_t devices[] = {nullptr, device->toHandle()};
std::unique_ptr<L0::EventPool> eventPool(EventPool::create(driverHandle.get(), context, 2, devices, &eventPoolDesc)); std::unique_ptr<L0::EventPool> eventPool(EventPool::create(driverHandle.get(), context, 2, devices, &eventPoolDesc));
ASSERT_EQ(nullptr, eventPool);
}
TEST_F(EventPoolCreate, GivenNullptrDeviceWithoutNumberOfDevicesWhenCreatingEventPoolThenEventPoolCreated) {
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr,
ZE_EVENT_POOL_FLAG_HOST_VISIBLE,
1};
ze_device_handle_t devices[] = {nullptr, device->toHandle()};
std::unique_ptr<L0::EventPool> eventPool(EventPool::create(driverHandle.get(), context, 0, devices, &eventPoolDesc));
ASSERT_NE(nullptr, eventPool); ASSERT_NE(nullptr, eventPool);
} }
@@ -751,13 +764,10 @@ TEST_F(EventPoolCreateNegativeTest, whenInitializingEventPoolButMemoryManagerFai
result = zeDeviceGet(driverHandle.get(), &deviceCount, devices); result = zeDeviceGet(driverHandle.get(), &deviceCount, devices);
EXPECT_EQ(ZE_RESULT_SUCCESS, result); EXPECT_EQ(ZE_RESULT_SUCCESS, result);
auto eventPool = new L0::EventPoolImp(driverHandle.get(), numRootDevices, auto eventPool = new L0::EventPoolImp(&eventPoolDesc);
devices, eventPoolDesc.count,
eventPoolDesc.flags);
EXPECT_NE(nullptr, eventPool); EXPECT_NE(nullptr, eventPool);
result = eventPool->initialize(driverHandle.get(), context, numRootDevices, devices, result = eventPool->initialize(driverHandle.get(), context, numRootDevices, devices);
eventPoolDesc.count);
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY, result); EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY, result);
delete eventPool; delete eventPool;
@@ -847,5 +857,110 @@ TEST_F(EventTests, givenTwoEventsCreatedThenTheyHaveDifferentAddresses) {
event1->destroy(); event1->destroy();
} }
struct EventSizeTests : public DeviceFixture, public testing::Test {
void SetUp() override {
DeviceFixture::SetUp();
hDevice = device->toHandle();
}
void TearDown() override {
DeviceFixture::TearDown();
}
void createEvents() {
ze_event_handle_t hEvent0 = 0;
ze_event_handle_t hEvent1 = 0;
ze_event_desc_t eventDesc0 = {};
ze_event_desc_t eventDesc1 = {};
eventDesc0.index = 0;
eventDesc1.index = 1;
auto result = eventPool->createEvent(&eventDesc0, &hEvent0);
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
result = eventPool->createEvent(&eventDesc1, &hEvent1);
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
eventObj0.reset(L0::Event::fromHandle(hEvent0));
eventObj1.reset(L0::Event::fromHandle(hEvent1));
}
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr,
ZE_EVENT_POOL_FLAG_HOST_VISIBLE,
4};
DebugManagerStateRestore restore;
ze_device_handle_t hDevice = 0;
std::unique_ptr<EventPoolImp> eventPool;
std::unique_ptr<L0::Event> eventObj0;
std::unique_ptr<L0::Event> eventObj1;
};
HWTEST_F(EventSizeTests, whenCreatingEventPoolThenUseCorrectSizeAndAlignment) {
eventPool.reset(static_cast<EventPoolImp *>(EventPool::create(device->getDriverHandle(), context, 1, &hDevice, &eventPoolDesc)));
auto &hwHelper = device->getHwHelper();
auto expectedAlignment = static_cast<uint32_t>(hwHelper.getTimestampPacketAllocatorAlignment());
auto singlePacketSize = TimestampPackets<typename FamilyType::TimestampPacketType>::getSinglePacketSize();
auto expectedSize = static_cast<uint32_t>(alignUp(EventPacketsCount::eventPackets * singlePacketSize, expectedAlignment));
EXPECT_EQ(expectedSize, eventPool->getEventSize());
createEvents();
auto hostPtrDiff = ptrDiff(eventObj1->getHostAddress(), eventObj0->getHostAddress());
EXPECT_EQ(expectedSize, hostPtrDiff);
}
HWTEST_F(EventSizeTests, givenDebugFlagwhenCreatingEventPoolThenUseCorrectSizeAndAlignment) {
auto &hwHelper = device->getHwHelper();
auto expectedAlignment = static_cast<uint32_t>(hwHelper.getTimestampPacketAllocatorAlignment());
{
DebugManager.flags.OverrideTimestampPacketSize.set(4);
eventPool.reset(static_cast<EventPoolImp *>(EventPool::create(device->getDriverHandle(), context, 1, &hDevice, &eventPoolDesc)));
auto singlePacketSize = TimestampPackets<uint32_t>::getSinglePacketSize();
auto expectedSize = static_cast<uint32_t>(alignUp(EventPacketsCount::eventPackets * singlePacketSize, expectedAlignment));
EXPECT_EQ(expectedSize, eventPool->getEventSize());
createEvents();
auto hostPtrDiff = ptrDiff(eventObj1->getHostAddress(), eventObj0->getHostAddress());
EXPECT_EQ(expectedSize, hostPtrDiff);
}
{
DebugManager.flags.OverrideTimestampPacketSize.set(8);
eventPool.reset(static_cast<EventPoolImp *>(EventPool::create(device->getDriverHandle(), context, 1, &hDevice, &eventPoolDesc)));
auto singlePacketSize = TimestampPackets<uint64_t>::getSinglePacketSize();
auto expectedSize = static_cast<uint32_t>(alignUp(EventPacketsCount::eventPackets * singlePacketSize, expectedAlignment));
EXPECT_EQ(expectedSize, eventPool->getEventSize());
createEvents();
auto hostPtrDiff = ptrDiff(eventObj1->getHostAddress(), eventObj0->getHostAddress());
EXPECT_EQ(expectedSize, hostPtrDiff);
}
{
DebugManager.flags.OverrideTimestampPacketSize.set(12);
EXPECT_ANY_THROW(EventPool::create(device->getDriverHandle(), context, 1, &hDevice, &eventPoolDesc));
EXPECT_ANY_THROW(createEvents());
}
}
} // namespace ult } // namespace ult
} // namespace L0 } // namespace L0

View File

@@ -153,6 +153,7 @@ class HwHelper {
size_t initialTagCount, CommandStreamReceiverType csrType, size_t initialTagCount, CommandStreamReceiverType csrType,
DeviceBitfield deviceBitfield) const = 0; DeviceBitfield deviceBitfield) const = 0;
virtual size_t getTimestampPacketAllocatorAlignment() const = 0; virtual size_t getTimestampPacketAllocatorAlignment() const = 0;
virtual size_t getSingleTimestampPacketSize() const = 0;
static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo); static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo);
static uint32_t getEnginesCount(const HardwareInfo &hwInfo); static uint32_t getEnginesCount(const HardwareInfo &hwInfo);
@@ -381,6 +382,8 @@ class HwHelperHw : public HwHelper {
DeviceBitfield deviceBitfield) const override; DeviceBitfield deviceBitfield) const override;
size_t getTimestampPacketAllocatorAlignment() const override; size_t getTimestampPacketAllocatorAlignment() const override;
size_t getSingleTimestampPacketSize() const override;
protected: protected:
LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override; LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override;

View File

@@ -493,6 +493,21 @@ size_t HwHelperHw<GfxFamily>::getTimestampPacketAllocatorAlignment() const {
return MemoryConstants::cacheLineSize * 4; return MemoryConstants::cacheLineSize * 4;
} }
template <typename GfxFamily>
size_t HwHelperHw<GfxFamily>::getSingleTimestampPacketSize() const {
if (DebugManager.flags.OverrideTimestampPacketSize.get() != -1) {
if (DebugManager.flags.OverrideTimestampPacketSize.get() == 4) {
return TimestampPackets<uint32_t>::getSinglePacketSize();
} else if (DebugManager.flags.OverrideTimestampPacketSize.get() == 8) {
return TimestampPackets<uint64_t>::getSinglePacketSize();
} else {
UNRECOVERABLE_IF(true);
}
}
return TimestampPackets<typename GfxFamily::TimestampPacketType>::getSinglePacketSize();
}
template <typename GfxFamily> template <typename GfxFamily>
LocalMemoryAccessMode HwHelperHw<GfxFamily>::getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const { LocalMemoryAccessMode HwHelperHw<GfxFamily>::getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const {
switch (static_cast<LocalMemoryAccessMode>(DebugManager.flags.ForceLocalMemoryAccessMode.get())) { switch (static_cast<LocalMemoryAccessMode>(DebugManager.flags.ForceLocalMemoryAccessMode.get())) {