@@ -934,6 +934,102 @@ HWTEST_F(CommandQueueIndirectAllocations, givenDeviceThatSupportsSubmittingIndir
934934 commandQueue->destroy ();
935935}
936936
937+ HWTEST_F (CommandQueueIndirectAllocations, givenDeviceThatSupportsSubmittingIndirectAllocationsAsPackWhenIndirectAccessIsUsedThenWholePackIsMadeResidentWithImmediateCommandListAndFlushTask) {
938+ DebugManagerStateRestore restorer;
939+ NEO::DebugManager.flags .EnableFlushTaskSubmission .set (true );
940+
941+ MockCsrHw2<FamilyType> csr (*neoDevice->getExecutionEnvironment (), 0 , neoDevice->getDeviceBitfield ());
942+ csr.initializeTagAllocation ();
943+ csr.setupContext (*neoDevice->getDefaultEngine ().osContext );
944+
945+ ze_result_t returnValue;
946+ ze_command_queue_desc_t desc = {};
947+ desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
948+ std::unique_ptr<L0::CommandList> commandList (CommandList::createImmediate (productFamily,
949+ device,
950+ &desc,
951+ false ,
952+ NEO::EngineGroupType::Compute,
953+ returnValue));
954+ ASSERT_NE (nullptr , commandList);
955+ EXPECT_EQ (1u , commandList->cmdListType );
956+ EXPECT_NE (nullptr , commandList->cmdQImmediate );
957+
958+ void *deviceAlloc = nullptr ;
959+ ze_device_mem_alloc_desc_t deviceDesc = {};
960+ auto result = context->allocDeviceMem (device->toHandle (), &deviceDesc, 16384u , 4096u , &deviceAlloc);
961+ ASSERT_EQ (ZE_RESULT_SUCCESS, result);
962+
963+ auto gpuAlloc = device->getDriverHandle ()->getSvmAllocsManager ()->getSVMAllocs ()->get (deviceAlloc)->gpuAllocations .getGraphicsAllocation (device->getRootDeviceIndex ());
964+ ASSERT_NE (nullptr , gpuAlloc);
965+
966+ createKernel ();
967+ kernel->unifiedMemoryControls .indirectDeviceAllocationsAllowed = true ;
968+ EXPECT_TRUE (kernel->getUnifiedMemoryControls ().indirectDeviceAllocationsAllowed );
969+
970+ static_cast <MockMemoryManager *>(driverHandle.get ()->getMemoryManager ())->overrideAllocateAsPackReturn = 1u ;
971+
972+ ze_group_count_t groupCount{1 , 1 , 1 };
973+ result = commandList->appendLaunchKernel (kernel->toHandle (),
974+ &groupCount,
975+ nullptr ,
976+ 0 ,
977+ nullptr );
978+ ASSERT_EQ (ZE_RESULT_SUCCESS, result);
979+
980+ EXPECT_TRUE (gpuAlloc->isResident (csr.getOsContext ().getContextId ()));
981+ EXPECT_EQ (GraphicsAllocation::objectAlwaysResident, gpuAlloc->getResidencyTaskCount (csr.getOsContext ().getContextId ()));
982+
983+ device->getDriverHandle ()->getSvmAllocsManager ()->freeSVMAlloc (deviceAlloc);
984+ }
985+
986+ HWTEST_F (CommandQueueIndirectAllocations, givenImmediateCommandListAndFlushTaskWithIndirectAllocsAsPackDisabledThenLaunchKernelWorks) {
987+ DebugManagerStateRestore restorer;
988+ NEO::DebugManager.flags .EnableFlushTaskSubmission .set (true );
989+ NEO::DebugManager.flags .MakeIndirectAllocationsResidentAsPack .set (0 );
990+
991+ MockCsrHw2<FamilyType> csr (*neoDevice->getExecutionEnvironment (), 0 , neoDevice->getDeviceBitfield ());
992+ csr.initializeTagAllocation ();
993+ csr.setupContext (*neoDevice->getDefaultEngine ().osContext );
994+
995+ ze_result_t returnValue;
996+ ze_command_queue_desc_t desc = {};
997+ desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
998+ std::unique_ptr<L0::CommandList> commandList (CommandList::createImmediate (productFamily,
999+ device,
1000+ &desc,
1001+ false ,
1002+ NEO::EngineGroupType::Compute,
1003+ returnValue));
1004+ ASSERT_NE (nullptr , commandList);
1005+ EXPECT_EQ (1u , commandList->cmdListType );
1006+ EXPECT_NE (nullptr , commandList->cmdQImmediate );
1007+
1008+ void *deviceAlloc = nullptr ;
1009+ ze_device_mem_alloc_desc_t deviceDesc = {};
1010+ auto result = context->allocDeviceMem (device->toHandle (), &deviceDesc, 16384u , 4096u , &deviceAlloc);
1011+ ASSERT_EQ (ZE_RESULT_SUCCESS, result);
1012+
1013+ auto gpuAlloc = device->getDriverHandle ()->getSvmAllocsManager ()->getSVMAllocs ()->get (deviceAlloc)->gpuAllocations .getGraphicsAllocation (device->getRootDeviceIndex ());
1014+ ASSERT_NE (nullptr , gpuAlloc);
1015+
1016+ createKernel ();
1017+ kernel->unifiedMemoryControls .indirectDeviceAllocationsAllowed = true ;
1018+ EXPECT_TRUE (kernel->getUnifiedMemoryControls ().indirectDeviceAllocationsAllowed );
1019+
1020+ static_cast <MockMemoryManager *>(driverHandle.get ()->getMemoryManager ())->overrideAllocateAsPackReturn = 1u ;
1021+
1022+ ze_group_count_t groupCount{1 , 1 , 1 };
1023+ result = commandList->appendLaunchKernel (kernel->toHandle (),
1024+ &groupCount,
1025+ nullptr ,
1026+ 0 ,
1027+ nullptr );
1028+ ASSERT_EQ (ZE_RESULT_SUCCESS, result);
1029+
1030+ device->getDriverHandle ()->getSvmAllocsManager ()->freeSVMAlloc (deviceAlloc);
1031+ }
1032+
9371033using DeviceCreateCommandQueueTest = Test<DeviceFixture>;
9381034TEST_F (DeviceCreateCommandQueueTest, givenLowPriorityDescWhenCreateCommandQueueIsCalledThenLowPriorityCsrIsAssigned) {
9391035 ze_command_queue_desc_t desc{};
0 commit comments