Revert "Fix Device Allocated IPC Events for L0"

This reverts commit 1292ea26f5.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2022-12-22 20:53:39 +01:00
committed by Compute-Runtime-Automation
parent 47b6801b0b
commit 08f53f4e96
6 changed files with 7 additions and 329 deletions

View File

@@ -568,12 +568,6 @@ ze_result_t EventPoolImp::getIpcHandle(ze_ipc_event_pool_handle_t *pIpcHandle) {
memcpy_s(pIpcHandle->data + sizeof(int) + sizeof(this->numEvents),
sizeof(rootDeviceIndex), &rootDeviceIndex, sizeof(rootDeviceIndex));
memcpy_s(pIpcHandle->data + sizeof(int) + sizeof(this->numEvents) + sizeof(uint32_t),
sizeof(this->isDeviceEventPoolAllocation), &this->isDeviceEventPoolAllocation, sizeof(this->isDeviceEventPoolAllocation));
memcpy_s(pIpcHandle->data + sizeof(int) + sizeof(this->numEvents) + sizeof(uint32_t) + sizeof(bool),
sizeof(this->isHostVisibleEventPoolAllocation), &this->isHostVisibleEventPoolAllocation, sizeof(this->isHostVisibleEventPoolAllocation));
return ZE_RESULT_SUCCESS;
}
@@ -593,26 +587,15 @@ ze_result_t ContextImp::openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t
memcpy_s(&rootDeviceIndex, sizeof(rootDeviceIndex),
hIpc.data + sizeof(int) + sizeof(numEvents), sizeof(rootDeviceIndex));
memcpy_s(&eventPool->isDeviceEventPoolAllocation, sizeof(eventPool->isDeviceEventPoolAllocation),
hIpc.data + sizeof(int) + sizeof(numEvents) + sizeof(rootDeviceIndex), sizeof(eventPool->isDeviceEventPoolAllocation));
memcpy_s(&eventPool->isHostVisibleEventPoolAllocation, sizeof(eventPool->isHostVisibleEventPoolAllocation),
hIpc.data + sizeof(int) + sizeof(numEvents) + sizeof(rootDeviceIndex) + sizeof(bool), sizeof(eventPool->isDeviceEventPoolAllocation));
auto device = Device::fromHandle(this->devices.begin()->second);
auto neoDevice = device->getNEODevice();
NEO::osHandle osHandle = static_cast<NEO::osHandle>(handle);
eventPool->initializeSizeParameters(this->numDevices, this->deviceHandles.data(), *this->driverHandle, neoDevice->getRootDeviceEnvironment());
NEO::AllocationType allocationType = NEO::AllocationType::BUFFER_HOST_MEMORY;
if (eventPool->isDeviceEventPoolAllocation) {
allocationType = NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER;
}
NEO::AllocationProperties unifiedMemoryProperties{rootDeviceIndex,
eventPool->getEventPoolSize(),
allocationType,
NEO::AllocationType::BUFFER_HOST_MEMORY,
systemMemoryBitfield};
unifiedMemoryProperties.subDevicesBitfield = neoDevice->getDeviceBitfield();
@@ -620,7 +603,7 @@ ze_result_t ContextImp::openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t
NEO::GraphicsAllocation *alloc = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle,
unifiedMemoryProperties,
false,
eventPool->isHostVisibleEventPoolAllocation,
true,
false);
if (alloc == nullptr) {

View File

@@ -48,7 +48,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uin
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(driver);
bool useDevicesFromApi = true;
this->isDeviceEventPoolAllocation = isEventPoolDeviceAllocationFlagSet();
bool useDeviceAlloc = isEventPoolDeviceAllocationFlagSet();
if (numDevices == 0) {
currentNumDevices = static_cast<uint32_t>(driverHandleImp->devices.size());
@@ -78,17 +78,17 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uin
auto &rootDeviceEnvironment = getDevice()->getNEODevice()->getRootDeviceEnvironment();
auto &l0GfxCoreHelper = rootDeviceEnvironment.getHelper<L0GfxCoreHelper>();
this->isDeviceEventPoolAllocation |= l0GfxCoreHelper.alwaysAllocateEventInLocalMem();
useDeviceAlloc |= l0GfxCoreHelper.alwaysAllocateEventInLocalMem();
initializeSizeParameters(numDevices, phDevices, *driverHandleImp, rootDeviceEnvironment);
NEO::AllocationType allocationType = isEventPoolTimestampFlagSet() ? NEO::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER
: NEO::AllocationType::BUFFER_HOST_MEMORY;
if (this->devices.size() > 1) {
this->isDeviceEventPoolAllocation = false;
useDeviceAlloc = false;
}
if (this->isDeviceEventPoolAllocation) {
if (useDeviceAlloc) {
allocationType = NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER;
}
@@ -96,9 +96,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, Context *context, uin
bool allocatedMemory = false;
this->isHostVisibleEventPoolAllocation = !(isEventPoolDeviceAllocationFlagSet());
if (this->isDeviceEventPoolAllocation) {
if (useDeviceAlloc) {
NEO::AllocationProperties allocationProperties{*rootDeviceIndices.begin(), this->eventPoolSize, allocationType, devices[0]->getNEODevice()->getDeviceBitfield()};
allocationProperties.alignment = eventAlignment;

View File

@@ -312,8 +312,6 @@ struct EventPool : _ze_event_pool_handle_t {
std::unique_ptr<NEO::MultiGraphicsAllocation> eventPoolAllocations;
ze_event_pool_flags_t eventPoolFlags;
bool isDeviceEventPoolAllocation = false;
bool isHostVisibleEventPoolAllocation = false;
protected:
EventPool() = default;

View File

@@ -343,90 +343,6 @@ TEST_F(EventPoolIPCHandleTests, whenGettingIpcHandleForEventPoolThenHandleAndNum
driverHandle->setMemoryManager(curMemoryManager);
}
TEST_F(EventPoolIPCHandleTests, whenGettingIpcHandleForEventPoolThenHandleAndIsHostVisibleAreReturnedInHandle) {
uint32_t numEvents = 4;
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr,
ZE_EVENT_POOL_FLAG_HOST_VISIBLE | ZE_EVENT_POOL_FLAG_IPC,
numEvents};
auto deviceHandle = device->toHandle();
ze_result_t result = ZE_RESULT_SUCCESS;
auto curMemoryManager = driverHandle->getMemoryManager();
MemoryManagerEventPoolIPCMock *mockMemoryManager = new MemoryManagerEventPoolIPCMock(*neoDevice->executionEnvironment);
driverHandle->setMemoryManager(mockMemoryManager);
auto eventPool = EventPool::create(driverHandle.get(), context, 1, &deviceHandle, &eventPoolDesc, result);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, eventPool);
ze_ipc_event_pool_handle_t ipcHandle = {};
ze_result_t res = eventPool->getIpcHandle(&ipcHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
int handle = -1;
memcpy_s(&handle, sizeof(int), ipcHandle.data, sizeof(int));
EXPECT_NE(handle, -1);
bool isHostVisible = 0;
memcpy_s(&isHostVisible, sizeof(isHostVisible), ipcHandle.data + sizeof(int) + sizeof(size_t) + sizeof(uint32_t) + sizeof(bool), sizeof(isHostVisible));
EXPECT_TRUE(isHostVisible);
res = eventPool->destroy();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
delete mockMemoryManager;
driverHandle->setMemoryManager(curMemoryManager);
}
TEST_F(EventPoolIPCHandleTests, whenGettingIpcHandleForEventPoolWithDeviceAllocThenHandleAndDeviceAllocAreReturnedInHandle) {
uint32_t numEvents = 4;
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr,
ZE_EVENT_POOL_FLAG_IPC,
numEvents};
auto deviceHandle = device->toHandle();
ze_result_t result = ZE_RESULT_SUCCESS;
auto curMemoryManager = driverHandle->getMemoryManager();
MemoryManagerEventPoolIPCMock *mockMemoryManager = new MemoryManagerEventPoolIPCMock(*neoDevice->executionEnvironment);
driverHandle->setMemoryManager(mockMemoryManager);
auto eventPool = EventPool::create(driverHandle.get(), context, 1, &deviceHandle, &eventPoolDesc, result);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, eventPool);
EXPECT_TRUE(eventPool->isDeviceEventPoolAllocation);
auto allocation = &eventPool->getAllocation();
EXPECT_EQ(allocation->getAllocationType(), NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER);
ze_ipc_event_pool_handle_t ipcHandle = {};
ze_result_t res = eventPool->getIpcHandle(&ipcHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
int handle = -1;
memcpy_s(&handle, sizeof(int), ipcHandle.data, sizeof(int));
EXPECT_NE(handle, -1);
uint32_t expectedNumEvents = 0;
memcpy_s(&expectedNumEvents, sizeof(expectedNumEvents), ipcHandle.data + sizeof(int), sizeof(expectedNumEvents));
EXPECT_EQ(numEvents, expectedNumEvents);
uint32_t rootDeviceIndex = 0;
memcpy_s(&rootDeviceIndex, sizeof(rootDeviceIndex), ipcHandle.data + sizeof(int) + sizeof(size_t), sizeof(rootDeviceIndex));
EXPECT_EQ(0u, rootDeviceIndex);
bool deviceAlloc = false;
memcpy_s(&deviceAlloc, sizeof(deviceAlloc), ipcHandle.data + sizeof(int) + sizeof(size_t) + sizeof(rootDeviceIndex), sizeof(deviceAlloc));
EXPECT_TRUE(deviceAlloc);
res = eventPool->destroy();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
delete mockMemoryManager;
driverHandle->setMemoryManager(curMemoryManager);
}
using EventPoolCreateMultiDevice = Test<MultiDeviceFixture>;
TEST_F(EventPoolCreateMultiDevice, whenGettingIpcHandleForEventPoolWhenHostShareableMemoryIsFalseThenUnsuportedIsReturned) {
@@ -498,94 +414,6 @@ TEST_F(EventPoolIPCHandleTests, whenOpeningIpcHandleForEventPoolThenEventPoolIsC
driverHandle->setMemoryManager(curMemoryManager);
}
TEST_F(EventPoolIPCHandleTests, whenOpeningIpcHandleForEventPoolWithHostVisibleThenEventPoolIsCreatedAndIsHostVisibleIsSet) {
uint32_t numEvents = 4;
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr,
ZE_EVENT_POOL_FLAG_HOST_VISIBLE | ZE_EVENT_POOL_FLAG_IPC,
numEvents};
auto deviceHandle = device->toHandle();
ze_result_t result = ZE_RESULT_SUCCESS;
auto curMemoryManager = driverHandle->getMemoryManager();
MemoryManagerEventPoolIPCMock *mockMemoryManager = new MemoryManagerEventPoolIPCMock(*neoDevice->executionEnvironment);
driverHandle->setMemoryManager(mockMemoryManager);
auto eventPool = EventPool::create(driverHandle.get(), context, 1, &deviceHandle, &eventPoolDesc, result);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, eventPool);
ze_ipc_event_pool_handle_t ipcHandle = {};
ze_result_t res = eventPool->getIpcHandle(&ipcHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
ze_event_pool_handle_t ipcEventPoolHandle = {};
res = context->openEventPoolIpcHandle(ipcHandle, &ipcEventPoolHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
auto ipcEventPool = static_cast<L0::EventPoolImp *>(L0::EventPool::fromHandle(ipcEventPoolHandle));
EXPECT_EQ(ipcEventPool->isHostVisibleEventPoolAllocation, eventPool->isHostVisibleEventPoolAllocation);
EXPECT_TRUE(ipcEventPool->isHostVisibleEventPoolAllocation);
res = ipcEventPool->closeIpcHandle();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
res = eventPool->destroy();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
delete mockMemoryManager;
driverHandle->setMemoryManager(curMemoryManager);
}
TEST_F(EventPoolIPCHandleTests, whenOpeningIpcHandleForEventPoolWithDeviceAllocThenEventPoolIsCreatedAsDeviceBufferAndDeviceAllocIsSet) {
uint32_t numEvents = 4;
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr,
ZE_EVENT_POOL_FLAG_IPC,
numEvents};
auto deviceHandle = device->toHandle();
ze_result_t result = ZE_RESULT_SUCCESS;
auto curMemoryManager = driverHandle->getMemoryManager();
MemoryManagerEventPoolIPCMock *mockMemoryManager = new MemoryManagerEventPoolIPCMock(*neoDevice->executionEnvironment);
driverHandle->setMemoryManager(mockMemoryManager);
auto eventPool = EventPool::create(driverHandle.get(), context, 1, &deviceHandle, &eventPoolDesc, result);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, eventPool);
ze_ipc_event_pool_handle_t ipcHandle = {};
ze_result_t res = eventPool->getIpcHandle(&ipcHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
ze_event_pool_handle_t ipcEventPoolHandle = {};
res = context->openEventPoolIpcHandle(ipcHandle, &ipcEventPoolHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
bool deviceAlloc = false;
memcpy_s(&deviceAlloc, sizeof(deviceAlloc), ipcHandle.data + sizeof(int) + sizeof(size_t) + sizeof(uint32_t), sizeof(deviceAlloc));
EXPECT_TRUE(deviceAlloc);
auto ipcEventPool = static_cast<L0::EventPoolImp *>(L0::EventPool::fromHandle(ipcEventPoolHandle));
EXPECT_TRUE(ipcEventPool->isDeviceEventPoolAllocation);
auto allocation = &ipcEventPool->getAllocation();
EXPECT_EQ(allocation->getAllocationType(), NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER);
EXPECT_EQ(ipcEventPool->getEventSize(), eventPool->getEventSize());
EXPECT_EQ(numEvents, static_cast<uint32_t>(ipcEventPool->getNumEvents()));
res = ipcEventPool->closeIpcHandle();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
res = eventPool->destroy();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
delete mockMemoryManager;
driverHandle->setMemoryManager(curMemoryManager);
}
TEST_F(EventPoolIPCHandleTests, GivenEventPoolWithIPCEventFlagAndDeviceMemoryThenShareableEventMemoryIsTrue) {
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,

View File

@@ -15,7 +15,6 @@ if(TESTS_XE_HPC_CORE)
${CMAKE_CURRENT_SOURCE_DIR}/test_module_xe_hpc_core.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xe_hpc_core_test_l0_fixtures.h
${CMAKE_CURRENT_SOURCE_DIR}/xe_hpc_core_test_l0_fixtures.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_event_xe_hpc_core.cpp
)
add_subdirectories()
endif()

View File

@@ -1,128 +0,0 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
namespace L0 {
namespace ult {
class MemoryManagerEventPoolIPCMock : public NEO::MockMemoryManager {
public:
MemoryManagerEventPoolIPCMock(NEO::ExecutionEnvironment &executionEnvironment) : NEO::MockMemoryManager(executionEnvironment) {}
void *createMultiGraphicsAllocationInSystemMemoryPool(RootDeviceIndicesContainer &rootDeviceIndices, AllocationProperties &properties, NEO::MultiGraphicsAllocation &multiGraphicsAllocation) override {
alloc = new NEO::MockGraphicsAllocation(&buffer, sizeof(buffer));
alloc->isShareableHostMemory = true;
multiGraphicsAllocation.addAllocation(alloc);
return reinterpret_cast<void *>(alloc->getUnderlyingBuffer());
};
char buffer[64];
NEO::MockGraphicsAllocation *alloc;
};
using EventPoolIPCHandleHpcCoreTests = Test<DeviceFixture>;
HWTEST2_F(EventPoolIPCHandleHpcCoreTests, whenGettingIpcHandleForEventPoolWithDeviceAllocThenHandleDeviceAllocAndIsHostVisibleAreReturnedInHandle, IsXeHpcCore) {
uint32_t numEvents = 4;
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr,
ZE_EVENT_POOL_FLAG_IPC | ZE_EVENT_POOL_FLAG_HOST_VISIBLE,
numEvents};
auto deviceHandle = device->toHandle();
ze_result_t result = ZE_RESULT_SUCCESS;
auto curMemoryManager = driverHandle->getMemoryManager();
MemoryManagerEventPoolIPCMock *mockMemoryManager = new MemoryManagerEventPoolIPCMock(*neoDevice->executionEnvironment);
driverHandle->setMemoryManager(mockMemoryManager);
auto eventPool = EventPool::create(driverHandle.get(), context, 1, &deviceHandle, &eventPoolDesc, result);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, eventPool);
EXPECT_TRUE(eventPool->isDeviceEventPoolAllocation);
auto allocation = &eventPool->getAllocation();
EXPECT_EQ(allocation->getAllocationType(), NEO::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER);
ze_ipc_event_pool_handle_t ipcHandle = {};
ze_result_t res = eventPool->getIpcHandle(&ipcHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
int handle = -1;
memcpy_s(&handle, sizeof(int), ipcHandle.data, sizeof(int));
EXPECT_NE(handle, -1);
uint32_t expectedNumEvents = 0;
memcpy_s(&expectedNumEvents, sizeof(expectedNumEvents), ipcHandle.data + sizeof(int), sizeof(expectedNumEvents));
EXPECT_EQ(numEvents, expectedNumEvents);
uint32_t rootDeviceIndex = 0;
memcpy_s(&rootDeviceIndex, sizeof(rootDeviceIndex), ipcHandle.data + sizeof(int) + sizeof(size_t), sizeof(rootDeviceIndex));
EXPECT_EQ(0u, rootDeviceIndex);
bool deviceAlloc = 0;
memcpy_s(&deviceAlloc, sizeof(deviceAlloc), ipcHandle.data + sizeof(int) + sizeof(size_t) + sizeof(rootDeviceIndex), sizeof(deviceAlloc));
EXPECT_TRUE(deviceAlloc);
bool isHostVisible = 0;
memcpy_s(&isHostVisible, sizeof(isHostVisible), ipcHandle.data + sizeof(int) + sizeof(size_t) + sizeof(rootDeviceIndex) + sizeof(bool), sizeof(isHostVisible));
EXPECT_TRUE(isHostVisible);
res = eventPool->destroy();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
delete mockMemoryManager;
driverHandle->setMemoryManager(curMemoryManager);
}
HWTEST2_F(EventPoolIPCHandleHpcCoreTests, whenOpeningIpcHandleForEventPoolWithHostVisibleThenEventPoolIsCreatedAsDeviceAndIsHostVisibleIsSet, IsXeHpcCore) {
uint32_t numEvents = 4;
ze_event_pool_desc_t eventPoolDesc = {
ZE_STRUCTURE_TYPE_EVENT_POOL_DESC,
nullptr,
ZE_EVENT_POOL_FLAG_HOST_VISIBLE | ZE_EVENT_POOL_FLAG_IPC,
numEvents};
auto deviceHandle = device->toHandle();
ze_result_t result = ZE_RESULT_SUCCESS;
auto curMemoryManager = driverHandle->getMemoryManager();
MemoryManagerEventPoolIPCMock *mockMemoryManager = new MemoryManagerEventPoolIPCMock(*neoDevice->executionEnvironment);
driverHandle->setMemoryManager(mockMemoryManager);
auto eventPool = EventPool::create(driverHandle.get(), context, 1, &deviceHandle, &eventPoolDesc, result);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, eventPool);
ze_ipc_event_pool_handle_t ipcHandle = {};
ze_result_t res = eventPool->getIpcHandle(&ipcHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
ze_event_pool_handle_t ipcEventPoolHandle = {};
res = context->openEventPoolIpcHandle(ipcHandle, &ipcEventPoolHandle);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
auto ipcEventPool = static_cast<L0::EventPoolImp *>(L0::EventPool::fromHandle(ipcEventPoolHandle));
EXPECT_EQ(ipcEventPool->isDeviceEventPoolAllocation, eventPool->isDeviceEventPoolAllocation);
EXPECT_TRUE(ipcEventPool->isDeviceEventPoolAllocation);
EXPECT_EQ(ipcEventPool->isHostVisibleEventPoolAllocation, eventPool->isHostVisibleEventPoolAllocation);
EXPECT_TRUE(ipcEventPool->isHostVisibleEventPoolAllocation);
res = ipcEventPool->closeIpcHandle();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
res = eventPool->destroy();
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
delete mockMemoryManager;
driverHandle->setMemoryManager(curMemoryManager);
}
} // namespace ult
} // namespace L0