Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 46fc03b

Browse files
authored
[SYCL] Support accessor property interface (#1165)
SYCL 2020 defines a common property interface for accessor and host_accessor. SYCL patch: intel/llvm#6614
1 parent 8c8996a commit 46fc03b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

SYCL/Basic/accessor/accessor.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,5 +740,52 @@ int main() {
740740
}
741741
}
742742

743+
// Accessor common property interface
744+
{
745+
using namespace sycl::ext::oneapi;
746+
int data[1] = {0};
747+
748+
// host accessor
749+
try {
750+
sycl::buffer<int, 1> buf_data(data, sycl::range<1>(1),
751+
{sycl::property::buffer::use_host_ptr()});
752+
accessor_property_list PL{no_alias, no_offset, sycl::no_init};
753+
sycl::accessor acc_1(buf_data, PL);
754+
static_assert(acc_1.has_property<property::no_alias>());
755+
static_assert(acc_1.has_property<property::no_offset>());
756+
assert(acc_1.has_property<sycl::property::no_init>());
757+
758+
static_assert(acc_1.get_property<property::no_alias>() == no_alias);
759+
static_assert(acc_1.get_property<property::no_offset>() == no_offset);
760+
// Should not throw "The property is not found"
761+
auto noInit = acc_1.get_property<sycl::property::no_init>();
762+
} catch (sycl::exception e) {
763+
std::cout << "SYCL exception caught: " << e.what() << std::endl;
764+
}
765+
766+
// base accessor
767+
try {
768+
sycl::buffer<int, 1> buf_data(data, sycl::range<1>(1),
769+
{sycl::property::buffer::use_host_ptr()});
770+
sycl::queue q;
771+
accessor_property_list PL{no_alias, no_offset, sycl::no_init};
772+
773+
q.submit([&](sycl::handler &cgh) {
774+
sycl::accessor acc_1(buf_data, PL);
775+
static_assert(acc_1.has_property<property::no_alias>());
776+
static_assert(acc_1.has_property<property::no_offset>());
777+
assert(acc_1.has_property<sycl::property::no_init>());
778+
779+
static_assert(acc_1.get_property<property::no_alias>() == no_alias);
780+
static_assert(acc_1.get_property<property::no_offset>() == no_offset);
781+
// Should not throw "The property is not found"
782+
auto noInit = acc_1.get_property<sycl::property::no_init>();
783+
});
784+
q.wait();
785+
} catch (sycl::exception e) {
786+
std::cout << "SYCL exception caught: " << e.what() << std::endl;
787+
}
788+
}
789+
743790
std::cout << "Test passed" << std::endl;
744791
}

0 commit comments

Comments
 (0)