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
1517int 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