Skip to content

Commit

Permalink
fix: update metric query tests (#101)
Browse files Browse the repository at this point in the history
Resolves: VLCLJ-2321

Signed-off-by: Bagria, Narendra <[email protected]>
  • Loading branch information
narenbagria authored Nov 8, 2024
1 parent 18ecdba commit d05d68f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
31 changes: 20 additions & 11 deletions conformance_tests/tools/metrics/src/test_metric.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -432,30 +432,35 @@ TEST_F(

class zetMetricQueryTest : public zetMetricGroupTest {
protected:
zet_metric_query_pool_handle_t metricQueryPoolHandle;
zet_metric_query_handle_t metricQueryHandle;
zet_metric_query_pool_handle_t metricQueryPoolHandle{};
zet_metric_query_handle_t metricQueryHandle{};

std::vector<std::string> groupNameList;
zet_metric_group_handle_t matchedGroupHandle;
zet_metric_group_handle_t matchedGroupHandle{};
std::string groupName;

zetMetricQueryTest() {

void SetUp() override {
groupNameList = lzt::get_metric_group_name_list(
device, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED, false);
ASSERT_GT(groupNameList.size(), 0u) << "No query metric groups found";
groupName = groupNameList[0];

matchedGroupHandle = lzt::find_metric_group(
device, groupName, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED);
EXPECT_NE(nullptr, matchedGroupHandle);
ASSERT_NE(nullptr, matchedGroupHandle);
metricQueryPoolHandle = lzt::create_metric_query_pool(
1000, ZET_METRIC_QUERY_POOL_TYPE_PERFORMANCE, matchedGroupHandle);
EXPECT_NE(nullptr, metricQueryPoolHandle);
ASSERT_NE(nullptr, metricQueryPoolHandle);
metricQueryHandle = lzt::metric_query_create(metricQueryPoolHandle);
}

void TearDown() override {
lzt::destroy_metric_query(metricQueryHandle);
lzt::destroy_metric_query_pool(metricQueryPoolHandle);
if (metricQueryHandle != nullptr) {
lzt::destroy_metric_query(metricQueryHandle);
}
if (metricQueryPoolHandle != nullptr) {
lzt::destroy_metric_query_pool(metricQueryPoolHandle);
}
}
};

Expand All @@ -473,7 +478,6 @@ TEST_F(zetMetricQueryTest,
TEST_F(
zetMetricQueryTest,
GivenOnlyMetricQueryWhenCommandListIsCreatedThenExpectCommandListToExecuteSucessfully) {

zet_command_list_handle_t commandList = lzt::create_command_list();
lzt::activate_metric_groups(device, 1, &matchedGroupHandle);
lzt::append_metric_query_begin(commandList, metricQueryHandle);
Expand Down Expand Up @@ -535,6 +539,7 @@ TEST_F(

auto metricGroupInfo = lzt::get_metric_group_info(
device, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED, false);
ASSERT_GT(metricGroupInfo.size(), 0u) << "No query metric groups found";
metricGroupInfo = lzt::optimize_metric_group_info_list(metricGroupInfo);

for (auto groupInfo : metricGroupInfo) {
Expand Down Expand Up @@ -629,6 +634,7 @@ void run_test(const ze_device_handle_t &device,
}
auto metricGroupInfo = lzt::get_metric_group_info(
device, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED, false);
ASSERT_GT(metricGroupInfo.size(), 0u) << "No query metric groups found";
metricGroupInfo =
lzt::optimize_metric_group_info_list(metricGroupInfo, reset ? 1 : 20);

Expand Down Expand Up @@ -802,8 +808,10 @@ void run_multi_device_query_load_test(

auto metric_group_info_0 = lzt::get_metric_group_info(
device_0, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED, true);
ASSERT_GT(metric_group_info_0.size(), 0u) << "No query metric groups found";
auto metric_group_info_1 = lzt::get_metric_group_info(
device_1, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED, true);
ASSERT_GT(metric_group_info_1.size(), 0u) << "No query metric groups found";

metric_group_info_0 =
lzt::optimize_metric_group_info_list(metric_group_info_0);
Expand Down Expand Up @@ -970,6 +978,7 @@ TEST_F(

auto metricGroupInfo = lzt::get_metric_group_info(
device, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED, false);
ASSERT_GT(metricGroupInfo.size(), 0u) << "No query metric groups found";
metricGroupInfo = lzt::optimize_metric_group_info_list(metricGroupInfo, 1);

for (auto groupInfo : metricGroupInfo) {
Expand Down
7 changes: 4 additions & 3 deletions utils/test_harness/tools/include/test_harness_metric.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2019 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -103,8 +103,9 @@ size_t metric_streamer_read_data_size(
void metric_streamer_read_data(
zet_metric_streamer_handle_t metricStreamerHandle,
std::vector<uint8_t> *metricData);
void activate_metric_groups(ze_device_handle_t device, uint32_t count,
zet_metric_group_handle_t *matchedGroupHandle);
void activate_metric_groups(
ze_device_handle_t device, uint32_t count,
zet_metric_group_handle_t *ptr_matched_group_handle);
void deactivate_metric_groups(ze_device_handle_t device);
void append_metric_query_begin(zet_command_list_handle_t commandList,
zet_metric_query_handle_t metricQueryHandle);
Expand Down
16 changes: 12 additions & 4 deletions utils/test_harness/tools/src/test_harness_metric.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2019 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -468,10 +468,12 @@ metric_query_create(zet_metric_query_pool_handle_t metricQueryPoolHandle) {
}

void destroy_metric_query(zet_metric_query_handle_t metricQueryHandle) {
ASSERT_NE(nullptr, metricQueryHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, zetMetricQueryDestroy(metricQueryHandle));
}

void reset_metric_query(zet_metric_query_handle_t &metricQueryHandle) {
ASSERT_NE(nullptr, metricQueryHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, zetMetricQueryReset(metricQueryHandle));
}

Expand Down Expand Up @@ -579,12 +581,15 @@ void metric_streamer_read_data(
rawDataSize = metricSize;
}

void activate_metric_groups(ze_device_handle_t device, uint32_t count,
zet_metric_group_handle_t *matchedGroupHandle) {
void activate_metric_groups(
ze_device_handle_t device, uint32_t count,
zet_metric_group_handle_t *ptr_matched_group_handle) {
ASSERT_NE(nullptr, *ptr_matched_group_handle);
EXPECT_EQ(ZE_RESULT_SUCCESS,
zetContextActivateMetricGroups(lzt::get_default_context(), device,
count, matchedGroupHandle));
count, ptr_matched_group_handle));
}

void deactivate_metric_groups(ze_device_handle_t device) {
EXPECT_EQ(ZE_RESULT_SUCCESS,
zetContextActivateMetricGroups(lzt::get_default_context(), device,
Expand All @@ -593,13 +598,15 @@ void deactivate_metric_groups(ze_device_handle_t device) {

void append_metric_query_begin(zet_command_list_handle_t commandList,
zet_metric_query_handle_t metricQueryHandle) {
ASSERT_NE(nullptr, metricQueryHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, zetCommandListAppendMetricQueryBegin(
commandList, metricQueryHandle));
}

void append_metric_query_end(zet_command_list_handle_t commandList,
zet_metric_query_handle_t metricQueryHandle,
ze_event_handle_t eventHandle) {
ASSERT_NE(nullptr, metricQueryHandle);
append_metric_query_end(commandList, metricQueryHandle, eventHandle, 0,
nullptr);
}
Expand All @@ -609,6 +616,7 @@ void append_metric_query_end(zet_command_list_handle_t commandList,
ze_event_handle_t eventHandle,
uint32_t numWaitEvents,
ze_event_handle_t *waitEvents) {
ASSERT_NE(nullptr, metricQueryHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, zetCommandListAppendMetricQueryEnd(
commandList, metricQueryHandle, eventHandle,
numWaitEvents, waitEvents));
Expand Down

0 comments on commit d05d68f

Please sign in to comment.