@@ -1527,5 +1527,127 @@ TEST_F(MetricStreamerMultiDeviceTest, givenValidArgumentsWhenZetMetricStreamerRe
15271527 EXPECT_EQ (zetMetricStreamerClose (streamerHandle), ZE_RESULT_SUCCESS);
15281528}
15291529
1530+ TEST_F (MetricStreamerMultiDeviceTest, givenMultipleMarkerInsertionsWhenZetCommandListAppendMetricStreamerMarkerIsCalledThenReturnsSuccess) {
1531+
1532+ zet_device_handle_t metricDeviceHandle = devices[0 ]->toHandle ();
1533+ auto &deviceImp = *static_cast <DeviceImp *>(devices[0 ]);
1534+ const uint32_t subDeviceCount = static_cast <uint32_t >(deviceImp.subDevices .size ());
1535+
1536+ ze_event_handle_t eventHandle = {};
1537+
1538+ ze_result_t returnValue;
1539+ std::unique_ptr<L0::CommandList> commandList (CommandList::create (productFamily, devices[0 ], NEO::EngineGroupType::RenderCompute, 0u , returnValue));
1540+
1541+ zet_metric_streamer_handle_t streamerHandle = {};
1542+ zet_metric_streamer_desc_t streamerDesc = {};
1543+
1544+ streamerDesc.stype = ZET_STRUCTURE_TYPE_METRIC_STREAMER_DESC;
1545+ streamerDesc.notifyEveryNReports = 32768 ;
1546+ streamerDesc.samplingPeriod = 1000 ;
1547+
1548+ Mock<MetricGroup> metricGroup;
1549+ zet_metric_group_handle_t metricGroupHandle = metricGroup.toHandle ();
1550+ zet_metric_group_properties_t metricGroupProperties = {};
1551+
1552+ metricsDeviceParams.ConcurrentGroupsCount = 1 ;
1553+
1554+ Mock<IConcurrentGroup_1_5> metricsConcurrentGroup;
1555+ TConcurrentGroupParams_1_0 metricsConcurrentGroupParams = {};
1556+ metricsConcurrentGroupParams.MetricSetsCount = 1 ;
1557+ metricsConcurrentGroupParams.SymbolName = " OA" ;
1558+ metricsConcurrentGroupParams.Description = " OA description" ;
1559+
1560+ Mock<MetricsDiscovery::IMetricSet_1_5> metricsSet;
1561+ MetricsDiscovery::TMetricSetParams_1_4 metricsSetParams = {};
1562+ metricsSetParams.ApiMask = MetricsDiscovery::API_TYPE_IOSTREAM;
1563+ metricsSetParams.MetricsCount = 0 ;
1564+ metricsSetParams.SymbolName = " Metric set name" ;
1565+ metricsSetParams.ShortName = " Metric set description" ;
1566+ metricsSetParams.RawReportSize = 256 ;
1567+
1568+ TypedValue_1_0 value = {};
1569+ value.Type = ValueType::Uint32;
1570+ value.ValueUInt32 = 64 ;
1571+
1572+ ContextHandle_1_0 contextHandle = {&value};
1573+
1574+ CommandBufferSize_1_0 commandBufferSize = {};
1575+ commandBufferSize.GpuMemorySize = 100 ;
1576+
1577+ openMetricsAdapter ();
1578+
1579+ EXPECT_CALL (*mockMetricEnumerationSubDevices[0 ], isInitialized ())
1580+ .Times (1 )
1581+ .WillOnce (Return (true ));
1582+
1583+ EXPECT_CALL (*mockMetricsLibrarySubDevices[0 ]->g_mockApi , MockCommandBufferGetSize (_, _))
1584+ .Times (10 )
1585+ .WillRepeatedly (DoAll (::testing::SetArgPointee<1 >(::testing::ByRef (commandBufferSize)), Return (StatusCode::Success)));
1586+
1587+ EXPECT_CALL (*mockMetricsLibrarySubDevices[0 ]->g_mockApi , MockCommandBufferGet (_))
1588+ .Times (10 )
1589+ .WillRepeatedly (Return (StatusCode::Success));
1590+
1591+ EXPECT_CALL (*mockMetricsLibrarySubDevices[0 ], getContextData (_, _))
1592+ .Times (1 )
1593+ .WillOnce (Return (true ));
1594+
1595+ EXPECT_CALL (*mockMetricsLibrarySubDevices[0 ]->g_mockApi , MockContextCreate (_, _, _))
1596+ .Times (1 )
1597+ .WillOnce (DoAll (::testing::SetArgPointee<2 >(contextHandle), Return (StatusCode::Success)));
1598+
1599+ EXPECT_CALL (*mockMetricsLibrarySubDevices[0 ]->g_mockApi , MockContextDelete (_))
1600+ .Times (1 )
1601+ .WillOnce (Return (StatusCode::Success));
1602+
1603+ EXPECT_CALL (metricsDevice, GetParams ())
1604+ .WillRepeatedly (Return (&metricsDeviceParams));
1605+
1606+ EXPECT_CALL (metricsDevice, GetConcurrentGroup (_))
1607+ .Times (subDeviceCount)
1608+ .WillRepeatedly (Return (&metricsConcurrentGroup));
1609+
1610+ EXPECT_CALL (metricsConcurrentGroup, GetParams ())
1611+ .Times (subDeviceCount)
1612+ .WillRepeatedly (Return (&metricsConcurrentGroupParams));
1613+
1614+ EXPECT_CALL (metricsConcurrentGroup, GetMetricSet (_))
1615+ .WillRepeatedly (Return (&metricsSet));
1616+
1617+ EXPECT_CALL (metricsSet, GetParams ())
1618+ .WillRepeatedly (Return (&metricsSetParams));
1619+
1620+ EXPECT_CALL (metricsSet, SetApiFiltering (_))
1621+ .WillRepeatedly (Return (TCompletionCode::CC_OK));
1622+
1623+ EXPECT_CALL (metricsConcurrentGroup, OpenIoStream (_, _, _, _))
1624+ .Times (subDeviceCount)
1625+ .WillRepeatedly (Return (TCompletionCode::CC_OK));
1626+
1627+ EXPECT_CALL (metricsConcurrentGroup, CloseIoStream ())
1628+ .Times (subDeviceCount)
1629+ .WillRepeatedly (Return (TCompletionCode::CC_OK));
1630+
1631+ uint32_t metricGroupCount = 0 ;
1632+ EXPECT_EQ (zetMetricGroupGet (metricDeviceHandle, &metricGroupCount, nullptr ), ZE_RESULT_SUCCESS);
1633+ EXPECT_EQ (metricGroupCount, 1u );
1634+
1635+ EXPECT_EQ (zetMetricGroupGet (metricDeviceHandle, &metricGroupCount, &metricGroupHandle), ZE_RESULT_SUCCESS);
1636+ EXPECT_EQ (metricGroupCount, 1u );
1637+ EXPECT_NE (metricGroupHandle, nullptr );
1638+
1639+ EXPECT_EQ (zetMetricGroupGetProperties (metricGroupHandle, &metricGroupProperties), ZE_RESULT_SUCCESS);
1640+ EXPECT_EQ (zetContextActivateMetricGroups (context->toHandle (), metricDeviceHandle, 1 , &metricGroupHandle), ZE_RESULT_SUCCESS);
1641+ EXPECT_EQ (zetMetricStreamerOpen (context->toHandle (), metricDeviceHandle, metricGroupHandle, &streamerDesc, eventHandle, &streamerHandle), ZE_RESULT_SUCCESS);
1642+ EXPECT_NE (streamerHandle, nullptr );
1643+
1644+ std::array<uint32_t , 10 > markerValues = {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 };
1645+ for (auto &markerValue : markerValues) {
1646+ EXPECT_EQ (zetCommandListAppendMetricStreamerMarker (commandList->toHandle (), streamerHandle, markerValue), ZE_RESULT_SUCCESS);
1647+ }
1648+
1649+ EXPECT_EQ (zetMetricStreamerClose (streamerHandle), ZE_RESULT_SUCCESS);
1650+ }
1651+
15301652} // namespace ult
15311653} // namespace L0
0 commit comments