Skip to content

Commit 0c886cb

Browse files
committed
Vector Addition example update
Works with latest DPC++ and SYCL2020 features README updated to reflect CUDA backend has USM support
1 parent 245ccd0 commit 0c886cb

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

examples/vector_addition/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ to highlight how to build an application with SYCL for CUDA using DPC++ support,
77
for which an example CMakefile is provided. For detailed documentation on how to
88
migrate from CUDA to SYCL, see [SYCL For CUDA Developers](https://developer.codeplay.com/products/computecpp/ce/guides/sycl-for-cuda-developers).
99

10-
Note currently the CUDA backend does not support the [USM](https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/USM.adoc) extension, so we use
11-
`sycl::buffer` and `sycl::accessors` instead.
12-
1310
Pre-requisites
1411
---------------
1512

examples/vector_addition/vector_addition.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ int main(int argc, char *argv[]) {
3434

3535
// Initialize input data
3636
{
37-
const auto dwrite_t = sycl::access::mode::discard_write;
37+
const auto dwrite_t = sycl::write_only;
38+
39+
40+
sycl::host_accessor h_a{bufA, sycl::write_only};
41+
sycl::host_accessor h_b{bufB, sycl::write_only};
3842

39-
auto h_a = bufA.get_access<dwrite_t>();
40-
auto h_b = bufB.get_access<dwrite_t>();
4143
for (int i = 0; i < N; i++) {
4244
h_a[i] = sin(i) * sin(i);
4345
h_b[i] = cos(i) * cos(i);
@@ -70,8 +72,8 @@ int main(int argc, char *argv[]) {
7072
myQueue.submit(cg);
7173

7274
{
73-
const auto read_t = sycl::access::mode::read;
74-
auto h_c = bufC.get_access<read_t>();
75+
sycl::host_accessor h_c{bufC, sycl::read_only};
76+
7577
double sum = 0.0f;
7678
for (int i = 0; i < N; i++) {
7779
sum += h_c[i];

0 commit comments

Comments
 (0)