|
|
|
|
@@ -444,8 +444,8 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetCommandListAppendMetricQ
|
|
|
|
|
|
|
|
|
|
zet_device_handle_t metricDevice = device->toHandle();
|
|
|
|
|
|
|
|
|
|
MockCommandList commandList;
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList.toHandle();
|
|
|
|
|
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList->toHandle();
|
|
|
|
|
|
|
|
|
|
Mock<MetricGroup> metricGroup;
|
|
|
|
|
zet_metric_group_properties_t metricGroupProperties = {};
|
|
|
|
|
@@ -465,6 +465,9 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetCommandListAppendMetricQ
|
|
|
|
|
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));
|
|
|
|
|
@@ -496,6 +499,14 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetCommandListAppendMetricQ
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockCommandBufferGetSize(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<1>(::testing::ByRef(commandBufferSize)), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockCommandBufferGet(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
@@ -592,8 +603,8 @@ TEST_F(MetricQueryPoolTest, givenIncorrectArgumentsWhenZetCommandListAppendMetri
|
|
|
|
|
zet_device_handle_t metricDevice = device->toHandle();
|
|
|
|
|
zet_driver_handle_t driver = driverHandle->toHandle();
|
|
|
|
|
|
|
|
|
|
MockCommandList commandList;
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList.toHandle();
|
|
|
|
|
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList->toHandle();
|
|
|
|
|
|
|
|
|
|
ze_event_pool_handle_t eventPoolHandle = {};
|
|
|
|
|
ze_event_pool_desc_t eventPoolDesc = {};
|
|
|
|
|
@@ -626,6 +637,9 @@ TEST_F(MetricQueryPoolTest, givenIncorrectArgumentsWhenZetCommandListAppendMetri
|
|
|
|
|
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));
|
|
|
|
|
@@ -657,6 +671,14 @@ TEST_F(MetricQueryPoolTest, givenIncorrectArgumentsWhenZetCommandListAppendMetri
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockCommandBufferGetSize(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<1>(::testing::ByRef(commandBufferSize)), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockCommandBufferGet(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
@@ -692,8 +714,8 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetCommandListAppendMetricQ
|
|
|
|
|
zet_device_handle_t metricDevice = device->toHandle();
|
|
|
|
|
zet_driver_handle_t driver = driverHandle->toHandle();
|
|
|
|
|
|
|
|
|
|
MockCommandList commandList;
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList.toHandle();
|
|
|
|
|
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList->toHandle();
|
|
|
|
|
|
|
|
|
|
ze_event_pool_handle_t eventPoolHandle = {};
|
|
|
|
|
ze_event_pool_desc_t eventPoolDesc = {};
|
|
|
|
|
@@ -726,6 +748,9 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetCommandListAppendMetricQ
|
|
|
|
|
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));
|
|
|
|
|
@@ -757,6 +782,14 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetCommandListAppendMetricQ
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), 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));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
@@ -792,13 +825,129 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetCommandListAppendMetricQ
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolDestroy(poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetCommandListAppendMetricQueryEndExtIsCalledThenReturnsSuccess) {
|
|
|
|
|
|
|
|
|
|
zet_device_handle_t metricDevice = device->toHandle();
|
|
|
|
|
zet_driver_handle_t driver = driverHandle->toHandle();
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList->toHandle();
|
|
|
|
|
|
|
|
|
|
ze_event_pool_handle_t eventPoolHandle = {};
|
|
|
|
|
ze_event_pool_desc_t eventPoolDesc = {};
|
|
|
|
|
eventPoolDesc.count = 1;
|
|
|
|
|
eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_DEFAULT;
|
|
|
|
|
eventPoolDesc.version = ZE_EVENT_POOL_DESC_VERSION_CURRENT;
|
|
|
|
|
|
|
|
|
|
ze_event_handle_t eventHandle = {};
|
|
|
|
|
ze_event_desc_t eventDesc = {};
|
|
|
|
|
eventDesc.index = 0;
|
|
|
|
|
eventDesc.version = ZE_EVENT_DESC_VERSION_CURRENT;
|
|
|
|
|
eventDesc.wait = ZE_EVENT_SCOPE_FLAG_HOST;
|
|
|
|
|
eventDesc.signal = ZE_EVENT_SCOPE_FLAG_DEVICE;
|
|
|
|
|
|
|
|
|
|
Mock<MetricGroup> metricGroup;
|
|
|
|
|
zet_metric_group_properties_t metricGroupProperties = {};
|
|
|
|
|
metricGroupProperties.samplingType = ZET_METRIC_GROUP_SAMPLING_TYPE_EVENT_BASED;
|
|
|
|
|
|
|
|
|
|
zet_metric_query_handle_t queryHandle = {};
|
|
|
|
|
zet_metric_query_pool_handle_t poolHandle = {};
|
|
|
|
|
zet_metric_query_pool_desc_t poolDesc = {};
|
|
|
|
|
poolDesc.version = ZET_METRIC_QUERY_POOL_DESC_VERSION_CURRENT;
|
|
|
|
|
poolDesc.count = 1;
|
|
|
|
|
poolDesc.flags = ZET_METRIC_QUERY_POOL_FLAG_PERFORMANCE;
|
|
|
|
|
|
|
|
|
|
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(metricGroup, getProperties(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<0>(metricGroupProperties), Return(ZE_RESULT_SUCCESS)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockQueryCreate(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<1>(metricsLibraryQueryHandle), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockQueryDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockGetParameter(_, _, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(value), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextCreate(_, _, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), 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));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
// Create metric query pool.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolCreate(metricDevice, metricGroup.toHandle(), &poolDesc, &poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(poolHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create metric query.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryCreate(poolHandle, 0, &queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(queryHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create event pool.
|
|
|
|
|
EXPECT_EQ(zeEventPoolCreate(driver, &eventPoolDesc, 1, &metricDevice, &eventPoolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(eventPoolHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create event.
|
|
|
|
|
EXPECT_EQ(zeEventCreate(eventPoolHandle, &eventDesc, &eventHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(eventHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Write BEGIN metric query to command list.
|
|
|
|
|
EXPECT_EQ(zetCommandListAppendMetricQueryBegin(commandListHandle, queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Write END metric query to command list, use an event to determine if the data is available.
|
|
|
|
|
EXPECT_EQ(zetCommandListAppendMetricQueryEndExt(commandListHandle, queryHandle, eventHandle, 0, nullptr), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Destroy event and its pool.
|
|
|
|
|
EXPECT_EQ(zeEventDestroy(eventHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_EQ(zeEventPoolDestroy(eventPoolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Destroy query and its pool.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryDestroy(queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolDestroy(poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MetricQueryPoolTest, givenIncorrectArgumentsWhenZetMetricQueryGetDataIsCalledThenReturnsFail) {
|
|
|
|
|
|
|
|
|
|
zet_device_handle_t metricDevice = device->toHandle();
|
|
|
|
|
zet_driver_handle_t driver = driverHandle->toHandle();
|
|
|
|
|
|
|
|
|
|
MockCommandList commandList;
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList.toHandle();
|
|
|
|
|
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList->toHandle();
|
|
|
|
|
|
|
|
|
|
ze_event_pool_handle_t eventPoolHandle = {};
|
|
|
|
|
ze_event_pool_desc_t eventPoolDesc = {};
|
|
|
|
|
@@ -831,6 +980,9 @@ TEST_F(MetricQueryPoolTest, givenIncorrectArgumentsWhenZetMetricQueryGetDataIsCa
|
|
|
|
|
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));
|
|
|
|
|
@@ -862,6 +1014,14 @@ TEST_F(MetricQueryPoolTest, givenIncorrectArgumentsWhenZetMetricQueryGetDataIsCa
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), 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));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
@@ -897,13 +1057,129 @@ TEST_F(MetricQueryPoolTest, givenIncorrectArgumentsWhenZetMetricQueryGetDataIsCa
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolDestroy(poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MetricQueryPoolTest, givenIncorrectArgumentsWhenZetMetricQueryGetDataIsCalledThenReturnsFailExt) {
|
|
|
|
|
|
|
|
|
|
zet_device_handle_t metricDevice = device->toHandle();
|
|
|
|
|
zet_driver_handle_t driver = driverHandle->toHandle();
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList->toHandle();
|
|
|
|
|
|
|
|
|
|
ze_event_pool_handle_t eventPoolHandle = {};
|
|
|
|
|
ze_event_pool_desc_t eventPoolDesc = {};
|
|
|
|
|
eventPoolDesc.count = 1;
|
|
|
|
|
eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_DEFAULT;
|
|
|
|
|
eventPoolDesc.version = ZE_EVENT_POOL_DESC_VERSION_CURRENT;
|
|
|
|
|
|
|
|
|
|
ze_event_handle_t eventHandle = {};
|
|
|
|
|
ze_event_desc_t eventDesc = {};
|
|
|
|
|
eventDesc.index = 0;
|
|
|
|
|
eventDesc.version = ZE_EVENT_DESC_VERSION_CURRENT;
|
|
|
|
|
eventDesc.wait = ZE_EVENT_SCOPE_FLAG_HOST;
|
|
|
|
|
eventDesc.signal = ZE_EVENT_SCOPE_FLAG_DEVICE;
|
|
|
|
|
|
|
|
|
|
Mock<MetricGroup> metricGroup;
|
|
|
|
|
zet_metric_group_properties_t metricGroupProperties = {};
|
|
|
|
|
metricGroupProperties.samplingType = ZET_METRIC_GROUP_SAMPLING_TYPE_EVENT_BASED;
|
|
|
|
|
|
|
|
|
|
zet_metric_query_handle_t queryHandle = {};
|
|
|
|
|
zet_metric_query_pool_handle_t poolHandle = {};
|
|
|
|
|
zet_metric_query_pool_desc_t poolDesc = {};
|
|
|
|
|
poolDesc.version = ZET_METRIC_QUERY_POOL_DESC_VERSION_CURRENT;
|
|
|
|
|
poolDesc.count = 1;
|
|
|
|
|
poolDesc.flags = ZET_METRIC_QUERY_POOL_FLAG_PERFORMANCE;
|
|
|
|
|
|
|
|
|
|
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(metricGroup, getProperties(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<0>(metricGroupProperties), Return(ZE_RESULT_SUCCESS)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockQueryCreate(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<1>(metricsLibraryQueryHandle), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockQueryDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockGetParameter(_, _, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(value), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextCreate(_, _, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), 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));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
// Create metric query pool.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolCreate(metricDevice, metricGroup.toHandle(), &poolDesc, &poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(poolHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create metric query.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryCreate(poolHandle, 0, &queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(queryHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create event pool.
|
|
|
|
|
EXPECT_EQ(zeEventPoolCreate(driver, &eventPoolDesc, 1, &metricDevice, &eventPoolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(eventPoolHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create event.
|
|
|
|
|
EXPECT_EQ(zeEventCreate(eventPoolHandle, &eventDesc, &eventHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(eventHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Write BEGIN metric query to command list.
|
|
|
|
|
EXPECT_EQ(zetCommandListAppendMetricQueryBegin(commandListHandle, queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Write END metric query to command list, use an event to determine if the data is available.
|
|
|
|
|
EXPECT_EQ(zetCommandListAppendMetricQueryEndExt(commandListHandle, queryHandle, eventHandle, 0, nullptr), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Destroy event and its pool.
|
|
|
|
|
EXPECT_EQ(zeEventDestroy(eventHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_EQ(zeEventPoolDestroy(eventPoolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Destroy query and its pool.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryDestroy(queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolDestroy(poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetMetricQueryGetDataIsCalledThenReturnsSuccess) {
|
|
|
|
|
|
|
|
|
|
zet_device_handle_t metricDevice = device->toHandle();
|
|
|
|
|
zet_driver_handle_t driver = driverHandle->toHandle();
|
|
|
|
|
|
|
|
|
|
MockCommandList commandList;
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList.toHandle();
|
|
|
|
|
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList->toHandle();
|
|
|
|
|
|
|
|
|
|
ze_event_pool_handle_t eventPoolHandle = {};
|
|
|
|
|
ze_event_pool_desc_t eventPoolDesc = {};
|
|
|
|
|
@@ -938,6 +1214,9 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetMetricQueryGetDataIsCall
|
|
|
|
|
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));
|
|
|
|
|
@@ -969,6 +1248,14 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetMetricQueryGetDataIsCall
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), 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));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary, getMetricQueryReportSize(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgReferee<0>(reportSize), Return(true)));
|
|
|
|
|
@@ -1021,5 +1308,140 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetMetricQueryGetDataIsCall
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolDestroy(poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenZetMetricQueryGetDataIsCalledThenReturnsSuccessExt) {
|
|
|
|
|
|
|
|
|
|
zet_device_handle_t metricDevice = device->toHandle();
|
|
|
|
|
zet_driver_handle_t driver = driverHandle->toHandle();
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
|
|
|
|
zet_command_list_handle_t commandListHandle = commandList->toHandle();
|
|
|
|
|
|
|
|
|
|
ze_event_pool_handle_t eventPoolHandle = {};
|
|
|
|
|
ze_event_pool_desc_t eventPoolDesc = {};
|
|
|
|
|
eventPoolDesc.count = 1;
|
|
|
|
|
eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_DEFAULT;
|
|
|
|
|
eventPoolDesc.version = ZE_EVENT_POOL_DESC_VERSION_CURRENT;
|
|
|
|
|
|
|
|
|
|
ze_event_handle_t eventHandle = {};
|
|
|
|
|
ze_event_desc_t eventDesc = {};
|
|
|
|
|
eventDesc.index = 0;
|
|
|
|
|
eventDesc.version = ZE_EVENT_DESC_VERSION_CURRENT;
|
|
|
|
|
eventDesc.wait = ZE_EVENT_SCOPE_FLAG_HOST;
|
|
|
|
|
eventDesc.signal = ZE_EVENT_SCOPE_FLAG_DEVICE;
|
|
|
|
|
|
|
|
|
|
Mock<MetricGroup> metricGroup;
|
|
|
|
|
zet_metric_group_properties_t metricGroupProperties = {};
|
|
|
|
|
metricGroupProperties.samplingType = ZET_METRIC_GROUP_SAMPLING_TYPE_EVENT_BASED;
|
|
|
|
|
|
|
|
|
|
zet_metric_query_handle_t queryHandle = {};
|
|
|
|
|
zet_metric_query_pool_handle_t poolHandle = {};
|
|
|
|
|
zet_metric_query_pool_desc_t poolDesc = {};
|
|
|
|
|
poolDesc.version = ZET_METRIC_QUERY_POOL_DESC_VERSION_CURRENT;
|
|
|
|
|
poolDesc.count = 1;
|
|
|
|
|
poolDesc.flags = ZET_METRIC_QUERY_POOL_FLAG_PERFORMANCE;
|
|
|
|
|
|
|
|
|
|
TypedValue_1_0 value = {};
|
|
|
|
|
value.Type = ValueType::Uint32;
|
|
|
|
|
value.ValueUInt32 = 64;
|
|
|
|
|
|
|
|
|
|
size_t reportSize = 256;
|
|
|
|
|
|
|
|
|
|
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(metricGroup, getProperties(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<0>(metricGroupProperties), Return(ZE_RESULT_SUCCESS)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockQueryCreate(_, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<1>(metricsLibraryQueryHandle), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockQueryDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockGetParameter(_, _, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(value), Return(StatusCode::Success)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextCreate(_, _, _))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgPointee<2>(metricsLibraryContextHandle), 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));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary, getMetricQueryReportSize(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(DoAll(::testing::SetArgReferee<0>(reportSize), Return(true)));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockGetData(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextDelete(_))
|
|
|
|
|
.Times(1)
|
|
|
|
|
.WillOnce(Return(StatusCode::Success));
|
|
|
|
|
|
|
|
|
|
// Create metric query pool.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolCreate(metricDevice, metricGroup.toHandle(), &poolDesc, &poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(poolHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create metric query.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryCreate(poolHandle, 0, &queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(queryHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create event pool.
|
|
|
|
|
EXPECT_EQ(zeEventPoolCreate(driver, &eventPoolDesc, 1, &metricDevice, &eventPoolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(eventPoolHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create event.
|
|
|
|
|
EXPECT_EQ(zeEventCreate(eventPoolHandle, &eventDesc, &eventHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_NE(eventHandle, nullptr);
|
|
|
|
|
|
|
|
|
|
// Write BEGIN metric query to command list.
|
|
|
|
|
EXPECT_EQ(zetCommandListAppendMetricQueryBegin(commandListHandle, queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Write END metric query to command list, use an event to determine if the data is available.
|
|
|
|
|
EXPECT_EQ(zetCommandListAppendMetricQueryEndExt(commandListHandle, queryHandle, eventHandle, 0, nullptr), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Get desired raw data size.
|
|
|
|
|
size_t rawSize = 0;
|
|
|
|
|
EXPECT_EQ(zetMetricQueryGetData(queryHandle, &rawSize, nullptr), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Get data.
|
|
|
|
|
std::vector<uint8_t> rawData;
|
|
|
|
|
rawData.resize(rawSize);
|
|
|
|
|
EXPECT_EQ(zetMetricQueryGetData(queryHandle, &rawSize, rawData.data()), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Destroy event and its pool.
|
|
|
|
|
EXPECT_EQ(zeEventDestroy(eventHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_EQ(zeEventPoolDestroy(eventPoolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// Destroy query and its pool.
|
|
|
|
|
EXPECT_EQ(zetMetricQueryDestroy(queryHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
EXPECT_EQ(zetMetricQueryPoolDestroy(poolHandle), ZE_RESULT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ult
|
|
|
|
|
} // namespace L0
|
|
|
|
|
|