8
8
// Test fails on hip flakily, disable temprorarily.
9
9
// UNSUPPORTED: hip
10
10
11
+ #include < cassert>
12
+ #include < iostream>
11
13
#include < sycl/detail/core.hpp>
12
14
#include < sycl/properties/all_properties.hpp>
13
15
#include < sycl/usm.hpp>
14
16
15
17
int main (void ) {
18
+ constexpr size_t n = 16 ;
16
19
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);
18
22
19
- for (int i = 0 ; i < 20 ; i++) {
23
+ for (int i = 0 ; i < 5 ; i++) {
20
24
auto event = q.submit ([&](sycl::handler &cgh) {
21
25
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; });
23
27
});
24
28
25
29
event.wait ();
@@ -30,8 +34,42 @@ int main(void) {
30
34
auto end_time =
31
35
event.get_profiling_info <sycl::info::event_profiling::command_end>();
32
36
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" );
33
43
assert ((submit_time <= start_time) && (start_time <= end_time));
34
44
}
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
+
35
72
sycl::free (data, q);
73
+ sycl::free (dest, q);
36
74
return 0 ;
37
75
}
0 commit comments