-
Notifications
You must be signed in to change notification settings - Fork 38
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
test: Added a new test to accurately check streamer event generation #107
Open
shubskmr
wants to merge
1
commit into
master
Choose a base branch
from
notifyNReports_test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+109
−7
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,9 +398,11 @@ TEST_F( | |
for (auto &test_metric_group : test_metric_groups) { | ||
|
||
lzt::activate_metric_groups(deviceh, 1, &test_metric_group); | ||
uint32_t notifyEveryNReports = 100; | ||
uint32_t samplingPeriod = 100000; | ||
zet_metric_streamer_handle_t metric_streamer_handle = | ||
lzt::metric_streamer_open_for_device(deviceh, test_metric_group, | ||
nullptr, 100, 100000); | ||
nullptr, notifyEveryNReports, samplingPeriod); | ||
auto report_size = | ||
lzt::metric_streamer_read_data_size(metric_streamer_handle, 1); | ||
lzt::metric_streamer_close(metric_streamer_handle); | ||
|
@@ -1231,6 +1233,7 @@ TEST_F( | |
zetMetricStreamerTest, | ||
GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToSucceed) { | ||
|
||
notifyEveryNReports = 9000; | ||
for (auto device : devices) { | ||
|
||
ze_device_properties_t deviceProperties = { | ||
|
@@ -1321,6 +1324,103 @@ TEST_F( | |
} | ||
} | ||
|
||
TEST_F( | ||
zetMetricStreamerTest, | ||
GivenValidMetricGroupWhenTimerBasedStreamerIsCreatedThenExpectStreamerToNotifyEventAtProperTimeAndSucceed) { | ||
|
||
uint32_t notifyEveryNReports = 1000; | ||
uint32_t samplingPeriod = 50000000; | ||
for (auto device : devices) { | ||
|
||
ze_device_properties_t deviceProperties = { | ||
ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES, nullptr}; | ||
zeDeviceGetProperties(device, &deviceProperties); | ||
|
||
LOG_INFO << "test device name " << deviceProperties.name << " uuid " | ||
<< lzt::to_string(deviceProperties.uuid); | ||
if (deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE) { | ||
LOG_INFO << "test subdevice id " << deviceProperties.subdeviceId; | ||
} else { | ||
LOG_INFO << "test device is a root device"; | ||
} | ||
|
||
ze_command_queue_handle_t commandQueue = lzt::create_command_queue(device); | ||
zet_command_list_handle_t commandList = lzt::create_command_list(device); | ||
|
||
auto metricGroupInfo = lzt::get_metric_group_info( | ||
device, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_TIME_BASED, true); | ||
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); | ||
|
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the above till 1360 could be moved outside the loop |
||
|
||
auto startTime = std::chrono::system_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<uint64_t>::max()); | ||
|
||
double minimumTimeBeforeEventIsExpected = notifyEveryNReports * (static_cast<double>(samplingPeriod) / 1000000000); | ||
// Initializing a 5% error buffer to prevent corner cases | ||
double errorBuffer = 0.05 * minimumTimeBeforeEventIsExpected; | ||
LOG_INFO << "minimumTimeBeforeEventIsExpected " << minimumTimeBeforeEventIsExpected; | ||
LOG_INFO << "errorBuffer " << errorBuffer; | ||
|
||
ze_result_t eventResult; | ||
while (true) { | ||
auto currentTime = std::chrono::system_clock::now(); | ||
std::chrono::duration<double> elapsedSeconds = currentTime - startTime; | ||
if (elapsedSeconds.count() >= (minimumTimeBeforeEventIsExpected - errorBuffer)) { | ||
break; | ||
} | ||
eventResult = zeEventQueryStatus(eventHandle); | ||
EXPECT_EQ(eventResult, ZE_RESULT_NOT_READY); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); | ||
} | ||
|
||
// Sleep again for 2x the buffer time to ensure corner cases are avoided. 2x is the amount to maintain the timeline itself. | ||
uint32_t sleep = std::ceil(2 * errorBuffer); | ||
LOG_INFO << "additional sleep before expecting event to be ready " << sleep; | ||
std::this_thread::sleep_for(std::chrono::seconds(sleep)); | ||
|
||
eventResult = zeEventQueryStatus(eventHandle); | ||
EXPECT_EQ(eventResult, ZE_RESULT_SUCCESS); | ||
|
||
lzt::metric_streamer_close(metricStreamerHandle); | ||
lzt::deactivate_metric_groups(device); | ||
lzt::destroy_function(function); | ||
lzt::free_memory(a_buffer); | ||
lzt::free_memory(b_buffer); | ||
lzt::free_memory(c_buffer); | ||
eventPool.destroy_event(eventHandle); | ||
lzt::reset_command_list(commandList); | ||
} | ||
lzt::destroy_command_queue(commandQueue); | ||
lzt::destroy_command_list(commandList); | ||
} | ||
} | ||
|
||
void metric_validate_stall_sampling_data( | ||
std::vector<zet_metric_properties_t> &metricProperties, | ||
std::vector<zet_typed_value_t> &totalMetricValues, | ||
|
@@ -2330,8 +2430,8 @@ void run_multi_device_streamer_test( | |
eventPool.create_event(eventHandle_1, ZE_EVENT_SCOPE_FLAG_HOST, | ||
ZE_EVENT_SCOPE_FLAG_HOST); | ||
|
||
auto notifyEveryNReports = 3000; | ||
auto samplingPeriod = 1000000; | ||
uint32_t notifyEveryNReports = 3000; | ||
uint32_t samplingPeriod = 1000000; | ||
auto metricStreamerHandle_0 = lzt::metric_streamer_open_for_device( | ||
device_0, groupInfo_0.metricGroupHandle, eventHandle_0, | ||
notifyEveryNReports, samplingPeriod); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test validated for EU stall ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is validated on PVC