Skip to content

Commit e85232c

Browse files
[SYCL] Update simple-sycl-app.cpp example in GetStartedGuide.md (#8025)
Fixes #5738
1 parent e64433c commit e85232c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

sycl/doc/GetStartedGuide.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ Creating a file `simple-sycl-app.cpp` with the following C++/SYCL code:
566566
#include <sycl/sycl.hpp>
567567
568568
int main() {
569-
// Creating buffer of 4 ints to be used inside the kernel code
570-
sycl::buffer<sycl::cl_int, 1> Buffer(4);
569+
// Creating buffer of 4 elements to be used inside the kernel code
570+
sycl::buffer<size_t, 1> Buffer(4);
571571
572572
// Creating SYCL queue
573573
sycl::queue Queue;
@@ -577,19 +577,19 @@ int main() {
577577
578578
// Submitting command group(work) to queue
579579
Queue.submit([&](sycl::handler &cgh) {
580-
// Getting write only access to the buffer on a device
581-
auto Accessor = Buffer.get_access<sycl::access::mode::write>(cgh);
580+
// Getting write only access to the buffer on a device.
581+
sycl::accessor Accessor{Buffer, cgh, sycl::write_only};
582582
// Executing kernel
583583
cgh.parallel_for<class FillBuffer>(
584584
NumOfWorkItems, [=](sycl::id<1> WIid) {
585-
// Fill buffer with indexes
586-
Accessor[WIid] = (sycl::cl_int)WIid.get(0);
585+
// Fill buffer with indexes.
586+
Accessor[WIid] = WIid.get(0);
587587
});
588588
});
589589
590590
// Getting read only access to the buffer on the host.
591591
// Implicit barrier waiting for queue to complete the work.
592-
const auto HostAccessor = Buffer.get_access<sycl::access::mode::read>();
592+
sycl::host_accessor HostAccessor{Buffer, sycl::read_only};
593593
594594
// Check the results
595595
bool MismatchFound = false;

0 commit comments

Comments
 (0)