Skip to content

reducer is missing deleted members #6065

@Pennycook

Description

@Pennycook

SYCL 2020 explicitly deletes the following:

reducer(const reducer&) = delete;
reducer(reducer&&) = delete;
reducer& operator=(const reducer&) = delete;
reducer& operator=(reducer&&) = delete;

These are deleted to prevent mistakes. For example, the code below currently compiles with DPC++ but produces the wrong answer, because the lambda is passed a private copy of the reducer argument. The code is only correct if the final parameter is declared as auto& reducer.

q.parallel_for(sycl::range<1>{N}, sycl::reduction(sum, sycl::plus<>), [=](sycl::id<1>, auto reducer) {
  reducer++;
});

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions