Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update metric tests #94

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 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,33 @@ 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";
narenbagria marked this conversation as resolved.
Show resolved Hide resolved
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 +476,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 +537,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 +632,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 +806,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 +976,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
5 changes: 3 additions & 2 deletions utils/test_harness/tools/include/test_harness_metric.hpp
Original file line number Diff line number Diff line change
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
Loading