Skip to content

[SYCL][USM] Update usm_allocator impl so that it's properly move assignable. #3115

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

Merged
merged 2 commits into from
Feb 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions sycl/include/CL/sycl/usm/usm_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@ class usm_allocator {
: MContext(Q.get_context()), MDevice(Q.get_device()) {}
usm_allocator(const usm_allocator &) noexcept = default;
usm_allocator(usm_allocator &&) noexcept = default;
usm_allocator &operator=(const usm_allocator &) = delete;
usm_allocator &operator=(usm_allocator &&) = default;
usm_allocator &operator=(const usm_allocator &Other) {
MContext = Other.MContext;
MDevice = Other.MDevice;
return *this;
}
usm_allocator &operator=(usm_allocator &&Other) {
MContext = std::move(Other.MContext);
MDevice = std::move(Other.MDevice);
return *this;
}

template <class U>
usm_allocator(const usm_allocator<U, AllocKind, Alignment> &Other) noexcept
Expand Down Expand Up @@ -101,8 +109,8 @@ class usm_allocator {
template <class U, usm::alloc AllocKindU, size_t AlignmentU>
friend class usm_allocator;

const context MContext;
const device MDevice;
context MContext;
device MDevice;
};

} // namespace sycl
Expand Down