From 91c6a8afd37cdc2f3c1782d7820990a1808b6d99 Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Thu, 28 Nov 2024 16:30:54 +0000 Subject: [PATCH 1/5] fix: Enhance streamer tests Related-To: VLCLJ-2365 Signed-off-by: shubham kumar --- .../tools/metrics/src/test_metric.cpp | 110 ++++++------------ 1 file changed, 38 insertions(+), 72 deletions(-) diff --git a/conformance_tests/tools/metrics/src/test_metric.cpp b/conformance_tests/tools/metrics/src/test_metric.cpp index e5f8a3df..9b932823 100644 --- a/conformance_tests/tools/metrics/src/test_metric.cpp +++ b/conformance_tests/tools/metrics/src/test_metric.cpp @@ -1094,36 +1094,27 @@ TEST_F( eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); - zet_metric_streamer_handle_t metricStreamerHandle = - lzt::metric_streamer_open_for_device( - device, groupInfo.metricGroupHandle, eventHandle, - notifyEveryNReports, samplingPeriod); - ASSERT_NE(nullptr, metricStreamerHandle); - void *a_buffer, *b_buffer, *c_buffer; ze_group_count_t tg; ze_kernel_handle_t function = get_matrix_multiplication_kernel( device, &tg, &a_buffer, &b_buffer, &c_buffer); zeCommandListAppendLaunchKernel(commandList, function, &tg, nullptr, 0, nullptr); - lzt::close_command_list(commandList); + + zet_metric_streamer_handle_t metricStreamerHandle = + lzt::metric_streamer_open_for_device( + device, groupInfo.metricGroupHandle, eventHandle, + notifyEveryNReports, samplingPeriod); + ASSERT_NE(nullptr, metricStreamerHandle); + lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::synchronize(commandQueue, std::numeric_limits::max()); ze_result_t eventResult; eventResult = zeEventQueryStatus(eventHandle); if (ZE_RESULT_SUCCESS == eventResult) { - size_t oneReportSize, allReportsSize; - oneReportSize = - lzt::metric_streamer_read_data_size(metricStreamerHandle, 1); - allReportsSize = lzt::metric_streamer_read_data_size( - metricStreamerHandle, UINT32_MAX); - LOG_DEBUG << "Event triggered. Single report size: " << oneReportSize - << ". All reports size:" << allReportsSize; - - EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports); - + LOG_DEBUG << "Event triggered"; } else if (ZE_RESULT_NOT_READY == eventResult) { LOG_WARNING << "wait on event returned ZE_RESULT_NOT_READY"; } else { @@ -1186,12 +1177,6 @@ TEST_F( eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); - zet_metric_streamer_handle_t metricStreamerHandle = - lzt::metric_streamer_open_for_device( - device, groupInfo.metricGroupHandle, eventHandle, - notifyEveryNReports, samplingPeriod); - ASSERT_NE(nullptr, metricStreamerHandle); - void *a_buffer, *b_buffer, *c_buffer; ze_group_count_t tg; @@ -1199,10 +1184,15 @@ TEST_F( device, &tg, &a_buffer, &b_buffer, &c_buffer); zeCommandListAppendLaunchKernel(commandList, function, &tg, nullptr, 0, nullptr); - lzt::close_command_list(commandList); - lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); + zet_metric_streamer_handle_t metricStreamerHandle = + lzt::metric_streamer_open_for_device( + device, groupInfo.metricGroupHandle, eventHandle, + notifyEveryNReports, samplingPeriod); + ASSERT_NE(nullptr, metricStreamerHandle); + + lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::event_host_synchronize(eventHandle, UINT64_MAX); std::vector rawData; uint32_t rawDataSize = 0; @@ -1235,7 +1225,7 @@ TEST_F( zetMetricStreamerTest, GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToSucceed) { - notifyEveryNReports = 9000; + notifyEveryNReports = 5000; for (auto device : devices) { ze_device_properties_t deviceProperties = { @@ -1258,46 +1248,34 @@ TEST_F( metricGroupInfo = lzt::optimize_metric_group_info_list(metricGroupInfo); for (auto groupInfo : metricGroupInfo) { - LOG_INFO << "test metricGroup name " << groupInfo.metricGroupName; - lzt::activate_metric_groups(device, 1, &groupInfo.metricGroupHandle); - ze_event_handle_t eventHandle; lzt::zeEventPool eventPool; eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); - zet_metric_streamer_handle_t metricStreamerHandle = - lzt::metric_streamer_open_for_device( - device, groupInfo.metricGroupHandle, eventHandle, - notifyEveryNReports, samplingPeriod); - ASSERT_NE(nullptr, metricStreamerHandle); - void *a_buffer, *b_buffer, *c_buffer; ze_group_count_t tg; ze_kernel_handle_t function = get_matrix_multiplication_kernel( device, &tg, &a_buffer, &b_buffer, &c_buffer, 8192); zeCommandListAppendLaunchKernel(commandList, function, &tg, nullptr, 0, nullptr); - lzt::close_command_list(commandList); + + zet_metric_streamer_handle_t metricStreamerHandle = + lzt::metric_streamer_open_for_device( + device, groupInfo.metricGroupHandle, eventHandle, + notifyEveryNReports, samplingPeriod); + ASSERT_NE(nullptr, metricStreamerHandle); + lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::synchronize(commandQueue, std::numeric_limits::max()); ze_result_t eventResult; eventResult = zeEventQueryStatus(eventHandle); if (ZE_RESULT_SUCCESS == eventResult) { - size_t oneReportSize, allReportsSize; - oneReportSize = - lzt::metric_streamer_read_data_size(metricStreamerHandle, 1); - allReportsSize = lzt::metric_streamer_read_data_size( - metricStreamerHandle, UINT32_MAX); - LOG_DEBUG << "Event triggered. Single report size: " << oneReportSize - << ". All reports size:" << allReportsSize; - - EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports); - + LOG_DEBUG << "Event triggered"; } else if (ZE_RESULT_NOT_READY == eventResult) { LOG_WARNING << "wait on event returned ZE_RESULT_NOT_READY"; } else { @@ -1336,8 +1314,7 @@ TEST_F( * the loop and expect the event to be generated. */ - uint32_t notifyEveryNReports = 1000; - uint32_t samplingPeriod = 50000000; + uint32_t notifyEveryNReports = 4500; for (auto device : devices) { ze_device_properties_t deviceProperties = { @@ -1436,8 +1413,7 @@ TEST_F( zetMetricStreamerTest, GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToGenrateCorrectNumberOfReports) { - uint32_t notifyEveryNReports = 1000; - uint32_t samplingPeriod = 50000000; + uint32_t notifyEveryNReports = 4500; for (auto device : devices) { ze_device_properties_t deviceProperties = { @@ -1759,12 +1735,6 @@ void run_ip_sampling_with_validation( eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); - zet_metric_streamer_handle_t metricStreamerHandle = - lzt::metric_streamer_open_for_device( - device, groupInfo.metricGroupHandle, eventHandle, - notifyEveryNReports, samplingPeriod); - ASSERT_NE(nullptr, metricStreamerHandle); - for (auto &fData : functionDataBuf) { fData.function = get_matrix_multiplication_kernel( device, &fData.tg, &fData.a_buffer, &fData.b_buffer, @@ -1774,26 +1744,22 @@ void run_ip_sampling_with_validation( } lzt::close_command_list(commandList); - std::chrono::steady_clock::time_point startTime = std::chrono::steady_clock::now(); + zet_metric_streamer_handle_t metricStreamerHandle = + lzt::metric_streamer_open_for_device( + device, groupInfo.metricGroupHandle, eventHandle, + notifyEveryNReports, samplingPeriod); + ASSERT_NE(nullptr, metricStreamerHandle); + lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::synchronize(commandQueue, std::numeric_limits::max()); ze_result_t eventResult; eventResult = zeEventQueryStatus(eventHandle); if (ZE_RESULT_SUCCESS == eventResult) { - size_t oneReportSize, allReportsSize; - oneReportSize = - lzt::metric_streamer_read_data_size(metricStreamerHandle, 1); - allReportsSize = lzt::metric_streamer_read_data_size( - metricStreamerHandle, UINT32_MAX); - LOG_DEBUG << "Event triggered. Single report size: " << oneReportSize - << ". All reports size:" << allReportsSize; - - EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports); - + LOG_DEBUG << "Event triggered"; } else if (ZE_RESULT_NOT_READY == eventResult) { LOG_WARNING << "wait on event returned ZE_RESULT_NOT_READY"; } else { @@ -1917,17 +1883,17 @@ TEST_F( eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); + void *a_buffer, *b_buffer, *c_buffer; + ze_group_count_t tg{}; + ze_kernel_handle_t function = get_matrix_multiplication_kernel( + device, &tg, &a_buffer, &b_buffer, &c_buffer); + zet_metric_streamer_handle_t metricStreamerHandle = lzt::metric_streamer_open_for_device( device, groupInfo.metricGroupHandle, eventHandle, notifyEveryNReports, samplingPeriod); ASSERT_NE(nullptr, metricStreamerHandle); - void *a_buffer, *b_buffer, *c_buffer; - ze_group_count_t tg{}; - ze_kernel_handle_t function = get_matrix_multiplication_kernel( - device, &tg, &a_buffer, &b_buffer, &c_buffer); - uint32_t streamerMarker = 0; markerResult = lzt::commandlist_append_streamer_marker( commandList, metricStreamerHandle, ++streamerMarker); From 7398612903cee47aaa54a980942ec899c728cfe9 Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Fri, 29 Nov 2024 10:24:31 +0000 Subject: [PATCH 2/5] fix: Enhance streamer tests Related-To: VLCLJ-2365 Signed-off-by: shubham kumar --- .../tools/metrics/src/test_metric.cpp | 67 +++++-------------- .../tools/include/test_harness_metric.hpp | 4 ++ .../tools/src/test_harness_metric.cpp | 12 ++++ 3 files changed, 34 insertions(+), 49 deletions(-) diff --git a/conformance_tests/tools/metrics/src/test_metric.cpp b/conformance_tests/tools/metrics/src/test_metric.cpp index 9b932823..768ab376 100644 --- a/conformance_tests/tools/metrics/src/test_metric.cpp +++ b/conformance_tests/tools/metrics/src/test_metric.cpp @@ -1110,20 +1110,9 @@ TEST_F( lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::synchronize(commandQueue, std::numeric_limits::max()); - ze_result_t eventResult; - eventResult = zeEventQueryStatus(eventHandle); - - if (ZE_RESULT_SUCCESS == eventResult) { - LOG_DEBUG << "Event triggered"; - } else if (ZE_RESULT_NOT_READY == eventResult) { - LOG_WARNING << "wait on event returned ZE_RESULT_NOT_READY"; - } else { - FAIL() << "zeEventQueryStatus() FAILED with " << eventResult; - } std::vector rawData; lzt::metric_streamer_read_data(metricStreamerHandle, &rawData); - lzt::metric_streamer_close(metricStreamerHandle); lzt::deactivate_metric_groups(device); lzt::destroy_function(function); @@ -1195,9 +1184,9 @@ TEST_F( lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::event_host_synchronize(eventHandle, UINT64_MAX); std::vector rawData; - uint32_t rawDataSize = 0; - lzt::metric_streamer_read_data(metricStreamerHandle, rawDataSize, - &rawData); + size_t rawDataSize = 0; + lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, + rawDataSize, &rawData); LOG_INFO << "raw data size " << rawDataSize; EXPECT_GT(rawDataSize, 0); @@ -1225,7 +1214,8 @@ TEST_F( zetMetricStreamerTest, GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToSucceed) { - notifyEveryNReports = 5000; + uint32_t notifyEveryNReports = 256; + uint32_t samplingPeriod = 1000000000; for (auto device : devices) { ze_device_properties_t deviceProperties = { @@ -1271,25 +1261,15 @@ TEST_F( lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::synchronize(commandQueue, std::numeric_limits::max()); - ze_result_t eventResult; - eventResult = zeEventQueryStatus(eventHandle); - - if (ZE_RESULT_SUCCESS == eventResult) { - LOG_DEBUG << "Event triggered"; - } else if (ZE_RESULT_NOT_READY == eventResult) { - LOG_WARNING << "wait on event returned ZE_RESULT_NOT_READY"; - } else { - FAIL() << "zeEventQueryStatus() FAILED with " << eventResult; - } std::vector rawData; - uint32_t rawDataSize = 0; - lzt::metric_streamer_read_data(metricStreamerHandle, rawDataSize, - &rawData); + size_t rawDataSize = 0; + lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, + rawDataSize, &rawData); + LOG_INFO << "rawDataSize " << rawDataSize; lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize, rawData.data()); - lzt::metric_streamer_close(metricStreamerHandle); lzt::deactivate_metric_groups(device); lzt::destroy_function(function); @@ -1755,20 +1735,9 @@ void run_ip_sampling_with_validation( lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::synchronize(commandQueue, std::numeric_limits::max()); - ze_result_t eventResult; - eventResult = zeEventQueryStatus(eventHandle); - - if (ZE_RESULT_SUCCESS == eventResult) { - LOG_DEBUG << "Event triggered"; - } else if (ZE_RESULT_NOT_READY == eventResult) { - LOG_WARNING << "wait on event returned ZE_RESULT_NOT_READY"; - } else { - FAIL() << "zeEventQueryStatus() FAILED with " << eventResult; - } std::chrono::steady_clock::time_point endTime = std::chrono::steady_clock::now(); - uint64_t elapsedTime = std::chrono::duration_cast(endTime - startTime) @@ -1781,9 +1750,9 @@ void run_ip_sampling_with_validation( } std::vector rawData; - uint32_t rawDataSize = 0; - lzt::metric_streamer_read_data(metricStreamerHandle, rawDataSize, - &rawData); + size_t rawDataSize = 0; + lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, + rawDataSize, &rawData); lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize, rawData.data(), false); rawData.resize(rawDataSize); @@ -1829,7 +1798,6 @@ void run_ip_sampling_with_validation( TEST_F( zetMetricStreamerTest, GivenValidTypeIpMetricGroupWhenTimerBasedStreamerIsCreatedAndOverflowTriggeredThenExpectStreamerValidateError) { - run_ip_sampling_with_validation(true, devices, notifyEveryNReports, samplingPeriod, TimeForNReportsComplete); } @@ -1837,7 +1805,6 @@ TEST_F( TEST_F( zetMetricStreamerTest, GivenValidTypeIpMetricGroupWhenTimerBasedStreamerIsCreatedWithNoOverflowThenValidateStallSampleData) { - run_ip_sampling_with_validation(false, devices, notifyEveryNReports, samplingPeriod, TimeForNReportsComplete); } @@ -2316,8 +2283,9 @@ TEST( EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports); std::vector rawData; - uint32_t rawDataSize = 0; - lzt::metric_streamer_read_data(metricStreamerHandle, rawDataSize, &rawData); + size_t rawDataSize = 0; + lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, + rawDataSize, &rawData); lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize, rawData.data()); @@ -2397,8 +2365,9 @@ TEST( EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports); std::vector rawData; - uint32_t rawDataSize = 0; - lzt::metric_streamer_read_data(metricStreamerHandle, rawDataSize, &rawData); + size_t rawDataSize = 0; + lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, + rawDataSize, &rawData); lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize, rawData.data()); diff --git a/utils/test_harness/tools/include/test_harness_metric.hpp b/utils/test_harness/tools/include/test_harness_metric.hpp index 58b84d59..742b0caf 100644 --- a/utils/test_harness/tools/include/test_harness_metric.hpp +++ b/utils/test_harness/tools/include/test_harness_metric.hpp @@ -141,6 +141,10 @@ void metric_streamer_read_data( zet_metric_streamer_handle_t metricStreamerHandle, uint32_t &rawDataSize, std::vector *metricData); +void metric_streamer_read_data( + zet_metric_streamer_handle_t metricStreamerHandle, uint32_t reports, + size_t &rawDataSize, std::vector *metricData); + std::vector get_metric_groups_with_different_domains(const ze_device_handle_t device, uint32_t metric_groups_per_domain); diff --git a/utils/test_harness/tools/src/test_harness_metric.cpp b/utils/test_harness/tools/src/test_harness_metric.cpp index 48f19c89..86b6c846 100644 --- a/utils/test_harness/tools/src/test_harness_metric.cpp +++ b/utils/test_harness/tools/src/test_harness_metric.cpp @@ -582,6 +582,18 @@ void metric_streamer_read_data( rawDataSize = metricSize; } +void metric_streamer_read_data( + zet_metric_streamer_handle_t metricStreamerHandle, uint32_t reports, + size_t &rawDataSize, std::vector *metricData) { + ASSERT_NE(nullptr, metricData); + rawDataSize = metric_streamer_read_data_size(metricStreamerHandle, reports); + EXPECT_GT(rawDataSize, 0); + metricData->resize(rawDataSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, + zetMetricStreamerReadData(metricStreamerHandle, reports, + &rawDataSize, metricData->data())); +} + void activate_metric_groups( ze_device_handle_t device, uint32_t count, zet_metric_group_handle_t *ptr_matched_group_handle) { From 00caf0932d3074dbc7e50598239bb94678a054ba Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Fri, 29 Nov 2024 10:24:31 +0000 Subject: [PATCH 3/5] 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 From b3aeff2b51c5ee0dfb415e57ed03eb08f07b6dde Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Mon, 2 Dec 2024 10:56:42 +0000 Subject: [PATCH 4/5] 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 --- .../tools/metrics/src/test_metric.cpp | 52 ++++++++++++++----- .../tools/src/test_harness_metric.cpp | 3 -- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/conformance_tests/tools/metrics/src/test_metric.cpp b/conformance_tests/tools/metrics/src/test_metric.cpp index 768ab376..63657cd1 100644 --- a/conformance_tests/tools/metrics/src/test_metric.cpp +++ b/conformance_tests/tools/metrics/src/test_metric.cpp @@ -1183,8 +1183,11 @@ TEST_F( lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::event_host_synchronize(eventHandle, UINT64_MAX); - std::vector rawData; size_t rawDataSize = 0; + std::vector rawData; + rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports); + EXPECT_GT(rawDataSize, 0); + rawData.resize(rawDataSize); lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, rawDataSize, &rawData); @@ -1214,6 +1217,9 @@ TEST_F( zetMetricStreamerTest, GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToSucceed) { + /* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds)) + * For this test it will be 512 seconds which ensure this limit is never likely to hit even on the slowest of platform + */ uint32_t notifyEveryNReports = 256; uint32_t samplingPeriod = 1000000000; for (auto device : devices) { @@ -1262,8 +1268,11 @@ TEST_F( lzt::execute_command_lists(commandQueue, 1, &commandList, nullptr); lzt::synchronize(commandQueue, std::numeric_limits::max()); - std::vector rawData; size_t rawDataSize = 0; + std::vector rawData; + rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports); + EXPECT_GT(rawDataSize, 0); + rawData.resize(rawDataSize); lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, rawDataSize, &rawData); @@ -1293,7 +1302,11 @@ TEST_F( * ZE_RESULT_NOT_READY. Once the expected time has elapsed it will come out of * the loop and expect the event to be generated. */ - + + /* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds)) + * 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 + * which ensure this limit is never likely to hit even on the slowest of platform + */ uint32_t notifyEveryNReports = 4500; for (auto device : devices) { @@ -1392,7 +1405,11 @@ TEST_F( TEST_F( zetMetricStreamerTest, GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToGenrateCorrectNumberOfReports) { - + + /* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds)) + * 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 + * which ensure this limit is never likely to hit even on the slowest of platform + */ uint32_t notifyEveryNReports = 4500; for (auto device : devices) { @@ -1749,8 +1766,11 @@ void run_ip_sampling_with_validation( LOG_WARNING << "elapsed time for workload completion is too short"; } - std::vector rawData; size_t rawDataSize = 0; + std::vector rawData; + rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports); + EXPECT_GT(rawDataSize, 0); + rawData.resize(rawDataSize); lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, rawDataSize, &rawData); lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize, @@ -2247,8 +2267,8 @@ TEST( eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); - uint32_t notifyEveryNReports = 3000; - uint32_t samplingPeriod = 10000; + uint32_t notifyEveryNReports = 4500; + uint32_t samplingPeriod = 1000000; zet_metric_streamer_handle_t metricStreamerHandle = lzt::metric_streamer_open_for_device(device, groupInfo.metricGroupHandle, eventHandle, notifyEveryNReports, @@ -2282,10 +2302,13 @@ TEST( EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports); - std::vector rawData; size_t rawDataSize = 0; + std::vector rawData; + rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports); + EXPECT_GT(rawDataSize, 0); + rawData.resize(rawDataSize); lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, - rawDataSize, &rawData); + rawDataSize, &rawData); lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize, rawData.data()); @@ -2330,8 +2353,8 @@ TEST( eventPool.create_event(eventHandle, ZE_EVENT_SCOPE_FLAG_HOST, ZE_EVENT_SCOPE_FLAG_HOST); - uint32_t notifyEveryNReports = 3000; - uint32_t samplingPeriod = 10000; + uint32_t notifyEveryNReports = 4500; + uint32_t samplingPeriod = 1000000; zet_metric_streamer_handle_t metricStreamerHandle = lzt::metric_streamer_open_for_device(device, groupInfo.metricGroupHandle, eventHandle, notifyEveryNReports, @@ -2364,10 +2387,13 @@ TEST( EXPECT_GE(allReportsSize / oneReportSize, notifyEveryNReports); - std::vector rawData; size_t rawDataSize = 0; + std::vector rawData; + rawDataSize = lzt::metric_streamer_read_data_size(metricStreamerHandle, notifyEveryNReports); + EXPECT_GT(rawDataSize, 0); + rawData.resize(rawDataSize); lzt::metric_streamer_read_data(metricStreamerHandle, notifyEveryNReports, - rawDataSize, &rawData); + rawDataSize, &rawData); lzt::validate_metrics(groupInfo.metricGroupHandle, rawDataSize, rawData.data()); diff --git a/utils/test_harness/tools/src/test_harness_metric.cpp b/utils/test_harness/tools/src/test_harness_metric.cpp index 86b6c846..064e94e1 100644 --- a/utils/test_harness/tools/src/test_harness_metric.cpp +++ b/utils/test_harness/tools/src/test_harness_metric.cpp @@ -586,9 +586,6 @@ void metric_streamer_read_data( zet_metric_streamer_handle_t metricStreamerHandle, uint32_t reports, size_t &rawDataSize, std::vector *metricData) { ASSERT_NE(nullptr, metricData); - rawDataSize = metric_streamer_read_data_size(metricStreamerHandle, reports); - EXPECT_GT(rawDataSize, 0); - metricData->resize(rawDataSize); EXPECT_EQ(ZE_RESULT_SUCCESS, zetMetricStreamerReadData(metricStreamerHandle, reports, &rawDataSize, metricData->data())); From 49a3574681a99688d810d2f0ee014c601cbc1b95 Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Mon, 2 Dec 2024 13:29:48 +0000 Subject: [PATCH 5/5] 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 --- conformance_tests/tools/metrics/src/test_metric.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/conformance_tests/tools/metrics/src/test_metric.cpp b/conformance_tests/tools/metrics/src/test_metric.cpp index 63657cd1..362af77e 100644 --- a/conformance_tests/tools/metrics/src/test_metric.cpp +++ b/conformance_tests/tools/metrics/src/test_metric.cpp @@ -1217,9 +1217,7 @@ TEST_F( zetMetricStreamerTest, GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToSucceed) { - /* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds)) - * For this test it will be 512 seconds which ensure this limit is never likely to hit even on the slowest of platform - */ + // The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds)) for this test it will be 512 seconds uint32_t notifyEveryNReports = 256; uint32_t samplingPeriod = 1000000000; for (auto device : devices) { @@ -1305,7 +1303,6 @@ TEST_F( /* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds)) * 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 - * which ensure this limit is never likely to hit even on the slowest of platform */ uint32_t notifyEveryNReports = 4500; for (auto device : devices) { @@ -1408,7 +1405,6 @@ TEST_F( /* The time in seconds for the buffer to overflow would be 2 * (notifyEveryNReports * (samplingPeriod/nanoSecToSeconds)) * 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 - * which ensure this limit is never likely to hit even on the slowest of platform */ uint32_t notifyEveryNReports = 4500; for (auto device : devices) {