8
8
#include < stdlib.h>
9
9
#include < sycl/sycl.hpp>
10
10
11
- sycl::event add (sycl::queue q, sycl::buffer<int > buff, int *usm,
12
- sycl::event e) {
11
+ sycl::event add (sycl::queue& q, sycl::buffer<int >& buff, int *usm,
12
+ sycl::event& e) {
13
13
return q.submit ([&](sycl::handler &cgh) {
14
14
auto acc = buff.get_access <sycl::access::mode::read_write>(cgh);
15
15
cgh.depends_on (e);
@@ -35,25 +35,23 @@ int main() {
35
35
36
36
int a = 1 ;
37
37
int b = 2 ;
38
- int c = 4 ;
39
- int d = 5 ;
40
38
{
41
39
sycl::buffer<int > buff1 (&a, 1 );
42
40
sycl::buffer<int > buff2 (&b, 1 );
43
41
44
42
// Test copying usm.
45
43
int *usm1 = sycl::malloc_device<int >(1 , q1);
46
44
int *usm2 = sycl::malloc_device<int >(1 , q2);
47
- sycl::event e1 = q1.memcpy (usm1, &c , 1 );
48
- sycl::event e2 = q2.memcpy (usm2, &d , 1 );
45
+ sycl::event e1 = q1.fill (usm1, 4 , 1 );
46
+ sycl::event e2 = q2.fill (usm2, 5 , 1 );
49
47
50
48
// Test combination of usm and buffers in a kernel.
51
49
sycl::event e3 = add (q1, buff1, usm1, e1 );
52
50
sycl::event e4 = add (q2, buff2, usm2, e2 );
53
51
54
52
// Change values in usm to ensure results are distinct.
55
- sycl::event e5 = q1.memcpy (usm1, &d , 1 , e3 );
56
- sycl::event e6 = q2.memcpy (usm2, &c , 1 , e4 );
53
+ sycl::event e5 = q1.fill (usm1, 5 , 1 , e3 );
54
+ sycl::event e6 = q2.fill (usm2, 4 , 1 , e4 );
57
55
58
56
// Use each buffer on the other device than before - tests that copying
59
57
// between devices works.
0 commit comments