@@ -31,22 +31,24 @@ int main() {
31
31
C{{0 , 0 , 0 , 0 , 0 }};
32
32
sycl::queue deviceQueue;
33
33
sycl::range<1 > numOfItems{N};
34
- sycl::buffer<int , 1 > bufferA (A.data (), numOfItems);
35
- sycl::buffer<int , 1 > bufferB (B.data (), numOfItems);
36
- sycl::buffer<int , 1 > bufferC (C.data (), numOfItems);
37
-
38
- deviceQueue
39
- .submit ([&](sycl::handler &cgh) {
40
- auto accessorA = bufferA.get_access <sycl_read>(cgh);
41
- auto accessorB = bufferB.get_access <sycl_read>(cgh);
42
- auto accessorC = bufferC.get_access <sycl_write>(cgh);
43
-
44
- auto kern = [=](sycl::id<1 > wiID) {
45
- accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
46
- };
47
- cgh.parallel_for <class SimpleVadd >(numOfItems, kern);
48
- })
49
- .wait ();
34
+ {
35
+ sycl::buffer<int , 1 > bufferA (A.data (), numOfItems);
36
+ sycl::buffer<int , 1 > bufferB (B.data (), numOfItems);
37
+ sycl::buffer<int , 1 > bufferC (C.data (), numOfItems);
38
+
39
+ deviceQueue
40
+ .submit ([&](sycl::handler &cgh) {
41
+ auto accessorA = bufferA.get_access <sycl_read>(cgh);
42
+ auto accessorB = bufferB.get_access <sycl_read>(cgh);
43
+ auto accessorC = bufferC.get_access <sycl_write>(cgh);
44
+
45
+ auto kern = [=](sycl::id<1 > wiID) {
46
+ accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
47
+ };
48
+ cgh.parallel_for <class SimpleVadd >(numOfItems, kern);
49
+ })
50
+ .wait ();
51
+ }
50
52
51
53
for (unsigned int i = 0 ; i < N; i++) {
52
54
std::cout << " C[" << i << " ] = " << C[i] << " \n " ;
0 commit comments