Skip to content

Commit 05a805e

Browse files
authored
[SYCL][USM] Fix usm_allocator impl so that it's properly move assignable (#3115)
Signed-off-by: James Brodman <james.brodman@intel.com>
1 parent 88fab25 commit 05a805e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

sycl/include/CL/sycl/usm/usm_allocator.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,16 @@ class usm_allocator {
5050
: MContext(Q.get_context()), MDevice(Q.get_device()) {}
5151
usm_allocator(const usm_allocator &) noexcept = default;
5252
usm_allocator(usm_allocator &&) noexcept = default;
53-
usm_allocator &operator=(const usm_allocator &) = delete;
54-
usm_allocator &operator=(usm_allocator &&) = default;
53+
usm_allocator &operator=(const usm_allocator &Other) {
54+
MContext = Other.MContext;
55+
MDevice = Other.MDevice;
56+
return *this;
57+
}
58+
usm_allocator &operator=(usm_allocator &&Other) {
59+
MContext = std::move(Other.MContext);
60+
MDevice = std::move(Other.MDevice);
61+
return *this;
62+
}
5563

5664
template <class U>
5765
usm_allocator(const usm_allocator<U, AllocKind, Alignment> &Other) noexcept
@@ -101,8 +109,8 @@ class usm_allocator {
101109
template <class U, usm::alloc AllocKindU, size_t AlignmentU>
102110
friend class usm_allocator;
103111

104-
const context MContext;
105-
const device MDevice;
112+
context MContext;
113+
device MDevice;
106114
};
107115

108116
} // namespace sycl

0 commit comments

Comments
 (0)