|
14 | 14 | #include "level_zero/core/source/event/event.h" |
15 | 15 | #include "level_zero/core/test/unit_tests/fixtures/module_fixture.h" |
16 | 16 | #include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" |
| 17 | +#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" |
17 | 18 | #include "level_zero/core/test/unit_tests/mocks/mock_module.h" |
18 | 19 |
|
19 | 20 | namespace L0 { |
@@ -317,6 +318,74 @@ HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenAppendMemoryPrefetchForKmdMigr |
317 | 318 | commandList->destroy(); |
318 | 319 | } |
319 | 320 |
|
| 321 | +HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenAppendMemoryPrefetchForKmdMigratedSharedAllocationsSetWhenPrefetchApiIsCalledOnUnifiedSharedMemoryThenCallMigrateAllocationsToGpu, IsXeHpcCore) { |
| 322 | + using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily; |
| 323 | + using POSTSYNC_DATA = typename FamilyType::POSTSYNC_DATA; |
| 324 | + using WALKER_TYPE = typename FamilyType::WALKER_TYPE; |
| 325 | + |
| 326 | + DebugManagerStateRestore restore; |
| 327 | + DebugManager.flags.AppendMemoryPrefetchForKmdMigratedSharedAllocations.set(1); |
| 328 | + DebugManager.flags.UseKmdMigration.set(1); |
| 329 | + |
| 330 | + neoDevice->deviceBitfield = 0b1000; |
| 331 | + |
| 332 | + auto memoryManager = static_cast<MockMemoryManager *>(device->getDriverHandle()->getMemoryManager()); |
| 333 | + memoryManager->prefetchManager.reset(new MockPrefetchManager()); |
| 334 | + |
| 335 | + createKernel(); |
| 336 | + ze_result_t returnValue; |
| 337 | + ze_command_queue_desc_t queueDesc = {}; |
| 338 | + |
| 339 | + ze_command_list_handle_t commandListHandle = CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)->toHandle(); |
| 340 | + auto commandList = CommandList::fromHandle(commandListHandle); |
| 341 | + auto commandQueue = CommandQueue::create(productFamily, device, neoDevice->getDefaultEngine().commandStreamReceiver, &queueDesc, false, false, returnValue); |
| 342 | + |
| 343 | + ze_event_pool_desc_t eventPoolDesc = {}; |
| 344 | + eventPoolDesc.count = 1; |
| 345 | + eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP; |
| 346 | + |
| 347 | + ze_event_desc_t eventDesc = {}; |
| 348 | + eventDesc.index = 0; |
| 349 | + |
| 350 | + auto eventPool = std::unique_ptr<EventPool>(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, returnValue)); |
| 351 | + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); |
| 352 | + auto event = std::unique_ptr<Event>(Event::create<uint32_t>(eventPool.get(), &eventDesc, device)); |
| 353 | + |
| 354 | + size_t size = 10; |
| 355 | + size_t alignment = 1u; |
| 356 | + void *ptr = nullptr; |
| 357 | + |
| 358 | + ze_device_mem_alloc_desc_t deviceDesc = {}; |
| 359 | + ze_host_mem_alloc_desc_t hostDesc = {}; |
| 360 | + auto result = context->allocSharedMem(device->toHandle(), &deviceDesc, &hostDesc, size, alignment, &ptr); |
| 361 | + EXPECT_EQ(ZE_RESULT_SUCCESS, result); |
| 362 | + EXPECT_NE(nullptr, ptr); |
| 363 | + |
| 364 | + result = commandList->appendMemoryPrefetch(ptr, size); |
| 365 | + EXPECT_EQ(ZE_RESULT_SUCCESS, result); |
| 366 | + |
| 367 | + auto prefetchManager = static_cast<MockPrefetchManager *>(memoryManager->prefetchManager.get()); |
| 368 | + EXPECT_EQ(1u, prefetchManager->allocations.size()); |
| 369 | + |
| 370 | + ze_group_count_t groupCount{1, 1, 1}; |
| 371 | + CmdListKernelLaunchParams launchParams = {}; |
| 372 | + result = commandList->appendLaunchKernel(kernel->toHandle(), &groupCount, event->toHandle(), 0, nullptr, launchParams); |
| 373 | + EXPECT_EQ(ZE_RESULT_SUCCESS, result); |
| 374 | + |
| 375 | + result = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, true); |
| 376 | + EXPECT_EQ(ZE_RESULT_SUCCESS, result); |
| 377 | + |
| 378 | + EXPECT_TRUE(memoryManager->setMemPrefetchCalled); |
| 379 | + EXPECT_EQ(3u, memoryManager->memPrefetchSubDeviceId); |
| 380 | + |
| 381 | + EXPECT_TRUE(prefetchManager->migrateAllocationsToGpuCalled); |
| 382 | + EXPECT_EQ(0u, prefetchManager->allocations.size()); |
| 383 | + |
| 384 | + context->freeMem(ptr); |
| 385 | + commandList->destroy(); |
| 386 | + commandQueue->destroy(); |
| 387 | +} |
| 388 | + |
320 | 389 | using CommandListEventFenceTestsXeHpcCore = Test<ModuleFixture>; |
321 | 390 |
|
322 | 391 | HWTEST2_F(CommandListEventFenceTestsXeHpcCore, givenCommandListWithProfilingEventAfterCommandWhenRevId03ThenMiFenceIsAdded, IsXeHpcCore) { |
|
0 commit comments