Skip to content

Commit 1e38df9

Browse files
authored
Fix formatting in Managing_Data (#389)
By removing the unneeded wait, and replacing the other wait with a queue wait, we can improve the formatting of the sample and make it a bit simpler too (especially in the buffer case which is already correct).
1 parent f1091a6 commit 1e38df9

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

Code_Exercises/Managing_Data/solution.cpp

+11-15
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ void test_usm() {
2727
defaultQueue.memcpy(dev_A, &a, 1 * sizeof(int)).wait();
2828
defaultQueue.memcpy(dev_B, &b, 1 * sizeof(int)).wait();
2929

30-
defaultQueue
31-
.submit([&](sycl::handler& cgh) {
32-
cgh.single_task<scalar_add_usm>(
33-
[=] { dev_R[0] = dev_A[0] + dev_B[0]; });
34-
})
35-
.wait();
30+
defaultQueue.submit([&](sycl::handler& cgh) {
31+
cgh.single_task<scalar_add_usm>([=] { dev_R[0] = dev_A[0] + dev_B[0]; });
32+
});
33+
defaultQueue.wait();
3634

3735
defaultQueue.memcpy(&r, dev_R, 1 * sizeof(int)).wait();
3836

@@ -53,16 +51,14 @@ void test_buffer() {
5351
auto bufB = sycl::buffer{&b, sycl::range{1}};
5452
auto bufR = sycl::buffer{&r, sycl::range{1}};
5553

56-
defaultQueue
57-
.submit([&](sycl::handler& cgh) {
58-
auto accA = sycl::accessor{bufA, cgh, sycl::read_only};
59-
auto accB = sycl::accessor{bufB, cgh, sycl::read_only};
60-
auto accR = sycl::accessor{bufR, cgh, sycl::write_only};
54+
defaultQueue.submit([&](sycl::handler& cgh) {
55+
auto accA = sycl::accessor{bufA, cgh, sycl::read_only};
56+
auto accB = sycl::accessor{bufB, cgh, sycl::read_only};
57+
auto accR = sycl::accessor{bufR, cgh, sycl::write_only};
6158

62-
cgh.single_task<scalar_add_buff_acc>(
63-
[=] { accR[0] = accA[0] + accB[0]; });
64-
})
65-
.wait();
59+
cgh.single_task<scalar_add_buff_acc>(
60+
[=] { accR[0] = accA[0] + accB[0]; });
61+
})
6662
}
6763

6864
SYCLACADEMY_ASSERT_EQUAL(r, 42);

0 commit comments

Comments
 (0)