diff --git a/SYCL/Basic/accessor/accessor.cpp b/SYCL/Basic/accessor/accessor.cpp index 36ecea25c5..5ca49f0067 100644 --- a/SYCL/Basic/accessor/accessor.cpp +++ b/SYCL/Basic/accessor/accessor.cpp @@ -740,5 +740,52 @@ int main() { } } + // Accessor common property interface + { + using namespace sycl::ext::oneapi; + int data[1] = {0}; + + // host accessor + try { + sycl::buffer buf_data(data, sycl::range<1>(1), + {sycl::property::buffer::use_host_ptr()}); + accessor_property_list PL{no_alias, no_offset, sycl::no_init}; + sycl::accessor acc_1(buf_data, PL); + static_assert(acc_1.has_property()); + static_assert(acc_1.has_property()); + assert(acc_1.has_property()); + + static_assert(acc_1.get_property() == no_alias); + static_assert(acc_1.get_property() == no_offset); + // Should not throw "The property is not found" + auto noInit = acc_1.get_property(); + } catch (sycl::exception e) { + std::cout << "SYCL exception caught: " << e.what() << std::endl; + } + + // base accessor + try { + sycl::buffer buf_data(data, sycl::range<1>(1), + {sycl::property::buffer::use_host_ptr()}); + sycl::queue q; + accessor_property_list PL{no_alias, no_offset, sycl::no_init}; + + q.submit([&](sycl::handler &cgh) { + sycl::accessor acc_1(buf_data, PL); + static_assert(acc_1.has_property()); + static_assert(acc_1.has_property()); + assert(acc_1.has_property()); + + static_assert(acc_1.get_property() == no_alias); + static_assert(acc_1.get_property() == no_offset); + // Should not throw "The property is not found" + auto noInit = acc_1.get_property(); + }); + q.wait(); + } catch (sycl::exception e) { + std::cout << "SYCL exception caught: " << e.what() << std::endl; + } + } + std::cout << "Test passed" << std::endl; }