Skip to content

Commit e231e58

Browse files
fknorrpsalz
authored andcommitted
Use accessor ctor instead of get_access in examples
1 parent e88ba9f commit e231e58

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

examples/convolution/convolution.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ int main(int argc, char* argv[]) {
5757

5858
// Do a gaussian blur
5959
queue.submit([=](celerity::handler& cgh) {
60-
auto in = image_input_buf.get_access<cl::sycl::access::mode::read>(cgh, celerity::access::neighborhood{FILTER_SIZE / 2, FILTER_SIZE / 2});
61-
auto gauss = gaussian_mat_buf.get_access<cl::sycl::access::mode::read>(cgh, celerity::access::all{});
62-
auto out = image_tmp_buf.get_access<cl::sycl::access::mode::discard_write>(cgh, celerity::access::one_to_one{});
60+
celerity::accessor in{image_input_buf, cgh, celerity::access::neighborhood{FILTER_SIZE / 2, FILTER_SIZE / 2}, celerity::read_only};
61+
celerity::accessor gauss{gaussian_mat_buf, cgh, celerity::access::all{}, celerity::read_only};
62+
celerity::accessor out{image_tmp_buf, cgh, celerity::access::one_to_one{}, celerity::write_only, celerity::no_init};
6363

6464
cgh.parallel_for<class gaussian_blur>(celerity::range<2>(image_height, image_width), [=, fs = FILTER_SIZE](celerity::item<2> item) {
6565
using cl::sycl::float3;
@@ -82,8 +82,9 @@ int main(int argc, char* argv[]) {
8282

8383
// Now apply a sharpening kernel
8484
queue.submit([=](celerity::handler& cgh) {
85-
auto in = image_tmp_buf.get_access<cl::sycl::access::mode::read>(cgh, celerity::access::neighborhood{1, 1});
86-
auto out = image_output_buf.get_access<cl::sycl::access::mode::discard_write>(cgh, celerity::access::one_to_one{});
85+
celerity::accessor in{image_tmp_buf, cgh, celerity::access::neighborhood{1, 1}, celerity::read_only};
86+
celerity::accessor out{image_output_buf, cgh, celerity::access::one_to_one{}, celerity::write_only, celerity::no_init};
87+
8788
cgh.parallel_for<class sharpen>(celerity::range<2>(image_height, image_width), [=, fs = FILTER_SIZE](celerity::item<2> item) {
8889
using cl::sycl::float3;
8990
if(is_on_boundary(celerity::range<2>(image_height, image_width), fs, item)) {
@@ -101,7 +102,7 @@ int main(int argc, char* argv[]) {
101102
});
102103

103104
queue.submit([=](celerity::handler& cgh) {
104-
auto out = image_output_buf.get_access<cl::sycl::access::mode::read, celerity::target::host_task>(cgh, celerity::access::all{});
105+
celerity::accessor out{image_output_buf, cgh, celerity::access::all{}, celerity::read_only_host_task};
105106

106107
cgh.host_task(celerity::on_master_node, [=] {
107108
std::vector<uint8_t> image_output(image_width * image_height * 3);

examples/distr_io/distr_io.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static std::pair<hid_t, hid_t> allocation_window_to_dataspace(const celerity::bu
2929

3030
static void read_hdf5_file(celerity::distr_queue& q, const celerity::buffer<float, 2>& buffer, const char* file_name) {
3131
q.submit([=](celerity::handler& cgh) {
32-
auto a = buffer.get_access<cl::sycl::access::mode::discard_write, celerity::target::host_task>(cgh, celerity::experimental::access::even_split<2>());
32+
celerity::accessor a{buffer, cgh, celerity::experimental::access::even_split<2>{}, celerity::write_only_host_task, celerity::no_init};
3333
cgh.host_task(celerity::experimental::collective, [=](celerity::experimental::collective_partition part) {
3434
auto plist = H5Pcreate(H5P_FILE_ACCESS);
3535
H5Pset_fapl_mpio(plist, part.get_collective_mpi_comm(), MPI_INFO_NULL);
@@ -56,7 +56,7 @@ static void read_hdf5_file(celerity::distr_queue& q, const celerity::buffer<floa
5656

5757
static void write_hdf5_file(celerity::distr_queue& q, const celerity::buffer<float, 2>& buffer, const char* file_name) {
5858
q.submit([=](celerity::handler& cgh) {
59-
auto a = buffer.get_access<cl::sycl::access::mode::read, celerity::target::host_task>(cgh, celerity::experimental::access::even_split<2>());
59+
celerity::accessor a{buffer, cgh, celerity::experimental::access::even_split<2>{}, celerity::read_only_host_task};
6060
cgh.host_task(celerity::experimental::collective, [=](celerity::experimental::collective_partition part) {
6161
auto plist = H5Pcreate(H5P_FILE_ACCESS);
6262
H5Pset_fapl_mpio(plist, part.get_collective_mpi_comm(), MPI_INFO_NULL);
@@ -119,8 +119,8 @@ int main(int argc, char* argv[]) {
119119
read_hdf5_file(q, in, argv[2]);
120120

121121
q.submit([=](celerity::handler& cgh) {
122-
auto a = in.get_access<cl::sycl::access::mode::read>(cgh, celerity::access::one_to_one{});
123-
auto b = out.get_access<cl::sycl::access::mode::discard_write>(cgh, transposed);
122+
celerity::accessor a{in, cgh, celerity::access::one_to_one{}, celerity::read_only};
123+
celerity::accessor b{out, cgh, transposed, celerity::write_only, celerity::no_init};
124124
cgh.parallel_for<class transpose>(celerity::range<2>{N, N}, [=](celerity::item<2> item) {
125125
auto id = item.get_id();
126126
b[{id[1], id[0]}] = a[id];
@@ -140,8 +140,8 @@ int main(int argc, char* argv[]) {
140140
read_hdf5_file(q, right, argv[3]);
141141

142142
q.submit(celerity::allow_by_ref, [=, &equal](celerity::handler& cgh) {
143-
auto a = left.get_access<cl::sycl::access::mode::read, celerity::target::host_task>(cgh, celerity::access::all{});
144-
auto b = right.get_access<cl::sycl::access::mode::read, celerity::target::host_task>(cgh, celerity::access::all{});
143+
celerity::accessor a{left, cgh, celerity::access::all{}, celerity::read_only_host_task};
144+
celerity::accessor b{right, cgh, celerity::access::all{}, celerity::read_only_host_task};
145145
cgh.host_task(celerity::on_master_node, [=, &equal] {
146146
for(size_t i = 0; i < N; ++i) {
147147
for(size_t j = 0; j < N; ++j) {

0 commit comments

Comments
 (0)