Skip to content

[SYCL] Record submit time for shortcut operations #18455

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

Draft
wants to merge 1 commit into
base: sycl
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr<queue_impl> &Self,
{
NestedCallsTracker tracker;
ur_event_handle_t UREvent = nullptr;
EventImpl->setSubmissionTime();
MemOpFunc(MemOpArgs..., getUrEvents(ExpandedDepEvents), &UREvent);
EventImpl->setHandle(UREvent);
EventImpl->setEnqueued();
Expand Down
44 changes: 41 additions & 3 deletions sycl/test-e2e/Basic/submit_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@
// Test fails on hip flakily, disable temprorarily.
// UNSUPPORTED: hip

#include <cassert>
#include <iostream>
#include <sycl/detail/core.hpp>
#include <sycl/properties/all_properties.hpp>
#include <sycl/usm.hpp>

int main(void) {
constexpr size_t n = 16;
sycl::queue q({sycl::property::queue::enable_profiling{}});
int *data = sycl::malloc_host<int>(1024, q);
int *data = sycl::malloc_host<int>(n, q);
int *dest = sycl::malloc_host<int>(n, q);

for (int i = 0; i < 20; i++) {
for (int i = 0; i < 5; i++) {
auto event = q.submit([&](sycl::handler &cgh) {
cgh.parallel_for<class KernelTime>(
sycl::range<1>(1024), [=](sycl::id<1> idx) { data[idx] = idx; });
sycl::range<1>(n), [=](sycl::id<1> idx) { data[idx] = idx; });
});

event.wait();
Expand All @@ -30,8 +34,42 @@ int main(void) {
auto end_time =
event.get_profiling_info<sycl::info::event_profiling::command_end>();

// Print for debugging
std::cout << "Kernel Event - Submit: " << submit_time
<< ", Start: " << start_time << ", End: " << end_time
<< std::endl;

assert(submit_time != 0 && "Submit time should not be zero");
assert((submit_time <= start_time) && (start_time <= end_time));
}

// All shortcut memory operations use queue_impl::submitMemOpHelper.
// This test covers memcpy as a representative, extend if other operations
// diverge.
for (int i = 0; i < 5; i++) {
auto memcpy_event = q.memcpy(dest, data, sizeof(int) * n);
memcpy_event.wait();

auto submit_time =
memcpy_event
.get_profiling_info<sycl::info::event_profiling::command_submit>();
auto start_time =
memcpy_event
.get_profiling_info<sycl::info::event_profiling::command_start>();
auto end_time =
memcpy_event
.get_profiling_info<sycl::info::event_profiling::command_end>();

// Print for debugging
std::cout << "Memcpy Event - Submit: " << submit_time
<< ", Start: " << start_time << ", End: " << end_time
<< std::endl;

assert(submit_time != 0 && "Submit time should not be zero");
assert((submit_time <= start_time) && (start_time <= end_time));
}

sycl::free(data, q);
sycl::free(dest, q);
return 0;
}
Loading