diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index c692de05d1..f9cdb7a7ec 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -2839,6 +2839,7 @@ ze_result_t CommandListCoreFamily::appendQueryKernelTimestamps( auto dstAllocationType = dstPtrAllocationStruct.alloc->getAllocationType(); CmdListKernelLaunchParams launchParams = {}; launchParams.isBuiltInKernel = true; + launchParams.isCooperative = containsCooperativeKernelsFlag; launchParams.isDestinationAllocationInSystemMemory = (dstAllocationType == NEO::AllocationType::bufferHostMemory) || (dstAllocationType == NEO::AllocationType::externalHostPtr); diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp index 3bf358c7c9..dba42f473a 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_3.cpp @@ -485,6 +485,73 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenKernelUsingSyncBufferWhenAppendLau } } +HWTEST2_F(CommandListAppendLaunchKernel, whenAppendLaunchCooperativeKernelAndQueryKernelTimestampsToTheSameCmdlistThenFronEndStateIsNotChanged, IsAtLeastSkl) { + Mock<::L0::KernelImp> kernel; + auto pMockModule = std::unique_ptr(new Mock(device, nullptr)); + kernel.module = pMockModule.get(); + + kernel.setGroupSize(4, 1, 1); + ze_group_count_t groupCount{8, 1, 1}; + + auto &kernelAttributes = kernel.immutableData.kernelDescriptor->kernelAttributes; + kernelAttributes.flags.usesSyncBuffer = true; + kernelAttributes.numGrfRequired = GrfConfig::defaultGrfNumber; + + auto pCommandList = std::make_unique>>(); + auto &productHelper = device->getProductHelper(); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + auto engineGroupType = NEO::EngineGroupType::compute; + if (productHelper.isCooperativeEngineSupported(*defaultHwInfo)) { + engineGroupType = gfxCoreHelper.getEngineGroupType(aub_stream::EngineType::ENGINE_CCS, EngineUsage::cooperative, *defaultHwInfo); + } + pCommandList->initialize(device, engineGroupType, 0u); + + ze_event_pool_desc_t eventPoolDesc = {}; + eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP; + eventPoolDesc.count = 1; + + ze_event_desc_t eventDesc = {}; + eventDesc.index = 0; + + ze_result_t returnValue = ZE_RESULT_ERROR_NOT_AVAILABLE; + + auto eventPool = std::unique_ptr(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, returnValue)); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + auto event = std::unique_ptr(Event::create(eventPool.get(), &eventDesc, device)); + returnValue = pCommandList->appendLaunchCooperativeKernel(kernel.toHandle(), groupCount, event->toHandle(), 0, nullptr, false); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + + void *alloc; + ze_device_mem_alloc_desc_t deviceDesc = {}; + auto result = context->allocDeviceMem(device, &deviceDesc, 128, 1, &alloc); + EXPECT_EQ(result, ZE_RESULT_SUCCESS); + auto eventHandle = event->toHandle(); + + result = pCommandList->appendQueryKernelTimestamps(1u, &eventHandle, alloc, nullptr, nullptr, 1u, &eventHandle); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + pCommandList->close(); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(pCommandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), pCommandList->getCmdContainer().getCommandStream()->getUsed())); + + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(itor, cmdList.end()); + auto firstWalker = itor; + + itor++; + itor = find(itor, cmdList.end()); + EXPECT_NE(itor, cmdList.end()); + + auto secondWalker = itor; + itor = find(firstWalker, secondWalker); + + EXPECT_EQ(itor, secondWalker); + + context->freeMem(alloc); +} + HWTEST2_F(CommandListAppendLaunchKernel, givenDisableOverdispatchPropertyWhenUpdateStreamPropertiesIsCalledThenRequiredStateAndFinalStateAreCorrectlySet, IsAtLeastSkl) { Mock<::L0::KernelImp> kernel; auto pMockModule = std::unique_ptr(new Mock(device, nullptr));