Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement chained subscript operator on Celerity accessors #16

Closed
n-io opened this issue Aug 6, 2020 · 1 comment · Fixed by #37
Closed

Implement chained subscript operator on Celerity accessors #16

n-io opened this issue Aug 6, 2020 · 1 comment · Fixed by #37
Labels
enhancement New feature or request
Milestone

Comments

@n-io
Copy link

n-io commented Aug 6, 2020

Hello,

I have the following piece of code:

QueueManager::getInstance().with_master_access([&](celerity::handler& cgh) {
      auto result = output_buf.template get_access<cl::sycl::access::mode::read>(cgh, cl::sycl::range<2>(args.problem_size, args.problem_size));
      
      for (size_t i = 0; i < args.problem_size; i++) {
        for (size_t j = 0; j < args.problem_size; j++) {
          output[i*args.problem_size + j] = result[i][j];
        }
      }

It yields the following error (using a hipSYCL CPU-backend):

/p/project/celerity/code/celerity-bench/single-kernel/sobel.cc:108:51: error: no match for ‘operator[]’ (operand types are ‘celerity::accessor<hipsycl::sycl::vec<float, 4>, 2, (hipsycl::sycl::access::mode)1024, (hipsycl::sycl::access::target)2018>’ and ‘size_t’ {aka ‘long unsigned int’})
           output[i*args.problem_size + j] = result[i][j];
                                                   ^

Using a hipSYCL GPU-backend the error message appears similar:

/data/code/celerity-bench/single-kernel/sobel.cc:108:51: error: no viable overloaded operator[] for type 'celerity::accessor<hipsycl::sycl::vec<float, 4>, 2, hipsycl::sycl::access::mode::read, hipsycl::sycl::access::target::host_buffer>'
          output[i*args.problem_size + j] = result[i][j];
                                            ~~~~~~^~

The code has not changed since the last time I used it successfully on the master branch. Please could you have a look and advise?

Many thanks in advance!

@psalz psalz changed the title WIP branch memory management -- access error Implement chained subscript operator on Celerity accessors Aug 11, 2020
@psalz
Copy link
Member

psalz commented Aug 11, 2020

This is because we now return a custom celerity::accessor type from calls to celerity::buffer::get_access, as opposed to simply returning cl::sycl::accessor. Our custom accessor currently doesn't support the "chained subscript operator" for accessing elements, however you can simply use the overload taking a cl::sycl::id instead!

We should implement the chained operator at some point however. I've renamed the issue so we can keep track of this going forward.

@psalz psalz added the enhancement New feature or request label Aug 11, 2020
@psalz psalz added this to the Celerity 0.3.0 milestone Jun 2, 2021
@psalz psalz linked a pull request Jun 29, 2021 that will close this issue
@facuMH facuMH closed this as completed in #37 Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants