Activate metric group for immediate command list

Related-To: LOCI-3518

Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@intel.com>
This commit is contained in:
Aravind Gopalakrishnan
2022-10-22 00:36:02 +00:00
committed by Compute-Runtime-Automation
parent 0ef6b9b64c
commit fcd0dd95a1
2 changed files with 196 additions and 0 deletions

View File

@@ -293,6 +293,198 @@ TEST_F(MetricQueryPoolTest, givenExecutionQueryTypeAndCompletionEventWhenAppendM
EXPECT_EQ(zeEventPoolDestroy(eventPoolHandle), ZE_RESULT_SUCCESS);
}
TEST_F(MetricQueryPoolTest, givenExecutionQueryTypeWithImmediateCommandListDefaultModeAndFlushTaskEnabledAndCompletionEventWhenAppendMetricQueryBeginAndEndIsCalledThenReturnSuccess) {
DebugManagerStateRestore restorer;
ze_result_t returnValue;
DebugManager.flags.EnableFlushTaskSubmission.set(1);
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_DEFAULT;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue));
zet_device_handle_t metricDevice = device->toHandle();
zet_metric_query_pool_handle_t poolHandle = {};
zet_metric_query_handle_t queryHandle = {};
zet_metric_query_pool_desc_t poolDesc = {};
poolDesc.stype = ZET_STRUCTURE_TYPE_METRIC_QUERY_POOL_DESC;
poolDesc.count = 1;
poolDesc.type = ZET_METRIC_QUERY_POOL_TYPE_EXECUTION;
ASSERT_EQ(ZE_RESULT_SUCCESS, returnValue);
ASSERT_NE(nullptr, commandList);
EXPECT_EQ(device, commandList->device);
EXPECT_EQ(CommandList::CommandListType::TYPE_IMMEDIATE, commandList->cmdListType);
EXPECT_NE(nullptr, commandList->cmdQImmediate);
zet_command_list_handle_t commandListHandle = commandList->toHandle();
TypedValue_1_0 value = {};
value.Type = ValueType::Uint32;
value.ValueUInt32 = 64;
QueryHandle_1_0 metricsLibraryQueryHandle = {&value};
ContextHandle_1_0 metricsLibraryContextHandle = {&value};
CommandBufferSize_1_0 commandBufferSize = {};
commandBufferSize.GpuMemorySize = 100;
EXPECT_CALL(*mockMetricEnumeration, isInitialized())
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*mockMetricsLibrary, getContextData(_, _))
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*mockMetricsLibrary, load())
.Times(0);
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextCreate(_, _, _))
.Times(1)
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), Return(StatusCode::Success)));
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
.Times(1)
.WillOnce(Return(StatusCode::Success));
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockCommandBufferGetSize(_, _))
.Times(2)
.WillRepeatedly(DoAll(::testing::SetArgPointee<1>(::testing::ByRef(commandBufferSize)), Return(StatusCode::Success)));
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockCommandBufferGet(_))
.Times(2)
.WillRepeatedly(Return(StatusCode::Success));
ze_event_pool_handle_t eventPoolHandle = {};
ze_event_pool_desc_t eventPoolDesc = {};
eventPoolDesc.count = 1;
eventPoolDesc.flags = 0;
eventPoolDesc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC;
ze_event_handle_t eventHandle = {};
ze_event_desc_t eventDesc = {};
eventDesc.index = 0;
eventDesc.stype = ZE_STRUCTURE_TYPE_EVENT_DESC;
eventDesc.wait = ZE_EVENT_SCOPE_FLAG_HOST;
eventDesc.signal = ZE_EVENT_SCOPE_FLAG_DEVICE;
EXPECT_EQ(zeEventPoolCreate(context->toHandle(), &eventPoolDesc, 1, &metricDevice, &eventPoolHandle), ZE_RESULT_SUCCESS);
EXPECT_NE(eventPoolHandle, nullptr);
EXPECT_EQ(zeEventCreate(eventPoolHandle, &eventDesc, &eventHandle), ZE_RESULT_SUCCESS);
EXPECT_NE(eventHandle, nullptr);
EXPECT_EQ(zetMetricQueryPoolCreate(context->toHandle(), metricDevice, nullptr, &poolDesc, &poolHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zetMetricQueryCreate(poolHandle, 0, &queryHandle), ZE_RESULT_SUCCESS);
EXPECT_NE(queryHandle, nullptr);
EXPECT_EQ(zetCommandListAppendMetricQueryBegin(commandListHandle, queryHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zetCommandListAppendMetricQueryEnd(commandListHandle, queryHandle, eventHandle, 0, nullptr), ZE_RESULT_SUCCESS);
EXPECT_EQ(zetMetricQueryDestroy(queryHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zetMetricQueryPoolDestroy(poolHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zeEventDestroy(eventHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zeEventPoolDestroy(eventPoolHandle), ZE_RESULT_SUCCESS);
}
TEST_F(MetricQueryPoolTest, givenExecutionQueryTypeWithImmediateCommandListDefaultModeAndFlushTaskDisabledAndCompletionEventWhenAppendMetricQueryBeginAndEndIsCalledThenReturnSuccess) {
DebugManagerStateRestore restorer;
ze_result_t returnValue;
DebugManager.flags.EnableFlushTaskSubmission.set(0);
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_DEFAULT;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue));
zet_device_handle_t metricDevice = device->toHandle();
zet_metric_query_pool_handle_t poolHandle = {};
zet_metric_query_handle_t queryHandle = {};
zet_metric_query_pool_desc_t poolDesc = {};
poolDesc.stype = ZET_STRUCTURE_TYPE_METRIC_QUERY_POOL_DESC;
poolDesc.count = 1;
poolDesc.type = ZET_METRIC_QUERY_POOL_TYPE_EXECUTION;
ASSERT_EQ(ZE_RESULT_SUCCESS, returnValue);
ASSERT_NE(nullptr, commandList);
EXPECT_EQ(device, commandList->device);
EXPECT_EQ(CommandList::CommandListType::TYPE_IMMEDIATE, commandList->cmdListType);
EXPECT_NE(nullptr, commandList->cmdQImmediate);
zet_command_list_handle_t commandListHandle = commandList->toHandle();
TypedValue_1_0 value = {};
value.Type = ValueType::Uint32;
value.ValueUInt32 = 64;
QueryHandle_1_0 metricsLibraryQueryHandle = {&value};
ContextHandle_1_0 metricsLibraryContextHandle = {&value};
CommandBufferSize_1_0 commandBufferSize = {};
commandBufferSize.GpuMemorySize = 100;
EXPECT_CALL(*mockMetricEnumeration, isInitialized())
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*mockMetricsLibrary, getContextData(_, _))
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*mockMetricsLibrary, load())
.Times(0);
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextCreate(_, _, _))
.Times(1)
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), Return(StatusCode::Success)));
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
.Times(1)
.WillOnce(Return(StatusCode::Success));
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockCommandBufferGetSize(_, _))
.Times(2)
.WillRepeatedly(DoAll(::testing::SetArgPointee<1>(::testing::ByRef(commandBufferSize)), Return(StatusCode::Success)));
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockCommandBufferGet(_))
.Times(2)
.WillRepeatedly(Return(StatusCode::Success));
ze_event_pool_handle_t eventPoolHandle = {};
ze_event_pool_desc_t eventPoolDesc = {};
eventPoolDesc.count = 1;
eventPoolDesc.flags = 0;
eventPoolDesc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC;
ze_event_handle_t eventHandle = {};
ze_event_desc_t eventDesc = {};
eventDesc.index = 0;
eventDesc.stype = ZE_STRUCTURE_TYPE_EVENT_DESC;
eventDesc.wait = ZE_EVENT_SCOPE_FLAG_HOST;
eventDesc.signal = ZE_EVENT_SCOPE_FLAG_DEVICE;
EXPECT_EQ(zeEventPoolCreate(context->toHandle(), &eventPoolDesc, 1, &metricDevice, &eventPoolHandle), ZE_RESULT_SUCCESS);
EXPECT_NE(eventPoolHandle, nullptr);
EXPECT_EQ(zeEventCreate(eventPoolHandle, &eventDesc, &eventHandle), ZE_RESULT_SUCCESS);
EXPECT_NE(eventHandle, nullptr);
EXPECT_EQ(zetMetricQueryPoolCreate(context->toHandle(), metricDevice, nullptr, &poolDesc, &poolHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zetMetricQueryCreate(poolHandle, 0, &queryHandle), ZE_RESULT_SUCCESS);
EXPECT_NE(queryHandle, nullptr);
EXPECT_EQ(zetCommandListAppendMetricQueryBegin(commandListHandle, queryHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zetCommandListAppendMetricQueryEnd(commandListHandle, queryHandle, eventHandle, 0, nullptr), ZE_RESULT_SUCCESS);
EXPECT_EQ(zetMetricQueryDestroy(queryHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zetMetricQueryPoolDestroy(poolHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zeEventDestroy(eventHandle), ZE_RESULT_SUCCESS);
EXPECT_EQ(zeEventPoolDestroy(eventPoolHandle), ZE_RESULT_SUCCESS);
}
TEST_F(MetricQueryPoolTest, givenExecutionQueryTypeAndMetricsLibraryWillFailWhenAppendMetricQueryBeginAndEndIsCalledThenReturnFail) {
zet_device_handle_t metricDevice = device->toHandle();