What is the correct way to create a 2D std::vector buffer in SYCL?
I have a template function which receives arguments as shown below:
template <typename T>
void MatrixMulParallelNaive(queue& q,
std::vector<std::vector<T>>& a,
std::vector<std::vector<T>>& b,
std::vector<std::vector<T>>& c){
// Is this a correct way?
buffer<T, 2> a_buf(a.data(), range<2>{a.size(), a[0].size()})
buffer<T, 2> b_buf(b.data(), range<2>{b.size(), b[0].size()})
buffer<T, 2> c_buf(c.data(), range<2>{c.size(), c[0].size()})
/* ... */
}
a, b and c are 2D std::vectors
I have been able to implement buffers for 2D C-style arrays, but I've tried multiple docs and answers, but none seem to match this specific usecase.
No.
vector<vector<T>>doesn't create a contiguous block of memory. You need to usevector<T>and interpret it as a two dimensional block of data.