Hello, I’m trying to build a SYCL application but I’m having some problems with the buffers, depending on how I specify the buffer’s data type either the program runs or it fails to compile at the line of the ‘get_access’ call. I’ll provide a simplified source code bellow.
Source code
template <typename C1_T>
void test(C1_T &input) {
auto size = input.size();
using container_t = typename C1_T::value_type;
sycl::queue queue{sycl::host_selector()};
sycl::buffer<container_t> buffer (input.data(), sycl::range<1>{size});
queue.submit([&] (sycl::handler &cgh) {
auto acc = buffer.get_access<sycl::access::mode::read_write>(cgh);
cgh.parallel_for<class map_func>(sycl::range<1>{size}, [=] (sycl::id<1> index) {
acc[index] += 1;
});
});
queue.wait();
}
int main() {
std::vector<int> vec = {1,2,3,4};
test(vec);
}
I’m trying to infer the type of the data from containers like std vector or std array. However while trying to compile the code I get the following error:
Error
error: reference to non-static member function must be called
auto acc = buffer.get_access<sycl::access::mode::read_write>(cgh);
Now if I replace ‘container_t’ by ‘int’ at the line:
sycl::buffer<container_t> buffer (input.data(), sycl::range<1>{size});
Now the code compiles and runs successfully.
I’d like to avoid adding extra parameters to the template function ‘test’. Any help is appreciated, and thank you for your time.