Skip to content

Commit

Permalink
tests: benchdnn: graph: fix data init with sycl
Browse files Browse the repository at this point in the history
  • Loading branch information
chuanqi129 authored and TaoLv committed Oct 9, 2022
1 parent 19a62f1 commit c02bb43
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/benchdnn/graph/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,18 @@ void fill_buffer(void *src, size_t total_size, int val) {
}

#ifdef DNNL_GRAPH_WITH_SYCL

template <typename dtype>
class init_kernel;

template <typename dtype>
void fill_buffer(sycl::queue &q, void *usm_buffer, size_t length, dtype value) {
dtype *usm_buffer_casted = static_cast<dtype *>(usm_buffer);
q.parallel_for(sycl::range<1>(length), [=](sycl::id<1> i) {
int idx = (int)i[0];
usm_buffer_casted[idx] = value;
}).wait();
auto ker = [=](sycl::id<1> i) {
int idx = (int)i[0];
usm_buffer_casted[idx] = value;
};
q.parallel_for<init_kernel<dtype>>(sycl::range<1>(length), ker).wait();
}
#endif

Expand Down

0 comments on commit c02bb43

Please sign in to comment.