Skip to content

Commit b3aeff2

Browse files
committed
fix: Enhance streamer tests
Moved streamer open calls just before execute_command_lists. Removed zeEventQueryStatus() check from streamer tests since they have a dedicated test. Adjusted notifyNReport and samplingPeriod values to minimize the test runtimes. Added a new read function in harness to read specific number of reports. Related-To: VLCLJ-2365 Signed-off-by: shubham kumar <[email protected]>
1 parent 00caf09 commit b3aeff2

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

conformance_tests/tools/metrics/src/test_metric.cpp

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,8 +1183,11 @@ TEST_F(
11831183

11841184
lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr);
11851185
lzt::event_host_synchronize(eventHandle, UINT64_MAX);
1186-
std::vector<uint8_t> rawData;
11871186
size_t rawDataSize = 0;
1187+
std::vector<uint8_t> rawData;
1188+
rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports);
1189+
EXPECT_GT(rawDataSize, 0);
1190+
rawData.resize(rawDataSize);
11881191
lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports,
11891192
rawDataSize, &rawData);
11901193

@@ -1214,6 +1217,9 @@ TEST_F(
12141217
zetMetricStreamerTest,
12151218
GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToSucceed) {
12161219

1220+
/* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds))
1221+
* For this test it will be 512 seconds which ensure this limit is never likely to hit even on the slowest of platform
1222+
*/
12171223
uint32_t notifyEveryNReports = 256;
12181224
uint32_t samplingPeriod = 1000000000;
12191225
for (auto device : devices) {
@@ -1262,8 +1268,11 @@ TEST_F(
12621268
lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr);
12631269
lzt::synchronize(commandQueue, std::numeric_limits<uint64_t>::max());
12641270

1265-
std::vector<uint8_t> rawData;
12661271
size_t rawDataSize = 0;
1272+
std::vector<uint8_t> rawData;
1273+
rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports);
1274+
EXPECT_GT(rawDataSize, 0);
1275+
rawData.resize(rawDataSize);
12671276
lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports,
12681277
rawDataSize, &rawData);
12691278

@@ -1293,7 +1302,11 @@ TEST_F(
12931302
* ZE_RESULT_NOT_READY. Once the expected time has elapsed it will come out of
12941303
* the loop and expect the event to be generated.
12951304
*/
1296-
1305+
1306+
/* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds))
1307+
* For this test it will be 9 seconds. The execution time between metric_streamer_open_for_device and synchronize observed on average is less than 50% of this
1308+
* which ensure this limit is never likely to hit even on the slowest of platform
1309+
*/
12971310
uint32_t notifyEveryNReports = 4500;
12981311
for (auto device : devices) {
12991312

@@ -1392,7 +1405,11 @@ TEST_F(
13921405
TEST_F(
13931406
zetMetricStreamerTest,
13941407
GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToGenrateCorrectNumberOfReports) {
1395-
1408+
1409+
/* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds))
1410+
* For this test it will be 9 seconds. The execution time between metric_streamer_open_for_device and synchronize observed on average is less than 50% of this
1411+
* which ensure this limit is never likely to hit even on the slowest of platform
1412+
*/
13961413
uint32_t notifyEveryNReports = 4500;
13971414
for (auto device : devices) {
13981415

@@ -1749,8 +1766,11 @@ void run_ip_sampling_with_validation(
17491766
LOG_WARNING << "elapsed time for workload completion is too short";
17501767
}
17511768

1752-
std::vector<uint8_t> rawData;
17531769
size_t rawDataSize = 0;
1770+
std::vector<uint8_t> rawData;
1771+
rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports);
1772+
EXPECT_GT(rawDataSize, 0);
1773+
rawData.resize(rawDataSize);
17541774
lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports,
17551775
rawDataSize, &rawData);
17561776
lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize,
@@ -2247,8 +2267,8 @@ TEST(
22472267
eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST,
22482268
ZE_EVENT_SCOPE_FLAG_HOST);
22492269

2250-
uint32_t notifyEveryNReports = 3000;
2251-
uint32_t samplingPeriod = 10000;
2270+
uint32_t notifyEveryNReports = 4500;
2271+
uint32_t samplingPeriod = 1000000;
22522272
zet_metric_streamer_handle_t metricStreamerHandle =
22532273
lzt::metric_streamer_open_for_device(device, groupInfo.metricGroupHandle,
22542274
eventHandle, notifyEveryNReports,
@@ -2282,10 +2302,13 @@ TEST(
22822302

22832303
EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports);
22842304

2285-
std::vector<uint8_t> rawData;
22862305
size_t rawDataSize = 0;
2306+
std::vector<uint8_t> rawData;
2307+
rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports);
2308+
EXPECT_GT(rawDataSize, 0);
2309+
rawData.resize(rawDataSize);
22872310
lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports,
2288-
rawDataSize, &rawData);
2311+
rawDataSize, &rawData);
22892312
lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize,
22902313
rawData.data());
22912314

@@ -2330,8 +2353,8 @@ TEST(
23302353
eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST,
23312354
ZE_EVENT_SCOPE_FLAG_HOST);
23322355

2333-
uint32_t notifyEveryNReports = 3000;
2334-
uint32_t samplingPeriod = 10000;
2356+
uint32_t notifyEveryNReports = 4500;
2357+
uint32_t samplingPeriod = 1000000;
23352358
zet_metric_streamer_handle_t metricStreamerHandle =
23362359
lzt::metric_streamer_open_for_device(device, groupInfo.metricGroupHandle,
23372360
eventHandle, notifyEveryNReports,
@@ -2364,10 +2387,13 @@ TEST(
23642387

23652388
EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports);
23662389

2367-
std::vector<uint8_t> rawData;
23682390
size_t rawDataSize = 0;
2391+
std::vector<uint8_t> rawData;
2392+
rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports);
2393+
EXPECT_GT(rawDataSize, 0);
2394+
rawData.resize(rawDataSize);
23692395
lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports,
2370-
rawDataSize, &rawData);
2396+
rawDataSize, &rawData);
23712397
lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize,
23722398
rawData.data());
23732399

utils/test_harness/tools/src/test_harness_metric.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,6 @@ void metric_streamer_read_data(
586586
zet_metric_streamer_handle_t metricStreamerHandle, uint32_t reports,
587587
size_t &rawDataSize, std::vector<uint8_t> *metricData) {
588588
ASSERT_NE(nullptr, metricData);
589-
rawDataSize = metric_streamer_read_data_size(metricStreamerHandle, reports);
590-
EXPECT_GT(rawDataSize, 0);
591-
metricData->resize(rawDataSize);
592589
EXPECT_EQ(ZE_RESULT_SUCCESS,
593590
zetMetricStreamerReadData(metricStreamerHandle, reports,
594591
&rawDataSize, metricData->data()));

0 commit comments

Comments
 (0)