Skip to content

Commit 046d824

Browse files
committed
[SYCL] Record submit time for shortcut operations
1 parent 4b7a7f9 commit 046d824

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

sycl/source/detail/queue_impl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr<queue_impl> &Self,
492492
{
493493
NestedCallsTracker tracker;
494494
ur_event_handle_t UREvent = nullptr;
495+
EventImpl->setSubmissionTime();
495496
MemOpFunc(MemOpArgs..., getUrEvents(ExpandedDepEvents), &UREvent);
496497
EventImpl->setHandle(UREvent);
497498
EventImpl->setEnqueued();

sycl/test-e2e/Basic/submit_time.cpp

+41-3
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@
88
// Test fails on hip flakily, disable temprorarily.
99
// UNSUPPORTED: hip
1010

11+
#include <cassert>
12+
#include <iostream>
1113
#include <sycl/detail/core.hpp>
1214
#include <sycl/properties/all_properties.hpp>
1315
#include <sycl/usm.hpp>
1416

1517
int main(void) {
18+
constexpr size_t n = 16;
1619
sycl::queue q({sycl::property::queue::enable_profiling{}});
17-
int *data = sycl::malloc_host<int>(1024, q);
20+
int *data = sycl::malloc_host<int>(n, q);
21+
int *dest = sycl::malloc_host<int>(n, q);
1822

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

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

37+
// Print for debugging
38+
std::cout << "Kernel Event - Submit: " << submit_time
39+
<< ", Start: " << start_time << ", End: " << end_time
40+
<< std::endl;
41+
42+
assert(submit_time != 0 && "Submit time should not be zero");
3343
assert((submit_time <= start_time) && (start_time <= end_time));
3444
}
45+
46+
// All shortcut memory operations use queue_impl::submitMemOpHelper.
47+
// This test covers memcpy as a representative, extend if other operations
48+
// diverge.
49+
for (int i = 0; i < 5; i++) {
50+
auto memcpy_event = q.memcpy(dest, data, sizeof(int) * n);
51+
memcpy_event.wait();
52+
53+
auto submit_time =
54+
memcpy_event
55+
.get_profiling_info<sycl::info::event_profiling::command_submit>();
56+
auto start_time =
57+
memcpy_event
58+
.get_profiling_info<sycl::info::event_profiling::command_start>();
59+
auto end_time =
60+
memcpy_event
61+
.get_profiling_info<sycl::info::event_profiling::command_end>();
62+
63+
// Print for debugging
64+
std::cout << "Memcpy Event - Submit: " << submit_time
65+
<< ", Start: " << start_time << ", End: " << end_time
66+
<< std::endl;
67+
68+
assert(submit_time != 0 && "Submit time should not be zero");
69+
assert((submit_time <= start_time) && (start_time <= end_time));
70+
}
71+
3572
sycl::free(data, q);
73+
sycl::free(dest, q);
3674
return 0;
3775
}

0 commit comments

Comments
 (0)