33// RUN: %{build} -o %t.out
44// RUN: %{run} %t.out
55
6+ #include " sycl/handler.hpp"
67#include < sycl/ext/oneapi/experimental/device_architecture.hpp>
78#include < sycl/ext/oneapi/virtual_mem/physical_mem.hpp>
89#include < sycl/ext/oneapi/virtual_mem/virtual_mem.hpp>
@@ -12,6 +13,7 @@ namespace syclext = sycl::ext::oneapi::experimental;
1213int main () {
1314 sycl::queue Q;
1415 sycl::context Context = Q.get_context ();
16+ int Failed = 0 ;
1517
1618 size_t UsedGranularityInBytes = syclext::get_mem_granularity (Context, syclext::granularity_mode::recommended);
1719
@@ -31,24 +33,22 @@ int main() {
3133 Q.fill (DataPtr,ExpectedValueAfterFill , NumItems.size ()).wait_and_throw ();
3234 {
3335 sycl::buffer<int > CheckBuffer (ResultHostData);
34- Q.submit ([&](auto &handle ) {
35- sycl::accessor A (CheckBuffer, handle , sycl::write_only);
36- handle .parallel_for (NumItems, [=](auto i ) { A[i ] = DataPtr[i ]; });
36+ Q.submit ([&](sycl::handler &Handle ) {
37+ sycl::accessor A (CheckBuffer, Handle , sycl::write_only);
38+ Handle .parallel_for (NumItems, [=](sycl::id< 1 > Idx ) { A[Idx ] = DataPtr[Idx ]; });
3739 });
3840 }
3941
4042 for (size_t i = 0 ; i < ResultHostData.size (); i++) {
4143 if (ResultHostData[i] != ExpectedValueAfterFill) {
4244 std::cout << " Comparison failed after fill operation at index " << i << " : " << ResultHostData[i]
4345 << " != " <<ExpectedValueAfterFill << std::endl;
44- return 1 ;
46+ ++Failed ;
4547 }
4648 }
4749
48- Q.submit ([&](auto &handle) {
49- handle.parallel_for (NumItems, [=](auto i) {
50- DataPtr[i] = i;
51- });
50+ Q.parallel_for (NumItems, [=](sycl::id<1 > Idx) {
51+ DataPtr[Idx] = Idx;
5252 }).wait_and_throw ();
5353
5454 syclext::set_access_mode (DataPtr,UsedGranularityInBytes, syclext::address_access_mode::read, Context);
@@ -57,9 +57,9 @@ int main() {
5757 {
5858 sycl::buffer<int > ResultBuffer (ResultHostData);
5959
60- Q.submit ([&](auto &handle ) {
61- sycl::accessor A (ResultBuffer, handle , sycl::write_only);
62- handle .parallel_for (NumItems, [=](auto i ) { A[i ] = DataPtr[i ]; });
60+ Q.submit ([&](sycl::handler &Handle ) {
61+ sycl::accessor A (ResultBuffer, Handle , sycl::write_only);
62+ Handle .parallel_for (NumItems, [=](sycl::id< 1 > Idx ) { A[Idx ] = DataPtr[Idx ]; });
6363 });
6464 }
6565
@@ -68,12 +68,12 @@ int main() {
6868 if (ResultHostData[i] != ExpectedValue) {
6969 std::cout << " Comparison failed at index " << i << " : " << ResultHostData[i]
7070 << " != " << ExpectedValue<< std::endl;
71- return 1 ;
71+ ++Failed ;
7272 }
7373 }
7474
7575 syclext::unmap (MappedPtr, UsedGranularityInBytes, Context);
7676 syclext::free_virtual_mem (VirtualMemoryPtr, UsedGranularityInBytes, Context);
7777
78- return 0 ;
78+ return Failed ;
7979}
0 commit comments