Add unit test for append memory prefetch for regular command list

Related-To: NEO-6740

Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2022-08-04 01:45:19 +00:00
committed by Compute-Runtime-Automation
parent 3de620af15
commit 601ace6a25
3 changed files with 78 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
#include "level_zero/core/source/event/event.h"
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
#include "level_zero/core/test/unit_tests/mocks/mock_module.h"
namespace L0 {
@@ -317,6 +318,74 @@ HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenAppendMemoryPrefetchForKmdMigr
commandList->destroy();
}
HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenAppendMemoryPrefetchForKmdMigratedSharedAllocationsSetWhenPrefetchApiIsCalledOnUnifiedSharedMemoryThenCallMigrateAllocationsToGpu, IsXeHpcCore) {
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
using POSTSYNC_DATA = typename FamilyType::POSTSYNC_DATA;
using WALKER_TYPE = typename FamilyType::WALKER_TYPE;
DebugManagerStateRestore restore;
DebugManager.flags.AppendMemoryPrefetchForKmdMigratedSharedAllocations.set(1);
DebugManager.flags.UseKmdMigration.set(1);
neoDevice->deviceBitfield = 0b1000;
auto memoryManager = static_cast<MockMemoryManager *>(device->getDriverHandle()->getMemoryManager());
memoryManager->prefetchManager.reset(new MockPrefetchManager());
createKernel();
ze_result_t returnValue;
ze_command_queue_desc_t queueDesc = {};
ze_command_list_handle_t commandListHandle = CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)->toHandle();
auto commandList = CommandList::fromHandle(commandListHandle);
auto commandQueue = CommandQueue::create(productFamily, device, neoDevice->getDefaultEngine().commandStreamReceiver, &queueDesc, false, false, returnValue);
ze_event_pool_desc_t eventPoolDesc = {};
eventPoolDesc.count = 1;
eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP;
ze_event_desc_t eventDesc = {};
eventDesc.index = 0;
auto eventPool = std::unique_ptr<EventPool>(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, returnValue));
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
auto event = std::unique_ptr<Event>(Event::create<uint32_t>(eventPool.get(), &eventDesc, device));
size_t size = 10;
size_t alignment = 1u;
void *ptr = nullptr;
ze_device_mem_alloc_desc_t deviceDesc = {};
ze_host_mem_alloc_desc_t hostDesc = {};
auto result = context->allocSharedMem(device->toHandle(), &deviceDesc, &hostDesc, size, alignment, &ptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, ptr);
result = commandList->appendMemoryPrefetch(ptr, size);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
auto prefetchManager = static_cast<MockPrefetchManager *>(memoryManager->prefetchManager.get());
EXPECT_EQ(1u, prefetchManager->allocations.size());
ze_group_count_t groupCount{1, 1, 1};
CmdListKernelLaunchParams launchParams = {};
result = commandList->appendLaunchKernel(kernel->toHandle(), &groupCount, event->toHandle(), 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
result = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, true);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_TRUE(memoryManager->setMemPrefetchCalled);
EXPECT_EQ(3u, memoryManager->memPrefetchSubDeviceId);
EXPECT_TRUE(prefetchManager->migrateAllocationsToGpuCalled);
EXPECT_EQ(0u, prefetchManager->allocations.size());
context->freeMem(ptr);
commandList->destroy();
commandQueue->destroy();
}
using CommandListEventFenceTestsXeHpcCore = Test<ModuleFixture>;
HWTEST2_F(CommandListEventFenceTestsXeHpcCore, givenCommandListWithProfilingEventAfterCommandWhenRevId03ThenMiFenceIsAdded, IsXeHpcCore) {